relaton-iec 1.7.2 → 1.7.7

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: 157261e9f755e3f373aa9bc025389029f4b069519d7ab4842ea41d3c9a9e19ce
4
- data.tar.gz: 89f46eb034143a119e842677074058db9a684eacef09dc4c5b42ec8670f1636f
3
+ metadata.gz: 6adf6dcf2372c1e9dff549a4d4145fcbbd9bd1aced1924183a30d5253a760757
4
+ data.tar.gz: 26065c6b757cd9e1818568f6ef07b83041ea3e10cf4f6c331925c807a8c22c50
5
5
  SHA512:
6
- metadata.gz: ecc69a778b11e14465ef0c1827eb038d22fee208f8920772670d95bb48c62d656179871bf47ef6ef4b7a3615ea997349eeee819bd0bd585133c8c3b794afa737
7
- data.tar.gz: 74c0e6583725319b9a45429f5cbb9bc7c6434a830268215e243029a3334516854cce54b28229e6797361665bb79da9d42a994bd62cd331710987bb3d46c86244
6
+ metadata.gz: d6c2a5cb8df0993d39c2d150f1f1abc6cddfe0b6ddc88e0ff3f309603de964eccf4242dc273c89659fcfd4323a73b8ecbcc152d9203bcdadc618df5171313f47
7
+ data.tar.gz: b76ea74bdf8204c525d8db77b03d53157a26ae0f797edfb5be908b33c28c426add2de763e51ee92a98b778e64084230ea699b4c2a79420cb3166c72be7308b9f
@@ -0,0 +1,46 @@
1
+ # Auto-generated by Cimas: Do not edit it manually!
2
+ # See https://github.com/metanorma/cimas
3
+ name: rake
4
+
5
+ on:
6
+ push:
7
+ branches: [ master, main ]
8
+ tags: [ v* ]
9
+ pull_request:
10
+
11
+ jobs:
12
+ rake:
13
+ name: Test on Ruby ${{ matrix.ruby }} ${{ matrix.os }}
14
+ runs-on: ${{ matrix.os }}
15
+ continue-on-error: ${{ matrix.experimental }}
16
+ strategy:
17
+ fail-fast: false
18
+ matrix:
19
+ ruby: [ '2.7', '2.6', '2.5', '2.4' ]
20
+ os: [ ubuntu-latest, windows-latest, macos-latest ]
21
+ experimental: [ false ]
22
+ include:
23
+ - ruby: '3.0'
24
+ os: 'ubuntu-latest'
25
+ experimental: true
26
+ - ruby: '3.0'
27
+ os: 'windows-latest'
28
+ experimental: true
29
+ - ruby: '3.0'
30
+ os: 'macos-latest'
31
+ experimental: true
32
+ steps:
33
+ - uses: actions/checkout@v2
34
+ with:
35
+ submodules: true
36
+
37
+ # https://github.com/ruby-debug/debase/issues/89#issuecomment-686827382
38
+ - if: matrix.os == 'macos-latest' && matrix.ruby == '2.5'
39
+ run: echo BUNDLE_BUILD__DEBASE="--with-cflags=\"-Wno-error=implicit-function-declaration\"" >> $GITHUB_ENV
40
+
41
+ - uses: ruby/setup-ruby@v1
42
+ with:
43
+ ruby-version: ${{ matrix.ruby }}
44
+ bundler-cache: true
45
+
46
+ - run: bundle exec rake
data/README.adoc CHANGED
@@ -31,7 +31,211 @@ Or install it yourself as:
31
31
 
32
32
  == Usage
33
33
 
