nist-pubid 0.1.2 → 0.1.3
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 +4 -4
- data/.github/workflows/release.yml +46 -0
- data/lib/nist_pubid/document.rb +12 -9
- data/lib/nist_pubid/serie.rb +1 -1
- data/lib/nist_pubid/stage.rb +23 -8
- data/lib/nist_pubid/version.rb +1 -1
- data/stages.yaml +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 48d1d54a6499cb679c33cfa2a7cc2a682b6b41e9c66aab0c301375c5df28e3f3
|
4
|
+
data.tar.gz: 64fa186792b6564f8afc4f2388f4e2859b04dbcdca5f7cd00e40b192c7f9fc4a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 25197a16bbaa8b4799d0279cf19303de616da1e34452997df576be22cb459aa3b00f538af680d9fa37330d6c7358587d56173ab2bc10f57755774537185c205e
|
7
|
+
data.tar.gz: 3e6ae4db9939f1f415ae56ec5aba095a41706157143740a6412d78b560cf850854a779104b22edbc278234fc657ed3289aaf1ab832ef909d58b9d465ec86170b
|
@@ -0,0 +1,46 @@
|
|
1
|
+
name: release
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
tags:
|
6
|
+
- '*'
|
7
|
+
workflow_dispatch:
|
8
|
+
inputs:
|
9
|
+
next_version:
|
10
|
+
description: |
|
11
|
+
Next release version. Possible values: x.y.z, major, minor, patch or pre|rc|etc
|
12
|
+
required: true
|
13
|
+
default: 'skip'
|
14
|
+
|
15
|
+
jobs:
|
16
|
+
release:
|
17
|
+
runs-on: ubuntu-18.04
|
18
|
+
steps:
|
19
|
+
- uses: actions/checkout@v1
|
20
|
+
|
21
|
+
- uses: ruby/setup-ruby@v1
|
22
|
+
with:
|
23
|
+
ruby-version: '2.6'
|
24
|
+
bundler-cache: true
|
25
|
+
|
26
|
+
- run: bundle exec rake
|
27
|
+
|
28
|
+
- run: gem install gem-release
|
29
|
+
|
30
|
+
- run: |
|
31
|
+
git config user.name github-actions
|
32
|
+
git config user.email github-actions@github.com
|
33
|
+
- if: github.event_name == 'workflow_dispatch' && github.event.inputs.next_version != 'skip'
|
34
|
+
run: gem bump --version ${{ github.event.inputs.next_version }} --tag --push
|
35
|
+
|
36
|
+
- name: Publish to rubygems.org
|
37
|
+
env:
|
38
|
+
RUBYGEMS_API_KEY: ${{secrets.METANORMA_CI_RUBYGEMS_API_KEY}}
|
39
|
+
run: |
|
40
|
+
gem install gem-release
|
41
|
+
cat > ~/.gem/credentials << EOF
|
42
|
+
---
|
43
|
+
:rubygems_api_key: ${RUBYGEMS_API_KEY}
|
44
|
+
EOF
|
45
|
+
chmod 0600 ~/.gem/credentials
|
46
|
+
gem release
|
data/lib/nist_pubid/document.rb
CHANGED
@@ -40,11 +40,10 @@ module NistPubid
|
|
40
40
|
attr_accessor :serie, :code, :revision, :publisher, :version, :volume,
|
41
41
|
:part, :addendum, :stage, :translation, :update, :edition
|
42
42
|
|
43
|
-
def initialize(publisher:, serie:, docnumber:,
|
43
|
+
def initialize(publisher:, serie:, docnumber:, **opts)
|
44
44
|
@publisher = Publisher.new(publisher: publisher)
|
45
45
|
@serie = Serie.new(serie: serie)
|
46
46
|
@code = docnumber
|
47
|
-
@stage = Stage.new(stage: stage)
|
48
47
|
opts.each { |key, value| send("#{key}=", value) }
|
49
48
|
end
|
50
49
|
|
@@ -52,7 +51,7 @@ module NistPubid
|
|
52
51
|
matches = {
|
53
52
|
publisher: match(Publisher.regexp, code) || "NIST",
|
54
53
|
serie: match(Serie.regexp, code)&.gsub(/\./, " "),
|
55
|
-
stage:
|
54
|
+
stage: Stage.parse(code),
|
56
55
|
docnumber: match(/(?<=\.|\s)[0-9-]{3,}[A-Z]?/, code),
|
57
56
|
part: /(?<=(\.))?pt(?(1)-)([A-Z\d]+)/.match(code)&.[](2),
|
58
57
|
volume: /(?<=(\.))?v(?(1)-)(\d+)/.match(code)&.[](2),
|
@@ -60,11 +59,13 @@ module NistPubid
|
|
60
59
|
revision: /(?<=[^a-z])(?<=(\.))?(?:r(?(1)-)|Rev\.\s)(\d+)/
|
61
60
|
.match(code)&.[](2),
|
62
61
|
addendum: match(/(?<=(\.))?(add(?(1)-)\d+|Addendum)/, code),
|
63
|
-
translation: match(/(?<=\()\w{3}(?=\))/, code),
|
64
62
|
update: match(/(?<=Upd\s)([\d:]+)/, code),
|
65
63
|
edition: /(?<=[^a-z])(?<=(\.))?(?:e(?(1)-)|Ed\.\s)(\d+)/
|
66
64
|
.match(code)&.[](2),
|
67
65
|
}
|
66
|
+
code = code.gsub(matches[:stage].original_code, "") unless matches[:stage].nil?
|
67
|
+
matches[:translation] = match(/(?<=\()\w{3}(?=\))/, code)
|
68
|
+
|
68
69
|
new(**matches)
|
69
70
|
end
|
70
71
|
|
@@ -73,9 +74,11 @@ module NistPubid
|
|
73
74
|
end
|
74
75
|
|
75
76
|
def to_s(format)
|
76
|
-
result =
|
77
|
-
|
78
|
-
|
77
|
+
result = render_serie(format)
|
78
|
+
result += " " unless format == :short || stage.nil?
|
79
|
+
result += "#{stage&.to_s(format)}"\
|
80
|
+
" #{code}#{render_part(format)}#{render_edition(format)}"\
|
81
|
+
"#{render_update(format)}#{render_translation(format)}"
|
79
82
|
result = render_addendum(result, format)
|
80
83
|
|
81
84
|
return result.gsub(" ", ".") if format == :mr
|
@@ -84,9 +87,9 @@ module NistPubid
|
|
84
87
|
end
|
85
88
|
|
86
89
|
def render_serie(format)
|
87
|
-
return
|
90
|
+
return serie.to_s(format) if %i[mr short].include?(format)
|
88
91
|
|
89
|
-
"#{publisher.to_s(format)} #{serie.to_s(format)}
|
92
|
+
"#{publisher.to_s(format)} #{serie.to_s(format)}"
|
90
93
|
end
|
91
94
|
|
92
95
|
def render_part(format)
|
data/lib/nist_pubid/serie.rb
CHANGED
data/lib/nist_pubid/stage.rb
CHANGED
@@ -2,21 +2,36 @@ STAGES = YAML.load_file(File.join(File.dirname(__FILE__), "../../stages.yaml"))
|
|
2
2
|
|
3
3
|
module NistPubid
|
4
4
|
class Stage
|
5
|
-
attr_accessor :stage
|
5
|
+
attr_accessor :stage, :original_code
|
6
6
|
|
7
|
-
def initialize(
|
8
|
-
|
7
|
+
def initialize(original_code)
|
8
|
+
self.original_code = original_code
|
9
|
+
@stage = self.class.regexp.match(original_code)&.[](1)
|
9
10
|
end
|
10
11
|
|
11
|
-
def to_s(format)
|
12
|
-
return "" if
|
13
|
-
return "#{@stage} " if %i[short mr].include?(format)
|
12
|
+
def to_s(format = :short)
|
13
|
+
return "" if nil?
|
14
14
|
|
15
|
-
|
15
|
+
case format
|
16
|
+
when :short
|
17
|
+
"(#{@stage})"
|
18
|
+
when :mr
|
19
|
+
@stage
|
20
|
+
else
|
21
|
+
STAGES[@stage]
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.parse(code)
|
26
|
+
new(regexp.match(code)&.to_s)
|
16
27
|
end
|
17
28
|
|
18
29
|
def self.regexp
|
19
|
-
|
30
|
+
/\((#{STAGES.keys.join('|')})\)/
|
31
|
+
end
|
32
|
+
|
33
|
+
def nil?
|
34
|
+
@stage.nil?
|
20
35
|
end
|
21
36
|
end
|
22
37
|
end
|
data/lib/nist_pubid/version.rb
CHANGED
data/stages.yaml
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nist-pubid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-12-
|
11
|
+
date: 2021-12-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -48,6 +48,7 @@ extra_rdoc_files:
|
|
48
48
|
- LICENSE.txt
|
49
49
|
files:
|
50
50
|
- ".github/workflows/rake.yml"
|
51
|
+
- ".github/workflows/release.yml"
|
51
52
|
- ".rspec"
|
52
53
|
- ".rubocop.yml"
|
53
54
|
- Gemfile
|