pubid-itu 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/i18n.yaml +13 -0
- data/lib/pubid/itu/identifier/annex.rb +7 -0
- data/lib/pubid/itu/identifier/base.rb +13 -6
- data/lib/pubid/itu/identifier/contribution.rb +15 -0
- data/lib/pubid/itu/identifier/question.rb +1 -1
- data/lib/pubid/itu/identifier/resolution.rb +1 -1
- data/lib/pubid/itu/identifier.rb +1 -1
- data/lib/pubid/itu/parser.rb +5 -1
- data/lib/pubid/itu/renderer/base.rb +41 -7
- data/lib/pubid/itu/renderer/contribution.rb +15 -0
- data/lib/pubid/itu/renderer/implementers_guide.rb +1 -1
- data/lib/pubid/itu/version.rb +1 -1
- data/lib/pubid/itu.rb +6 -1
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4b5ede4e5121a3af045e2b6459a59f540449c7c68cd167ab2941b00c793668ed
|
4
|
+
data.tar.gz: 51a94e41094937353557a316b72dd1fb7fb44a7a14f4efc5dbc17ed61e06c35f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 32adffd9092c1ded6b651e39a8093a578cc26f13ad2fadd7e59219b88fa6a548074718195957f411a3e95bbd5e409b227dc09789d18aa403ec673af25485000b
|
7
|
+
data.tar.gz: 07aec0fd86e6dd91ec5503eb878d43b05a01dcdf253ecbb2ed95053387d580a7321caef6d738a7a41e76192e839dadda3b6b54c954271fc693e7a596bbc04d5b
|
data/i18n.yaml
ADDED
@@ -3,6 +3,13 @@ module Pubid::Itu
|
|
3
3
|
class Annex < Supplement
|
4
4
|
def_delegators 'Pubid::Itu::Identifier::Annex', :type
|
5
5
|
|
6
|
+
attr_accessor :base
|
7
|
+
|
8
|
+
def initialize(base: nil, **opts)
|
9
|
+
super(**opts)
|
10
|
+
@base = base
|
11
|
+
end
|
12
|
+
|
6
13
|
def self.type
|
7
14
|
{ key: :annex, title: "Annex" }
|
8
15
|
end
|
@@ -47,12 +47,19 @@ module Pubid::Itu
|
|
47
47
|
end
|
48
48
|
|
49
49
|
def transform_supplements(type, identifier_params)
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
50
|
+
if identifier_params[type].is_a?(Hash)
|
51
|
+
Identifier.create(
|
52
|
+
type: type,
|
53
|
+
base: transform(
|
54
|
+
**identifier_params.dup.tap { |h| h.delete(type) }),
|
55
|
+
**identifier_params[type],
|
56
|
+
)
|
57
|
+
else
|
58
|
+
Identifier.create(
|
59
|
+
type: type,
|
60
|
+
base: transform(**identifier_params.dup.tap { |h| h.delete(type) })
|
61
|
+
)
|
62
|
+
end
|
56
63
|
end
|
57
64
|
|
58
65
|
# Use Identifier#create to resolve identifier's type class
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Pubid::Itu
|
2
|
+
module Identifier
|
3
|
+
class Contribution < Base
|
4
|
+
def_delegators 'Pubid::Itu::Identifier::Contribution', :type
|
5
|
+
|
6
|
+
def self.type
|
7
|
+
{ key: :contribution, title: "Contribution" }
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.get_renderer_class
|
11
|
+
Renderer::Contribution
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/lib/pubid/itu/identifier.rb
CHANGED
@@ -9,7 +9,7 @@ module Pubid::Itu
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def resolve_identifier(parameters = {})
|
12
|
-
return Question.new(**parameters) if parameters[:series].to_s.match?(/^SG/)
|
12
|
+
return Question.new(**parameters) if parameters[:series].to_s.match?(/^SG/) && !parameters[:type]
|
13
13
|
|
14
14
|
return Resolution.new(**parameters) if parameters[:series].to_s == "R"
|
15
15
|
|
data/lib/pubid/itu/parser.rb
CHANGED
@@ -88,6 +88,10 @@ module Pubid::Itu
|
|
88
88
|
space >> str("Annex") >> space >> (match["A-Z"] >> digits.maybe >> str("+").maybe).as(:number).as(:annex)
|
89
89
|
end
|
90
90
|
|
91
|
+
rule(:annex_to) do
|
92
|
+
str("Annex to ").as(:annex)
|
93
|
+
end
|
94
|
+
|
91
95
|
rule(:corrigendum) do
|
92
96
|
(published >> space >> str("Cor.") >> space >>
|
93
97
|
digits.as(:number)).as(:corrigendum)
|
@@ -107,7 +111,7 @@ module Pubid::Itu
|
|
107
111
|
end
|
108
112
|
|
109
113
|
rule(:identifier) do
|
110
|
-
str("ITU") >> (dash | space) >> sector_series_number >> supplement.maybe >>
|
114
|
+
annex_to.maybe >> str("ITU") >> (dash | space) >> sector_series_number >> supplement.maybe >>
|
111
115
|
annex.maybe >> corrigendum.maybe >> addendum.maybe >> appendix.maybe >>
|
112
116
|
published.maybe >> amendment.maybe >> str("-I").maybe >> language.maybe
|
113
117
|
end
|
@@ -10,14 +10,48 @@ module Pubid::Itu::Renderer
|
|
10
10
|
"%{type}%{series}" % params
|
11
11
|
end
|
12
12
|
|
13
|
-
def
|
14
|
-
|
13
|
+
def render_base_identifier(**args)
|
14
|
+
prerender(**args)
|
15
|
+
|
16
|
+
# pass args to render_identifier
|
17
|
+
render_identifier(@prerendered_params, args)
|
18
|
+
end
|
19
|
+
|
20
|
+
# can prepend entity, can postpend, can use item holder
|
21
|
+
|
22
|
+
def render_identifier(params, opts)
|
23
|
+
postfix = prefix = ""
|
24
|
+
if @params[:annex] && @params[:annex][:number].nil?
|
25
|
+
prefix += "Annex to "
|
26
|
+
elsif opts[:language] &&
|
27
|
+
(type_translation = Pubid::Itu::I18N["type"][@params[:type]]&.fetch(opts[:language].to_s, nil))
|
28
|
+
if opts[:language] == :cn
|
29
|
+
postfix =+ type_translation
|
30
|
+
elsif opts[:language] == :ar
|
31
|
+
postfix += " #{type_translation}"
|
32
|
+
else
|
33
|
+
prefix += "#{type_translation} "
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
"#{prefix}%{publisher}-%{sector} #{render_type_series(params)}%{number}%{subseries}"\
|
15
38
|
"%{part}%{second_number}%{range}%{annex}%{amendment}%{corrigendum}%{supplement}"\
|
16
|
-
"%{addendum}%{appendix}%{date}" % params
|
39
|
+
"%{addendum}%{appendix}%{date}#{postfix}" % params
|
40
|
+
end
|
41
|
+
|
42
|
+
def render_publisher(publisher, opts, params)
|
43
|
+
if opts[:language] &&
|
44
|
+
(publisher_translation = Pubid::Itu::I18N["publisher"][publisher]&.fetch(opts[:language].to_s, nil))
|
45
|
+
return super(publisher_translation, opts, params)
|
46
|
+
end
|
47
|
+
|
48
|
+
super
|
17
49
|
end
|
18
50
|
|
19
51
|
def render_number(number, _opts, params)
|
20
|
-
params[:series]
|
52
|
+
return " No. #{number}" if params[:series] == "OB"
|
53
|
+
|
54
|
+
number
|
21
55
|
end
|
22
56
|
|
23
57
|
def render_date(date, opts, _params)
|
@@ -38,8 +72,8 @@ module Pubid::Itu::Renderer
|
|
38
72
|
"-#{part}"
|
39
73
|
end
|
40
74
|
|
41
|
-
def render_series(series, _opts,
|
42
|
-
|
75
|
+
def render_series(series, _opts, params)
|
76
|
+
series + (params[:series] != "OB" && params[:number] ? "." : "")
|
43
77
|
end
|
44
78
|
|
45
79
|
def render_amendment(amendment, _opts, _params)
|
@@ -67,7 +101,7 @@ module Pubid::Itu::Renderer
|
|
67
101
|
end
|
68
102
|
|
69
103
|
def render_annex(annex, _opts, _params)
|
70
|
-
" Annex #{annex[:number]}"
|
104
|
+
" Annex #{annex[:number]}" if annex[:number]
|
71
105
|
end
|
72
106
|
|
73
107
|
def render_corrigendum(corrigendum, opts, params)
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Pubid::Itu::Renderer
|
2
|
+
class Contribution < Base
|
3
|
+
def render_identifier(params, _opts)
|
4
|
+
("%{series}-C%{number}" % params)
|
5
|
+
end
|
6
|
+
|
7
|
+
def render_series(series, _opts, _params)
|
8
|
+
series
|
9
|
+
end
|
10
|
+
|
11
|
+
def render_number(number, _opts, params)
|
12
|
+
number
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/lib/pubid/itu/version.rb
CHANGED
data/lib/pubid/itu.rb
CHANGED
@@ -13,6 +13,8 @@ module Pubid
|
|
13
13
|
"es": "S",
|
14
14
|
"zh": "C",
|
15
15
|
}.freeze
|
16
|
+
|
17
|
+
I18N = YAML.load_file(File.join(File.dirname(__FILE__), "../../i18n.yaml"))
|
16
18
|
end
|
17
19
|
end
|
18
20
|
|
@@ -32,9 +34,11 @@ require_relative "itu/identifier/annex"
|
|
32
34
|
require_relative "itu/identifier/corrigendum"
|
33
35
|
require_relative "itu/identifier/addendum"
|
34
36
|
require_relative "itu/identifier/appendix"
|
37
|
+
require_relative "itu/identifier/contribution"
|
35
38
|
require_relative "itu/transformer"
|
36
39
|
require_relative "itu/renderer/base"
|
37
40
|
require_relative "itu/renderer/implementers_guide"
|
41
|
+
require_relative "itu/renderer/contribution"
|
38
42
|
require_relative "itu/parser"
|
39
43
|
require_relative "itu/identifier"
|
40
44
|
require_relative "itu/configuration"
|
@@ -53,7 +57,8 @@ config.types = [Pubid::Itu::Identifier::Base,
|
|
53
57
|
Pubid::Itu::Identifier::Supplement,
|
54
58
|
Pubid::Itu::Identifier::Annex,
|
55
59
|
Pubid::Itu::Identifier::Addendum,
|
56
|
-
Pubid::Itu::Identifier::Appendix
|
60
|
+
Pubid::Itu::Identifier::Appendix,
|
61
|
+
Pubid::Itu::Identifier::Contribution]
|
57
62
|
config.type_names = {}.freeze
|
58
63
|
config.series = YAML.load_file(File.join(File.dirname(__FILE__), "../../series.yaml"))
|
59
64
|
Pubid::Itu::Identifier.set_config(config)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pubid-itu
|
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: 2024-
|
11
|
+
date: 2024-10-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -77,6 +77,7 @@ extra_rdoc_files:
|
|
77
77
|
files:
|
78
78
|
- LICENSE.txt
|
79
79
|
- README.adoc
|
80
|
+
- i18n.yaml
|
80
81
|
- lib/pubid-itu.rb
|
81
82
|
- lib/pubid/itu.rb
|
82
83
|
- lib/pubid/itu/configuration.rb
|
@@ -87,6 +88,7 @@ files:
|
|
87
88
|
- lib/pubid/itu/identifier/annex.rb
|
88
89
|
- lib/pubid/itu/identifier/appendix.rb
|
89
90
|
- lib/pubid/itu/identifier/base.rb
|
91
|
+
- lib/pubid/itu/identifier/contribution.rb
|
90
92
|
- lib/pubid/itu/identifier/corrigendum.rb
|
91
93
|
- lib/pubid/itu/identifier/implementers_guide.rb
|
92
94
|
- lib/pubid/itu/identifier/question.rb
|
@@ -97,6 +99,7 @@ files:
|
|
97
99
|
- lib/pubid/itu/identifier/supplement.rb
|
98
100
|
- lib/pubid/itu/parser.rb
|
99
101
|
- lib/pubid/itu/renderer/base.rb
|
102
|
+
- lib/pubid/itu/renderer/contribution.rb
|
100
103
|
- lib/pubid/itu/renderer/implementers_guide.rb
|
101
104
|
- lib/pubid/itu/transformer.rb
|
102
105
|
- lib/pubid/itu/version.rb
|
@@ -120,7 +123,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
120
123
|
- !ruby/object:Gem::Version
|
121
124
|
version: '0'
|
122
125
|
requirements: []
|
123
|
-
rubygems_version: 3.3.
|
126
|
+
rubygems_version: 3.3.27
|
124
127
|
signing_key:
|
125
128
|
specification_version: 4
|
126
129
|
summary: Library to generate, parse and manipulate ITU PubID.
|