relaton-cen 1.13.0 → 1.14.1

Sign up to get free protection for your applications and to get access to all the features.
data/grammars/biblio.rng CHANGED
@@ -33,9 +33,10 @@
33
33
  <param name="pattern">([\+\-]?\d{4})((-?)((0[1-9]|1[0-2])((-?)([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-2])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6]))))?</param>
34
34
  </data>
35
35
  </define>
36
- <start>
37
- <ref name="bibitem"/>
38
- </start>
36
+ <!-- start = bibitem -->
37
+ <define name="BibData">
38
+ <ref name="BibliographicItem"/>
39
+ </define>
39
40
  <define name="status">
40
41
  <element name="status">
41
42
  <ref name="stage"/>
@@ -73,8 +74,14 @@
73
74
  <text/>
74
75
  </element>
75
76
  </define>
76
- <define name="script">
77
+ <define name="locale">
77
78
  <a:documentation>ISO-639</a:documentation>
79
+ <element name="locale">
80
+ <text/>
81
+ </element>
82
+ </define>
83
+ <define name="script">
84
+ <a:documentation>ISO-3166</a:documentation>
78
85
  <element name="script">
79
86
  <text/>
80
87
  </element>
@@ -93,6 +100,9 @@
93
100
  <!-- multiple languages and scripts possible: comma delimit them if so -->
94
101
  <attribute name="language"/>
95
102
  </optional>
103
+ <optional>
104
+ <attribute name="locale"/>
105
+ </optional>
96
106
  <optional>
97
107
  <attribute name="script"/>
98
108
  </optional>
@@ -136,6 +146,9 @@
136
146
  <!-- multiple languages and scripts possible: comma delimit them if so -->
137
147
  <attribute name="language"/>
138
148
  </optional>
149
+ <optional>
150
+ <attribute name="locale"/>
151
+ </optional>
139
152
  <optional>
140
153
  <attribute name="script"/>
141
154
  </optional>
@@ -158,27 +171,30 @@
158
171
  </define>
159
172
  <define name="contributor">
160
173
  <element name="contributor">
161
- <zeroOrMore>
174
+ <oneOrMore>
162
175
  <ref name="role"/>
163
- </zeroOrMore>
176
+ </oneOrMore>
164
177
  <ref name="ContributorInfo"/>
165
178
  </element>
166
179
  </define>
167
180
  <define name="role">
168
181
  <element name="role">
169
- <optional>
170
- <attribute name="type">
171
- <choice>
172
- <value>author</value>
173
- <value>performer</value>
174
- <value>publisher</value>
175
- <value>editor</value>
176
- <value>adapter</value>
177
- <value>translator</value>
178
- <value>distributor</value>
179
- </choice>
180
- </attribute>
181
- </optional>
182
+ <attribute name="type">
183
+ <choice>
184
+ <value>author</value>
185
+ <value>performer</value>
186
+ <value>publisher</value>
187
+ <value>editor</value>
188
+ <value>adapter</value>
189
+ <value>translator</value>
190
+ <value>distributor</value>
191
+ <value>realizer</value>
192
+ <value>owner</value>
193
+ <value>authorizer</value>
194
+ <value>enabler</value>
195
+ <value>subject</value>
196
+ </choice>
197
+ </attribute>
182
198
  <zeroOrMore>
183
199
  <ref name="roledescription"/>
184
200
  </zeroOrMore>
@@ -200,6 +216,9 @@
200
216
  <optional>
201
217
  <ref name="fullname"/>
202
218
  </optional>
219
+ <zeroOrMore>
220
+ <ref name="credential"/>
221
+ </zeroOrMore>
203
222
  <zeroOrMore>
204
223
  <ref name="affiliation"/>
205
224
  </zeroOrMore>
@@ -216,6 +235,11 @@
216
235
  <ref name="FullNameType"/>
217
236
  </element>
218
237
  </define>