34
- Refer to https://github.com/relaton/relaton-iso/blob/master/README.adoc the usage interface is identical.
34
+ === Search for a standard using keywords
35
+
36
+ `RelatonIec::IecBibliography.search(ref, year)` method returns hits collection. Each hit can be used to fetch a document.
37
+
38
+ - `ref` - reference to search document
39
+ - `year` - filter by year (optional)
40
+
41
+ [source,ruby]
42
+ ----
43
+ require 'relaton_iec'
44
+ => true
45
+
46
+ hit_collection = RelatonIec::IecBibliography.search("60050")
47
+ => <RelatonIec::HitCollection:0x007fe0d7126f28 @ref=60050 @fetched=false>
48
+
49
+ hit_collection.first
50
+ => <RelatonIec::Hit:0x007fe1068b4d10 @text="60050" @fetched="false" @fullIdentifier="" @title="IEC 60050-102:2007">
51
+
52
+ item = hit_collection[2].fetch
53
+ => #<RelatonIec::IecBibliographicItem:0x007fe1171a06f8
54
+ ...
55
+
56
+ item.docidentifier
57
+ => [#<RelatonBib::DocumentIdentifier:0x007fe1171bb930 @id="IEC 60050-112:2010", @scope=nil, @type="IEC">,
58
+ #<RelatonBib::DocumentIdentifier:0x007fe1171bb728 @id="urn:iec:std:iec:60050-112:2010:::en", @scope=nil, @type="URN">]
59
+
60
+ item.docidentifier.detect { |di| di.type == "URN" }.id
61
+ => "urn:iec:std:iec:60050-112:2010:::en"
62
+ ----
63
+
64
+ === Fetch documen by keywords
65
+
66
+ `RelatonIec::IecBibliography.get(ref, year, opts)` method returns document.
67
+
68
+ - `ref` - reference to search document
69
+ - `year` - filter by year (optional)
70
+ - `opts` - hash of options (optional). Supported options are `:all_parts` (boolean), `:keep_year` (boolean).
71
+
72
+ [source,ruby]
73
+ ----
74
+ item = RelatonIec::IecBibliography.get("IEC 60050-112:2010")
75
+ [relaton-iec] ("IEC 60050-112") fetching...
76
+ [relaton-iec] ("IEC 60050-112") found IEC 60050-112:2010
77
+ => #<RelatonIec::IecBibliographicItem:0x007fa64e874f78
78
+
79
+ item = RelatonIec::IecBibliography.get("IEC 60050-112", "2010", all_parts: true)
80
+ [relaton-iec] ("IEC 60050-112") fetching...
81
+ [relaton-iec] ("IEC 60050-112") found IEC 60050 (all parts)
82
+ => #<RelatonIec::IecBibliographicItem:0x007fa69e9b3948
83
+
84
+ item.docidentifier.first
85
+ => #<RelatonBib::DocumentIdentifier:0x007fa69e9abd10 @id="IEC 60050 (all parts)", @scope=nil, @type="IEC">
86
+
87
+ item = RelatonIec::IecBibliography.get("IEC 60050-112", "2010")
88
+ [relaton-iec] ("IEC 60050-112") fetching...
89
+ [relaton-iec] ("IEC 60050-112") found IEC 60050-112:2010
90
+ => #<RelatonIec::IecBibliographicItem:0x007fa69f296da8
91
+
92
+ item.docidentifier.first
93
+ => #<RelatonBib::DocumentIdentifier:0x007fa69f2a65f0 @id="IEC 60050-112:2010", @scope=nil, @type="IEC">
94
+ ----
95
+
96
+ === XML serialization
97
+
98
+ Possible options:
99
+
100
+ - *bibdata* - If true then wrapp item with _bibdata_ element and add _ext_ element.
101
+ - *note* - Array of hashes `{ text: "Note", type: "note" }`. These notes will be added to XML.
102
+
103
+ [source,ruby]
104
+ ----
105
+ item.to_xml
106
+ => "<bibitem id="IEC60050-112-2010" type="standard">
107
+ <fetched>2021-01-28</fetched>
108
+ <title type="title-main" format="text/plain" language="en" script="Latn">International Electrotechnical Vocabulary (IEV)</title>
109
+ <title type="title-part" format="text/plain" language="en" script="Latn">Part 112: Quantities and units</title>
110
+ <title type="main" format="text/plain" language="en" script="Latn">International Electrotechnical Vocabulary (IEV) - Part 112: Quantities and units</title>
111
+ <uri type="src">https://webstore.iec.ch/publication/162</uri>
112
+ <uri type="obp">/preview/info_iec60050-112%7Bed1.0%7Db.pdf</uri>
113
+ <docidentifier type="IEC">IEC 60050-112:2010</docidentifier>
114
+ <docidentifier type="URN">urn:iec:std:iec:60050-112:2010:::en</docidentifier>
115
+ <date type="published">
116
+ <on>2010-01-27</on>
117
+ </date>
118
+ <contributor>
119
+ <role type="publisher"/>
120
+ <organization>
121
+ <name>International Electrotechnical Commission</name>
122
+ <abbreviation>IEC</abbreviation>
123
+ <uri>www.iec.ch</uri>
124
+ </organization>
125
+ </contributor>
126
+ <edition>1.0</edition>
127
+ <language>en</language>
128
+ <script>Latn</script>
129
+ <abstract format="text/plain" language="en" script="Latn">
130
+ IEC 60050-112:2010 gives the general terminology concerning quantities and units, the terminology of SI, terms used in names and definitions of quantities, and some basic concepts in metrology. It cancels and replaces Sections 111-11 and 111-12 of International Standard IEC 60050-111:1996. It has the status of a horizontal standard in accordance with IEC Guide 108.
131
+ </abstract>
132
+ <status>
133
+ <stage>60</stage>
134
+ <substage>60</substage>
135
+ </status>
136
+ <copyright>
137
+ <from>2010</from>
138
+ <owner>
139
+ <organization>
140
+ <name>International Electrotechnical Commission</name>
141
+ <abbreviation>IEC</abbreviation>
142
+ <uri>www.iec.ch</uri>
143
+ </organization>
144
+ </owner>
145
+ </copyright>
146
+ <place>Geneva</place>
147
+ </bibitem>"
148
+
149
+ item.to_xml bibdata: true
150
+ => "<bibdata type="standard">
151
+ <fetched>2021-01-28</fetched>
152
+ <title type="title-main" format="text/plain" language="en" script="Latn">International Electrotechnical Vocabulary (IEV)</title>
153
+ <title type="title-part" format="text/plain" language="en" script="Latn">Part 112: Quantities and units</title>
154
+ <title type="main" format="text/plain" language="en" script="Latn">International Electrotechnical Vocabulary (IEV) - Part 112: Quantities and units</title>
155
+ <uri type="src">https://webstore.iec.ch/publication/162</uri>
156
+ <uri type="obp">/preview/info_iec60050-112%7Bed1.0%7Db.pdf</uri>
157
+ <docidentifier type="IEC">IEC 60050-112:2010</docidentifier>
158
+ <docidentifier type="URN">urn:iec:std:iec:60050-112:2010:::en</docidentifier>
159
+ ...
160
+ <ext>
161
+ <doctype>international-standard</doctype>
162
+ <editorialgroup>
163
+ <technical-committee number="1" type="technicalCommittee">TC 1 - Terminology</technical-committee>
164
+ </editorialgroup>
165
+ <ics>
166
+ <code>01.040.01</code>
167
+ <text>Generalities. Terminology. Standardization. Documentation (Vocabularies)</text>
168
+ </ics>
169
+ <ics>
170
+ <code>01.060</code>
171
+ <text>Quantities and units</text>
172
+ </ics>
173
+ <structuredidentifier type="IEC">
174
+ <project-number>60050</project-number>
175
+ </structuredidentifier>
176
+ </ext>
177
+ </bibdata>"
178
+
179
+ item.to_xml note: [{ text: "Note", type: "note" }]
180
+ => "<bibitem id="IEC60050-112-2010" type="standard">
181
+ ...
182
+ <note format="text/plain" type="note">Note</note>
183
+ ...
184
+ </bibitem>"
185
+ ----
186
+
187
+ === Converting reference to URN
188
+
189
+ URN is document a identifier format. It has fields delimited by colon. If any field is absent then it's place is empty. All values are in lower-case.
190
+
191
+ URN structure: +
192
+ `urn:sdo_namespace:content_type_namespace:header:project_number:date:type:deliverable:language:relation:adjunct_type:adjunct_number:date[#/=]component_or_related_asset`
193
+
194
+ * prefix
195
+ - `urn` - value: urn
196
+ - `sdo_namespace` - value: iec
197
+ - `content_type_namespace` - value: std
198
+ * base document information
199
+ - `header` - possible values are: iec, iso, iec-iso, iec-ieee, iec-itu, iec-astm
200
+ - `project_number` - number and partnumber. For example 67654, 60601-1, 61076-7-101
201
+ - `date` - document date (optional). Examples: 2010-03, 2010, 2010-10-11 etc.
202
+ - `type` - documant type (optional). Possible values: ts, tr, pas, guide, is, ser.
203
+ - `deliverable` - (optional) possible values: prv, csv, exv, rlv, cmv
204
+ - `language` - (optional) examples: en, fr, ru, en-fr, en-fr-ru etc.
205
+ * adjunct document information (optional)
206
+ - `relation` - "plus" for consolidations of ajancts with a base document or "/" for ajancts itself
207
+ - `adjunct_type` - possible values: amd, cor, ish
208
+ - `adjunct_number` - adjunct number. Examples: 1, 2, 3, etc.
209
+ - `date` - adjanct date. Example: 2009
210
+ * component or related asset information (optional)
211
+ - `component_or_related_asset` - # or = followed by component id or related asset. Exammples: #fig-1, #sec-1, =forum
212
+
213
+ For more information see https://github.com/relaton/relaton-iec/issues/22
214
+
215
+ The method `RelatonIec.code_to_urn(code, lang)` converts document identifier to URN.
216
+
217
+ * `code` is a document identifier
218
+ * `lang` is a laguage code (optional). Examples: en, fr, en-fr etc.
219
+
220
+ [source,ruby]
221
+ ----
222
+ RelatonIec.code_to_urn "IEC 60050-102:2007/AMD1:2017"
223
+ => "urn:iec:std:iec:60050-102:2007:::::amd:1:2017"
224
+
225
+ RelatonIec.code_to_urn "IEC 60034-1:1969+AMD1:1977+AMD2:1979+AMD3:1980 CSV", "en-fr"
226
+ => "urn:iec:std:iec:60034-1:1969::csv:en-fr:plus:amd:1:1977:plus:amd:2:1979:plus:amd:3:1980"
227
+ ----
228
+
229
+ The method `RelatonIec.urn_to_code(urn)` converts URN to document identifier.
230
+
231
+ [source,ruby]
232
+ ----
233
+ RelatonIec.urn_to_code "urn:iec:std:iec:60050-102:2007:::::amd:1:2017"
234
+ => ["IEC 60050-102:2007/AMD1:2017", ""]
235
+
236
+ RelatonIec.urn_to_code "urn:iec:std:iec:60034-1:1969::csv:en-fr:plus:amd:1:1977:plus:amd:2:1979:plus:amd:3:1980"
237
+ => ["IEC 60034-1:1969+AMD1:1977+AMD2:1979+AMD3:1980 CSV", "en-fr"]
238
+ ----
35
239
 
36
240
  == Development
37
241
 
data/bin/rspec ADDED
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'rspec' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require "pathname"
12
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13
+ Pathname.new(__FILE__).realpath)
14
+
15
+ bundle_binstub = File.expand_path("../bundle", __FILE__)
16
+
17
+ if File.file?(bundle_binstub)
18
+ if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19
+ load(bundle_binstub)
20
+ else
21
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23
+ end
24
+ end
25
+
26
+ require "rubygems"
27
+ require "bundler/setup"
28
+
29
+ load Gem.bin_path("rspec-core", "rspec")
data/lib/relaton_iec.rb CHANGED
@@ -10,12 +10,76 @@ require "relaton_iec/hash_converter"
10
10
  require "digest/md5"
