relaton 3.0.0.pre.alpha.4 → 3.0.0.pre.alpha.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/relaton/3gpp/bibliography.rb +19 -6
- data/lib/relaton/3gpp/processor.rb +6 -0
- data/lib/relaton/adobe/processor.rb +9 -0
- data/lib/relaton/bib/converter/csl.rb +110 -0
- data/lib/relaton/bib/converter/ris.rb +104 -0
- data/lib/relaton/bib/converter/titles.rb +24 -0
- data/lib/relaton/bib/item_data.rb +23 -0
- data/lib/relaton/bib/model/item.rb +6 -6
- data/lib/relaton/bib/sanitizer.rb +71 -30
- data/lib/relaton/bib.rb +10 -0
- data/lib/relaton/bipm/bibliography.rb +24 -21
- data/lib/relaton/bipm/processor.rb +1 -0
- data/lib/relaton/bipm/rawdata_bipm_metrologia/affiliations.rb +6 -6
- data/lib/relaton/bipm/si_brochure_parser.rb +2 -2
- data/lib/relaton/bsi/bibliography.rb +26 -23
- data/lib/relaton/bsi/processor.rb +5 -0
- data/lib/relaton/calconnect/bibliography.rb +6 -6
- data/lib/relaton/calconnect/hit_collection.rb +4 -1
- data/lib/relaton/ccsds/bibliography.rb +16 -10
- data/lib/relaton/ccsds/hit_collection.rb +1 -1
- data/lib/relaton/ccsds/processor.rb +13 -0
- data/lib/relaton/cen/bibliography.rb +27 -24
- data/lib/relaton/cen/hit_collection.rb +1 -1
- data/lib/relaton/cen/processor.rb +5 -0
- data/lib/relaton/cen/scraper.rb +9 -9
- data/lib/relaton/cie/bibliography.rb +11 -9
- data/lib/relaton/cie/data_fetcher.rb +18 -18
- data/lib/relaton/cie/processor.rb +1 -0
- data/lib/relaton/cie/scrapper.rb +15 -8
- data/lib/relaton/cie.rb +1 -1
- data/lib/relaton/cloud.rb +127 -0
- data/lib/relaton/core/hit_collection.rb +6 -10
- data/lib/relaton/core/processor.rb +121 -0
- data/lib/relaton/core/request_error.rb +21 -3
- data/lib/relaton/db/cache.rb +474 -148
- data/lib/relaton/db/cache_entry.rb +42 -0
- data/lib/relaton/db/registry.rb +152 -0
- data/lib/relaton/db.rb +275 -102
- data/lib/relaton/doi/crossref.rb +23 -6
- data/lib/relaton/doi/processor.rb +1 -0
- data/lib/relaton/easc/processor.rb +1 -0
- data/lib/relaton/ecma/bibliography.rb +18 -13
- data/lib/relaton/ecma/data_fetcher.rb +1 -1
- data/lib/relaton/ecma/data_parser.rb +1 -1
- data/lib/relaton/ecma/edition_parser.rb +2 -2
- data/lib/relaton/ecma/memento_parser.rb +4 -4
- data/lib/relaton/ecma/standard_parser.rb +6 -6
- data/lib/relaton/etsi/bibliography.rb +8 -7
- data/lib/relaton/etsi/processor.rb +1 -0
- data/lib/relaton/gb/bibliography.rb +20 -12
- data/lib/relaton/gb/gb_scraper.rb +5 -5
- data/lib/relaton/gb/scraper.rb +16 -16
- data/lib/relaton/gb/sec_scraper.rb +8 -8
- data/lib/relaton/gb/t_scraper.rb +5 -5
- data/lib/relaton/gost/processor.rb +1 -0
- data/lib/relaton/iala/bibliography.rb +15 -12
- data/lib/relaton/iala/processor.rb +1 -0
- data/lib/relaton/iana/bibliography.rb +12 -12
- data/lib/relaton/iana/data_fetcher.rb +3 -3
- data/lib/relaton/iana/parser.rb +12 -5
- data/lib/relaton/iana/processor.rb +9 -0
- data/lib/relaton/iec/bibliography.rb +18 -7
- data/lib/relaton/iec/data_parser.rb +24 -9
- data/lib/relaton/iec/processor.rb +11 -0
- data/lib/relaton/iec.rb +1 -1
- data/lib/relaton/ieee/bibliography.rb +19 -13
- data/lib/relaton/ieee/data_fetcher.rb +1 -1
- data/lib/relaton/ieee/processor.rb +24 -0
- data/lib/relaton/ieee/rawbib_id_parser.rb +2 -2
- data/lib/relaton/ietf/bibliography.rb +11 -9
- data/lib/relaton/ietf/data_fetcher.rb +1 -1
- data/lib/relaton/ietf/processor.rb +1 -0
- data/lib/relaton/ietf/rfc/entry.rb +15 -19
- data/lib/relaton/ietf/scraper.rb +5 -4
- data/lib/relaton/iho/processor.rb +1 -0
- data/lib/relaton/index/file_io.rb +2 -2
- data/lib/relaton/index/pool.rb +4 -3
- data/lib/relaton/index/shard_source.rb +1 -1
- data/lib/relaton/index/type.rb +2 -5
- data/lib/relaton/isbn/open_library.rb +11 -7
- data/lib/relaton/isbn/processor.rb +10 -0
- data/lib/relaton/iso/bibliography.rb +11 -9
- data/lib/relaton/iso/data_parser.rb +2 -2
- data/lib/relaton/iso/processor.rb +5 -0
- data/lib/relaton/iso/scraper.rb +20 -20
- data/lib/relaton/itu/bibliography.rb +107 -16
- data/lib/relaton/itu/data_crawler_r.rb +2 -2
- data/lib/relaton/itu/hit_collection.rb +64 -52
- data/lib/relaton/itu/processor.rb +1 -0
- data/lib/relaton/itu/scraper.rb +13 -3
- data/lib/relaton/itu.rb +0 -2
- data/lib/relaton/jis/bibliography.rb +22 -11
- data/lib/relaton/jis/data_fetcher.rb +4 -4
- data/lib/relaton/jis/processor.rb +1 -0
- data/lib/relaton/jis/scraper.rb +8 -8
- data/lib/relaton/nist/bibliography.rb +25 -21
- data/lib/relaton/oasis/bibliography.rb +16 -13
- data/lib/relaton/oasis/browser_agent.rb +2 -2
- data/lib/relaton/oasis/data_parser.rb +5 -5
- data/lib/relaton/oasis/data_parser_utils.rb +2 -2
- data/lib/relaton/oasis/data_part_parser.rb +7 -7
- data/lib/relaton/ogc/bibliography.rb +15 -14
- data/lib/relaton/ogc/hit_collection.rb +9 -7
- data/lib/relaton/ogc/processor.rb +13 -0
- data/lib/relaton/oiml/processor.rb +1 -0
- data/lib/relaton/omg/bibliography.rb +9 -9
- data/lib/relaton/omg/scraper.rb +14 -13
- data/lib/relaton/omg.rb +1 -1
- data/lib/relaton/plateau/bibliography.rb +9 -7
- data/lib/relaton/plateau/hit_collection.rb +2 -1
- data/lib/relaton/plateau/processor.rb +1 -0
- data/lib/relaton/un/bibliography.rb +21 -10
- data/lib/relaton/un/processor.rb +1 -0
- data/lib/relaton/version.rb +1 -1
- data/lib/relaton/w3c/processor.rb +1 -0
- data/lib/relaton/xsf/bibliography.rb +11 -6
- data/lib/relaton.rb +13 -0
- metadata +60 -14
- data/lib/relaton/itu/pubid.rb +0 -199
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: relaton
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.0.0.pre.alpha.
|
|
4
|
+
version: 3.0.0.pre.alpha.6
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ribose Inc.
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-10-02 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: addressable
|
|
@@ -302,14 +302,28 @@ dependencies:
|
|
|
302
302
|
requirements:
|
|
303
303
|
- - "~>"
|
|
304
304
|
- !ruby/object:Gem::Version
|
|
305
|
-
version: 0.8.
|
|
305
|
+
version: 0.8.76
|
|
306
306
|
type: :runtime
|
|
307
307
|
prerelease: false
|
|
308
308
|
version_requirements: !ruby/object:Gem::Requirement
|
|
309
309
|
requirements:
|
|
310
310
|
- - "~>"
|
|
311
311
|
- !ruby/object:Gem::Version
|
|
312
|
-
version: 0.8.
|
|
312
|
+
version: 0.8.76
|
|
313
|
+
- !ruby/object:Gem::Dependency
|
|
314
|
+
name: lutaml-store
|
|
315
|
+
requirement: !ruby/object:Gem::Requirement
|
|
316
|
+
requirements:
|
|
317
|
+
- - "~>"
|
|
318
|
+
- !ruby/object:Gem::Version
|
|
319
|
+
version: 0.3.2
|
|
320
|
+
type: :runtime
|
|
321
|
+
prerelease: false
|
|
322
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
323
|
+
requirements:
|
|
324
|
+
- - "~>"
|
|
325
|
+
- !ruby/object:Gem::Version
|
|
326
|
+
version: 0.3.2
|
|
313
327
|
- !ruby/object:Gem::Dependency
|
|
314
328
|
name: mechanize
|
|
315
329
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -353,19 +367,33 @@ dependencies:
|
|
|
353
367
|
- !ruby/object:Gem::Version
|
|
354
368
|
version: 0.3.4
|
|
355
369
|
- !ruby/object:Gem::Dependency
|
|
356
|
-
name:
|
|
370
|
+
name: moxml
|
|
357
371
|
requirement: !ruby/object:Gem::Requirement
|
|
358
372
|
requirements:
|
|
359
373
|
- - ">="
|
|
360
374
|
- !ruby/object:Gem::Version
|
|
361
|
-
version: '
|
|
375
|
+
version: '0.5'
|
|
362
376
|
type: :runtime
|
|
363
377
|
prerelease: false
|
|
364
378
|
version_requirements: !ruby/object:Gem::Requirement
|
|
365
379
|
requirements:
|
|
366
380
|
- - ">="
|
|
367
381
|
- !ruby/object:Gem::Version
|
|
368
|
-
version: '
|
|
382
|
+
version: '0.5'
|
|
383
|
+
- !ruby/object:Gem::Dependency
|
|
384
|
+
name: leptris
|
|
385
|
+
requirement: !ruby/object:Gem::Requirement
|
|
386
|
+
requirements:
|
|
387
|
+
- - ">="
|
|
388
|
+
- !ruby/object:Gem::Version
|
|
389
|
+
version: 1.9.80
|
|
390
|
+
type: :runtime
|
|
391
|
+
prerelease: false
|
|
392
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
393
|
+
requirements:
|
|
394
|
+
- - ">="
|
|
395
|
+
- !ruby/object:Gem::Version
|
|
396
|
+
version: 1.9.80
|
|
369
397
|
- !ruby/object:Gem::Dependency
|
|
370
398
|
name: parallel
|
|
371
399
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -395,33 +423,47 @@ dependencies:
|
|
|
395
423
|
- !ruby/object:Gem::Version
|
|
396
424
|
version: 2.0.0
|
|
397
425
|
- !ruby/object:Gem::Dependency
|
|
398
|
-
name:
|
|
426
|
+
name: pubid
|
|
399
427
|
requirement: !ruby/object:Gem::Requirement
|
|
400
428
|
requirements:
|
|
401
429
|
- - "~>"
|
|
402
430
|
- !ruby/object:Gem::Version
|
|
403
|
-
version:
|
|
431
|
+
version: 2.0.0.pre.alpha.21
|
|
404
432
|
type: :runtime
|
|
405
433
|
prerelease: false
|
|
406
434
|
version_requirements: !ruby/object:Gem::Requirement
|
|
407
435
|
requirements:
|
|
408
436
|
- - "~>"
|
|
409
437
|
- !ruby/object:Gem::Version
|
|
410
|
-
version:
|
|
438
|
+
version: 2.0.0.pre.alpha.21
|
|
411
439
|
- !ruby/object:Gem::Dependency
|
|
412
|
-
name:
|
|
440
|
+
name: yeptris
|
|
441
|
+
requirement: !ruby/object:Gem::Requirement
|
|
442
|
+
requirements:
|
|
443
|
+
- - ">="
|
|
444
|
+
- !ruby/object:Gem::Version
|
|
445
|
+
version: '0.4'
|
|
446
|
+
type: :runtime
|
|
447
|
+
prerelease: false
|
|
448
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
449
|
+
requirements:
|
|
450
|
+
- - ">="
|
|
451
|
+
- !ruby/object:Gem::Version
|
|
452
|
+
version: '0.4'
|
|
453
|
+
- !ruby/object:Gem::Dependency
|
|
454
|
+
name: relaton-render
|
|
413
455
|
requirement: !ruby/object:Gem::Requirement
|
|
414
456
|
requirements:
|
|
415
457
|
- - "~>"
|
|
416
458
|
- !ruby/object:Gem::Version
|
|
417
|
-
version:
|
|
459
|
+
version: 1.4.0.pre.alpha.1
|
|
418
460
|
type: :runtime
|
|
419
461
|
prerelease: false
|
|
420
462
|
version_requirements: !ruby/object:Gem::Requirement
|
|
421
463
|
requirements:
|
|
422
464
|
- - "~>"
|
|
423
465
|
- !ruby/object:Gem::Version
|
|
424
|
-
version:
|
|
466
|
+
version: 1.4.0.pre.alpha.1
|
|
425
467
|
- !ruby/object:Gem::Dependency
|
|
426
468
|
name: rfcxml
|
|
427
469
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -523,6 +565,9 @@ files:
|
|
|
523
565
|
- lib/relaton/bib/converter/bibxml/from_rfcxml_referencegroup.rb
|
|
524
566
|
- lib/relaton/bib/converter/bibxml/to_rfcxml.rb
|
|
525
567
|
- lib/relaton/bib/converter/bibxml/to_rfcxml_referencegroup.rb
|
|
568
|
+
- lib/relaton/bib/converter/csl.rb
|
|
569
|
+
- lib/relaton/bib/converter/ris.rb
|
|
570
|
+
- lib/relaton/bib/converter/titles.rb
|
|
526
571
|
- lib/relaton/bib/hash_parser_v1.rb
|
|
527
572
|
- lib/relaton/bib/item_data.rb
|
|
528
573
|
- lib/relaton/bib/model/abstract.rb
|
|
@@ -676,6 +721,7 @@ files:
|
|
|
676
721
|
- lib/relaton/cie/processor.rb
|
|
677
722
|
- lib/relaton/cie/scrapper.rb
|
|
678
723
|
- lib/relaton/cie/util.rb
|
|
724
|
+
- lib/relaton/cloud.rb
|
|
679
725
|
- lib/relaton/core.rb
|
|
680
726
|
- lib/relaton/core/array_wrapper.rb
|
|
681
727
|
- lib/relaton/core/data_fetcher.rb
|
|
@@ -690,6 +736,7 @@ files:
|
|
|
690
736
|
- lib/relaton/core/workers_pool.rb
|
|
691
737
|
- lib/relaton/db.rb
|
|
692
738
|
- lib/relaton/db/cache.rb
|
|
739
|
+
- lib/relaton/db/cache_entry.rb
|
|
693
740
|
- lib/relaton/db/config.rb
|
|
694
741
|
- lib/relaton/db/registry.rb
|
|
695
742
|
- lib/relaton/db/util.rb
|
|
@@ -945,7 +992,6 @@ files:
|
|
|
945
992
|
- lib/relaton/itu/model/recommendation_status.rb
|
|
946
993
|
- lib/relaton/itu/model/structured_identifier.rb
|
|
947
994
|
- lib/relaton/itu/processor.rb
|
|
948
|
-
- lib/relaton/itu/pubid.rb
|
|
949
995
|
- lib/relaton/itu/radio_regulations_parser.rb
|
|
950
996
|
- lib/relaton/itu/recommendation_fields.rb
|
|
951
997
|
- lib/relaton/itu/recommendation_parser.rb
|
data/lib/relaton/itu/pubid.rb
DELETED
|
@@ -1,199 +0,0 @@
|
|
|
1
|
-
module Relaton
|
|
2
|
-
module Itu
|
|
3
|
-
class Pubid
|
|
4
|
-
class Parser < Parslet::Parser
|
|
5
|
-
rule(:dash) { str("-") }
|
|
6
|
-
rule(:dot) { str(".") }
|
|
7
|
-
rule(:dot?) { dot.maybe }
|
|
8
|
-
rule(:separator) { match['\s-'] }
|
|
9
|
-
rule(:space) { match("\s") }
|
|
10
|
-
rule(:num) { match["0-9"] }
|
|
11
|
-
|
|
12
|
-
rule(:prefix) { str("ITU").as(:prefix) }
|
|
13
|
-
rule(:sector) { separator >> match("[A-Z]").as(:sector) }
|
|
14
|
-
# "Report" is not decoration: ITU-R Recommendations and Reports number
|
|
15
|
-
# independently, so "ITU-R BT.2020-1" alone names two different documents
|
|
16
|
-
# (Rec. BT.2020-1, 06/2014 vs Report BT.2020-1, 2000). ITU writes the
|
|
17
|
-
# discriminator first ("Report ITU-R BT.2020-1"), which is the form
|
|
18
|
-
# `Pubid::Itu` parses as `pubid:itu:report`; the sector-first spelling is
|
|
19
|
-
# accepted too because bibliographies use both.
|
|
20
|
-
rule(:report) { (str("Report") | str("REP")).as(:type) >> space }
|
|
21
|
-
rule(:report?) { report.maybe }
|
|
22
|
-
rule(:type) { separator >> (str("REC") | str("Report") | str("REP")).as(:type) }
|
|
23
|
-
rule(:type?) { type.maybe }
|
|
24
|
-
rule(:code) { separator >> (match["A-Z0-9"].repeat(1) >> match["[:alnum:]/.-"].repeat).as(:code) }
|
|
25
|
-
rule(:year) { (match["12"] >> num.repeat(3, 3)).as(:year) }
|
|
26
|
-
|
|
27
|
-
rule(:month1) { num.repeat(2, 2).as(:month) }
|
|
28
|
-
rule(:date1) { str(" (") >> (month1 >> str("/")).maybe >> year >> str(")") }
|
|
29
|
-
rule(:month2) { match["IVX"].repeat(1, 3).as(:month) }
|
|
30
|
-
rule(:date2) { str(" - ") >> num.repeat(2, 2).as(:day) >> dot >> month2 >> dot >> year }
|
|
31
|
-
rule(:date) { date1 | date2 }
|
|
32
|
-
rule(:date?) { date.maybe }
|
|
33
|
-
|
|
34
|
-
rule(:amd_month) { num.repeat(2, 2) }
|
|
35
|
-
rule(:amd_year) { num.repeat(4, 4) }
|
|
36
|
-
rule(:amd_date) { str(" (") >> (amd_month >> str("/") >> amd_year).as(:amd_date) >> str(")") }
|
|
37
|
-
rule(:amd_date?) { amd_date.maybe }
|
|
38
|
-
rule(:amd) { space >> (str("Amd") | str("Amendment")) >> dot? >> space >> num.repeat(1, 2).as(:amd) >> amd_date? }
|
|
39
|
-
rule(:amd?) { amd.maybe }
|
|
40
|
-
|
|
41
|
-
rule(:sup) { space >> str("Suppl") >> dot? >> space >> num.repeat(1, 2).as(:suppl) }
|
|
42
|
-
rule(:sup?) { sup.maybe }
|
|
43
|
-
|
|
44
|
-
rule(:annex) { space >> str("Annex") >> space >> match["[:alnum:]"].repeat(1, 2).as(:annex) }
|
|
45
|
-
rule(:annex?) { annex.maybe }
|
|
46
|
-
|
|
47
|
-
rule(:ver) { space >> str("(V") >> num.repeat(1, 2).as(:version) >> str(")") }
|
|
48
|
-
rule(:ver?) { ver.maybe }
|
|
49
|
-
|
|
50
|
-
rule(:itu_pubid_sector) { prefix >> sector >> type? >> code >> sup? >> annex? >> ver? >> date? >> amd? >> any.repeat }
|
|
51
|
-
rule(:itu_pubid_no_sector) { prefix >> type? >> code >> sup? >> annex? >> ver? >> date? >> amd? >> any.repeat }
|
|
52
|
-
rule(:itu_pubid) { report? >> (itu_pubid_sector | itu_pubid_no_sector) }
|
|
53
|
-
root(:itu_pubid)
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
attr_accessor :prefix, :sector, :type, :code, :suppl, :annex, :version, :year, :month, :day, :amd, :amd_date
|
|
57
|
-
|
|
58
|
-
#
|
|
59
|
-
# Create a new ITU publication identifier.
|
|
60
|
-
#
|
|
61
|
-
# @param [String] prefix
|
|
62
|
-
# @param [String] code
|
|
63
|
-
#
|
|
64
|
-
def initialize(prefix:, code:, **args)
|
|
65
|
-
@prefix = prefix
|
|
66
|
-
@sector = args[:sector]
|
|
67
|
-
@type = args[:type]
|
|
68
|
-
@day = args[:day]
|
|
69
|
-
@code, year, month = date_from_code code
|
|
70
|
-
@suppl = args[:suppl]
|
|
71
|
-
@annex = args[:annex]
|
|
72
|
-
@version = args[:version]
|
|
73
|
-
@year = args[:year] || year
|
|
74
|
-
@month = roman_to_2digit args[:month] || month
|
|
75
|
-
@amd = args[:amd]
|
|
76
|
-
@amd_date = args[:amd_date]
|
|
77
|
-
end
|
|
78
|
-
|
|
79
|
-
def self.parse(id)
|
|
80
|
-
id_parts = Parser.new.parse(id).to_h.transform_values(&:to_s)
|
|
81
|
-
new(**id_parts)
|
|
82
|
-
rescue Parslet::ParseFailed => e
|
|
83
|
-
Util.error "`#{id}` is invalid ITU publication identifier\n" \
|
|
84
|
-
"#{e.parse_failure_cause.ascii_tree}"
|
|
85
|
-
# This grammar is local, so re-raise it as pubid's error: relaton-cli
|
|
86
|
-
# rescues `Pubid::Errors::Error`. `::` is needed, because inside this
|
|
87
|
-
# class a bare `Pubid` is `Relaton::Itu::Pubid`.
|
|
88
|
-
raise ::Pubid::Errors::ParseError.new(e.message, e.parse_failure_cause,
|
|
89
|
-
input: id, flavor: "itu")
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
def to_h(with_type: true) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
|
93
|
-
hash = { prefix: prefix, code: code }
|
|
94
|
-
hash[:sector] = sector if sector
|
|
95
|
-
hash[:type] = type if type && with_type
|
|
96
|
-
hash[:suppl] = suppl if suppl
|
|
97
|
-
hash[:annex] = annex if annex
|
|
98
|
-
hash[:version] = version if version
|
|
99
|
-
hash[:year] = year if year
|
|
100
|
-
hash[:month] = month if month
|
|
101
|
-
hash[:day] = day if day
|
|
102
|
-
hash[:amd] = amd if amd
|
|
103
|
-
hash[:amd_date] = amd_date if amd_date
|
|
104
|
-
hash
|
|
105
|
-
end
|
|
106
|
-
|
|
107
|
-
def to_ref
|
|
108
|
-
to_s ref: true
|
|
109
|
-
end
|
|
110
|
-
|
|
111
|
-
# @return [Boolean] whether this reference names an ITU-R Report rather
|
|
112
|
-
# than a Recommendation — the one type that must survive into #to_ref,
|
|
113
|
-
# because it is what tells the two apart (see the `report` parser rule).
|
|
114
|
-
def report?
|
|
115
|
-
%w[Report REP].include? type
|
|
116
|
-
end
|
|
117
|
-
|
|
118
|
-
def to_s(ref: false) # rubocop:disable Metrics/AbcSize
|
|
119
|
-
# "Report" leads, the way ITU cites it and the way Pubid::Itu parses it;
|
|
120
|
-
# `REC` stays dropped from a reference because it is redundant there.
|
|
121
|
-
s = report? ? +"Report " : +""
|
|
122
|
-
s << prefix
|
|
123
|
-
s << "-#{sector}" if sector
|
|
124
|
-
s << " #{type}" if type && !ref && !report?
|
|
125
|
-
s << " #{code}"
|
|
126
|
-
s << " Suppl. #{suppl}" if suppl
|
|
127
|
-
s << " Annex #{annex}" if annex
|
|
128
|
-
s << " (V#{version})" if version
|
|
129
|
-
s << date_to_s
|
|
130
|
-
s << " Amd #{amd}" if amd
|
|
131
|
-
s << " (#{amd_date})" if amd_date
|
|
132
|
-
s
|
|
133
|
-
end
|
|
134
|
-
|
|
135
|
-
def ===(other, ignore_args = [])
|
|
136
|
-
hash = to_h with_type: false
|
|
137
|
-
other_hash = other.to_h with_type: false
|
|
138
|
-
hash.delete(:version) if ignore_args.include?(:version)
|
|
139
|
-
other_hash.delete(:version) unless hash[:version]
|
|
140
|
-
hash.delete(:day)
|
|
141
|
-
other_hash.delete(:day)
|
|
142
|
-
hash.delete(:month)
|
|
143
|
-
other_hash.delete(:month)
|
|
144
|
-
hash.delete(:year) if ignore_args.include?(:year)
|
|
145
|
-
other_hash.delete(:year) unless hash[:year]
|
|
146
|
-
hash.delete(:amd_date) if ignore_args.include?(:amd_date)
|
|
147
|
-
other_hash.delete(:amd_date) unless hash[:amd_date]
|
|
148
|
-
hash == other_hash
|
|
149
|
-
end
|
|
150
|
-
|
|
151
|
-
private
|
|
152
|
-
|
|
153
|
-
def date_from_code(code)
|
|
154
|
-
/(?<cod>.+?)-(?<date>\d{6})(?:-I|$)/ =~ code
|
|
155
|
-
return [code, nil, nil] unless cod && date
|
|
156
|
-
|
|
157
|
-
[cod, date[0..3], date[4..5]]
|
|
158
|
-
end
|
|
159
|
-
|
|
160
|
-
def roman_to_2digit(num) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
|
161
|
-
return unless num
|
|
162
|
-
|
|
163
|
-
roman_nums = { "I" => 1, "V" => 5, "X" => 10 }
|
|
164
|
-
last = roman_nums[num[-1]]
|
|
165
|
-
return num unless last
|
|
166
|
-
|
|
167
|
-
return roman_nums[num].to_s.rjust(2, "0") if num.size == 1
|
|
168
|
-
|
|
169
|
-
num.chars.each_cons(2).reduce(last) do |acc, (a, b)|
|
|
170
|
-
if roman_nums[a] < roman_nums[b]
|
|
171
|
-
acc - roman_nums[a]
|
|
172
|
-
else
|
|
173
|
-
acc + roman_nums[a]
|
|
174
|
-
end
|
|
175
|
-
end.to_s.rjust(2, "0")
|
|
176
|
-
end
|
|
177
|
-
|
|
178
|
-
def month_to_roman
|
|
179
|
-
int = month.to_i
|
|
180
|
-
return month unless int.between? 1, 12
|
|
181
|
-
|
|
182
|
-
roman_tens = ["", "X"]
|
|
183
|
-
roman_units = ["", "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX"]
|
|
184
|
-
|
|
185
|
-
tens = int / 10
|
|
186
|
-
units = int % 10
|
|
187
|
-
|
|
188
|
-
roman_tens[tens] + roman_units[units]
|
|
189
|
-
end
|
|
190
|
-
|
|
191
|
-
def date_to_s
|
|
192
|
-
if month && year then " (#{month}/#{year})"
|
|
193
|
-
elsif year then " (#{year})"
|
|
194
|
-
else ""
|
|
195
|
-
end
|
|
196
|
-
end
|
|
197
|
-
end
|
|
198
|
-
end
|
|
199
|
-
end
|