relaton-nist 1.3.0 → 1.5.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: dac2975c8efc8f3fb1fe8720fb852daba9bd66fb0e7bfc5fd87e24b69ed08ff1
4
- data.tar.gz: 84503272191f86d904c947bbe6143c4363bc5fe03d0bb4f40b56162ef45f6c7d
3
+ metadata.gz: e04045cea97147ffffc8bab0c35810ce34a788483994aab230d877ce8b890633
4
+ data.tar.gz: '09da55208d81abc48309f63ae2ca85ae4fdc743e368efcca0b6cfe3b2f5fbd5d'
5
5
  SHA512:
6
- metadata.gz: b82763b595daf55b2d09643804f5caf2351e11f8de4f1e61b0c8f98273770da35aaa4161209ad21a137e04dbfc35fa6cc8ff14f9f15ad2e7c450e2e8bcb7e9a2
7
- data.tar.gz: 23f6829e141eb6b2f3f90f23de5b6f8b731b8659060ca7459599727ff5652368f8f8970a1234b0c551ffd40321b1a99e4a9e212b84669c803e4483f0eba079ad
6
+ metadata.gz: ae6e413d24ac3a426007a4e344c2475ee11049a0472dbac103967acc99408404a82dd3f961618f3a41c0c6285124656e8ddac0951afefe937e8155c862fad2bd
7
+ data.tar.gz: 4cf76e604f0abd5c812d412afb7034f4977ca75b38593297fe864ad0c8d597621ebdf9a15f5add133a77954fe6c4eb5aada43d189b9f6a5f25accbb319533381
@@ -26,6 +26,8 @@ jobs:
26
26
  - name: Update gems
27
27
  run: |
28
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"
29
31
  bundle install --jobs 4 --retry 3
30
32
  - name: Run specs
31
33
  run: |
@@ -39,11 +39,10 @@ Or install it yourself as:
39
39
  require 'relaton_nist'
40
40
 
41
41
  hit_collection = RelatonNist::NistBibliography.search("8200")
42
- => [<RelatonNist::Hit:0x007f82b9b2b298 @text="8200" @fetched="false" @fullIdentifier="" @title="8200">,
43
- <RelatonNist::Hit:0x007f82b9b2a1e0 @text="8200" @fetched="false" @fullIdentifier="" @title="8200">]
42
+ => <RelatonNist::HitCollection:0x007fc069d19da0 @ref=8200 @fetched=false>
44
43
 
45
44
  item = hit_collection[1].fetch
46
- => #<RelatonNist::NistBibliographicItem:0x007f82b986e668
45
+ => #<RelatonNist::NistBibliographicItem:0x007fc049aa6778
47
46
  ...
48
47
  ----
49
48
 
@@ -71,9 +70,6 @@ item.to_xml bibdata: true
71
70
  ...
72
71
  <ext>
73
72
  <doctype>stadard</doctype>
74
- <keyword>cybersecurity</keyword>
75
- <keyword>cybersecurity objectives</keyword>
76
- ...
77
73
  <commentperiod>
78
74
  <from>2018-02-01</from>
79
75
  <to>2018-04-18</to>
@@ -86,8 +82,9 @@ item.to_xml bibdata: true
86
82
  [source,ruby]
87
83
  ----
88
84
  RelatonNist::NistBibliography.get("8200", "2018", {})
89
- fetching 8200...
90
- => #<RelatonNist::NistBibliographicItem:0x007f82bb3370a8
85
+ [relaton-nist] ("8200") fetching...
86
+ [relaton-nist] ("8200") found NISTIR 8200
87
+ => #<RelatonNist::NistBibliographicItem:0x007fc06aa2b480
91
88
  ...
92
89
  ----
93
90
 
@@ -110,9 +107,10 @@ NIST FIPS {docnumber}
110
107
  ----
111
108
  [source,ruby]
112
109
  ----