238
+ <define name="credential">
239
+ <element name="credential">
240
+ <text/>
241
+ </element>
242
+ </define>
219
243
  <define name="FullNameType">
220
244
  <choice>
221
245
  <group>
@@ -289,7 +313,9 @@
289
313
  <zeroOrMore>
290
314
  <ref name="affiliationdescription"/>
291
315
  </zeroOrMore>
292
- <ref name="organization"/>
316
+ <optional>
317
+ <ref name="organization"/>
318
+ </optional>
293
319
  </element>
294
320
  </define>
295
321
  <define name="affiliationname">
@@ -500,6 +526,17 @@
500
526
  </define>
501
527
  <define name="localityStack">
502
528
  <element name="localityStack">
529
+ <optional>
530
+ <attribute name="connective">
531
+ <choice>
532
+ <value>and</value>
533
+ <value>or</value>
534
+ <value>from</value>
535
+ <value>to</value>
536
+ <value/>
537
+ </choice>
538
+ </attribute>
539
+ </optional>
503
540
  <zeroOrMore>
504
541
  <ref name="locality"/>
505
542
  </zeroOrMore>
@@ -512,6 +549,17 @@
512
549
  </define>
513
550
  <define name="sourceLocalityStack">
514
551
  <element name="sourceLocalityStack">
552
+ <optional>
553
+ <attribute name="connective">
554
+ <choice>
555
+ <value>and</value>
556
+ <value>or</value>
557
+ <value>from</value>
558
+ <value>to</value>
559
+ <value/>
560
+ </choice>
561
+ </attribute>
562
+ </optional>
515
563
  <zeroOrMore>
516
564
  <ref name="sourceLocality"/>
517
565
  </zeroOrMore>
@@ -614,6 +662,9 @@
614
662
  <ref name="BibItemType"/>
615
663
  </attribute>
616
664
  </optional>
665
+ <optional>
666
+ <attribute name="schema-version"/>
667
+ </optional>
617
668
  <optional>
618
669
  <ref name="fetched"/>
619
670
  </optional>
@@ -650,6 +701,9 @@
650
701
  <zeroOrMore>
651
702
  <ref name="language"/>
652
703
  </zeroOrMore>
704
+ <zeroOrMore>
705
+ <ref name="locale"/>
706
+ </zeroOrMore>
653
707
  <zeroOrMore>
654
708
  <ref name="script"/>
655
709
  </zeroOrMore>
@@ -705,6 +759,9 @@
705
759
  <ref name="BibItemType"/>
706
760
  </attribute>
707
761
  </optional>
762
+ <optional>
763
+ <attribute name="schema-version"/>
764
+ </optional>
708
765
  <optional>
709
766
  <ref name="fetched"/>
710
767
  </optional>
@@ -741,6 +798,9 @@
741
798
  <zeroOrMore>
742
799
  <ref name="language"/>
743
800
  </zeroOrMore>
801
+ <zeroOrMore>
802
+ <ref name="locale"/>
803
+ </zeroOrMore>
744
804
  <zeroOrMore>
745
805
  <ref name="script"/>
746
806
  </zeroOrMore>
@@ -854,6 +914,15 @@
854
914
  <optional>
855
915
  <attribute name="type"/>
856
916
  </optional>
917
+ <optional>
918
+ <attribute name="language"/>
919
+ </optional>
920
+ <optional>
921
+ <attribute name="locale"/>
922
+ </optional>
923
+ <optional>
924
+ <attribute name="script"/>
925
+ </optional>
857
926
  <data type="anyURI"/>
858
927
  </define>
859
928
  <define name="DateType">
@@ -882,6 +951,7 @@
882
951
  <value>vote-started</value>
883
952
  <value>vote-ended</value>
884
953
  <value>announced</value>
954
+ <value>stable-until</value>
885
955
  </choice>
886
956
  </define>
887
957
  <define name="bdate">
@@ -930,6 +1000,9 @@
930
1000
  <optional>