11
11
 
12
12
  module RelatonIec
13
- # Returns hash of XML reammar
14
- # @return [String]
15
- def self.grammar_hash
16
- gem_path = File.expand_path "..", __dir__
17
- grammars_path = File.join gem_path, "grammars", "*"
18
- grammars = Dir[grammars_path].sort.map { |gp| File.read gp }.join
19
- Digest::MD5.hexdigest grammars
13
+ class << self
14
+ # Returns hash of XML reammar
15
+ # @return [String]
16
+ def grammar_hash
17
+ gem_path = File.expand_path "..", __dir__
18
+ grammars_path = File.join gem_path, "grammars", "*"
19
+ grammars = Dir[grammars_path].sort.map { |gp| File.read gp }.join
20
+ Digest::MD5.hexdigest grammars
21
+ end
22
+
23
+ # @param code [String]
24
+ # @param lang [String]
25
+ # @return [String, nil]
26
+ def code_to_urn(code, lang = nil) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
27
+ rest = code.downcase.sub(%r{
28
+ (?<head>[^\s]+)\s
29
+ (?<type>is|ts|tr|pas|srd|guide|tec|wp)?(?(<type>)\s)
30
+ (?<pnum>[\d-]+)\s?
31
+ (?<_dd>:)?(?(<_dd>)(?<date>[\d-]+)\s?)
32
+ }x, "")
33
+ m = $~
34
+ return unless m[:head] && m[:pnum]
35
+
36
+ deliv = /cmv|csv|exv|prv|rlv|ser/.match(code.downcase).to_s
37
+ urn = ["urn", "iec", "std", m[:head].split("/").join("-"), m[:pnum], m[:date], m[:type], deliv, lang]
38
+ (urn + ajunct_to_urn(rest)).join ":"
39
+ end
40
+
41
+ # @param urn [String]
42
+ # @return [Array<String>, nil] urn & language
43
+ def urn_to_code(urn) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
44
+ fields = urn.upcase.split ":"
45
+ return if fields.size < 5
46
+
47
+ head, num, date, type, deliv, lang = fields[3, 8]
48
+ code = head.gsub("-", "/")
49
+ code += " #{type}" unless type.nil? || type.empty?
50
+ code += " #{num}"
51
+ code += ":#{date}" unless date.nil? || date.empty?
52
+ code += ajanct_to_code(fields[9..-1])
53
+ code += " #{deliv}" unless deliv.nil? || deliv.empty?
54
+ [code, lang&.downcase]
55
+ end
56
+
57
+ private
58
+
59
+ # @param fields [Array<String>]
60
+ # @return [String]
61
+ def ajanct_to_code(fields)
62
+ return "" if fields.nil? || fields.empty?
63
+
64
+ rel, type, num, date = fields[0..3]
65
+ code = (rel.empty? ? "/" : "+") + type + num
66
+ code += ":#{date}" unless date.empty?
67
+ code + ajanct_to_code(fields[4..-1])
68
+ end
69
+
70
+ # @param rest [String]
71
+ # @return [Array<String, nil>]
72
+ def ajunct_to_urn(rest)
73
+ r = rest.sub(%r{
74
+ (?<pl>\+|\/)(?(<pl>)(?<adjunct>(amd|cor|ish))(?<adjnum>\d+)\s?)
75
+ (?<_d2>:)?(?(<_d2>)(?<adjdt>[\d-]+)\s?)
76
+ }x, "")
77
+ m = $~ || {}
78
+ return [] unless m[:adjunct]
79
+
80
+ plus = "plus" if m[:pl] == "+"
81
+ urn = [plus, m[:adjunct], m[:adjnum], m[:adjdt]]
82
+ urn + ajunct_to_urn(r)
83
+ end
20
84
  end