113
- RelatonNist::NistBibliography.get("8200", "2018", {})
114
- fetching 8200...
115
- => #<RelatonNist::NistBibliographicItem:0x007f82bb3370a8
110
+ RelatonNist::NistBibliography.get("SP 800-205 (February 2019) (PD)")
111
+ [relaton-nist] ("SP 800-205") fetching...
112
+ [relaton-nist] ("SP 800-205") found SP 800-205 (Draft)
113
+ => #<RelatonNist::NistBibliographicItem:0x007fc059934768
116
114
  ...
117
115
  ----
118
116
 
@@ -43,7 +43,9 @@
43
43
  <define name="xref">
44
44
  <element name="xref">
45
45
  <attribute name="target">
46
- <data type="IDREF"/>
46
+ <data type="string">
47
+ <param name="pattern">\i\c*|\c+#\c+</param>
48
+ </data>
47
49
  </attribute>
48
50
  <optional>
49
51
  <attribute name="type">
@@ -61,6 +63,11 @@
61
63
  </choice>
62
64
  </attribute>
63
65
  </optional>
66
+ <optional>
67
+ <attribute name="droploc">
68
+ <data type="boolean"/>
69
+ </attribute>
70
+ </optional>
64
71
  <text/>
65
72
  </element>
66
73
  </define>
@@ -578,6 +585,8 @@
578
585
  <ref name="ol"/>
579
586
  <ref name="dl"/>
580
587
  <ref name="formula"/>
588
+ <ref name="quote"/>
589
+ <ref name="sourcecode"/>
581
590
  </choice>
582
591
  </oneOrMore>
583
592
  </element>
@@ -661,6 +670,16 @@
661
670
  </choice>
662
671
  </attribute>
663
672
  </optional>
673
+ <optional>
674
+ <attribute name="valign">
675
+ <choice>
676
+ <value>top</value>
677
+ <value>middle</value>
678
+ <value>bottom</value>
679
+ <value>baseline</value>
680
+ </choice>
681
+ </attribute>
682
+ </optional>
664
683
  <choice>
665
684
  <zeroOrMore>
666
685
  <choice>
@@ -697,6 +716,16 @@
697
716
  </choice>
698
717
  </attribute>
699
718
  </optional>
719
+ <optional>
720
+ <attribute name="valign">
721
+ <choice>
722
+ <value>top</value>
723
+ <value>middle</value>
724
+ <value>bottom</value>
725
+ <value>baseline</value>
726
+ </choice>
727
+ </attribute>
728
+ </optional>
700
729
  <choice>
701
730
  <zeroOrMore>
702
731
  <choice>
@@ -834,6 +863,13 @@
834
863
  </define>
835
864
  <define name="standard-document">
836
865
  <element name="standard-document">
866
+ <attribute name="version"/>
867
+ <attribute name="type">
868
+ <choice>
869
+ <value>semantic</value>
870
+ <value>presentation</value>
871
+ </choice>
872
+ </attribute>
837
873
  <ref name="bibdata"/>
838
874
  <optional>
839
875
  <ref name="boilerplate"/>
@@ -855,7 +891,7 @@
855
891
  <oneOrMore>
856
892
  <choice>
857
893
  <ref name="content"/>
858
- <ref name="preface_abstract"/>
894
+ <ref name="abstract"/>
859
895
  <ref name="foreword"/>
860
896
  <ref name="introduction"/>
861
897
  <ref name="acknowledgements"/>
@@ -922,6 +958,9 @@
922
958
  <optional>
923
959
  <attribute name="script"/>
924
960
  </optional>
961
+ <optional>
962
+ <attribute name="type"/>
963
+ </optional>
925
964
  <optional>
926
965
  <attribute name="obligation">
927
966
  <choice>
@@ -961,9 +1000,6 @@
961
1000
  </define>
962
1001
  <define name="content-subsection">
963
1002
  <element name="clause">
964
- <optional>
965
- <attribute name="type"/>
966
- </optional>
967
1003
  <ref name="Content-Section"/>
968
1004
  </element>
969
1005
  </define>
