epi_doc_validator 0.1.0-java
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.github/funding.yml +1 -0
- data/.github/workflows/test.yml +29 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/.rubocop.yml +16 -0
- data/.tool-versions +1 -0
- data/CODE_OF_CONDUCT.md +76 -0
- data/Gemfile +10 -0
- data/Gemfile.lock +83 -0
- data/LICENSE +21 -0
- data/README.md +101 -0
- data/Rakefile +6 -0
- data/epi_doc_validator.gemspec +28 -0
- data/lib/epi_doc_validator.rb +5 -0
- data/lib/epi_doc_validator/errors.rb +7 -0
- data/lib/epi_doc_validator/sem_ver.rb +60 -0
- data/lib/epi_doc_validator/validator.rb +45 -0
- data/lib/epi_doc_validator/version.rb +3 -0
- data/vendor/schema/8-rc1/tei-epidoc.rng +515 -0
- data/vendor/schema/8.10/LICENSE.txt +17 -0
- data/vendor/schema/8.10/tei-epidoc.rng +12117 -0
- data/vendor/schema/8.11/LICENSE.txt +17 -0
- data/vendor/schema/8.11/tei-epidoc.rng +12138 -0
- data/vendor/schema/8.12/LICENSE.txt +17 -0
- data/vendor/schema/8.12/tei-epidoc.rng +12292 -0
- data/vendor/schema/8.13/LICENSE.txt +17 -0
- data/vendor/schema/8.13/tei-epidoc.rng +12594 -0
- data/vendor/schema/8.14/LICENSE.txt +17 -0
- data/vendor/schema/8.14/tei-epidoc.rng +11480 -0
- data/vendor/schema/8.15/LICENSE.txt +17 -0
- data/vendor/schema/8.15/tei-epidoc.rng +11511 -0
- data/vendor/schema/8.16/LICENSE.txt +17 -0
- data/vendor/schema/8.16/tei-epidoc.rng +11435 -0
- data/vendor/schema/8.17/LICENSE.txt +17 -0
- data/vendor/schema/8.17/tei-epidoc.rng +10909 -0
- data/vendor/schema/8.18/LICENSE.txt +17 -0
- data/vendor/schema/8.18/tei-epidoc.rng +10897 -0
- data/vendor/schema/8.19/LICENSE.txt +17 -0
- data/vendor/schema/8.19/tei-epidoc.rng +11139 -0
- data/vendor/schema/8.2/LICENSE.txt +17 -0
- data/vendor/schema/8.2/tei-epidoc.rng +531 -0
- data/vendor/schema/8.20/LICENSE.txt +17 -0
- data/vendor/schema/8.20/tei-epidoc.rng +11193 -0
- data/vendor/schema/8.21/LICENSE.txt +17 -0
- data/vendor/schema/8.21/tei-epidoc.rng +11397 -0
- data/vendor/schema/8.22/LICENSE.txt +17 -0
- data/vendor/schema/8.22/tei-epidoc.rng +12548 -0
- data/vendor/schema/8.23/LICENSE.txt +17 -0
- data/vendor/schema/8.23/tei-epidoc.rng +12585 -0
- data/vendor/schema/8.3/LICENSE.txt +17 -0
- data/vendor/schema/8.3/tei-epidoc.rng +11335 -0
- data/vendor/schema/8.4/LICENSE.txt +17 -0
- data/vendor/schema/8.4/tei-epidoc.rng +540 -0
- data/vendor/schema/8.5/LICENSE.txt +17 -0
- data/vendor/schema/8.5/tei-epidoc.rng +541 -0
- data/vendor/schema/8.6/LICENSE.txt +17 -0
- data/vendor/schema/8.6/tei-epidoc.rng +541 -0
- data/vendor/schema/8.7/LICENSE.txt +17 -0
- data/vendor/schema/8.7/tei-epidoc.rng +11379 -0
- data/vendor/schema/8.8/LICENSE.txt +17 -0
- data/vendor/schema/8.8/tei-epidoc.rng +11389 -0
- data/vendor/schema/8.9/LICENSE.txt +17 -0
- data/vendor/schema/8.9/tei-epidoc.rng +11387 -0
- data/vendor/schema/8/LICENSE.txt +17 -0
- data/vendor/schema/8/tei-epidoc.rng +516 -0
- data/vendor/schema/9.0/LICENSE.txt +17 -0
- data/vendor/schema/9.0/tei-epidoc.rng +12558 -0
- data/vendor/schema/9.1/LICENSE.txt +17 -0
- data/vendor/schema/9.1/tei-epidoc.rng +13293 -0
- data/vendor/schema/9.2/LICENSE.txt +17 -0
- data/vendor/schema/9.2/tei-epidoc.rng +14637 -0
- data/vendor/schema/dev/LICENSE.txt +17 -0
- data/vendor/schema/dev/tei-epidoc.rng +14637 -0
- data/vendor/schema/latest/LICENSE.txt +17 -0
- data/vendor/schema/latest/tei-epidoc.rng +14637 -0
- metadata +135 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 31eba4f9eb1f3c5c9555a156f20fec249019d1f0323ecef39f28cf261682703c
|
|
4
|
+
data.tar.gz: 1f21040118e078e75fffa4e6d9e450bfef09855d630d54debfefeb5e9b370440
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 6849499c88ab0de5683dad81afa76a96d81466b05906467cc11058a40c205f59e96b19ef890ef60f1f694066a1e777188c9c0f9012985020b40ef6aa0268ed51
|
|
7
|
+
data.tar.gz: 8e842cae8f40b099d9b3e5d123cdb48db253b2bd9006ff0c9382b4f7995f72b6992221d5ba547feedecf173ca89fa441cd77f712777f49fed2d473b3a372d684
|
data/.github/funding.yml
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
custom: "https://tuftsgiving.org/giving-form.html?id=7&showarea=AR001037&areaid=601&recurring=true"
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
name: Run tests
|
|
2
|
+
|
|
3
|
+
on: [push, pull_request]
|
|
4
|
+
|
|
5
|
+
jobs:
|
|
6
|
+
test:
|
|
7
|
+
runs-on: ubuntu-latest
|
|
8
|
+
strategy:
|
|
9
|
+
matrix:
|
|
10
|
+
ruby: ['jruby', 'jruby-9.2.9.0']
|
|
11
|
+
name: Ruby ${{ matrix.ruby }} test
|
|
12
|
+
steps:
|
|
13
|
+
- uses: actions/checkout@v2
|
|
14
|
+
|
|
15
|
+
- uses: ruby/setup-ruby@v1
|
|
16
|
+
with:
|
|
17
|
+
ruby-version: ${{ matrix.ruby }}
|
|
18
|
+
|
|
19
|
+
- name: Install bundler
|
|
20
|
+
run: gem install bundler
|
|
21
|
+
|
|
22
|
+
- name: Install dependencies
|
|
23
|
+
run: bundle install
|
|
24
|
+
|
|
25
|
+
- name: Run tests
|
|
26
|
+
run: bundle exec rspec
|
|
27
|
+
|
|
28
|
+
- name: Lint code
|
|
29
|
+
run: bundle exec rubocop
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
inherit_gem:
|
|
2
|
+
gnar-style:
|
|
3
|
+
- rubocop/rubocop_gem.yml
|
|
4
|
+
|
|
5
|
+
AllCops:
|
|
6
|
+
TargetRubyVersion: 2.4
|
|
7
|
+
|
|
8
|
+
Layout/LineLength:
|
|
9
|
+
Max: 120
|
|
10
|
+
Severity: refactor
|
|
11
|
+
|
|
12
|
+
Style/StringLiterals:
|
|
13
|
+
EnforcedStyle: single_quotes
|
|
14
|
+
|
|
15
|
+
Style/MutableConstant:
|
|
16
|
+
Enabled: false
|
data/.tool-versions
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ruby jruby-9.2.11.1
|
data/CODE_OF_CONDUCT.md
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
|
2
|
+
|
|
3
|
+
## Our Pledge
|
|
4
|
+
|
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
|
6
|
+
contributors and maintainers pledge to make participation in the Perseids Project and
|
|
7
|
+
its associated community a harassment-free experience for everyone, regardless of age,
|
|
8
|
+
body size, disability, ethnicity, sex characteristics, gender identity and expression,
|
|
9
|
+
level of experience, education, socio-economic status, nationality, personal
|
|
10
|
+
appearance, race, religion, or sexual identity and orientation.
|
|
11
|
+
|
|
12
|
+
## Our Standards
|
|
13
|
+
|
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
|
15
|
+
include:
|
|
16
|
+
|
|
17
|
+
* Using welcoming and inclusive language
|
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
|
19
|
+
* Gracefully accepting constructive criticism
|
|
20
|
+
* Focusing on what is best for the community
|
|
21
|
+
* Showing empathy towards other community members
|
|
22
|
+
|
|
23
|
+
Examples of unacceptable behavior by participants include:
|
|
24
|
+
|
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
|
26
|
+
advances
|
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
|
28
|
+
* Public or private harassment
|
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
|
30
|
+
address, without explicit permission
|
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
|
32
|
+
professional setting
|
|
33
|
+
|
|
34
|
+
## Our Responsibilities
|
|
35
|
+
|
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
|
38
|
+
response to any instances of unacceptable behavior.
|
|
39
|
+
|
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
|
44
|
+
threatening, offensive, or harmful.
|
|
45
|
+
|
|
46
|
+
## Scope
|
|
47
|
+
|
|
48
|
+
This Code of Conduct applies within project spaces and when
|
|
49
|
+
an individual is officially representing the project or its community.
|
|
50
|
+
Examples of representing a project or community include using an official
|
|
51
|
+
project e-mail address, posting via an official social media account, or acting
|
|
52
|
+
as an appointed representative at an online or offline event. Representation of
|
|
53
|
+
a project may be further defined and clarified by project maintainers.
|
|
54
|
+
|
|
55
|
+
## Enforcement
|
|
56
|
+
|
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
58
|
+
reported by contacting the project team at perseids@tufts.edu. All
|
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
|
63
|
+
|
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
|
66
|
+
members of the project's leadership.
|
|
67
|
+
|
|
68
|
+
## Attribution
|
|
69
|
+
|
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
|
71
|
+
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
|
|
72
|
+
|
|
73
|
+
[homepage]: https://www.contributor-covenant.org
|
|
74
|
+
|
|
75
|
+
For answers to common questions about this code of conduct, see
|
|
76
|
+
https://www.contributor-covenant.org/faq
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
epi_doc_validator (0.1.0-java)
|
|
5
|
+
nokogiri (~> 1.10)
|
|
6
|
+
|
|
7
|
+
GEM
|
|
8
|
+
remote: https://rubygems.org/
|
|
9
|
+
specs:
|
|
10
|
+
ast (2.4.2)
|
|
11
|
+
diff-lcs (1.4.4)
|
|
12
|
+
gnar-style (0.13.0)
|
|
13
|
+
rubocop (>= 1.0.0, < 2.0)
|
|
14
|
+
rubocop-performance
|
|
15
|
+
rubocop-rails (~> 2.2.0)
|
|
16
|
+
thor
|
|
17
|
+
nokogiri (1.11.1-java)
|
|
18
|
+
racc (~> 1.4)
|
|
19
|
+
parallel (1.20.1)
|
|
20
|
+
parser (3.0.0.0)
|
|
21
|
+
ast (~> 2.4.1)
|
|
22
|
+
racc (1.5.2-java)
|
|
23
|
+
rack (2.2.3)
|
|
24
|
+
rainbow (3.0.0)
|
|
25
|
+
rake (13.0.3)
|
|
26
|
+
regexp_parser (2.1.1)
|
|
27
|
+
rexml (3.2.4)
|
|
28
|
+
rspec (3.10.0)
|
|
29
|
+
rspec-core (~> 3.10.0)
|
|
30
|
+
rspec-expectations (~> 3.10.0)
|
|
31
|
+
rspec-mocks (~> 3.10.0)
|
|
32
|
+
rspec-core (3.10.1)
|
|
33
|
+
rspec-support (~> 3.10.0)
|
|
34
|
+
rspec-expectations (3.10.1)
|
|
35
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
36
|
+
rspec-support (~> 3.10.0)
|
|
37
|
+
rspec-its (1.3.0)
|
|
38
|
+
rspec-core (>= 3.0.0)
|
|
39
|
+
rspec-expectations (>= 3.0.0)
|
|
40
|
+
rspec-mocks (3.10.2)
|
|
41
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
42
|
+
rspec-support (~> 3.10.0)
|
|
43
|
+
rspec-support (3.10.2)
|
|
44
|
+
rubocop (1.11.0)
|
|
45
|
+
parallel (~> 1.10)
|
|
46
|
+
parser (>= 3.0.0.0)
|
|
47
|
+
rainbow (>= 2.2.2, < 4.0)
|
|
48
|
+
regexp_parser (>= 1.8, < 3.0)
|
|
49
|
+
rexml
|
|
50
|
+
rubocop-ast (>= 1.2.0, < 2.0)
|
|
51
|
+
ruby-progressbar (~> 1.7)
|
|
52
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
|
53
|
+
rubocop-ast (1.4.1)
|
|
54
|
+
parser (>= 2.7.1.5)
|
|
55
|
+
rubocop-performance (1.10.1)
|
|
56
|
+
rubocop (>= 0.90.0, < 2.0)
|
|
57
|
+
rubocop-ast (>= 0.4.0)
|
|
58
|
+
rubocop-rails (2.2.1)
|
|
59
|
+
rack (>= 1.1)
|
|
60
|
+
rubocop (>= 0.72.0)
|
|
61
|
+
rubocop-rake (0.5.1)
|
|
62
|
+
rubocop
|
|
63
|
+
rubocop-rspec (2.2.0)
|
|
64
|
+
rubocop (~> 1.0)
|
|
65
|
+
rubocop-ast (>= 1.1.0)
|
|
66
|
+
ruby-progressbar (1.11.0)
|
|
67
|
+
thor (1.1.0)
|
|
68
|
+
unicode-display_width (2.0.0)
|
|
69
|
+
|
|
70
|
+
PLATFORMS
|
|
71
|
+
java
|
|
72
|
+
|
|
73
|
+
DEPENDENCIES
|
|
74
|
+
epi_doc_validator!
|
|
75
|
+
gnar-style
|
|
76
|
+
rake
|
|
77
|
+
rspec
|
|
78
|
+
rspec-its
|
|
79
|
+
rubocop-rake
|
|
80
|
+
rubocop-rspec
|
|
81
|
+
|
|
82
|
+
BUNDLED WITH
|
|
83
|
+
2.1.4
|
data/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021 The Perseids Project
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
# EpiDoc Validator
|
|
2
|
+
|
|
3
|
+
JRuby library for validating [EpiDoc XML](https://sourceforge.net/p/epidoc/wiki/Home/).
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Add this line to your application's Gemfile:
|
|
8
|
+
|
|
9
|
+
```ruby
|
|
10
|
+
gem 'epi_doc_validator'
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
And then execute:
|
|
14
|
+
|
|
15
|
+
```
|
|
16
|
+
$ bundle install
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Or install it yourself as:
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
$ gem install epi_doc_validator
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Requirements
|
|
26
|
+
|
|
27
|
+
* JRuby >= 9.2.9
|
|
28
|
+
|
|
29
|
+
## Usage
|
|
30
|
+
|
|
31
|
+
```ruby
|
|
32
|
+
require 'epi_doc_validator'
|
|
33
|
+
|
|
34
|
+
validator = EpiDocValidator::Validator.new
|
|
35
|
+
xml = File.read('my-epi-doc-file.xml')
|
|
36
|
+
|
|
37
|
+
# Validate against latest schema
|
|
38
|
+
validator.valid?(xml) # => `true` or `false`
|
|
39
|
+
|
|
40
|
+
# Validate against a specific schema version
|
|
41
|
+
validator.valid?(xml, version: '9.1') # => `true` or `false`
|
|
42
|
+
# => raises exception if version doesn't exist
|
|
43
|
+
|
|
44
|
+
# Get list of versions
|
|
45
|
+
validator.versions # => `["8", "8-rc1", "8.2", ... , "dev", "latest"]`
|
|
46
|
+
|
|
47
|
+
# Validate and return a list of errors
|
|
48
|
+
validator.valid?(xml) # => array of errors (`[]` if valid)
|
|
49
|
+
|
|
50
|
+
# Validate and return a list of errors for a specific schema version
|
|
51
|
+
validator.valid?(xml, version: '9.1') # => array of errors (`[]` if valid)
|
|
52
|
+
# => raises exception if version doesn't exist
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Development
|
|
56
|
+
|
|
57
|
+
### Setup
|
|
58
|
+
|
|
59
|
+
* `bundle install`
|
|
60
|
+
|
|
61
|
+
### Running tests
|
|
62
|
+
|
|
63
|
+
* `bundle exec rspec`
|
|
64
|
+
|
|
65
|
+
### Linting the code
|
|
66
|
+
|
|
67
|
+
* `bundle exec rubocop`
|
|
68
|
+
|
|
69
|
+
### Updating schemas
|
|
70
|
+
|
|
71
|
+
* `bash scripts/update-schema.sh` (requires `wget`)
|
|
72
|
+
|
|
73
|
+
### Publishing
|
|
74
|
+
|
|
75
|
+
* Bump version in `lib/epi_doc_validator/version.rb`
|
|
76
|
+
* Commit and push to GitHub
|
|
77
|
+
* On GitHub, create a new release
|
|
78
|
+
* Run `gem build epi_doc_validator.gemspec`
|
|
79
|
+
* Run `gem push epi_doc_validator-X.Y.Z-java.gem`
|
|
80
|
+
|
|
81
|
+
## Notes
|
|
82
|
+
|
|
83
|
+
Currently, the library only works with JRuby.
|
|
84
|
+
All of the code in *this* repository works with both Ruby MRI and JRuby.
|
|
85
|
+
In the future we hope to release a version that works with Ruby MRI.
|
|
86
|
+
|
|
87
|
+
The problem is that the EpiDoc schema is written in something called RELAX NG.
|
|
88
|
+
Nokogiri, the main XML processing library for Ruby, uses `libxml2` with Ruby MRI
|
|
89
|
+
and `jing` with JRuby. `jing` works correctly, but there are at least two long-standing
|
|
90
|
+
bugs in `libxml2`'s RELAX NG validation code.
|
|
91
|
+
Until these are fixed, this library is too unstable with Ruby MRI to release.
|
|
92
|
+
|
|
93
|
+
List of (known) bugs:
|
|
94
|
+
|
|
95
|
+
* 2008: "RNG internal error trying to compile notAllowed" warning is printed multiple times ([link](https://mail.gnome.org/archives/xml/2008-June/msg00087.html))
|
|
96
|
+
* 2012: Validation never terminates on occasion ([link](https://github.com/sparklemotion/nokogiri/issues/806))
|
|
97
|
+
|
|
98
|
+
For a more detailed explanation of this problem in a slightly different domain,
|
|
99
|
+
see Hugh Cayless's post [Experiment: is the JavaScript port of libxml2 viable?](https://github.com/hcayless/brackets/blob/master/experiment_1.md):
|
|
100
|
+
|
|
101
|
+
> Result: Inconclusive; lean towards endless screaming.
|
data/Rakefile
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
require_relative 'lib/epi_doc_validator/version'
|
|
2
|
+
|
|
3
|
+
Gem::Specification.new do |spec|
|
|
4
|
+
spec.name = 'epi_doc_validator'
|
|
5
|
+
spec.version = EpiDocValidator::VERSION
|
|
6
|
+
spec.authors = ['Perseids Project']
|
|
7
|
+
spec.email = ['perseids@tufts.edu']
|
|
8
|
+
|
|
9
|
+
spec.summary = 'Library for validating EpiDoc XML'
|
|
10
|
+
spec.description = 'Library for validating EpiDoc XML'
|
|
11
|
+
spec.homepage = 'https://github.com/perseids-tools/epi-doc-validator-rb'
|
|
12
|
+
spec.license = 'MIT'
|
|
13
|
+
spec.required_ruby_version = Gem::Requirement.new('>= 2.4')
|
|
14
|
+
|
|
15
|
+
spec.metadata['homepage_uri'] = 'https://github.com/perseids-tools/epi-doc-validator-rb'
|
|
16
|
+
spec.metadata['source_code_uri'] = 'https://github.com/perseids-tools/epi-doc-validator-rb'
|
|
17
|
+
spec.metadata['changelog_uri'] = 'https://github.com/perseids-tools/epi-doc-validator-rb/releases'
|
|
18
|
+
|
|
19
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
|
20
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features|bin|scripts)/}) }
|
|
21
|
+
end
|
|
22
|
+
spec.bindir = 'exe'
|
|
23
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
24
|
+
spec.require_paths = ['lib']
|
|
25
|
+
spec.platform = 'java'
|
|
26
|
+
|
|
27
|
+
spec.add_dependency 'nokogiri', '~> 1.10'
|
|
28
|
+
end
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
module EpiDocValidator
|
|
2
|
+
class SemVer
|
|
3
|
+
def self.sort(versions)
|
|
4
|
+
versions.map { |v| new(v) }.sort.map(&:semver)
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
def initialize(semver)
|
|
8
|
+
@semver = semver
|
|
9
|
+
|
|
10
|
+
numbers, @patch = *semver.split('-')
|
|
11
|
+
|
|
12
|
+
if semver.match?(/\A\d/)
|
|
13
|
+
@components = numbers.split('.').map(&:to_i)
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def <=>(other)
|
|
18
|
+
return 0 if semver == other.semver
|
|
19
|
+
|
|
20
|
+
return compare_strings(other) if string? || other.string?
|
|
21
|
+
|
|
22
|
+
compare_components(other)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
attr_reader :semver
|
|
26
|
+
|
|
27
|
+
protected
|
|
28
|
+
|
|
29
|
+
attr_reader :components
|
|
30
|
+
|
|
31
|
+
def patch
|
|
32
|
+
@patch || ''
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def string?
|
|
36
|
+
components.nil?
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def value_at(index)
|
|
40
|
+
components[index] || 0
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
private
|
|
44
|
+
|
|
45
|
+
def compare_strings(other)
|
|
46
|
+
return 1 if string? && !other.string?
|
|
47
|
+
return -1 if !string? && other.string?
|
|
48
|
+
|
|
49
|
+
semver <=> other.semver if string? && other.string?
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def compare_components(other, index = 0)
|
|
53
|
+
return patch <=> other.patch if !components[index] && !other.components[index]
|
|
54
|
+
return -1 if value_at(index) < other.value_at(index)
|
|
55
|
+
return 1 if value_at(index) > other.value_at(index)
|
|
56
|
+
|
|
57
|
+
compare_components(other, index + 1)
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|