21
85
  end
@@ -7,7 +7,7 @@ module RelatonIec
7
7
  # @param item [Hash]
8
8
  # @retirn [RelatonIec::IecBibliographicItem]
9
9
  def bib_item(item)
10
- IecBibliographicItem.new(item)
10
+ IecBibliographicItem.new(**item)
11
11
  end
12
12
  end
13
13
  end
@@ -8,5 +8,9 @@ module RelatonIec
8
8
  def fetch
9
9
  @fetch ||= Scrapper.parse_page @hit
10
10
  end
11
+
12
+ def part
13
+ @part ||= hit[:code].match(/(?<=-)[\w-]+/)&.to_s
14
+ end
11
15
  end
12
16
  end
@@ -6,52 +6,74 @@ require "addressable/uri"
6
6
  module RelatonIec
7
7
  # Page of hit collection.
8
8
  class HitCollection < RelatonBib::HitCollection
9
+ def_delegators :@array, :detect
10
+
11
+ attr_reader :part
12
+
9
13
  DOMAIN = "https://webstore.iec.ch"
10
14
 
11
- # @param ref_nbr [String]
15
+ # @param ref [String]
12
16
  # @param year [String, nil]
13
17
  # @param part [String, nil]
14
- def initialize(ref_nbr, year = nil, part = nil)
15
- super ref_nbr, year
16
- @array = hits ref_nbr, year, part
18
+ def initialize(ref, year = nil, part = nil)
19
+ super ref, year
20
+ @part = part
21
+ @array = ref ? hits(ref, year) : []
22
+ end
23
+
24
+ # @return [RelatonIec::IecBibliographicItem]
25
+ def to_all_parts # rubocop:disable Metrics/AbcSize,Metrics/MethodLength,Metrics/CyclomaticComplexity
26
+ parts = @array.reject { |h| h.part.nil? }
27
+ hit = parts.min_by &:part
28
+ return @array.first.fetch lang unless hit
29
+
30
+ bibitem = hit.fetch
31
+ all_parts_item = bibitem.to_all_parts
32
+ parts.reject { |h| h.hit[:code] == hit.hit[:code] }.each do |hi|
33
+ isobib = RelatonIec::IecBibliographicItem.new(
34
+ formattedref: RelatonBib::FormattedRef.new(content: hi.hit[:code])
35
+ )
36
+ all_parts_item.relation << RelatonBib::DocumentRelation.new(type: "partOf", bibitem: isobib)
37
+ end
38
+ all_parts_item
17
39
  end
18
40
 
19
41
  private
20
42
 
21
43
  # @param ref [String]
22
44
  # @param year [String, nil]
23
- # @param part [String, nil]
24
45
  # @return [Array<RelatonIec::Hit>]
25
- def hits(ref, year, part)
46
+ def hits(ref, year)
26
47
  from, to = nil
27
48
  if year
28
49
  from = Date.strptime year, "%Y"
29
50
  to = from.next_year.prev_day
30
51
  end
31
- get_results ref, from, to, part
52
+ get_results ref, from, to
32
53
  end
33
54
 
34
55
  # @param ref [String]
35
56
  # @param from [Date, nil]
36
57
  # @param to [Date, nil]
37
- # @param part [String, nil]
38
58
  # @return [Array<RelatonIec::Hit>]
39
- def get_results(ref, from, to, part = nil)
59
+ def get_results(ref, from, to)
40
60
  code = part ? ref.sub(/(?<=-\d)\d+/, "*") : ref
41
61
  [nil, "trf", "wr"].reduce([]) do |m, t|
42
62
  url = "#{DOMAIN}/searchkey"
43
63
  url += "&type=#{t}" if t
44
64
  url += "&RefNbr=#{code}&From=#{from}&To=#{to}&start=1"
45
- m + results(Addressable::URI.parse(url).normalize, part)
65
+ m + results(Addressable::URI.parse(url).normalize)
46
66
  end
47
67
  end
48
68
 
49
69
  # @param url [String]
50
- # @param part [String, nil]
51
70
  # @return [Array<RelatonIec::Hit>]
52
- def results(uri, part)
71
+ def results(uri)
53
72
  contains = "[contains(.,'Part #{part}:')]" if part
