relaton-iec 1.10.0 → 1.11.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: 96d2d6999eefa5afb477c3c783a8c8ff9a68b22b69d431973a16417be21e37d9
4
- data.tar.gz: 73437e701a2da723a1bc4d36113753dec5a99f9962937a2a7b1d61e50214e337
3
+ metadata.gz: 26f4ed095f846982958565c16856f12c681fb06f6b4dcdf6d9d51da5e122fda3
4
+ data.tar.gz: 9d6d6de7f5ecc68aa0133460e80070e79cf4d58e167ac546dbeb2eb3e18ba537
5
5
  SHA512:
6
- metadata.gz: 2682e97e9005ab0e32be5bc672dc1a958501ecc7fc5b23b909a808add96a473a472cdf255b5fb2b5c51664be12c4ce078e318acb44eafb7c6e207b9f31f63190
7
- data.tar.gz: 1361dc12bec431a896f5dab4a8d8230e62793da56f387bf8319e42bae35751df25cf79e09655cf111887292885e5105c0887377ebb81301bb33a0eda8dae8629
6
+ metadata.gz: f9110c1ee9b89a7a31048cb3f57814f16ba0835135849db067e6f4970a63f5f9a3af18507d6a5b040fa4e4a239873264b34e85673abb0b034afc45ca78bbe9fe
7
+ data.tar.gz: c2384461bcfd0715d241e0e5cd91f1631158293a57e488acea984f1fbdb3033997fcface2580d04c07212bd1d6e548edfe332da369b21e41a132673848648d5e
data/Gemfile CHANGED
@@ -1,6 +1,3 @@
1
- Encoding.default_external = Encoding::UTF_8
2
- Encoding.default_internal = Encoding::UTF_8
3
-
4
1
  source "https://rubygems.org"
5
2
 
6
3
  git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
data/grammars/biblio.rng CHANGED
@@ -209,9 +209,6 @@
209
209
  <zeroOrMore>
210
210
  <ref name="contact"/>
211
211
  </zeroOrMore>
212
- <zeroOrMore>
213
- <ref name="uri"/>
214
- </zeroOrMore>
215
212
  </element>
216
213
  </define>
217
214
  <define name="fullname">
@@ -680,6 +677,9 @@
680
677
  <zeroOrMore>
681
678
  <ref name="extent"/>
682
679
  </zeroOrMore>
680
+ <optional>
681
+ <ref name="bibliographic_size"/>
682
+ </optional>
683
683
  <zeroOrMore>
684
684
  <ref name="accesslocation"/>
685
685
  </zeroOrMore>
@@ -828,6 +828,11 @@
828
828
  <optional>
829
829
  <attribute name="scope"/>
830
830
  </optional>
831
+ <optional>
832
+ <attribute name="primary">
833
+ <data type="boolean"/>
834
+ </attribute>
835
+ </optional>
831
836
  <text/>
832
837
  </element>
833
838
  </define>
@@ -920,9 +925,29 @@
920
925
  <text/>
921
926
  </element>
922
927
  </define>
928
+ <define name="sizevalue">
929
+ <element name="value">
930
+ <attribute name="type"/>
931
+ <text/>
932
+ </element>
933
+ </define>
934
+ <define name="bibliographic_size">
935
+ <element name="size">
936
+ <oneOrMore>
937
+ <ref name="sizevalue"/>
938
+ </oneOrMore>
939
+ </element>
940
+ </define>
923
941
  <define name="extent">
924
942
  <element name="extent">
925
- <ref name="BibItemLocality"/>
943
+ <choice>
944
+ <zeroOrMore>
945
+ <ref name="locality"/>
946
+ </zeroOrMore>
947
+ <zeroOrMore>
948
+ <ref name="localityStack"/>
949
+ </zeroOrMore>
950
+ </choice>
926
951
  </element>
927
952
  </define>
928
953
  <define name="series">
data/grammars/isodoc.rng CHANGED
@@ -152,9 +152,7 @@
152
152
  <data type="boolean"/>
153
153
  </attribute>
154
154
  </optional>
155
- <oneOrMore>
156
- <ref name="PureTextElement"/>
157
- </oneOrMore>
155
+ <ref name="XrefBody"/>
158
156
  </element>
159
157
  </define>
160
158
  <define name="erefType">
@@ -188,6 +186,42 @@
188
186
  <ref name="PureTextElement"/>
189
187
  </oneOrMore>
190
188
  </define>
