relaton-un 1.3.0 → 1.4.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: 613a9a82547cda0760295b57949e565c868f3fd2b660a7f7d813ba6e224a00b8
4
- data.tar.gz: 5aa7797780314ab7887b540fb84105a0dccab4a36f1c5fabcf5f814e70d4b2e8
3
+ metadata.gz: 0725035a19dd3a50cf7c3cb122ff4af562adeba0c01447c7a41b8ea4aacd67f1
4
+ data.tar.gz: cd28290c02918a2f7754d453eb3f9977c311b354adb8fd55718c7bf2446909a0
5
5
  SHA512:
6
- metadata.gz: 4bf072e67d014ac53bc8a95650a87fcd079420cf93fe2b47ab051a6c41b406b5e75d45127b5d6ba8bab3a6c9279604aee9a059b620c4bc167659f19eb502fcbf
7
- data.tar.gz: 8d17af6fa62c494921521a3a4ce417f0fd604ce560949a587d1b37db1230d8a889cfdb831fcd0cef78bdbc676b594680abc51a75e06f67befb464b81756c1d8e
6
+ metadata.gz: dd656a5b34cadb82262c017c38e5ed7738abc3e76af883b3921b21fda57c0163153e8120bfbadebdfe541bf00b67646bb61f5304a529f4be09f0240a2036532b
7
+ data.tar.gz: 5b8f6f49eb1af0ce6d6ecf2c9aeed3173743a093b9319b68dcb5290e0e33a1b90f83c41c690c9255909cf29ec519a347cc0e0f3e735041bc0f3cc87a3de07921
@@ -25,9 +25,10 @@ Or install it yourself as:
25
25
 
26
26
  === Search for a standard using keywords
27
27
 
28
- [source]
28
+ [source,ruby]
29
29
  ----
30
30
  require 'relaton_un'
31
+ => true
31
32
 
32
33
  hits = RelatonUn::UnBibliography.search("TRADE/CEFACT/2004/32")
33
34
  => <RelatonUn::HitCollection:0x007fc4e6ec2018 @ref=TRADE/CEFACT/2004/32 @fetched=false>
@@ -39,23 +40,23 @@ item = hits[0].fetch
39
40
 
40
41
  === XML serialization
41
42
 
42
- [source]
43
+ [source,ruby]
43
44
  ----
44
45
  item.to_xml
45
- => '<bibitem id="TRADE/CEFACT/2004/32">
46
+ => "<bibitem id="TRADE/CEFACT/2004/32" type="standard">
46
47
  <title type="main" format="text/plain" language="en" script="Latn">SECRETARIAT REVIEW OF UN/LOCODE, 19 DECEMBER 2003 / SUBMITTED BY THE SECRETARIAT</title>
47
48
  <uri type="pdf">https://documents-dds-ny.un.org/doc/UNDOC/GEN/G04/306/83/pdf/G0430683.pdf?OpenElement</uri>
48
49
  <uri type="word">https://documents-dds-ny.un.org/doc/UNDOC/GEN/G04/306/83/doc/G0430683.DOC?OpenElement</uri>
49
50
  <docidentifier type="UN">TRADE/CEFACT/2004/32</docidentifier>
50
51
  <docnumber>TRADE/CEFACT/2004/32</docnumber>
51
52
  ...
52
- </bibitem>'
53
+ </bibitem>"
53
54
  ----
54
55
  With argument `bibdata: true` it ouputs XML wrapped by `bibdata` element and adds flavour `ext` element.
55
- [source]
56
+ [source,ruby]
56
57
  ----
57
58
  item.to_xml bibdata: true
58
- => '<bibdata type="standard">
59
+ => "<bibdata type="standard">
59
60
  <fetched>2020-03-13</fetched>
60
61
  <title type="main" format="text/plain" language="en" script="Latn">SECRETARIAT REVIEW OF UN/LOCODE, 19 DECEMBER 2003 / SUBMITTED BY THE SECRETARIAT</title>
61
62
  <uri type="pdf">https://documents-dds-ny.un.org/doc/UNDOC/GEN/G04/306/83/pdf/G0430683.pdf?OpenElement</uri>
@@ -63,11 +64,23 @@ item.to_xml bibdata: true
63
64
  <docidentifier type="UN">TRADE/CEFACT/2004/32</docidentifier>