@@ -992,6 +1028,9 @@
992
1028
  </choice>
993
1029
  </attribute>
994
1030
  </optional>
1031
+ <optional>
1032
+ <attribute name="type"/>
1033
+ </optional>
995
1034
  <optional>
996
1035
  <ref name="section-title"/>
997
1036
  </optional>
@@ -1011,9 +1050,6 @@
1011
1050
  </define>
1012
1051
  <define name="clause">
1013
1052
  <element name="clause">
1014
- <optional>
1015
- <attribute name="type"/>
1016
- </optional>
1017
1053
  <ref name="Clause-Section"/>
1018
1054
  </element>
1019
1055
  </define>
@@ -1042,18 +1078,24 @@
1042
1078
  </choice>
1043
1079
  </attribute>
1044
1080
  </optional>
1081
+ <optional>
1082
+ <attribute name="type"/>
1083
+ </optional>
1045
1084
  <optional>
1046
1085
  <ref name="section-title"/>
1047
1086
  </optional>
1048
1087
  <group>
1049
- <group>
1050
- <zeroOrMore>
1051
- <ref name="BasicBlock"/>
1052
- </zeroOrMore>
1053
- <zeroOrMore>
1054
- <ref name="note"/>
1055
- </zeroOrMore>
1056
- </group>
1088
+ <choice>
1089
+ <group>
1090
+ <zeroOrMore>
1091
+ <ref name="BasicBlock"/>
1092
+ </zeroOrMore>
1093
+ <zeroOrMore>
1094
+ <ref name="note"/>
1095
+ </zeroOrMore>
1096
+ </group>
1097
+ <ref name="amend"/>
1098
+ </choice>
1057
1099
  <zeroOrMore>
1058
1100
  <choice>
1059
1101
  <ref name="clause-subsection"/>
@@ -1180,6 +1222,9 @@
1180
1222
  <optional>
1181
1223
  <attribute name="script"/>
1182
1224
  </optional>
1225
+ <optional>
1226
+ <attribute name="type"/>
1227
+ </optional>
1183
1228
  <optional>
1184
1229
  <attribute name="obligation">
1185
1230
  <choice>
@@ -1447,11 +1492,6 @@
1447
1492
  </optional>
1448
1493
  </element>
1449
1494
  </define>
1450
- <define name="preface_abstract">
1451
- <element name="abstract">
1452
- <ref name="Basic-Section"/>
1453
- </element>
1454
- </define>
1455
1495
  <define name="term-clause">
1456
1496
  <element name="clause">
1457
1497
  <optional>
@@ -1501,4 +1541,79 @@
1501
1541
  <ref name="CitationType"/>
1502
1542
  </element>
1503
1543
  </define>
1544
+ <define name="amend">
1545
+ <element name="amend">
1546
+ <optional>
1547
+ <attribute name="id">
1548
+ <data type="ID"/>
1549
+ </attribute>
1550
+ </optional>
1551
+ <attribute name="change">
1552
+ <choice>
1553
+ <value>add</value>
1554
+ <value>modify</value>
1555
+ <value>delete</value>
1556
+ </choice>
1557
+ </attribute>
1558
+ <optional>
1559
+ <attribute name="path"/>
1560
+ </optional>
1561
+ <optional>
1562
+ <attribute name="path_end"/>
1563
+ </optional>
1564
+ <optional>
1565
+ <attribute name="title"/>
1566
+ </optional>
1567
+ <optional>
1568
+ <element name="location">
1569
+ <zeroOrMore>
1570
+ <ref name="locality"/>
1571
+ </zeroOrMore>
1572
+ </element>
1573
+ </optional>
1574
+ <zeroOrMore>
1575
+ <ref name="autonumber"/>
1576
+ </zeroOrMore>
1577
+ <optional>
1578
+ <element name="description">
1579
+ <zeroOrMore>
1580
+ <ref name="BasicBlock"/>
1581
+ </zeroOrMore>
1582
+ </element>
1583
+ </optional>
1584
+ <optional>
1585
+ <element name="newcontent">
1586
+ <zeroOrMore>
1587
+ <ref name="BasicBlock"/>
1588
+ </zeroOrMore>
1589
+ </element>
1590
+ </optional>
1591
+ <optional>
1592
+ <element name="description">
1593
+ <zeroOrMore>
1594
+ <ref name="BasicBlock"/>
1595
+ </zeroOrMore>
1596
+ </element>
1597
+ </optional>
1598
+ </element>
1599
+ </define>
1600
+ <define name="autonumber">
1601
+ <element name="autonumber">
1602
+ <attribute name="type">
1603
+ <choice>
1604
+ <value>requirement</value>
1605
+ <value>recommendation</value>
1606
+ <value>permission</value>
1607
+ <value>table</value>
1608
+ <value>figure</value>
1609
+ <value>admonition</value>
1610
+ <value>formula</value>
1611
+ <value>sourcecode</value>
1612
+ <value>example</value>
1613
+ <value>note</value>
1614
+ </choice>
1615
+ </attribute>
1616
+ <text/>
1617
+ </element>
1618
+ </define>
1504
1619
  </grammar>
