relaton-un 1.16.1 → 1.17.0

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: 8f1fa9196d2c00a4740b08e4ed793b3f0073defdfe9efde37f609aa3ae8755e8
4
- data.tar.gz: 97752fd7f24738baa8fe97de080c141dba11eab434697cbd04eca1dd158af5f6
3
+ metadata.gz: ce8d84211462e89a7e3fa8209cc642b62bc91ce3d59a137eb038c9e974b3e5c6
4
+ data.tar.gz: d1f53b8c63ffd65e91b85b26967b709b962cf5f1e69ac5e94143e3ac1029b9e1
5
5
  SHA512:
6
- metadata.gz: 5af293100d6b96a28da1b8c56e5f404f282bfcf06ea77408f3297b7a65d5a24375a2da5350f5e2fad4a75262d491e51eb334223f0ca5a90ecca2851d3bd1634b
7
- data.tar.gz: 2eb898c7ec22ee17ba302a7bdfb2d167466b1e0500b04048ab0be68f8ec118006f8d18a7af2596c5bf65573674b525516319f1a5bc1bd9a34b89e5b490b40a5a
6
+ metadata.gz: 8ffd4b9333da7e1ea09bb218fd20258126a77f571c48a800700cd72dd05d5b305dd36a676fefa927f175214b76e48e8ba45e2a87851d5e47a2202d9fad4450a3
7
+ data.tar.gz: 97053ef71c9b3b2a6728dec4402cb8ef181c9095687c3bf57676c8fc3f4e0d50b73956d5ad6606a0f511c8c3d4d183f50677ffe87a09a87d6354dd513f33594d
data/README.adoc CHANGED
@@ -23,13 +23,24 @@ Or install it yourself as:
23
23
 
24
24
  == Usage
25
25
 
26
- === Search for a standard using keywords
26
+ === Configuration
27
+
28
+ Configuration is optional. The available option is `logger` which is a `Logger` instance. By default, the logger is `Logger.new($stderr)` with `Logger::WARN` level. To change the logger level, use `RelatonUn.configure` block.
27
29
 
28
30
  [source,ruby]
29
31
  ----
30
32
  require 'relaton_un'
31
33
  => true
32
34
 
35
+ RelatonUn.configure do |config|
36
+ config.logger.level = Logger::DEBUG
37
+ end
38
+ ----
39
+
40
+ === Search for a standard using keywords
41
+
42
+ [source,ruby]
43
+ ----
33
44
  hits = RelatonUn::UnBibliography.search("TRADE/CEFACT/2004/32")
34
45
  => <RelatonUn::HitCollection:0x007fc4e6ec2018 @ref=TRADE/CEFACT/2004/32 @fetched=false>
35
46
 
@@ -69,8 +80,8 @@ item.to_xml bibdata: true
69
80
  [source,ruby]
70
81
  ----
71
82
  RelatonUn::UnBibliography.get "UN TRADE/CEFACT/2004/32"
72
- [relaton-un] ("UN TRADE/CEFACT/2004/32") fetching...
73
- [relaton-un] ("UN TRADE/CEFACT/2004/32") found TRADE/CEFACT/2004/32
83
+ [relaton-un] (UN TRADE/CEFACT/2004/32) Fetching from documents.un.org ...
84
+ [relaton-un] (UN TRADE/CEFACT/2004/32) Found: `TRADE/CEFACT/2004/32`
74
85
  => #<RelatonUn::UnBibliographicItem:0x007fdc5f1c3a20
75
86
  ...
76
87
  ----
@@ -346,6 +346,8 @@
346
346
  <ref name="keyword"/>
347
347
  <ref name="xref"/>
348
348
  <ref name="hyperlink"/>
349
+ <ref name="index"/>
350
+ <ref name="index-xref"/>
349
351
  </choice>
350
352
  </oneOrMore>
351
353
  </element>
@@ -623,6 +625,8 @@
623
625
  <ref name="eref"/>
624
626
  <ref name="xref"/>
625
627
  <ref name="hyperlink"/>
628
+ <ref name="index"/>
629
+ <ref name="index-xref"/>
626
630
  </choice>
627
631
  </zeroOrMore>
628
632
  </element>
@@ -636,6 +640,8 @@
636
640
  <ref name="eref"/>
637
641
  <ref name="xref"/>
638
642
  <ref name="hyperlink"/>
643
+ <ref name="index"/>
644
+ <ref name="index-xref"/>
639
645
  </choice>
640
646
  </zeroOrMore>
641
647
  </element>
@@ -648,6 +654,8 @@
648
654
  <ref name="eref"/>
649
655
  <ref name="xref"/>
650
656
  <ref name="hyperlink"/>
657
+ <ref name="index"/>
658
+ <ref name="index-xref"/>
651
659
  </choice>
652
660
  </zeroOrMore>
653
661
  </element>