64
65
  <docnumber>TRADE/CEFACT/2004/32</docnumber>
65
66
  ...
66
- </bibdata>'
67
+ <ext>
68
+ <editorialgroup>
69
+ <committee>Committee on Trade</committee>
70
+ <committee>Centre for Trade Facilitation and Electronic Business</committee>
71
+ </editorialgroup>
72
+ <distribution>general</distribution>
73
+ <session>
74
+ <number>10</number>
75
+ <agenda-id>12</agenda-id>
76
+ </session>
77
+ <job_number>G0430683</job_number>
78
+ </ext>
79
+ </bibdata>"
67
80
  ----
68
81
 
69
82
  === Get code, and year
70
- [source]
83
+ [source,ruby]
71
84
  ----
72
85
  RelatonUn::UnBibliography.get "UN TRADE/CEFACT/2004/32"
73
86
  [relaton-un] ("UN TRADE/CEFACT/2004/32") fetching...
@@ -77,7 +90,7 @@ RelatonUn::UnBibliography.get "UN TRADE/CEFACT/2004/32"
77
90
  ----
78
91
 
79
92
  === Create bibliographic item from XML
80
- [source]
93
+ [source,ruby]
81
94
  ----
82
95
  RelatonUn::XMLParser.from_xml File.read('spec/fixtures/un_bib.xml')
83
96
  => #<RelatonUn::UnBibliographicItem:0x007fdc5e7ab678
@@ -85,7 +98,7 @@ RelatonUn::XMLParser.from_xml File.read('spec/fixtures/un_bib.xml')
85
98
  ----
86
99
 
87
100
  === Create bibliographic item from YAML
88
- [source]
101
+ [source,ruby]
89
102
  ----
90
103
  hash = YAML.load_file 'spec/fixtures/un_bib.yaml'