189
+ <define name="localityStack">
190
+ <element name="localityStack">
191
+ <optional>
192
+ <attribute name="connective">
193
+ <choice>
194
+ <value>and</value>
195
+ <value>or</value>
196
+ <value>from</value>
197
+ <value>to</value>
198
+ <value/>
199
+ </choice>
200
+ </attribute>
201
+ </optional>
202
+ <zeroOrMore>
203
+ <ref name="locality"/>
204
+ </zeroOrMore>
205
+ </element>
206
+ </define>
207
+ <define name="sourceLocalityStack">
208
+ <element name="sourceLocalityStack">
209
+ <optional>
210
+ <attribute name="connective">
211
+ <choice>
212
+ <value>and</value>
213
+ <value>or</value>
214
+ <value>from</value>
215
+ <value>to</value>
216
+ <value/>
217
+ </choice>
218
+ </attribute>
219
+ </optional>
220
+ <zeroOrMore>
221
+ <ref name="sourceLocality"/>
222
+ </zeroOrMore>
223
+ </element>
224
+ </define>
191
225
  <define name="ul">
192
226
  <element name="ul">
193
227
  <attribute name="id">
@@ -1098,6 +1132,16 @@
1098
1132
  </define>
1099
1133
  </include>
1100
1134
  <!-- end overrides -->
1135
+ <define name="image" combine="choice">
1136
+ <element name="svg">
1137
+ <oneOrMore>
1138
+ <choice>
1139
+ <text/>
1140
+ <ref name="AnyElement"/>
1141
+ </choice>
1142
+ </oneOrMore>
1143
+ </element>
1144
+ </define>
1101
1145
  <define name="MultilingualRenderingType">
1102
1146
  <choice>
1103
1147
  <value>common</value>
@@ -2631,4 +2675,30 @@
2631
2675
  </zeroOrMore>
2632
2676
  </element>
2633
2677
  </define>
2678
+ <define name="XrefBody">
2679
+ <zeroOrMore>
2680
+ <ref name="XrefTarget"/>
2681
+ </zeroOrMore>
2682
+ <oneOrMore>
2683
+ <ref name="PureTextElement"/>
2684
+ </oneOrMore>
2685
+ </define>
2686
+ <define name="XrefTarget">
2687
+ <element name="location">
2688
+ <attribute name="target">
2689
+ <data type="string">
2690
+ <param name="pattern">\i\c*|\c+#\c+</param>
2691
+ </data>
2692
+ </attribute>
2693
+ <attribute name="connective">
2694
+ <choice>
2695
+ <value>and</value>
2696
+ <value>or</value>
2697
+ <value>from</value>
2698
+ <value>to</value>
2699
+ <value/>
2700
+ </choice>
2701
+ </attribute>
2702
+ </element>
2703
+ </define>
2634
2704
  </grammar>
@@ -31,7 +31,7 @@ module RelatonIec
31
31
  all_parts_item = bibitem.to_all_parts
32
32
  parts.reject { |h| h.hit[:code] == hit.hit[:code] }.each do |hi|
33
33
  isobib = RelatonIec::IecBibliographicItem.new(
34
- formattedref: RelatonBib::FormattedRef.new(content: hi.hit[:code])
34
+ formattedref: RelatonBib::FormattedRef.new(content: hi.hit[:code]),
35
35
  )
36
36
  all_parts_item.relation << RelatonBib::DocumentRelation.new(type: "partOf", bibitem: isobib)
37
37
  end
@@ -21,7 +21,7 @@ module RelatonIec
21
21
  # @param part [String, nil] search for packaged stndard if not nil
22
22
  # @return [RelatonIec::HitCollection]
23
23
  def search(text, year = nil, part = nil)
