pubid-cen 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pubid/cen/identifier/base.rb +5 -4
- data/lib/pubid/cen/identifier/corrigendum.rb +2 -2
- data/lib/pubid/cen/parser.rb +3 -2
- data/lib/pubid/cen/renderer/base.rb +2 -0
- data/lib/pubid/cen/transformer.rb +6 -0
- data/lib/pubid/cen/version.rb +1 -1
- data/lib/pubid/cen.rb +2 -0
- metadata +30 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ff3dc2816c021cb1fdb8c1402accf7ef56f9bdc96a62ae353961610206fcf7a3
|
4
|
+
data.tar.gz: c5346effa784afc5f8b14ff09656ae056c0715421faf3f7655762cfc2cf66bdb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d4c27399582f5265dd962fe9b352e2e24a81cbeeca9759fc54bb94777f70181825b5337917efa1a2b71df1cff09555197b9110d468e019ca7d56ba269fb2b3d6
|
7
|
+
data.tar.gz: 28551377f3767fed23b16d62ef51712f1e5380616edccfab47fceb3e870a701e8396e78467a0b310890d8c5d11284d9438f7329deb33ffc98819ac6dc1c92560
|
@@ -4,8 +4,7 @@ module Pubid::Cen
|
|
4
4
|
module Identifier
|
5
5
|
class Base < Pubid::Core::Identifier::Base
|
6
6
|
extend Forwardable
|
7
|
-
|
8
|
-
attr_accessor :supplements
|
7
|
+
attr_accessor :supplements, :adopted
|
9
8
|
|
10
9
|
def self.type
|
11
10
|
{ key: :en, title: "European Norm" }
|
@@ -13,11 +12,13 @@ module Pubid::Cen
|
|
13
12
|
|
14
13
|
# @param month [Integer] document's month
|
15
14
|
# @param edition [String] document's edition version, e.g. "3.0", "1.0"
|
16
|
-
def initialize(publisher: "EN", part: nil, stage: nil,
|
17
|
-
|
15
|
+
def initialize(number: nil, publisher: "EN", part: nil, stage: nil,
|
16
|
+
incorporated_supplements: nil, adopted: nil, **opts)
|
17
|
+
super(**opts.merge(publisher: publisher, number: number))
|
18
18
|
@part = part if part
|
19
19
|
@stage = Identifier.parse_stage(stage) if stage
|
20
20
|
@supplements = incorporated_supplements
|
21
|
+
@adopted = adopted
|
21
22
|
end
|
22
23
|
|
23
24
|
class << self
|
@@ -4,8 +4,8 @@ module Pubid::Cen
|
|
4
4
|
def_delegators 'Pubid::Cen::Identifier::Corrigendum', :type
|
5
5
|
attr_accessor :base
|
6
6
|
|
7
|
-
def initialize(
|
8
|
-
super(**opts
|
7
|
+
def initialize(base: nil, **opts)
|
8
|
+
super(**opts)
|
9
9
|
@base = base
|
10
10
|
end
|
11
11
|
|
data/lib/pubid/cen/parser.rb
CHANGED
@@ -38,8 +38,9 @@ module Pubid::Cen
|
|
38
38
|
end
|
39
39
|
|
40
40
|
rule(:identifier) do
|
41
|
-
stage.maybe >> originator.maybe >> type.maybe >> space >> digits.as(:number) >> part >>
|
42
|
-
(str(":") >> year).maybe
|
41
|
+
stage.maybe >> originator.maybe >> ((type.maybe >> space >> digits.as(:number) >> part >>
|
42
|
+
(str(":") >> year).maybe) | space >> match("[^+/]").repeat(1).as(:adopted)) >>
|
43
|
+
supplement.maybe >> incorporated_supplement.repeat
|
43
44
|
end
|
44
45
|
|
45
46
|
rule(:root) { identifier }
|
@@ -1,6 +1,8 @@
|
|
1
1
|
module Pubid::Cen::Renderer
|
2
2
|
class Base < Pubid::Core::Renderer::Base
|
3
3
|
def render_identifier(params)
|
4
|
+
return "%{publisher} %{adopted}%{supplements}" % params unless params[:adopted].to_s.empty?
|
5
|
+
|
4
6
|
"%{stage}%{publisher}%{type} %{number}%{part}%{year}%{supplements}" % params
|
5
7
|
end
|
6
8
|
|
@@ -19,6 +19,12 @@ module Pubid::Cen
|
|
19
19
|
context
|
20
20
|
end
|
21
21
|
|
22
|
+
rule(adopted: subtree(:adopted)) do |context|
|
23
|
+
{ adopted: Pubid::Iec::Identifier.parse(context[:adopted].to_s) }
|
24
|
+
rescue Pubid::Core::Errors::ParseError
|
25
|
+
{ adopted: Pubid::Iso::Identifier.parse(context[:adopted].to_s) }
|
26
|
+
end
|
27
|
+
|
22
28
|
def self.convert_supplement(supplement)
|
23
29
|
case supplement[:type]
|
24
30
|
when "A"
|
data/lib/pubid/cen/version.rb
CHANGED
data/lib/pubid/cen.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pubid-cen
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-04-
|
11
|
+
date: 2023-04-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -108,6 +108,34 @@ dependencies:
|
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: 1.8.0
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: pubid-iso
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: 0.5.2
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: 0.5.2
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: pubid-iec
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: 0.2.2
|
132
|
+
type: :runtime
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: 0.2.2
|
111
139
|
description: Library to generate, parse and manipulate CEN PubID.
|
112
140
|
email:
|
113
141
|
- open.source@ribose.com
|