54
- Nokogiri::HTML(OpenURI.open_uri(uri)).xpath(
73
+ resp = OpenURI.open_uri(uri, "User-Agent" => "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) "\
74
+ "AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.111 Safari/537.36")
75
+ doc = Nokogiri::HTML(resp)
76
+ doc.xpath(
55
77
  "//body/li#{contains}",
56
78
  "//ul[contains(@class,'search-results')]/li#{contains}",
57
79
  "//ul[contains(@class,'morethesame')]/li#{contains}"
@@ -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, year, 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,28 +32,29 @@ 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
37
  if year.nil?
36
- /^(?<code1>[^:]+):(?<year1>[^:]+)/ =~ code
38
+ /^(?<code1>[^:]+):(?<year1>[^:]+)/ =~ ref
37
39
  unless code1.nil?
38
- code = code1
40
+ ref = code1
39
41
  year = year1
40
42
  end
41
43
  end
44
+ return iev if ref.casecmp("IEV").zero?
42
45
 
43
- return iev if code.casecmp("IEV").zero?
44
-
45
- opts[:all_parts] ||= !(code =~ / \(all parts\)/).nil?
46
- code = code.sub(/ \(all parts\)/, "")
47
- ret = iecbib_get1(code, year, opts)
46
+ ret = iecbib_get(ref, year, opts)
48
47
  return nil if ret.nil?
49
48
 
50
49
  ret = ret.to_most_recent_reference unless year || opts[:keep_year]
51
- ret = ret.to_all_parts if opts[:all_parts]
52
50
  ret
53
51
  end
54
52
 
55
53
  private
56
54
 
55
+ # @param code [String]
56
+ # @param year [String]
57
+ # @param missed_years [Array<String>]
57
58
  def fetch_ref_err(code, year, missed_years) # rubocop:disable Metrics/MethodLength
58
59
  id = year ? "#{code}:#{year}" : code
59
60
  warn "[relaton-iec] WARNING: no match found online for #{id}. "\
@@ -77,29 +78,43 @@ module RelatonIec
77
78
  # @param hits [Array<RelatonIec::Hit>]
78
79
  # @param threads [Integer]
79
80
  # @return [Array<RelatonIec::Hit>]
80
- def fetch_pages(hits, threads)
81
- workers = RelatonBib::WorkersPool.new threads
82
- workers.worker { |w| { i: w[:i], hit: w[:hit].fetch } }
83
- hits.each_with_index { |hit, i| workers << { i: i, hit: hit } }
84
- workers.end
85
- workers.result.sort_by { |a| a[:i] }.map { |x| x[:hit] }
86
- end
87
-
88
- def isobib_search_filter(code, year) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
89
- docidrx = %r{^(ISO|IEC)[^0-9]*\s[0-9-]+}
90
- corrigrx = %r{^(ISO|IEC)[^0-9]*\s[0-9-]+:[0-9]+/}
91
- warn "[relaton-iec] (\"#{code}\") fetching..."
81
+ # def fetch_pages(hits, threads)
82
+ # workers = RelatonBib::WorkersPool.new threads
83
+ # workers.worker { |w| { i: w[:i], hit: w[:hit].fetch } }
84
+ # hits.each_with_index { |hit, i| workers << { i: i, hit: hit } }
85
+ # workers.end
86
+ # workers.result.sort_by { |a| a[:i] }.map { |x| x[:hit] }
87
+ # end
88
+
89
+ # @param ref [String]
90
+ # @param year [String, nil]
91
+ # @return [RelatonIec::HitCollection]
92
+ def search_filter(ref, year) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
93
+ %r{
94
+ ^(?<code>\S+[^\d]*\s\d+((?:-\w+)+)?)
95
+ (:(?<year1>\d{4}))?
96
+ (?<bundle>\+[^\s\/]+)?
97
+ (\/(?<corr>AMD\s\d+))?
98
+ }x =~ ref.upcase
99
+ year ||= year1
100
+ corr&.sub! " ", ""
101
+ warn "[relaton-iec] (\"#{ref}\") fetching..."
92
102
  result = search(code, year)
93
- if result.empty? && /(?<=-)(?<part>\d+)/ =~ code
103
+ if result.empty? && /(?<=-)(?<part>[\w-]+)/ =~ code
94
104
  # try to search packaged standard
95
105
  result = search code, year, part
96
- ref = code.sub /(?<=-\d)\d+/, ""
97
- else ref = code
98
106
  end
107
+ result = search code if result.empty?
108
+ code = result.text.dup
109
+ code&.sub! /((?:-\w+)+)/, ""
99
110
  result.select do |i|
100
- i.hit[:code] &&
101
- i.hit[:code].match(docidrx).to_s.include?(ref) &&
102
- corrigrx !~ i.hit[:code]
111
+ %r{
112
+ ^(?<code2>\S+[^\d]*\s\d+)((?:-\w+)+)?
113
+ (:\d{4})?
114
+ (?<bundle2>\+[^\s\/]+)?
115
+ (\/(?<corr2>AMD\d+))?
116
+ }x =~ i.hit[:code]
117
+ code == code2 && bundle == bundle2 && corr == corr2
103
118
  end
104
119
  end
105
120
 
@@ -144,30 +159,61 @@ module RelatonIec
144
159
  # Does not match corrigenda etc (e.g. ISO 3166-1:2006/Cor 1:2007)
145
160
  # If no match, returns any years which caused mismatch, for error
146
161
  # reporting
147
- def isobib_results_filter(result, year) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength
162
+ def results_filter(result, year, opts) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity
163
+ r_code, r_year = code_year result.text, result.part
164
+ r_year ||= year
148
165
  missed_years = []
149
- result.each_slice(3) do |s| # ISO website only allows 3 connections
150
- fetch_pages(s, 3).each_with_index do |r, _i|
151
- return { ret: r } if !year
152
-
153
- r.date.select { |d| d.type == "published" }.each do |d|
154
- return { ret: r } if year.to_i == d.on(:year)
155
-
156
- missed_years << d.on(:year)
157
- end
158
- end
159
- end
160
- { years: missed_years }
166
+ missed_parts = false
167
+ # result.each_slice(3) do |s| # ISO website only allows 3 connections
168
+ ret = if opts[:all_parts]
169
+ result.to_all_parts
170
+ else
171
+ result.detect do |h|
172
+ h_code, h_year = code_year h.hit[:code], result.part
173
+ missed_parts ||= !opts[:all_parts] && r_code != h_code
174
+ missed_years << h_year unless !r_year || h_year == r_year
175
+ r_code == h_code && (!year || h_year == r_year)
176
+ # fetch_pages(s, 3).each_with_index do |r, _i|
177
+ # return { ret: r } if !year
178
+
179
+ # r.date.select { |d| d.type == "published" }.each do |d|
180
+ # return { ret: r } if year.to_i == d.on(:year)
181
+
182
+ # missed_years << d.on(:year)
183
+ # end
184
+ # end
185
+ end&.fetch
186
+ end
187
+ { ret: ret, years: missed_years, missed_parts: missed_parts }
161
188
  end
162
189
 
163
- def iecbib_get1(code, year, _opts)
164
- return iev if code.casecmp("IEV").zero?
190
+ # @param ref [String]
191
+ # @param part [String, nil]
192
+ # @return [Array<String, nil>]
193
+ def code_year(ref, part)
194
+ %r{
195
+ ^(?<code>\S+[^\d]*\s\d+((?:-\w+)+)?)
196
+ (:(?<year>\d{4}))?
197
+ }x =~ ref
198
+ code.sub!(/-\d+/, "") if part
199
+ [code, year]
200
+ end
165
201
 
166
- result = isobib_search_filter(code, year) || return
167
- ret = isobib_results_filter(result, year)
202
+ # @param code [String]
203
+ # @param year [String, nil]
204
+ # @param opts [Hash]
205
+ # @return [RelatonIec::IecBibliographicItem, nil]
206
+ def iecbib_get(code, year, opts) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
207
+ result = search_filter(code, year) || return
208
+ ret = results_filter(result, year, opts)
168
209
  if ret[:ret]
169
- warn "[relaton-iec] (\"#{code}\") found "\
170
- "#{ret[:ret].docidentifier.first.id}"
210
+ if ret[:missed_parts]
211
+ warn "[relaton-iec] WARNING: #{code} found as #{ret[:ret].docidentifier.first.id} "\
212
+ "but also contain parts. If you wanted to cite all document parts for the reference, use "\
213
+ "\"#{code} (all parts)\""
214
+ else
215
+ warn "[relaton-iec] (\"#{code}\") found #{ret[:ret].docidentifier.first.id}"
216
+ end
171
217
  ret[:ret]
172
218
  else
173
219
  fetch_ref_err(code, year, ret[:years])
@@ -35,5 +35,11 @@ module RelatonIec
35
35
  def grammar_hash
36
36
  @grammar_hash ||= ::RelatonIec.grammar_hash
37
37
  end
38
+
39
+ # @param code [String]
40
+ # @return [String, nil]
41
+ def urn_to_code(code)
42
+ RelatonIec.urn_to_code code
43
+ end
38
44
  end
39
45
  end
@@ -69,38 +69,13 @@ module RelatonIec
69
69
  # @param hit [Hash]
70
70
  # @return [Array<RelatonBib::DocumentIdentifier>]
71
71
  def fetch_docid(hit)
72
- rest = hit[:code].downcase.sub(%r{
73
- (?<head>[^\s]+)\s
74
- (?<type>is|ts|tr|pas|srd|guide|tec|wp)?(?(<type>)\s)
75
- (?<pnum>[\d-]+)\s?
76
- (?<_dd>:)?(?(<_dd>)(?<date>[\d-]+)\s?)
77
- }x, "")
78
- m = $~
79
- deliv = /cmv|csv|exv|prv|rlv|ser/.match(hit[:code].downcase).to_s
80
- urn = ["urn", "iec", "std", m[:head].split("/").join("-"), m[:pnum],
81
- m[:date], m[:type], deliv, "en"]
82
- urn += fetch_ajunct(rest)
72
+ urn = RelatonIec.code_to_urn hit[:code], "en"
83
73
  [
84
74
  RelatonBib::DocumentIdentifier.new(id: hit[:code], type: "IEC"),
85
- RelatonBib::DocumentIdentifier.new(id: urn.join(":"), type: "URN"),
75
+ RelatonBib::DocumentIdentifier.new(id: urn, type: "URN"),
86
76
  ]
87
77
  end
88
78
 
89
- # @param rest [String]
90
- # @return [Array<String, nil>]
91
- def fetch_ajunct(rest)
92
- r = rest.sub(%r{
93
- (?<_pl>\+)(?(<_pl>)(?<adjunct>amd)(?<adjnum>\d+)\s?)
94
- (?<_d2>:)?(?(<_d2>)(?<adjdt>[\d-]+)\s?)
95
- }x, "")
96
- m = $~ || {}
97
- return [] unless m[:adjunct]
98
-
99
- plus = m[:adjunct] && "plus"
100
- urn = [plus, m[:adjunct], m[:adjnum], m[:adjdt]]
101
- urn + fetch_ajunct(r)
102
- end
103
-
104
79
  # Fetch abstracts.
105
80
  # @param doc [Nokigiri::HTML::Document]
106
81
  # @return [Array<Array>]
@@ -172,6 +147,8 @@ module RelatonIec
172
147
  if wip
173
148
  statuses = YAML.load_file File.join __dir__, "statuses.yml"
174
149
  s = wip.at("STAGE").text
150
+ return unless statuses[s]
151
+
175
152
  stage, substage = statuses[s]["stage"].split "."
176
153
  else
177
154
  stage = "60"
@@ -264,14 +241,7 @@ module RelatonIec
264
241
 
265
242
  def fetch_contributors(code)
266
243
  code.sub(/\s.*/, "").split("/").map do |abbrev|
267
- case abbrev
268
- when "ISO"
269
- name = "International Organization for Standardization"
270
- url = "www.iso.org"
271
- when "IEC"
272
- name = "International Electrotechnical Commission"
273
- url = "www.iec.ch"
274
- end
244
+ name, url = name_url abbrev
275
245
  { entity: { name: name, url: url, abbreviation: abbrev },
276
246
  role: [type: "publisher"] }
277
247
  end
@@ -308,11 +278,7 @@ module RelatonIec
308
278
  # @return [Array<Hash>]
309
279
  def fetch_copyright(code, doc)
310
280
  abbreviation = code.match(/.*?(?=\s)/).to_s
311
- case abbreviation
312
- when "IEC"
313
- name = "International Electrotechnical Commission"
314
- url = "www.iec.ch"
315
- end
281
+ name, url = name_url abbreviation
316
282
  from = code.match(/(?<=:)\d{4}/).to_s
317
283
  if from.empty?
318
284
  from = doc.xpath("//span[@itemprop='releaseDate']").text
@@ -324,6 +290,14 @@ module RelatonIec
324
290
  }]