91
104
  => {"id"=>"TRADE/CEFACT/2004/32",
@@ -42,8 +42,11 @@
42
42
  </define>
43
43
  <define name="xref">
44
44
  <element name="xref">
45
+ <!-- attribute target { xsd:IDREF }, -->
45
46
  <attribute name="target">
46
- <data type="IDREF"/>
47
+ <data type="string">
48
+ <param name="pattern">\i\c*|\c+#\c+</param>
49
+ </data>
47
50
  </attribute>
48
51
  <optional>
49
52
  <attribute name="type">
@@ -61,6 +64,11 @@
61
64
  </choice>
62
65
  </attribute>
63
66
  </optional>
67
+ <optional>
68
+ <attribute name="droploc">
69
+ <data type="boolean"/>
70
+ </attribute>
71
+ </optional>
64
72
  <text/>
65
73
  </element>
66
74
  </define>
@@ -578,6 +586,8 @@
578
586
  <ref name="ol"/>
579
587
  <ref name="dl"/>
580
588
  <ref name="formula"/>
589
+ <ref name="quote"/>
590
+ <ref name="sourcecode"/>
581
591
  </choice>
582
592
  </oneOrMore>
583
593
  </element>
@@ -661,6 +671,16 @@
661
671
  </choice>
662
672
  </attribute>
663
673
  </optional>
674
+ <optional>
675
+ <attribute name="valign">
676
+ <choice>
677
+ <value>top</value>
678
+ <value>middle</value>
679
+ <value>bottom</value>
680
+ <value>baseline</value>
681
+ </choice>
682
+ </attribute>
683
+ </optional>
664
684
  <choice>
665
685
  <zeroOrMore>
666
686
  <choice>
@@ -697,6 +717,16 @@
697
717
  </choice>
698
718
  </attribute>
699
719
  </optional>
720
+ <optional>
721
+ <attribute name="valign">
722
+ <choice>
723
+ <value>top</value>
724
+ <value>middle</value>
725
+ <value>bottom</value>
726
+ <value>baseline</value>
727
+ </choice>
728
+ </attribute>
729
+ </optional>
700
730
  <choice>
701
731
  <zeroOrMore>
702
732
  <choice>
@@ -855,7 +885,7 @@
855
885
  <oneOrMore>
856
886
  <choice>
857
887
  <ref name="content"/>
858
- <ref name="preface_abstract"/>
888
+ <ref name="abstract"/>
859
889
  <ref name="foreword"/>
860
890
  <ref name="introduction"/>
861
891
  <ref name="acknowledgements"/>
@@ -922,6 +952,9 @@
922
952
  <optional>
923
953
  <attribute name="script"/>
924
954
  </optional>
955
+ <optional>
956
+ <attribute name="type"/>
957
+ </optional>
925
958
  <optional>
926
959
  <attribute name="obligation">
927
960
  <choice>
@@ -961,9 +994,6 @@
961
994
  </define>
962
995
  <define name="content-subsection">
963
996
  <element name="clause">
964
- <optional>
965
- <attribute name="type"/>
966
- </optional>
967
997
  <ref name="Content-Section"/>
968
998
  </element>
969
999
  </define>
@@ -992,6 +1022,9 @@
992
1022
  </choice>
993
1023
  </attribute>
994
1024
  </optional>
1025
+ <optional>
1026
+ <attribute name="type"/>
1027
+ </optional>
995
1028
  <optional>
996
1029
  <ref name="section-title"/>
997
1030
  </optional>
@@ -1011,9 +1044,6 @@
1011
1044
  </define>
1012
1045
  <define name="clause">
1013
1046
  <element name="clause">
1014
- <optional>
1015
- <attribute name="type"/>
1016
- </optional>
1017
1047
  <ref name="Clause-Section"/>
1018
1048
  </element>
1019
1049
  </define>
@@ -1042,18 +1072,24 @@
1042
1072
  </choice>
1043
1073
  </attribute>
1044
1074
  </optional>
1075
+ <optional>
1076
+ <attribute name="type"/>
1077
+ </optional>
1045
1078
  <optional>
1046
1079
  <ref name="section-title"/>
1047
1080
  </optional>
1048
1081
  <group>
1049
- <group>
1050
- <zeroOrMore>
1051
- <ref name="BasicBlock"/>
1052
- </zeroOrMore>
1053
- <zeroOrMore>
1054
- <ref name="note"/>
1055
- </zeroOrMore>
1056
- </group>
1082
+ <choice>
1083
+ <group>
1084
+ <zeroOrMore>
1085
+ <ref name="BasicBlock"/>
1086
+ </zeroOrMore>
1087
+ <zeroOrMore>
1088
+ <ref name="note"/>
1089
+ </zeroOrMore>
1090
+ </group>
1091
+ <ref name="amend"/>
1092
+ </choice>
1057
1093
  <zeroOrMore>
1058
1094
  <choice>
1059
1095
  <ref name="clause-subsection"/>
@@ -1180,6 +1216,9 @@
1180
1216
  <optional>
1181
1217
  <attribute name="script"/>
1182
1218
  </optional>
1219
+ <optional>
1220
+ <attribute name="type"/>
1221
+ </optional>
1183
1222
  <optional>
1184
1223
  <attribute name="obligation">
1185
1224
  <choice>
@@ -1447,11 +1486,6 @@
1447
1486
  </optional>
1448
1487
  </element>
1449
1488
  </define>
1450
- <define name="preface_abstract">
1451
- <element name="abstract">
1452
- <ref name="Basic-Section"/>
1453
- </element>
1454
- </define>
1455
1489
  <define name="term-clause">
1456
1490
  <element name="clause">
1457
1491
  <optional>
@@ -1501,4 +1535,79 @@
1501
1535
  <ref name="CitationType"/>
1502
1536
  </element>
1503
1537
  </define>
1538
+ <define name="amend">
1539
+ <element name="amend">
1540
+ <optional>
1541
+ <attribute name="id">
1542
+ <data type="ID"/>
1543
+ </attribute>
1544
+ </optional>
1545
+ <attribute name="change">
1546
+ <choice>
1547
+ <value>add</value>
1548
+ <value>modify</value>
1549
+ <value>delete</value>
1550
+ </choice>
1551
+ </attribute>
1552
+ <optional>
1553
+ <attribute name="path"/>
1554
+ </optional>
1555
+ <optional>
1556
+ <attribute name="path_end"/>
1557
+ </optional>
1558
+ <optional>
1559
+ <attribute name="title"/>
1560
+ </optional>
1561
+ <optional>
1562
+ <element name="location">
1563
+ <zeroOrMore>
1564
+ <ref name="locality"/>
1565
+ </zeroOrMore>
1566
+ </element>
1567
+ </optional>
1568
+ <zeroOrMore>
1569
+ <ref name="autonumber"/>
1570
+ </zeroOrMore>
1571
+ <optional>
1572
+ <element name="description">
1573
+ <zeroOrMore>
1574
+ <ref name="BasicBlock"/>
1575
+ </zeroOrMore>
1576
+ </element>
1577
+ </optional>
1578
+ <optional>
1579
+ <element name="newcontent">
1580
+ <zeroOrMore>
1581
+ <ref name="BasicBlock"/>
1582
+ </zeroOrMore>
1583
+ </element>
1584
+ </optional>
1585
+ <optional>
1586
+ <element name="description">
1587
+ <zeroOrMore>
1588
+ <ref name="BasicBlock"/>
1589
+ </zeroOrMore>
1590
+ </element>
1591
+ </optional>
1592
+ </element>
1593
+ </define>
1594
+ <define name="autonumber">
1595
+ <element name="autonumber">
1596
+ <attribute name="type">
1597
+ <choice>
1598
+ <value>requirement</value>
1599
+ <value>recommendation</value>
1600
+ <value>permission</value>
1601
+ <value>table</value>
1602
+ <value>figure</value>
1603
+ <value>admonition</value>
1604
+ <value>formula</value>
1605
+ <value>sourcecode</value>
1606
+ <value>example</value>
1607
+ <value>note</value>
1608
+ </choice>
1609
+ </attribute>
1610
+ <text/>
1611
+ </element>
1612
+ </define>
1504
1613
  </grammar>
@@ -10,6 +10,11 @@ module RelatonUn
10
10
  @committee = committee
11
11
  end
12
12
 
13
+ # @return [true]
14
+ def presence?
15
+ true
16
+ end
17
+
13
18
  # @param builder [Nokogiri::XML::Builder]
14
19
  def to_xml(builder)
15
20
  builder.editorialgroup do |b|
@@ -6,18 +6,23 @@ 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_3) "\
10
- "AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36"
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"
11
11
  DOMAIN = "https://documents.un.org"