24
- HitCollection.new text.sub(/(^\w+)\//, '\1 '), year&.strip, part
24
+ HitCollection.new text&.sub(/(^\w+)\//, '\1 '), year&.strip, part
25
25
  rescue SocketError, OpenURI::HTTPError, OpenSSL::SSL::SSLError
26
26
  raise RelatonBib::RequestError, "Could not access http://www.iec.ch"
27
27
  end
@@ -32,8 +32,8 @@ module RelatonIec
32
32
  # reference is required
33
33
  # @return [String] Relaton XML serialisation of reference
34
34
  def get(code, year = nil, opts = {}) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity
35
- opts[:all_parts] ||= code.match? /\s\(all parts\)/
36
- ref = code.sub /\s\(all parts\)/, ""
35
+ opts[:all_parts] ||= code.match?(/\s\(all parts\)/)
36
+ ref = code.sub(/\s\(all parts\)/, "")
37
37
  if year.nil?
38
38
  /^(?<code1>[^:]+):(?<year1>[^:]+)/ =~ ref
39
39
  unless code1.nil?
@@ -91,10 +91,10 @@ module RelatonIec
91
91
  # @return [RelatonIec::HitCollection]
92
92
  def search_filter(ref, year) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
93
93
  %r{
94
- ^(?<code>\S+[^\d]*\s\d+((?:-\w+)+)?)
95
- (:(?<year1>\d{4}))?
96
- (?<bundle>\+[^\s\/]+)?
97
- (\/(?<corr>AMD\s\d+))?
94
+ ^(?<code>\S+[^\d]*\s\d+(?:-\w+)*)
95
+ (?::(?<year1>\d{4}))?
96
+ (?<bundle>\+[^\s/]+)?
97
+ (?:/(?<corr>AMD\s\d+))?
98
98
  }x =~ ref.upcase
99
99
  year ||= year1
100
100
  corr&.sub! " ", ""
@@ -106,13 +106,12 @@ module RelatonIec
106
106
  end
107
107
  result = search code if result.empty?
108
108
  code = result.text.dup
109
- code&.sub! /((?:-\w+)+)/, ""
109
+ code&.sub!(/((?:-\w+)+)/, "")
110
110
  result.select do |i|
111
111
  %r{
112
- ^(?<code2>\S+[^\d]*\s\d+)((?:-\w+)+)?
113
- (:\d{4})?
114
- (?<bundle2>\+[^\s\/]+)?
115
- (\/(?<corr2>AMD\d+))?
112
+ ^(?<code2>\S+[^\d]*\s\d+)(?:-\w+)*(?::\d{4})?
113
+ (?<bundle2>\+[^\s/]+)?
114
+ (?:/(?<corr2>AMD\d+))?
116
115
  }x =~ i.hit[:code]
117
116
  code == code2 && bundle == bundle2 && corr == corr2
118
117
  end
@@ -9,6 +9,11 @@ module RelatonIec
9
9
  # Scrapper.
10
10
  module Scrapper
11
11
  DOMAIN = "https://webstore.iec.ch"
12
+ ABBREVS = {
13
+ "ISO" => ["International Organization for Standardization", "www.iso.org"],
14
+ "IEC" => ["International Electrotechnical Commission", "www.iec.ch"],
15
+ "CISPR" => ["International special committee on radio interference", "www.iec.ch"],
16
+ }.freeze
12
17
 
13
18
  TYPES = {
14
19
  "ISO" => "international-standard",
@@ -36,7 +41,7 @@ module RelatonIec
36
41
 
37
42
  # Fetch edition.
38
43
  edition = doc.at(
39
- "//th[contains(., 'Edition')]/following-sibling::td/span"
44
+ "//th[contains(., 'Edition')]/following-sibling::td/span",
40
45
  ).text
41
46
 
42
47
  status, relations = fetch_status_relations hit_data[:url]
@@ -59,7 +64,7 @@ module RelatonIec
59
64
  copyright: fetch_copyright(hit_data[:code], doc),
60
65
  link: fetch_link(doc, hit_data[:url]),
61
66
  relation: relations,
62
- place: ["Geneva"]
67
+ place: ["Geneva"],
63
68
  )
64
69
  end
65
70
  # rubocop:enable Metrics/AbcSize, Metrics/MethodLength
@@ -71,7 +76,7 @@ module RelatonIec
71
76
  def fetch_docid(hit)
72
77
  urn = RelatonIec.code_to_urn hit[:code], "en"
73
78
  [
74
- RelatonBib::DocumentIdentifier.new(id: hit[:code], type: "IEC"),
79
+ RelatonBib::DocumentIdentifier.new(id: hit[:code], type: "IEC", primary: true),
75
80
  RelatonBib::DocumentIdentifier.new(id: urn, type: "URN"),
76
81
  ]
77
82
  end
@@ -121,12 +126,12 @@ module RelatonIec
121
126
  item_ref = doc.at("//span[@itemprop='productID']")
122
127
  unless item_ref
123
128
  return RelatonIsoBib::StructuredIdentifier.new(
124
- project_number: "?", part_number: "", prefix: nil, id: "?"
129
+ project_number: "?", part_number: "", prefix: nil, id: "?",
125
130
  )
126
131
  end
127
132
 
128
133
  m = item_ref.text.match(
129
- /(?<=\s)(?<project>\d+)-?(?<part>(?<=-)\d+|)-?(?<subpart>(?<=-)\d+|)/
134
+ /(?<=\s)(?<project>\d+)-?(?<part>(?<=-)\d+|)-?(?<subpart>(?<=-)\d+|)/,
130
135
  )
131
136
  RelatonIsoBib::StructuredIdentifier.new(
132
137
  project_number: m[:project],
@@ -134,7 +139,7 @@ module RelatonIec
134
139
  subpart_number: m[:subpart],
135
140
  prefix: nil,
136
141
  type: "IEC",
137
- id: item_ref.text
142
+ id: item_ref.text,
138
143
  )
139
144
  end
140
145
 
@@ -190,7 +195,7 @@ module RelatonIec
190
195
  else r_type
191
196
  end
192
197
  fref = RelatonBib::FormattedRef.new(
193
- content: r.at("FULL_NAME").text, format: "text/plain"
198
+ content: r.at("FULL_NAME").text, format: "text/plain",
194
199
  )
195
200
  bibitem = IecBibliographicItem.new(formattedref: fref)
196
201
  { type: type, bibitem: bibitem }
@@ -199,8 +204,8 @@ module RelatonIec
199
204
 
200
205
  def fetch_status_relations(url)
201
206
  pubid = url.match(/\d+$/).to_s
202
- uri = URI DOMAIN + "/webstore/webstore.nsf/AjaxRequestXML?"\
203
- "Openagent&url=" + pubid
207
+ uri = URI "#{DOMAIN}/webstore/webstore.nsf/AjaxRequestXML?"\
208
+ "Openagent&url=#{pubid}"
204
209
  resp = Net::HTTP.get_response uri
205
210
  doc = Nokogiri::XML resp.body
206
211
  status = fetch_status doc
@@ -214,7 +219,7 @@ module RelatonIec
214
219
  # @return [String]
215
220
  def fetch_type(doc)
216
221
  doc.at(
217
- '//th[contains(., "Publication type")]/following-sibling::td/span'
222
+ '//th[contains(., "Publication type")]/following-sibling::td/span',
218
223
  ).text.downcase.tr " ", "-"
219
224
  end
220
225
 
@@ -253,9 +258,9 @@ module RelatonIec
253
258
  # @return [Array<Hash>]
254
259
  def fetch_ics(doc)
255
260
  doc.xpath(
256
- '//th[contains(text(), "ICS")]/following-sibling::td/a'
261
+ '//th[contains(text(), "ICS")]/following-sibling::td/a',
257
262
  ).map do |i|
258
- code = i.text.match(/[\d\.]+/).to_s.split "."
263
+ code = i.text.match(/[\d.]+/).to_s.split "."
259
264
  { field: code[0], group: code[1], subgroup: code[2] }
260
265
  end
261
266
  end
@@ -292,11 +297,7 @@ module RelatonIec
292
297
  # rubocop:enable Metrics/MethodLength
293
298
 
294
299
  def name_url(abbrev)
295
- case abbrev
296
- when "ISO" then ["International Organization for Standardization", "www.iso.org"]
297
- when "IEC" then ["International Electrotechnical Commission", "www.iec.ch"]
298
- when "CISPR" then ["International special committee on radio interference", "www.iec.ch"]
299
- end
300
+ ABBREVS[abbrev]
300
301
  end
301
302
  end
302
303
  end
@@ -1,3 +1,3 @@
1
1
  module RelatonIec
2
- VERSION = "1.10.0".freeze
2
+ VERSION = "1.11.1".freeze
3
3
  end
data/relaton_iec.gemspec CHANGED
@@ -25,7 +25,7 @@ Gem::Specification.new do |spec|
25
25
 
26
26
  spec.add_development_dependency "equivalent-xml", "~> 0.6"
27
27
  spec.add_development_dependency "pry-byebug"
28
- spec.add_development_dependency "rake", "~> 10.0"
28
+ spec.add_development_dependency "rake", "~> 13.0"
29
29
  spec.add_development_dependency "rspec", "~> 3.0"
30
30
  spec.add_development_dependency "ruby-jing"
31
31
  spec.add_development_dependency "simplecov"
@@ -33,5 +33,5 @@ Gem::Specification.new do |spec|
33
33
  spec.add_development_dependency "webmock"
34
34
 
35
35
  spec.add_dependency "addressable"
36
- spec.add_dependency "relaton-iso-bib", "~> 1.10.0"
36
+ spec.add_dependency "relaton-iso-bib", "~> 1.11.0"
37
37
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: relaton-iec
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.10.0
4
+ version: 1.11.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: 2022-01-30 00:00:00.000000000 Z
11
+ date: 2022-04-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: equivalent-xml
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '10.0'
47
+ version: '13.0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '10.0'
54
+ version: '13.0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rspec
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -142,14 +142,14 @@ dependencies:
142
142
  requirements:
143
143
  - - "~>"
144
144
  - !ruby/object:Gem::Version
145
- version: 1.10.0
145
+ version: 1.11.0
146
146
  type: :runtime
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
150
  - - "~>"
151
151
  - !ruby/object:Gem::Version
152
- version: 1.10.0
152
+ version: 1.11.0
153
153
  description: 'RelatonIec: retrieve IEC Standards for bibliographic use using the IecBibliographicItem
154
154
  model'
155
155
  email: