Skip to content

Commit 2907107

Browse files
authored
Add the version() and cdm_version functions; don't export CDM_VERSION (#18)
We will recommend that users use the `cdm_version` function instead.
1 parent 7c41cb3 commit 2907107

6 files changed

Lines changed: 60 additions & 11 deletions

File tree

Project.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ version = "0.1.0-DEV"
66
[deps]
77
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
88
DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
9+
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
910

1011
[compat]
1112
DataFrames = "0.21"

docs/src/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ CurrentModule = OMOPCommonDataModel
44

55
# OMOPCommonDataModel
66

7-
[OMOPCommonDataModel.jl](https://github.com/JuliaHealth/OMOPCommonDataModel.jl) is a pure Julia implementation of the [OMOP Common Data Model (CDM)](https://github.com/OHDSI/CommonDataModel).
7+
[`OMOPCommonDataModel.jl`](https://github.com/JuliaHealth/OMOPCommonDataModel.jl) is a pure Julia implementation of the [OMOP Common Data Model (CDM)](https://github.com/OHDSI/CommonDataModel).

docs/src/version.md

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,34 @@ CurrentModule = OMOPCommonDataModel
44

55
# CDM Version
66

7-
The following table maps the version of OMOPCommonDataModel.jl to the
8-
corresponding version of the Common Data Model (CDM).
7+
The following table shows which version of the OMOP Common Data Model (CDM) is
8+
implemented in each version of the `OMOPCommonDataModel.jl` Julia package.
99

10-
| OMOPCommonDataModel.jl | CDM |
11-
| ---------------------- | ------ |
12-
| 0.1.0 | 6.0.0 |
10+
| Common Data Model (CDM) | `OMOPCommonDataModel.jl` |
11+
| ----------------------- | ------------------------ |
12+
| 6.0.0 | 0.1.0 |
1313

14-
In order to see the current CDM version, use the `OMOPCommonDataModel.CDM_VERSION` constant:
14+
In order to see the current CDM version, use the
15+
`OMOPCommonDataModel.cdm_version` function:
1516
```jldoctest
1617
julia> using OMOPCommonDataModel
1718
18-
julia> OMOPCommonDataModel.CDM_VERSION
19+
julia> OMOPCommonDataModel.cdm_version()
1920
v"6.0.0"
2021
```
22+
23+
In order to see the current `OMOPCommonDataModel.jl` version, use the
24+
`OMOPCommonDataModel.cdm_version` function:
25+
26+
```jldoctest
27+
julia> using OMOPCommonDataModel
28+
29+
julia> OMOPCommonDataModel.version()
30+
v"0.1.0-DEV"
31+
```
32+
33+
To see all versions of the Common Data Model, go to the
34+
[CommonDataModel release page](https://github.com/OHDSI/CommonDataModel/releases).
35+
36+
To see all versions of `OMOPCommonDataModel.jl`, go to the
37+
[`OMOPCommonDataModel.jl` release page](https://github.com/JuliaHealth/OMOPCommonDataModel.jl/releases).

src/OMOPCommonDataModel.jl

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,8 @@ import DocStringExtensions
55

66
abstract type OmopType end
77

8-
"""
9-
The version of the OMOP Common Data Model (CDM) being implemented.
10-
"""
118
const CDM_VERSION = v"6.0.0"
9+
include("version.jl")
1210

1311
# Standardized Vocabularies
1412
# export Concept

src/version.jl

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import Pkg
2+
3+
"""
4+
The version of the OMOPCommonDataModel.jl package.
5+
"""
6+
function version()::VersionNumber
7+
package_directory = dirname(dirname(@__FILE__))
8+
project_file = joinpath(package_directory, "Project.toml")
9+
version_string = Pkg.TOML.parsefile(project_file)["version"]
10+
version_number = VersionNumber(version_string)
11+
return version_number
12+
end
13+
14+
"""
15+
The version of the OMOP Common Data Model (CDM) being implemented.
16+
"""
17+
@inline function cdm_version()::VersionNumber
18+
return CDM_VERSION
19+
end

test/runtests.jl

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,21 @@ using PrettyPrint
66
using StructArrays
77
using Test
88

9+
using OMOPCommonDataModel
10+
11+
using Test
12+
13+
914
@testset "OMOPCommonDataModel.jl" begin
15+
@testset "Unit tests" begin
16+
@testset "version" begin
17+
@test OMOPCommonDataModel.version() isa VersionNumber
18+
@test OMOPCommonDataModel.version() > v"0"
19+
@test OMOPCommonDataModel.cdm_version() isa VersionNumber
20+
@test OMOPCommonDataModel.cdm_version() > v"0"
21+
@test OMOPCommonDataModel.cdm_version() == OMOPCommonDataModel.CDM_VERSION
22+
end
23+
end
1024
@testset "Doctests" begin
1125
doctest(OMOPCommonDataModel)
1226
end

0 commit comments

Comments
 (0)