931
1001
  <attribute name="language"/>
932
1002
  </optional>
1003
+ <optional>
1004
+ <attribute name="locale"/>
1005
+ </optional>
933
1006
  <optional>
934
1007
  <attribute name="script"/>
935
1008
  </optional>
@@ -1253,7 +1326,7 @@
1253
1326
  <value>commentaryOf</value>
1254
1327
  <value>hasCommentary</value>
1255
1328
  <value>related</value>
1256
- <value>complements</value>
1329
+ <value>hasComplement</value>
1257
1330
  <value>complementOf</value>
1258
1331
  <value>obsoletes</value>
1259
1332
  <value>obsoletedBy</value>
@@ -0,0 +1,11 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <grammar xmlns="http://relaxng.org/ns/structure/1.0">
3
+ <include href="basicdoc.rng"/>
4
+ <include href="relaton-cen.rng"/>
5
+ <start>
6
+ <choice>
7
+ <ref name="bibitem"/>
8
+ <ref name="bibdata"/>
9
+ </choice>
10
+ </start>
11
+ </grammar>
@@ -0,0 +1,4 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <grammar xmlns="http://relaxng.org/ns/structure/1.0">
3
+ <include href="biblio-standoc.rng"/>
4
+ </grammar>
@@ -0,0 +1,11 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <grammar xmlns="http://relaxng.org/ns/structure/1.0">
3
+ <include href="basicdoc.rng"/>
4
+ <include href="relaton-iso.rng"/>
5
+ <start>
6
+ <choice>
7
+ <ref name="bibitem"/>
8
+ <ref name="bibdata"/>
9
+ </choice>
10
+ </start>
11
+ </grammar>
@@ -0,0 +1,225 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <grammar xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
3
+ <include href="biblio-standoc.rng">
4
+ <define name="BibDataExtensionType">
5
+ <optional>
6
+ <attribute name="schema-version"/>
7
+ </optional>
8
+ <ref name="doctype"/>
9
+ <optional>
10
+ <ref name="docsubtype"/>
11
+ </optional>
12
+ <optional>
13
+ <ref name="horizontal"/>
14
+ </optional>
15
+ <ref name="editorialgroup"/>
16
+ <optional>
17
+ <ref name="approvalgroup"/>
18
+ </optional>
19
+ <zeroOrMore>
20
+ <ref name="ics"/>
21
+ </zeroOrMore>
22
+ <ref name="structuredidentifier"/>
23
+ <optional>
24
+ <ref name="stagename"/>
25
+ </optional>
26
+ <optional>
27
+ <ref name="updates_document_type"/>
28
+ </optional>
29
+ </define>
30
+ <define name="bdate">
31
+ <element name="date">
32
+ <attribute name="type">
33
+ <choice>
34
+ <ref name="BibliographicDateType"/>
35
+ <text/>
36
+ </choice>
37
+ </attribute>
38
+ <choice>
39
+ <group>
40
+ <element name="from">
41
+ <ref name="ISO8601Date"/>
42
+ </element>
43
+ <optional>
44
+ <element name="to">
45
+ <ref name="ISO8601Date"/>
46
+ </element>
47
+ </optional>
48
+ </group>
49
+ <element name="on">
50
+ <choice>
51
+ <ref name="ISO8601Date"/>
52
+ <value>--</value>
53
+ <value>–</value>
54
+ </choice>
55
+ </element>
56
+ </choice>
57
+ </element>
58
+ </define>
59
+ <define name="organization">
60
+ <element name="organization">
61
+ <oneOrMore>
62
+ <ref name="orgname"/>
63
+ </oneOrMore>
64
+ <optional>
65
+ <ref name="abbreviation"/>
66
+ </optional>
67
+ <optional>
68
+ <ref name="uri"/>
69
+ </optional>
70
+ <zeroOrMore>
71
+ <ref name="org-identifier"/>
72
+ </zeroOrMore>
73
+ <zeroOrMore>
74
+ <ref name="contact"/>
75
+ </zeroOrMore>
76
+ <optional>
77
+ <ref name="technical-committee"/>
78
+ </optional>
79
+ <optional>
80
+ <ref name="subcommittee"/>
81
+ </optional>
82
+ <optional>
83
+ <ref name="workgroup"/>
84
+ </optional>
85
+ <optional>
86
+ <ref name="secretariat"/>
87
+ </optional>
88
+ </element>
89
+ </define>
90
+ <define name="DocumentType">
91
+ <choice>
92
+ <value>international-standard</value>
93
+ <value>technical-specification</value>
94
+ <value>technical-report</value>
95
+ <value>publicly-available-specification</value>
96
+ <value>international-workshop-agreement</value>
97
+ <value>guide</value>
98
+ <value>amendment</value>
99
+ <value>technical-corrigendum</value>
100
+ <value>directive</value>
101
+ </choice>
102
+ </define>
103
+ <define name="DocumentSubtype">
104
+ <choice>
105
+ <value>specification</value>
106
+ <value>method-of-test</value>
107
+ <value>vocabulary</value>
108
+ <value>code-of-practice</value>
109
+ </choice>
110
+ </define>
111
+ <define name="structuredidentifier">
112
+ <element name="structuredidentifier">
113
+ <optional>
114
+ <attribute name="type"/>
115
+ </optional>
116
+ <group>
117
+ <ref name="documentnumber"/>
118
+ <optional>
119
+ <ref name="tc-documentnumber"/>
120
+ </optional>
121
+ </group>
122
+ </element>
123
+ </define>
124
+ <define name="editorialgroup">
125
+ <element name="editorialgroup">
126
+ <ref name="ISOProjectGroup"/>
127
+ </element>
128
+ </define>
129
+ </include>
130
+ <define name="updates_document_type">
131
+ <element name="updates-document-type">
132
+ <ref name="DocumentType"/>
133
+ </element>
134
+ </define>
135
+ <define name="ISOProjectGroup">
136
+ <zeroOrMore>
137
+ <ref name="agency"/>
138
+ </zeroOrMore>
139
+ <oneOrMore>
140
+ <ref name="technical-committee"/>
141
+ </oneOrMore>
142
+ <zeroOrMore>
143
+ <ref name="subcommittee"/>
144
+ </zeroOrMore>
145
+ <zeroOrMore>
146
+ <ref name="workgroup"/>
147
+ </zeroOrMore>
148
+ <optional>
149
+ <ref name="secretariat"/>
150
+ </optional>
151
+ </define>
152
+ <define name="approvalgroup">
153
+ <element name="approvalgroup">
154
+ <ref name="ISOProjectGroup"/>
155
+ </element>
156
+ </define>
157
+ <define name="agency">
158
+ <element name="agency">
159
+ <text/>
160
+ </element>
161
+ </define>
162
+ <define name="horizontal">
163
+ <element name="horizontal">
164
+ <data type="boolean"/>
165
+ </element>
166
+ </define>
167
+ <define name="documentnumber">
168
+ <element name="project-number">
169
+ <optional>
170
+ <attribute name="part">
171
+ <data type="int"/>
172
+ </attribute>
173
+ </optional>
174
+ <optional>
175
+ <attribute name="subpart">
176
+ <data type="int"/>
177
+ </attribute>
178
+ </optional>
179
+ <optional>
180
+ <attribute name="amendment">
181
+ <data type="int"/>
182
+ </attribute>
183
+ </optional>
184
+ <optional>
185
+ <attribute name="corrigendum">
186
+ <data type="int"/>
187
+ </attribute>
188
+ </optional>
189
+ <optional>
190
+ <attribute name="origyr">
191
+ <ref name="ISO8601Date"/>
192
+ </attribute>
193
+ </optional>
194
+ <text/>
195
+ </element>
196
+ </define>
197
+ <define name="tc-documentnumber">
198
+ <element name="tc-document-number">
199
+ <data type="int"/>
200
+ </element>
201
+ </define>
202
+ <define name="subcommittee">
203
+ <element name="subcommittee">
204
+ <ref name="IsoWorkgroup"/>
205
+ </element>
206
+ </define>
207
+ <define name="workgroup">
208
+ <element name="workgroup">
209
+ <ref name="IsoWorkgroup"/>
210
+ </element>
211
+ </define>
212
+ <define name="secretariat">
213
+ <element name="secretariat">
214
+ <text/>
215
+ </element>
216
+ </define>
217
+ <define name="stagename">
218
+ <element name="stagename">
219
+ <optional>
220
+ <attribute name="abbreviation"/>
221
+ </optional>
222
+ <text/>
223
+ </element>
224
+ </define>
225
+ </grammar>
@@ -0,0 +1,12 @@
1
+ module RelatonCen
2
+ class BibliographicItem < RelatonIsoBib::IsoBibliographicItem
3
+ #
4
+ # Fetches CEN flavor schema version.
5
+ #
6
+ # @return [String] schema version
7
+ #
8
+ def ext_schema
9
+ @ext_schema ||= schema_versions["relaton-model-cen"]
10
+ end
11
+ end
12
+ end
@@ -1,12 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "mechanize"
4
- require "relaton_iso_bib"
5
- require "relaton_cen/scrapper"
6
- require "relaton_cen/hit_collection"
7
- require "relaton_cen/hit"
8
- require "relaton_cen/xml_parser"
9
-
10
3
  module RelatonCen
11
4
  # Class methods for search Cenelec standards.
12
5
  class CenBibliography
@@ -0,0 +1,11 @@
1
+ module RelatonCen
2
+ class HashConverter < RelatonIsoBib::HashConverter
3
+ class << self
4
+ # @param item_hash [Hash]
5
+ # @return [RelatonCen::BibliographicItem]
6
+ def bib_item(item_hash)
7
+ BibliographicItem.new(**item_hash)
8
+ end
9
+ end
10
+ end
11
+ end
@@ -6,7 +6,7 @@ module RelatonCen
6
6
  attr_writer :fetch
7
7
 
8
8
  # Parse page.
9
- # @return [RelatonBib::BibliographicItem]
9
+ # @return [IsoRelatonBib::IsoBibliographicItem]
10
10
  def fetch
11
11
  @fetch ||= Scrapper.parse_page self
12
12
  end
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "relaton_cen/hit"
4
-
5
3
  module RelatonCen
6
4
  # Page of hit collection.
7
5
  class HitCollection < RelatonBib::HitCollection
@@ -26,13 +26,13 @@ module RelatonCen
26
26
  # @param hash [Hash]
27
27
  # @return [RelatonBib::BibliographicItem]
28
28
  def hash_to_bib(hash)
29
- ::RelatonIsoBib::IsoBibliographicItem.from_hash hash
29
+ ::RelatonCen::BibliographicItem.from_hash hash
30
30
  end