325
291
  end
326
292
  # rubocop:enable Metrics/MethodLength
293
+
294
+ 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
+ end
327
301
  end
328
302
  end
329
303
  end
@@ -4,6 +4,9 @@ ACD:
4
4
  ACDV:
5
5
  status: Approved for CDV
6
6
  stage: '30.99'
7
+ ADISSB:
8
+ status: Preparation of text subcontracted to CO
9
+ stage: '40.95'
7
10
  ADTR:
8
11
  status: Approved for DTR
9
12
  stage: '40.99'
@@ -13,30 +16,39 @@ ADTS:
13
16
  AFDIS:
14
17
  status: Approved for FDIS
15
18
  stage: '40.99'
19
+ AMW:
20
+ status: Document under revision
21
+ stage: '92.20'
22
+ ANW:
23
+ status: Registration of new project
24
+ stage: '20.00'
16
25
  APUB:
17
26
  status: Approved for publication
18
27
  stage: '50.99'
28
+ APUBSB:
29
+ status: Preparation of text subcontracted to CO
30
+ stage: '50.95'
19
31
  BPUB:
20
32
  status: Being published
21
33
  stage: '60.00'
34
+ BWG:
35
+ status: Return to drafting phase or redefine project
36
+ stage: '30.92'
22
37
  CAN:
