pubid-cen 0.1.1 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9e1da29b88d15117361e26282da95f073c8027ff11e82b1dc2e68a8e5481231f
4
- data.tar.gz: 4e262d7c9e52228f282e82b794d6036a7fdf85d59854fa6be1025da067af54ed
3
+ metadata.gz: 670ef1b7391c8d5b2f576a67f7da3f3320094778302898603ee9fb819d5d8b8e
4
+ data.tar.gz: bb1aa27c00811ad9b111da9c97f0f3b9190cc328b632361ed1314c36a26541e0
5
5
  SHA512:
6
- metadata.gz: 210ce4b95af59951c42d34cadfafe657b07af6ea3fe29bf7a3c82453fb7c0e4552b1f4f04e26f1852ae9b7e0785ed94e386743da07ff2f0b3641b31c3496602e
7
- data.tar.gz: c6f3e4cc992bb794e619d30bf9eef992f5bddb5dc7dd1c91f7675439db78ed5e62a7103b3ad444385a2e11a14db985a5d8483920c113345a064940f192580877
6
+ metadata.gz: 94795c4877fcf2d970377ce2455fda3f8abda4b54bd31f203d692fa1e1f9bae1fe00203f7623e343810c41ac372215727f166a22d62b6b04bd225f51dbe7f9ab
7
+ data.tar.gz: 21bd2bd896f9ad6de4fe3f9b8f9fa1e5ace3c2186e758d691a23172c6951b95b6b650afd8769445268c47e6f18222ca262c66373347a484c57e675da3caa4e46
@@ -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, incorporated_supplements: nil, **opts)
17
- super(**opts.merge(publisher: publisher))
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(number: nil, base: nil, **opts)
8
- super(**opts.merge(number: number))
7
+ def initialize(base: nil, **opts)
8
+ super(**opts)
9
9
  @base = base
10
10
  end
11
11
 
@@ -38,8 +38,14 @@ 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 >> supplement.maybe >> incorporated_supplement.repeat
41
+ stage.maybe >> originator.maybe >> ((type.maybe >> space >> digits.as(:number) >> part >>
42
+ (str(":") >> year).maybe) | (space >> (match("[^+/]").repeat(1) >>
43
+ # XXX: hack to match part after "/" for identifiers like
44
+ # EN ISO/IEC 80079-34:2020 ED2
45
+ # but march only part before "/" for identifiers like
46
+ # EN ISO 13485:2016/AC:2016
47
+ (supplement.absent? >> match("[^+]").repeat(1)).maybe).as(:adopted))) >>
48
+ supplement.maybe >> incorporated_supplement.repeat
43
49
  end
44
50
 
45
51
  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"
@@ -1,5 +1,5 @@
1
1
  module Pubid
2
2
  module Cen
3
- VERSION = "0.1.1".freeze
3
+ VERSION = "0.2.1".freeze
4
4
  end
5
5
  end
data/lib/pubid/cen.rb CHANGED
@@ -6,6 +6,8 @@ module Pubid
6
6
  end
7
7
 
8
8
  require "pubid-core"
9
+ require "pubid-iso"
10
+ require "pubid-iec"
9
11
 
10
12
  require_relative "cen/errors"
11
13
  require_relative "cen/transformer"
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.1.1
4
+ version: 0.2.1
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-02 00:00:00.000000000 Z
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