pubid-jis 0.2.0 → 0.3.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/jis/identifier/base.rb +12 -1
- data/lib/pubid/jis/identifier/explanation.rb +24 -0
- data/lib/pubid/jis/parser.rb +6 -2
- data/lib/pubid/jis/renderer/amendment.rb +4 -0
- data/lib/pubid/jis/renderer/base.rb +8 -0
- data/lib/pubid/jis/renderer/explanation.rb +13 -0
- data/lib/pubid/jis/version.rb +1 -1
- data/lib/pubid/jis.rb +7 -2
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 07eef4940f4a38e169eebcd786cb2d4456814c9bb0ab6eafba78eaf619dee42b
|
4
|
+
data.tar.gz: 6e42254073b7bcb5d8a00fc5c1d8c74d0a0ac116340f8b25ba6a77bbbc8b4de8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e94361974bb9a05aa7613270dbe940afeb45909274d279c505fa4612cb292854cea31b46c28d280348867cda5c9a620fb3fa4218dd833be84f8061d02ba4e254
|
7
|
+
data.tar.gz: b29aa12e363a0536f5a31bf8bc336ccaedc7e83d6e9f3a7c9ceb6d99f5f621245bd514150828c91fdbaea0039ffadec96ea40e353598e8c9fd668a44dba7ba70
|
@@ -44,7 +44,7 @@ module Pubid::Jis
|
|
44
44
|
def transform_supplements(supplements_params, base_params)
|
45
45
|
supplements = supplements_params.map do |supplement|
|
46
46
|
Identifier.create(number: supplement[:number], year: supplement[:year],
|
47
|
-
type:
|
47
|
+
type: :amd, base: Identifier.create(**base_params))
|
48
48
|
end
|
49
49
|
|
50
50
|
return supplements.first if supplements.count == 1
|
@@ -52,6 +52,10 @@ module Pubid::Jis
|
|
52
52
|
raise Errors::SupplementParsingError, "more than one or none supplements provided"
|
53
53
|
end
|
54
54
|
|
55
|
+
def transform_explanation(params, base_params)
|
56
|
+
Identifier.create(type: :explanation, base: Identifier.create(**base_params), **params)
|
57
|
+
end
|
58
|
+
|
55
59
|
# Use Identifier#create to resolve identifier's type class
|
56
60
|
def transform(params)
|
57
61
|
identifier_params = params.map do |k, v|
|
@@ -65,6 +69,13 @@ module Pubid::Jis
|
|
65
69
|
)
|
66
70
|
end
|
67
71
|
|
72
|
+
if identifier_params[:explanation]
|
73
|
+
return transform_explanation(
|
74
|
+
identifier_params[:explanation].is_a?(Hash) ? identifier_params[:explanation] : {},
|
75
|
+
identifier_params.dup.tap { |h| h.delete(:explanation) }
|
76
|
+
)
|
77
|
+
end
|
78
|
+
|
68
79
|
Identifier.create(**identifier_params)
|
69
80
|
end
|
70
81
|
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require_relative "../renderer/amendment"
|
2
|
+
|
3
|
+
module Pubid::Jis
|
4
|
+
module Identifier
|
5
|
+
class Explanation < Base
|
6
|
+
attr_accessor :base
|
7
|
+
|
8
|
+
def_delegators 'Pubid::Jis::Identifier::Explanation', :type
|
9
|
+
|
10
|
+
def initialize(base: nil, number: nil, **opts)
|
11
|
+
super(**opts.merge(number: number))
|
12
|
+
@base = base
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.type
|
16
|
+
{ key: :explanation, title: "Explanation", short: "EXPL" }
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.get_renderer_class
|
20
|
+
Renderer::Explanation
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/lib/pubid/jis/parser.rb
CHANGED
@@ -35,12 +35,16 @@ module Pubid::Jis
|
|
35
35
|
end
|
36
36
|
|
37
37
|
rule(:amendment) do
|
38
|
-
(str("/") >> str("AMD").as(:type) >> space >> digits.as(:number) >> colon >> year).repeat(1).as(:supplements)
|
38
|
+
(str("/") >> (str("AMD") | str("AMENDMENT")).as(:type) >> space >> digits.as(:number) >> colon >> year).repeat(1).as(:supplements)
|
39
|
+
end
|
40
|
+
|
41
|
+
rule(:explanation) do
|
42
|
+
(str("/") >> (str("EXPLANATION") | str("EXPL")) >> (space >> digits.as(:number)).maybe).as(:explanation)
|
39
43
|
end
|
40
44
|
|
41
45
|
rule(:identifier) do
|
42
46
|
str("JIS").maybe >> space? >> type.maybe >> space? >> series >> space? >> digits.as(:number) >> part >>
|
43
|
-
(colon >> year).maybe >> language.maybe >> all_parts.maybe >> amendment.maybe
|
47
|
+
(colon >> year).maybe >> language.maybe >> all_parts.maybe >> amendment.maybe >> explanation.maybe
|
44
48
|
end
|
45
49
|
|
46
50
|
rule(:root) { identifier }
|
@@ -2,6 +2,10 @@ module Pubid::Jis::Renderer
|
|
2
2
|
class Base < Pubid::Core::Renderer::Base
|
3
3
|
TYPE = "".freeze
|
4
4
|
|
5
|
+
def render(**args)
|
6
|
+
render_base_identifier(**args) + @prerendered_params[:language].to_s
|
7
|
+
end
|
8
|
+
|
5
9
|
def render_identifier(params)
|
6
10
|
"%{publisher}%{series} %{number}%{part}%{year}%{all_parts}" % params
|
7
11
|
end
|
@@ -23,5 +27,9 @@ module Pubid::Jis::Renderer
|
|
23
27
|
def render_all_parts(all_parts, _opts, _params)
|
24
28
|
"(規格群)" if all_parts
|
25
29
|
end
|
30
|
+
|
31
|
+
def render_year(year, _opts, _params)
|
32
|
+
":#{year}"
|
33
|
+
end
|
26
34
|
end
|
27
35
|
end
|
data/lib/pubid/jis/version.rb
CHANGED
data/lib/pubid/jis.rb
CHANGED
@@ -12,16 +12,21 @@ require_relative "jis/identifier/base"
|
|
12
12
|
require_relative "jis/identifier/technical_report"
|
13
13
|
require_relative "jis/identifier/technical_specification"
|
14
14
|
require_relative "jis/identifier/amendment"
|
15
|
+
require_relative "jis/identifier/explanation"
|
15
16
|
require_relative "jis/renderer/base"
|
16
17
|
require_relative "jis/renderer/technical_report"
|
17
18
|
require_relative "jis/renderer/technical_specification"
|
18
19
|
require_relative "jis/renderer/amendment"
|
20
|
+
require_relative "jis/renderer/explanation"
|
19
21
|
require_relative "jis/parser"
|
20
22
|
require_relative "jis/identifier"
|
21
23
|
|
22
24
|
config = Pubid::Core::Configuration.new
|
23
25
|
config.default_type = Pubid::Jis::Identifier::Base
|
24
|
-
config.types = [Pubid::Jis::Identifier::Base,
|
25
|
-
Pubid::Jis::Identifier::
|
26
|
+
config.types = [Pubid::Jis::Identifier::Base,
|
27
|
+
Pubid::Jis::Identifier::TechnicalReport,
|
28
|
+
Pubid::Jis::Identifier::TechnicalSpecification,
|
29
|
+
Pubid::Jis::Identifier::Amendment,
|
30
|
+
Pubid::Jis::Identifier::Explanation]
|
26
31
|
config.type_names = {}.freeze
|
27
32
|
Pubid::Jis::Identifier.set_config(config)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pubid-jis
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.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-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -125,11 +125,13 @@ files:
|
|
125
125
|
- lib/pubid/jis/identifier.rb
|
126
126
|
- lib/pubid/jis/identifier/amendment.rb
|
127
127
|
- lib/pubid/jis/identifier/base.rb
|
128
|
+
- lib/pubid/jis/identifier/explanation.rb
|
128
129
|
- lib/pubid/jis/identifier/technical_report.rb
|
129
130
|
- lib/pubid/jis/identifier/technical_specification.rb
|
130
131
|
- lib/pubid/jis/parser.rb
|
131
132
|
- lib/pubid/jis/renderer/amendment.rb
|
132
133
|
- lib/pubid/jis/renderer/base.rb
|
134
|
+
- lib/pubid/jis/renderer/explanation.rb
|
133
135
|
- lib/pubid/jis/renderer/technical_report.rb
|
134
136
|
- lib/pubid/jis/renderer/technical_specification.rb
|
135
137
|
- lib/pubid/jis/version.rb
|