23
38
  status: Draft cancelled
24
39
  stage: '20.98'
40
+ CCDV:
41
+ status: Draft circulated as CDV
42
+ stage: '40.00'
25
43
  CD:
26
44
  status: Draft circulated as CD
27
45
  stage: '30.00'
46
+ CDISH:
47
+ status: Draft circulated as DISH
48
+ stage: '50.20'
28
49
  CDM:
29
50
  status: CD to be discussed at meeting
30
51
  stage: '30.20'
31
- CCDV:
32
- status: Draft circulated as CDV
33
- stage: '40.00'
34
- CDVM:
35
- status: Rejected CDV to be discussed at a meeting
36
- stage: '40.93'
37
- CFDIS:
38
- status: Draft circulated as FDIS
39
- stage: '50.20'
40
52
  CDPAS:
41
53
  status: Draft circulated as DPAS
42
54
  stage: '50.20'
@@ -46,12 +58,15 @@ CDTR:
46
58
  CDTS:
47
59
  status: Draft circulated as DTS
48
60
  stage: '50.20'
49
- DTRM:
50
- status: Rejected DTR to be discussed at meeting
51
- stage: '50.92'
52
- DTSM:
53
- status: Rejected DTS to be discussed at meeting
54
- stage: '50.92'
61
+ CDVM:
62
+ status: Rejected CDV to be discussed at a meeting
63
+ stage: '40.93'
64
+ CFDIS:
65
+ status: Draft circulated as FDIS
66
+ stage: '50.20'
67
+ DECDISH:
68
+ status: DISH at editing check
69
+ stage: '40.99'
55
70
  DECFDIS:
56
71
  status: FDIS at editing check
57
72
  stage: '50.60'
@@ -64,6 +79,21 @@ DEL:
64
79
  DELPUB:
65
80
  status: Deleted publication
66
81
  stage: '90.99'
82
+ DREJ:
83
+ status: Abandon
84
+ stage: '30.98'
85
+ DTRM:
86
+ status: Rejected DTR to be discussed at meeting
87
+ stage: '50.92'
88
+ DTSM:
89
+ status: Rejected DTS to be discussed at meeting
90
+ stage: '50.92'
91
+ MERGED:
92
+ status: Fragment merged
93
+ stage: '30.97'
94
+ NADIS:
95
+ status: Repeat enquiry
96
+ stage: '40.93'
67
97
  NCDV:
68
98
  status: CDV rejected
69
99
  stage: '40.98'
@@ -84,13 +114,16 @@ PNW:
84
114
  stage: '10.00'
85
115
  PPUB:
86
116
  status: Publication issued
87
- stage: '60.60' # ?
117
+ stage: '60.60'
88
118
  PRVC:
89
119
  status: Preparation of RVC
90
120
  stage: '40.92'
91
121
  PRVD:
92
122
  status: Preparation of RVD
93
123
  stage: '40.92'
124
+ PRVDISH:
125
+ status: Preparation of RVDISH
126
+ stage: '40.92' # ?
94
127
  PRVDPAS:
95
128
  status: Preparation of RVDPAS
96
129
  stage: '40.92'
@@ -106,15 +139,34 @@ PRVN:
106
139
  PWI:
107
140
  status: Preliminary work item
108
141
  stage: '00.00'
142
+ RDIS:
143
+ status: Registration for formal approval
144
+ stage: '50.00'
145
+ RDISH:
146
+ status: DISH received and registered
147
+ stage: '50.00'
109
148
  RFDIS:
110
149
  status: FDIS received and registered
111
150
  stage: '50.00'
112
151
  RPUB:
113
152
  status: Publication received and registered
114
153
  stage: '60.60'
154
+ SPE:
155
+ stage: SPE # ?
156
+ SPLIT:
157
+ status: Project Fragmented
158
+ stage: SPLIT # ?
159
+ SRP:
160
+ stage: SRP
161
+ SUSPENDED:
162
+ status: Project Suspended
163
+ stage: SUSPENDED # ?
115
164
  TCDV:
116
165
  status: Translation of CDV
117
166
  stage: '50.00'
167
+ TDISH:
168
+ status: Translation of DISH
169
+ stage: '50.00' # ?
118
170
  TDTR:
119
171
  status: Translation of DTR
120
172
  stage: '50.00'
@@ -129,4 +181,19 @@ TPUB:
129
181
  stage: '60.00'
130
182
  WPUB:
131
183
  status: Publication withdrawn
132
- stage: '95.99'
184
+ stage: '95.99'
185
+ preCD:
186
+ status: Preparation of CD document
187
+ stage: preCD
188
+ preCDPAS:
189
+ status: Preparation of DPAS
190
+ stage: preCDPAS
191
+ preDISH:
192
+ status: Preparation of DISH
193
+ stage: preDISH
194
+ preDTR:
195
+ status: Preparation of DTR document
196
+ stage: preDTR
197
+ prePNW:
198
+ status: Preparation of NP document
199
+ stage: prePNW
@@ -1,3 +1,3 @@
1
1
  module RelatonIec
2
- VERSION = "1.7.2".freeze
2
+ VERSION = "1.7.7".freeze
3
3
  end
@@ -7,7 +7,7 @@ module RelatonIec
7
7
  # @param item_hash [Hash]
8
8
  # @return [RelatonIec::IecBibliographicItem]
9
9
  def bib_item(item_hash)
10
- IecBibliographicItem.new item_hash
10
+ IecBibliographicItem.new **item_hash
11
11
  end
12
12
  end
13
13
  end
data/relaton_iec.gemspec CHANGED
@@ -23,12 +23,12 @@ Gem::Specification.new do |spec|
23
23
  spec.require_paths = ["lib"]
24
24
  spec.required_ruby_version = Gem::Requirement.new(">= 2.4.0")
25
25
 
26
- spec.add_development_dependency "debase"
26
+ # spec.add_development_dependency "debase"
27
27
  spec.add_development_dependency "equivalent-xml", "~> 0.6"
28
28
  spec.add_development_dependency "pry-byebug"
29
29
  spec.add_development_dependency "rake", "~> 10.0"
30
30
  spec.add_development_dependency "rspec", "~> 3.0"
31
- spec.add_development_dependency "ruby-debug-ide"
31
+ # spec.add_development_dependency "ruby-debug-ide"
32
32
  spec.add_development_dependency "ruby-jing"
33
33
  spec.add_development_dependency "simplecov"
34
34
  spec.add_development_dependency "vcr"
metadata CHANGED
@@ -1,29 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: relaton-iec
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.2
4
+ version: 1.7.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-12-01 00:00:00.000000000 Z
11
+ date: 2021-03-17 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: debase
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: '0'
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ">="
25
- - !ruby/object:Gem::Version
26
- version: '0'
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: equivalent-xml
29
15
  requirement: !ruby/object:Gem::Requirement
@@ -80,20 +66,6 @@ dependencies:
80
66
  - - "~>"
81
67
  - !ruby/object:Gem::Version
82
68
  version: '3.0'
83
- - !ruby/object:Gem::Dependency
84
- name: ruby-debug-ide
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - ">="
88
- - !ruby/object:Gem::Version
89
- version: '0'
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - ">="
95
- - !ruby/object:Gem::Version
96
- version: '0'
97
69
  - !ruby/object:Gem::Dependency
98
70
  name: ruby-jing
99
71
  requirement: !ruby/object:Gem::Requirement
@@ -186,9 +158,7 @@ executables: []
186
158
  extensions: []
187
159
  extra_rdoc_files: []
188
160
  files:
189
- - ".github/workflows/macos.yml"
190
- - ".github/workflows/ubuntu.yml"
191
- - ".github/workflows/windows.yml"
161
+ - ".github/workflows/rake.yml"
192
162
  - ".gitignore"
193
163
  - ".rspec"
194
164
  - ".rubocop.yml"
@@ -197,6 +167,7 @@ files:
197
167
  - README.adoc
198
168
  - Rakefile
199
169
  - bin/console
170
+ - bin/rspec
200
171
  - bin/setup
201
172
  - grammars/basicdoc.rng
202
173
  - grammars/biblio.rng
@@ -235,7 +206,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
235
206
  - !ruby/object:Gem::Version
236
207
  version: '0'
237
208
  requirements: []
238
- rubygems_version: 3.0.6
209
+ rubygems_version: 3.2.3
239
210
  signing_key:
240
211
  specification_version: 4
241
212
  summary: 'RelatonIec: retrieve IEC Standards for bibliographic use using the IecBibliographicItem
@@ -1,34 +0,0 @@
1
- # Auto-generated by Cimas: Do not edit it manually!
2
- # See https://github.com/metanorma/cimas
3
- name: macos
4
-
5
- on:
6
- push:
7
- branches: [ master ]
8
- pull_request:
9
- branches: [ '**' ]
10
-
11
- jobs:
12
- test-macos:
13
- name: Test on Ruby ${{ matrix.ruby }} macOS
14
- runs-on: macos-latest
15
- strategy:
16
- fail-fast: false
17
- matrix:
18
- ruby: [ '2.6', '2.5', '2.4' ]
19
- steps:
20
- - uses: actions/checkout@master
21
- - name: Use Ruby
22
- uses: actions/setup-ruby@v1
23
- with:
24
- ruby-version: ${{ matrix.ruby }}
25
- architecture: 'x64'
26
- - name: Update gems
27
- run: |
28
- sudo gem install bundler --force
29
- ruby -v | grep 2.5 && bundle config set build.debase --with-cflags="-Wno-error=implicit-function-declaration"
30
- ruby -v | grep 2.5 && bundle config set build.ruby-debug-ide --with-cflags="-Wno-error=implicit-function-declaration"
31
- bundle install --jobs 4 --retry 3
32
- - name: Run specs
33
- run: |
34
- bundle exec rake
@@ -1,33 +0,0 @@
1
- # Auto-generated by Cimas: Do not edit it manually!
2
- # See https://github.com/metanorma/cimas
3
- name: ubuntu
4
-
5
- on:
6
- push:
7
- branches: [ master ]
8
- pull_request:
9
- branches: [ '**' ]
10
-
11
- jobs:
12
- test-linux:
13
- name: Test on Ruby ${{ matrix.ruby }} Ubuntu
14
- runs-on: ubuntu-latest
15
- strategy:
16
- fail-fast: false
17
- matrix:
18
- ruby: [ '2.6', '2.5', '2.4' ]
19
- steps:
20
- - uses: actions/checkout@master
21
- - name: Use Ruby
22
- uses: actions/setup-ruby@v1
23
- with:
24
- ruby-version: ${{ matrix.ruby }}
25
- architecture: 'x64'
26
- - name: Update gems
27
- run: |
28
- gem install bundler
29
- bundle install --jobs 4 --retry 3
30
- - name: Run specs
31
- run: |
32
- unset JAVA_TOOL_OPTIONS
33
- bundle exec rake
@@ -1,35 +0,0 @@
1
- # Auto-generated by Cimas: Do not edit it manually!
2
- # See https://github.com/metanorma/cimas
3
- name: windows
4
-
5
- on:
6
- push:
7
- branches: [ master ]
8
- pull_request:
9
- branches: [ '**' ]
10
-
11
- jobs:
12
- test-windows:
13
- name: Test on Ruby ${{ matrix.ruby }} Windows
14
- runs-on: windows-latest
15
- strategy:
16
- fail-fast: false
17
- matrix:
18
- ruby: [ '2.6', '2.5', '2.4' ]
19
- steps:
20
- - uses: actions/checkout@master
21
- - name: Use Ruby
22
- uses: actions/setup-ruby@v1
23
- with:
24
- ruby-version: ${{ matrix.ruby }}
25
- architecture: 'x64'
26
- - name: Update gems
27
- shell: pwsh
28
- run: |
29
- gem install bundler
30
- bundle config --local path vendor/bundle
31
- bundle update
32
- bundle install --jobs 4 --retry 3
33
- - name: Run specs
34
- run: |
35
- bundle exec rake