@@ -655,7 +663,11 @@
655
663
  <define name="keyword">
656
664
  <element name="keyword">
657
665
  <zeroOrMore>
658
- <ref name="PureTextElement"/>
666
+ <choice>
667
+ <ref name="PureTextElement"/>
668
+ <ref name="index"/>
669
+ <ref name="index-xref"/>
670
+ </choice>
659
671
  </zeroOrMore>
660
672
  </element>
661
673
  </define>
@@ -676,7 +688,11 @@
676
688
  <define name="strike">
677
689
  <element name="strike">
678
690
  <zeroOrMore>
679
- <ref name="PureTextElement"/>
691
+ <choice>
692
+ <ref name="PureTextElement"/>
693
+ <ref name="index"/>
694
+ <ref name="index-xref"/>
695
+ </choice>
680
696
  </zeroOrMore>
681
697
  </element>
682
698
  </define>
data/grammars/biblio.rng CHANGED
@@ -942,6 +942,7 @@
942
942
  <value>obsoleted</value>
943
943
  <value>confirmed</value>
944
944
  <value>updated</value>
945
+ <value>corrected</value>
945
946
  <value>issued</value>
946
947
  <value>transmitted</value>
947
948
  <value>copied</value>
@@ -0,0 +1,19 @@
1
+ module RelatonUn
2
+ class DocumentType < RelatonBib::DocumentType
3
+ DOCTYPES = %w[
4
+ recommendation plenary addendum communication corrigendum reissue agenda
5
+ budgetary sec-gen-notes expert-report resolution
6
+ ].freeze
7
+
8
+ def initialize(type:, abbreviation: nil)
9
+ check_type type
10
+ super
11
+ end
12
+
13
+ def check_type(type)
14
+ unless DOCTYPES.include? type
15
+ Util.warn "WARNING: invalid doctype: `#{type}`"
16
+ end
17
+ end
18
+ end
19
+ end
@@ -1,34 +1,38 @@
1
1
  module RelatonUn
2
- class HashConverter < RelatonBib::HashConverter
3
- class << self
4
- # @override RelatonIsoBib::HashConverter.hash_to_bib
5
- # @param args [Hash]
6
- # @param nested [TrueClass, FalseClass]
7
- # @return [Hash]
8
- def hash_to_bib(args)
9
- ret = super
10
- return if ret.nil?
2
+ module HashConverter
3
+ include RelatonBib::HashConverter
4
+ extend self
5
+ # @override RelatonIsoBib::HashConverter.hash_to_bib
6
+ # @param args [Hash]
7
+ # @param nested [TrueClass, FalseClass]
8
+ # @return [Hash]
9
+ def hash_to_bib(args)
10
+ ret = super
11
+ return if ret.nil?
11
12
 
12
- ret[:submissionlanguage] = RelatonBib.array ret[:submissionlanguage]
13
- session_hash_to_bib ret
14
- ret
15
- end
13
+ ret[:submissionlanguage] = RelatonBib.array ret[:submissionlanguage]
14
+ session_hash_to_bib ret
15
+ ret
16
+ end
17
+
18
+ private
16
19
 
17
- private
20
+ # @param ret [Hash]
21
+ def session_hash_to_bib(ret)
22
+ ret[:session] = Session.new(**ret[:session]) if ret[:session]
23
+ end
18
24
 
19
- # @param ret [Hash]
20
- def session_hash_to_bib(ret)
21
- ret[:session] = Session.new(**ret[:session]) if ret[:session]
22
- end
25
+ # @param ret [Hash]
26
+ def editorialgroup_hash_to_bib(ret)
27
+ eg = ret[:editorialgroup]
28
+ return unless eg
23
29
 
24
- # @param ret [Hash]
25
- def editorialgroup_hash_to_bib(ret)
26
- eg = ret[:editorialgroup]
27
- return unless eg
30
+ committee = eg.map { |e| e[:committee] }
31
+ ret[:editorialgroup] = EditorialGroup.new RelatonBib.array(committee)
32
+ end
28
33
 
29
- committee = eg.map { |e| e[:committee] }
30
- ret[:editorialgroup] = EditorialGroup.new RelatonBib.array(committee)
31
- end
34
+ def create_doctype(**args)
35
+ DocumentType.new(**args)
32
36
  end
33
37
  end
34
38
  end
@@ -6,13 +6,13 @@ require "http-cookie"
6
6
  module RelatonUn
7
7
  # Page of hit collection.
8
8
  class HitCollection < RelatonBib::HitCollection
9
- AGENT = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_5) "\
10
- "AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.102 Safari/537.36"
9
+ AGENT = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_5) AppleWebKit/537.36 " \
10
+ "(KHTML, like Gecko) Chrome/85.0.4183.102 Safari/537.36"
11
11
  DOMAIN = "https://documents.un.org"
12
12
  BOUNDARY = "----WebKitFormBoundaryVarT9Z7AFUzw2lma"
13
13
 
14
14
  # @param text [String] reference to search
15
- def initialize(text) # rubocop:disable Metrics/AbcSize
15
+ def initialize(text) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
16
16
  super
17
17
  @uri = URI.parse DOMAIN
18
18
  @jar = HTTP::CookieJar.new
@@ -2,11 +2,6 @@ module RelatonUn
2
2
  class UnBibliographicItem < RelatonBib::BibliographicItem
3
3
  include RelatonBib
4
4
 
5
- TYPES = %w[
6
- recommendation plenary addendum communication corrigendum reissue agenda
7
- budgetary sec-gen-notes expert-report resolution
8
- ].freeze
9
-
10
5
  DISTRIBUTIONS = { "GEN" => "general", "LTD" => "limited",
11
6
  "DER" => "restricted", "PRO" => "provisional" }.freeze
12
7
 
@@ -24,7 +19,7 @@ module RelatonUn
24
19
  # @param job_number [String, nil]
25
20
  def initialize(**args)
26
21
  if args[:distribution] && !DISTRIBUTIONS.has_value?(args[:distribution])
27
- Util.warn "WARNING: invalid distribution: `#{args[:distribution]}`"
22
+ Util.warn "WARNING: Invalid distribution: `#{args[:distribution]}`"
28
23
  end
29
24
  @submissionlanguage = args.delete :submissionlanguage
30
25
  @distribution = args.delete :distribution
@@ -50,7 +45,7 @@ module RelatonUn
50
45
  def to_xml(**opts) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity
51
46
  super(**opts) do |b|
52
47
  ext = b.ext do
53
- b.doctype doctype if doctype
48
+ doctype&.to_xml b
54
49
  submissionlanguage&.each { |sl| b.submissionlanguage sl }
55
50
  editorialgroup&.to_xml b
56
51
  ics&.each { |i| i.to_xml b }
@@ -21,14 +21,14 @@ module RelatonUn
21
21
  # @param opts [Hash] options
22
22
  # @return [RelatonUn::UnBibliographicItem]
23
23
  def get(ref, _year = nil, _opts = {})
24
- Util.warn "(#{ref}) fetching..."
24
+ Util.warn "(#{ref}) Fetching from documents.un.org ..."
25
25
  /^(?:UN\s)?(?<code>.*)/ =~ ref
26
26
  result = isobib_search_filter(code)
27
27
  if result
28
- Util.warn "(#{ref}) found `#{result.fetch.docidentifier[0].id}`"
28
+ Util.warn "(#{ref}) Found: `#{result.fetch.docidentifier[0].id}`"
29
29
  result.fetch
30
30
  else
31
- Util.warn "(#{ref}) nothing found"
31
+ Util.warn "(#{ref}) Not found."
32
32
  nil
33
33
  end
34
34
  end
@@ -1,3 +1,3 @@
1
1
  module RelatonUn
2
- VERSION = "1.16.1".freeze
2
+ VERSION = "1.17.0".freeze
3
3
  end
data/lib/relaton_un.rb CHANGED
@@ -3,6 +3,7 @@ require "relaton_bib"
3
3
  require "relaton_un/version"
4
4
  require "relaton_un/config"
5
5
  require "relaton_un/util"
6
+ require "relaton_un/document_type"
6
7
  require "relaton_un/un_bibliographic_item"
7
8
  require "relaton_un/un_bibliography"
8
9
  require "relaton_un/hit_collection"
data/relaton_un.gemspec CHANGED
@@ -35,7 +35,7 @@ Gem::Specification.new do |spec|
35
35
  spec.add_dependency "addressable", "~> 2.8.0"
36
36
  spec.add_dependency "faraday", "~> 2.7.0"
37
37
  spec.add_dependency "http-cookie", "~> 1.0.5"
38
- spec.add_dependency "relaton-bib", "~> 1.16.0"
38
+ spec.add_dependency "relaton-bib", "~> 1.17.0"
39
39
  spec.add_dependency "unf_ext", ">= 0.0.7.7"
40
40
  end
41
41
  # rubocop:enable Metrics/BlockLength
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: relaton-un
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.16.1
4
+ version: 1.17.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-09-22 00:00:00.000000000 Z
11
+ date: 2023-11-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 1.16.0
61
+ version: 1.17.0
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 1.16.0
68
+ version: 1.17.0
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: unf_ext
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -107,6 +107,7 @@ files:
107
107
  - grammars/relaton-un.rng
108
108
  - lib/relaton_un.rb
109
109
  - lib/relaton_un/config.rb
110
+ - lib/relaton_un/document_type.rb
110
111
  - lib/relaton_un/editorialgroup.rb
111
112
  - lib/relaton_un/hash_converter.rb
112
113
  - lib/relaton_un/hit.rb