@@ -9,6 +9,24 @@
9
9
  <start>
10
10
  <ref name="nist-standard"/>
11
11
  </start>
12
+ <define name="ol">
13
+ <element name="ol">
14
+ <attribute name="id">
15
+ <data type="ID"/>
16
+ </attribute>
17
+ <optional>
18
+ <attribute name="class">
19
+ <value>steps</value>
20
+ </attribute>
21
+ </optional>
22
+ <oneOrMore>
23
+ <ref name="li"/>
24
+ </oneOrMore>
25
+ <zeroOrMore>
26
+ <ref name="note"/>
27
+ </zeroOrMore>
28
+ </element>
29
+ </define>
12
30
  <define name="DocumentType">
13
31
  <value>standard</value>
14
32
  </define>
@@ -16,7 +34,7 @@
16
34
  <define name="preface">
17
35
  <element name="preface">
18
36
  <optional>
19
- <ref name="preface_abstract"/>
37
+ <ref name="abstract"/>
20
38
  </optional>
21
39
  <optional>
22
40
  <ref name="foreword"/>
@@ -164,6 +182,13 @@
164
182
  </define>
165
183
  <define name="nist-standard">
166
184
  <element name="nist-standard">
185
+ <attribute name="version"/>
186
+ <attribute name="type">
187
+ <choice>
188
+ <value>semantic</value>
189
+ <value>presentation</value>
190
+ </choice>
191
+ </attribute>
167
192
  <ref name="bibdata"/>
168
193
  <zeroOrMore>
169
194
  <ref name="termdocsource"/>
@@ -10,6 +10,7 @@ module RelatonNist
10
10
  # Page of hit collection.
11
11
  class HitCollection < RelatonBib::HitCollection
12
12
  DOMAIN = "https://csrc.nist.gov"
13
+ PUBS_EXPORT = URI.join(DOMAIN, "/CSRC/media/feeds/metanorma/pubs-export")
13
14
  DATAFILEDIR = File.expand_path ".relaton/nist", Dir.home
14
15
  DATAFILE = File.expand_path "pubs-export.zip", DATAFILEDIR
15
16
 
@@ -17,10 +18,10 @@ module RelatonNist
17
18
  # @param year [String]
18
19
  # @param opts [Hash]
19
20
  # @option opts [String] :stage
20
- def initialize(ref_nbr, year = nil, opts = {})
21
+ def initialize(ref_nbr, year = nil, opts = {}) # rubocop:disable Metrics/AbcSize
21
22
  super ref_nbr, year
22
23
 
23
- /(?<docid>(SP|FIPS)\s[0-9-]+)/ =~ text
24
+ /(?<docid>(SP|FIPS)\s[0-9-]+\w?)/ =~ text
24
25
  @array = docid ? from_json(docid, **opts) : from_csrc(**opts)
25
26
 