31
31
 
32
32
  # Returns hash of XML grammar
33
33
  # @return [String]
34
34
  def grammar_hash
35
- @grammar_hash ||= ::RelatonIsoBib.grammar_hash
35
+ @grammar_hash ||= ::RelatonCen.grammar_hash
36
36
  end
37
37
  end
38
38
  end
@@ -11,10 +11,10 @@ module RelatonCen
11
11
  class << self
12
12
  # Parse page.
13
13
  # @param hit [RelatonCen::Hit]
14
- # @return [RelatonBib::BibliographicItem]
14
+ # @return [RelatonIsoBib::IsoBibliographicItem]
15
15
  def parse_page(hit) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
16
16
  doc = hit.hit_collection.agent.get hit.hit[:url]
17
- RelatonIsoBib::IsoBibliographicItem.new(
17
+ BibliographicItem.new(
18
18
  fetched: Date.today.to_s,
19
19
  type: "standard",
20
20
  docid: fetch_docid(hit.hit[:code]),
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RelatonCen
4
- VERSION = "1.13.0"
4
+ VERSION = "1.14.1"
5
5
  end
@@ -1,5 +1,3 @@
1
- require "nokogiri"
2
-
3
1
  module RelatonCen
4
2
  class XMLParser < RelatonIsoBib::XMLParser
5
3
  class << self
@@ -19,10 +17,10 @@ module RelatonCen
19
17
  # end
20
18
 
21
19
  # @param item_hash [Hash]
22
- # @return [RelatonBib::BibliographicItem]
23
- # def bib_item(item_hash)
24
- # RelatonIsoBib::IsoBibliographicItem.new **item_hash
25
- # end
20
+ # @return [RelatonCen::BibliographicItem]
21
+ def bib_item(item_hash)
22
+ BibliographicItem.new(**item_hash)
23
+ end
26
24
  end
27
25
  end
28
26
  end
data/lib/relaton_cen.rb CHANGED
@@ -1,7 +1,16 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "digest/md5"
4
+ require "mechanize"
5
+ require "nokogiri"
4
6
  require_relative "relaton_cen/version"
7
+ require "relaton_iso_bib"
8
+ require "relaton_cen/biblographic_item"
9
+ require "relaton_cen/scrapper"
10
+ require "relaton_cen/hit_collection"
11
+ require "relaton_cen/hit"
12
+ require "relaton_cen/xml_parser"
13
+ require "relaton_cen/hash_converter"
5
14
  require "relaton_cen/cen_bibliography"
6
15
 
7
16
  module RelatonCen
data/relaton_cen.gemspec CHANGED
@@ -8,13 +8,13 @@ Gem::Specification.new do |spec|
8
8
  spec.authors = ["Ribose Inc."]
9
9
  spec.email = ["open.source@ribose.com"]
10
10
 
11
- spec.summary = "RelatonCen: retrieve Cenelec Standards for "\
11
+ spec.summary = "RelatonCen: retrieve Cenelec Standards for " \
12
12
  "bibliographic use using the IsoBibliographicItem model"
13
- spec.description = "RelatonCen: retrieve Cenelec Standards for "\
13
+ spec.description = "RelatonCen: retrieve Cenelec Standards for " \
14
14
  "bibliographic use using the IsoBibliographicItem model"
15
15
  spec.homepage = "https://github.com/metanorma/relaton-cen"
16
16
  spec.license = "BSD-2-Clause"
17
- spec.required_ruby_version = Gem::Requirement.new(">= 2.5.0")
17
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.7.0")
18
18
 
19
19
  # spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
20
20
 
@@ -31,18 +31,8 @@ Gem::Specification.new do |spec|
31
31
  spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
32
32
  spec.require_paths = ["lib"]
33
33
 
34
- spec.add_development_dependency "equivalent-xml", "~> 0.6"
35
- spec.add_development_dependency "pry-byebug"
36
- spec.add_development_dependency "rubocop", "~> 1.17.0"
37
- spec.add_development_dependency "rubocop-performance", "~> 1.11.0"
38
- spec.add_development_dependency "rubocop-rails", "~> 2.10.0"
39
- spec.add_development_dependency "ruby-jing"
40
- spec.add_development_dependency "simplecov"
41
- spec.add_development_dependency "vcr", "~> 5.0.0"
42
- spec.add_development_dependency "webmock"
43
-
44
- spec.add_dependency "mechanize"
45
- spec.add_dependency "relaton-iso-bib", "~> 1.13.0"
34
+ spec.add_dependency "mechanize", "~> 2.8.0"
35
+ spec.add_dependency "relaton-iso-bib", "~> 1.14.0"
46
36
 
47
37
  # For more information and examples about making a new gem, checkout our
48
38
  # guide at: https://bundler.io/guides/creating_gem.html