12
- BOUNDARY = "----WebKitFormBoundary6hkaBvITDck8dHCn"
12
+ BOUNDARY = "----WebKitFormBoundaryVarT9Z7AFUzw2lma"
13
13
 
14
14
  # @param text [String] reference to search
15
15
  def initialize(text)
16
16
  super
17
17
  @uri = URI.parse DOMAIN
18
18
  @jar = HTTP::CookieJar.new
19
- @http = Net::HTTP.new @uri.host, @uri.port
19
+ @http = Net::HTTP.new @uri.host, @uri.port # , "localhost", "8000"
20
20
  @http.use_ssl = true
21
+ # @http.verify_mode = OpenSSL::SSL::VERIFY_PEER
22
+ # @http.cert_store = OpenSSL::X509::Store.new
23
+ # ca_file = "/Users/andrej/Library/Preferences/httptoolkit/ca.pem"
24
+ # @http.cert_store.set_default_paths
25
+ # @http.cert_store.add_file ca_file
21
26
  @http.read_timeout = 120
22
27
  if (form_resp = get_page)
23
28
  doc = Nokogiri::HTML page_resp(form_resp, text).body
@@ -50,17 +55,19 @@ module RelatonUn
50
55
  # @return [Array<String>]
51
56
  def form_data(form, text) # rubocop:disable Metrics/CyclomaticComplexity
52
57
  fd = form.xpath(
53
- "//input[@type!='radio']",
54
- "//input[@type='radio'][@checked]",
55
- "//select[@name!='view:_id1:_id2:cbLang']",
58
+ "//input[@type!='radio']|"\
59
+ "//input[@type='radio'][@checked]|"\
60
+ "//select[@name!='view:_id1:_id2:cbLang']|"\
56
61
  "//textarea"
57
62
  ).reduce([]) do |m, i|
58
63
  v = case i[:name]
59
64
  when "view:_id1:_id2:txtSymbol" then text
65
+ when "view:_id1:_id2:rgTrunc" then "R"
60
66
  when "view:_id1:_id2:cbType" then "FP"
61
67
  when "view:_id1:_id2:cbSort" then "R"
62
68
  when "$$xspsubmitid" then "view:_id1:_id2:_id130"
63
- when "$$xspsubmitscroll" then "0|167"
69
+ when "$$xspsubmitscroll" then "0|102"
70
+ when "view:_id1" then "view:_id1"
64
71
  else i[:value]
65
72
  end
66
73
  m << %{--#{BOUNDARY}}
@@ -77,7 +84,7 @@ module RelatonUn
77
84
  form = Nokogiri::HTML form_resp.body
78
85
  req = Net::HTTP::Post.new form.at("//form")[:action]
79
86
  set_headers req
80
- req["Content-Type"] = "multipart/form-data, boundary=#{BOUNDARY}"
87
+ req["Content-Type"] = "multipart/form-data; boundary=#{BOUNDARY}"
81
88
  req.body = form_data(form, text).join("\r\n")
82
89
  resp = @http.request req
83
90
  get_page URI.parse(resp["location"]).request_uri
@@ -163,15 +170,18 @@ module RelatonUn
163
170
  # rubocop:disable Metrics/MethodLength
164
171
 
165
172
  # @param req [Net::HTTP::Get, Net::HTTP::Post]
166
- def set_headers(req)
173
+ def set_headers(req) # rubocop:disable Metrics/AbcSize
167
174
  set_cookie req
168
175
  req["Accept"] = "text/html,application/xhtml+xml,application/xml;q=0.9,"\
169
- "image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9"
176
+ "image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;"\
177
+ "v=b3;q=0.9"
170
178
  req["Accept-Encoding"] = "gzip, deflate, br"
179
+ req["Accept-Language"] = "en-US;q=0.8,en;q=0.7"
171
180
  req["Cache-Control"] = "max-age=0"
172
181
  req["Connection"] = "keep-alive"
173
182
  req["Origin"] = "https://documents.un.org"
174
183
  req["Referer"] = "https://documents.un.org/prod/ods.nsf/home.xsp"
184
+ req["Sec-Fetch-Dest"] = "document"
175
185
  req["Sec-Fetch-Mode"] = "navigate"
176
186
  req["Sec-Fetch-Site"] = "same-origin"
177
187
  req["Sec-Fetch-User"] = "?1"
@@ -1,3 +1,3 @@
1
1
  module RelatonUn
2
- VERSION = "1.3.0".freeze
2
+ VERSION = "1.4.0".freeze
3
3
  end
@@ -43,7 +43,7 @@ Gem::Specification.new do |spec|
43
43
 
44
44
  spec.add_dependency "faraday"
45
45
  spec.add_dependency "http-cookie"
46
- spec.add_dependency "relaton-bib", "~> 1.3.0"
46
+ spec.add_dependency "relaton-bib", "~> 1.4.0"
47
47
  spec.add_dependency "unf_ext", ">= 0.0.7.7"
48
48
  end
49
49
  # 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.3.0
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-08-21 00:00:00.000000000 Z
11
+ date: 2020-09-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: debase
@@ -156,14 +156,14 @@ dependencies:
156
156
  requirements:
157
157
  - - "~>"
158
158
  - !ruby/object:Gem::Version
159
- version: 1.3.0
159
+ version: 1.4.0
160
160
  type: :runtime
161
161
  prerelease: false
162
162
  version_requirements: !ruby/object:Gem::Requirement
163
163
  requirements:
164
164
  - - "~>"
165
165
  - !ruby/object:Gem::Version
166
- version: 1.3.0
166
+ version: 1.4.0
167
167
  - !ruby/object:Gem::Dependency
168
168
  name: unf_ext
169
169
  requirement: !ruby/object:Gem::Requirement
@@ -223,7 +223,7 @@ licenses:
223
223
  metadata:
224
224
  homepage_uri: https://github.com/relaton/relaton-un
225
225
  source_code_uri: https://github.com/relaton/relaton-un
226
- post_install_message:
226
+ post_install_message:
227
227
  rdoc_options: []
228
228
  require_paths:
229
229
  - lib
@@ -239,7 +239,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
239
239
  version: '0'
240
240
  requirements: []
241
241
  rubygems_version: 3.0.6
242
- signing_key:
242
+ signing_key:
243
243
  specification_version: 4
244
244
  summary: 'RelatonIso: retrieve CC Standards for bibliographic use using the IsoBibliographicItem
245
245
  model'