26
27
  @array.sort! do |a, b|
@@ -45,28 +46,29 @@ module RelatonNist
45
46
  from = d.strftime "%m/%d/%Y"
46
47
  to = d.next_year.prev_day.strftime "%m/%d/%Y"
47
48
  end
48
- url = "#{DOMAIN}/publications/search?keywords-lg=#{text}"
49
+ url = "#{DOMAIN}/publications/search?keywords-lg=#{text}"\
50
+ "&sortBy-lg=relevence"
49
51
  url += "&dateFrom-lg=#{from}" if from
50
52
  url += "&dateTo-lg=#{to}" if to
51
- url += if /PD/ =~ opts[:stage]
53
+ url += if /PD/.match? opts[:stage]
52
54
  "&status-lg=Draft,Retired Draft,Withdrawn"
53
55
  else
54
56
  "&status-lg=Final,Withdrawn"
55
57
  end
56
58
 
57
- doc = Nokogiri::HTML OpenURI.open_uri(::Addressable::URI.parse(url).normalize)
59
+ doc = Nokogiri::HTML OpenURI.open_uri(::Addressable::URI.parse(url).normalize)
58
60
  doc.css("table.publications-table > tbody > tr").map do |h|
59
61
  link = h.at("td/div/strong/a")
60
62
  serie = h.at("td[1]").text.strip
61
63
  code = h.at("td[2]").text.strip
62
64
  title = link.text
63
- doc_url = DOMAIN + link[:href]
65
+ doc_url = DOMAIN + link[:href]
64
66
  status = h.at("td[4]").text.strip.downcase
65
67
  release_date = Date.strptime h.at("td[5]").text.strip, "%m/%d/%Y"
66
68
  Hit.new(
67
69
  {
68
- code: code, serie: serie, title: title, url: doc_url, status: status,
69
- release_date: release_date
70
+ code: code, serie: serie, title: title, url: doc_url,
71
+ status: status, release_date: release_date
70
72
  }, self
71
73
  )
72
74
  end
@@ -91,17 +93,18 @@ module RelatonNist
91
93
  # @param docid [String]
92
94
  # @param stage [String]
93
95
  # @return [Array<Hach>]
94
- def select_data(docid, **opts)
96
+ def select_data(docid, **opts) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength,Metrics/PerceivedComplexity
95
97
  d = Date.strptime year, "%Y" if year
98
+ didrx = Regexp.new(docid)
96
99
  data.select do |doc|
97
100
  next unless match_year?(doc, d)
98
101
 
99
- if /PD/ =~ opts[:stage]
102
+ if /PD/.match? opts[:stage]
100
103
  next unless %w[draft-public draft-prelim].include? doc["status"]
101
104
  else
102
105
  next unless doc["status"] == "final"
103
106
  end
104
- doc["docidentifier"] =~ Regexp.new(docid)
107
+ doc["docidentifier"] =~ didrx
105
108
  end
106
109
  end
107
110
 
@@ -129,13 +132,12 @@ module RelatonNist
129
132
  #
130
133
  # @prarm ctime [Time, NilClass]
131
134
  def fetch_data(ctime)
132
- resp = OpenURI.open_uri("https://csrc.nist.gov/CSRC/media/feeds/metanorma/pubs-export.meta")
135
+ resp = OpenURI.open_uri("#{PUBS_EXPORT}.meta")
133
136
  if !ctime || ctime < resp.last_modified
134
137
  @data = nil
135
- zip = OpenURI.open_uri "https://csrc.nist.gov/CSRC/media/feeds/metanorma/pubs-export.zip"
136
- zip.close
138
+ uri_open = URI.method(:open) || Kernel.method(:open)
137
139
  FileUtils.mkdir_p DATAFILEDIR unless Dir.exist? DATAFILEDIR
138
- FileUtils.mv zip.path, DATAFILE
140
+ IO.copy_stream(uri_open.call("#{PUBS_EXPORT}.zip"), DATAFILE)
139
141
  end
140
142
  end
141
143