relaton-ietf 0.6.10 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
data/grammars/reqt.rng ADDED
@@ -0,0 +1,165 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <grammar xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
3
+ <!--
4
+ Presupposes isodoc.rnc, is included in it
5
+ include "isodoc.rnc" { }
6
+ -->
7
+ <define name="requirement">
8
+ <element name="requirement">
9
+ <ref name="RequirementType"/>
10
+ </element>
11
+ </define>
12
+ <define name="recommendation">
13
+ <element name="recommendation">
14
+ <ref name="RequirementType"/>
15
+ </element>
16
+ </define>
17
+ <define name="permission">
18
+ <element name="permission">
19
+ <ref name="RequirementType"/>
20
+ </element>
21
+ </define>
22
+ <define name="RequirementType">
23
+ <optional>
24
+ <attribute name="obligation">
25
+ <ref name="ObligationType"/>
26
+ </attribute>
27
+ </optional>
28
+ <optional>
29
+ <attribute name="unnumbered">
30
+ <data type="boolean"/>
31
+ </attribute>
32
+ </optional>
33
+ <optional>
34
+ <attribute name="subsequence"/>
35
+ </optional>
36
+ <attribute name="id">
37
+ <data type="ID"/>
38
+ </attribute>
39
+ <optional>
40
+ <attribute name="filename"/>
41
+ </optional>
42
+ <optional>
43
+ <ref name="reqtitle"/>
44
+ </optional>
45
+ <optional>
46
+ <ref name="label"/>
47
+ </optional>
48
+ <optional>
49
+ <ref name="subject"/>
50
+ </optional>
51
+ <optional>
52
+ <ref name="reqinherit"/>
53
+ </optional>
54
+ <zeroOrMore>
55
+ <ref name="classification"/>
56
+ </zeroOrMore>
57
+ <zeroOrMore>
58
+ <choice>
59
+ <ref name="measurementtarget"/>
60
+ <ref name="specification"/>
61
+ <ref name="verification"/>
62
+ <ref name="import"/>
63
+ <ref name="description"/>
64
+ </choice>
65
+ </zeroOrMore>
66
+ <optional>
67
+ <ref name="reqt_references"/>
68
+ </optional>
69
+ <zeroOrMore>
70
+ <choice>
71
+ <ref name="requirement"/>
72
+ <ref name="recommendation"/>
73
+ <ref name="permission"/>
74
+ </choice>
75
+ </zeroOrMore>
76
+ </define>
77
+ <define name="reqtitle">
78
+ <element name="title">
79
+ <ref name="FormattedString"/>
80
+ </element>
81
+ </define>
82
+ <define name="label">
83
+ <element name="label">
84
+ <text/>
85
+ </element>
86
+ </define>
87
+ <define name="subject">
88
+ <element name="subject">
89
+ <text/>
90
+ </element>
91
+ </define>
92
+ <define name="reqinherit">
93
+ <element name="inherit">
94
+ <text/>
95
+ </element>
96
+ </define>
97
+ <define name="measurementtarget">
98
+ <element name="measurement-target">
99
+ <ref name="RequirementSubpart"/>
100
+ </element>
101
+ </define>
102
+ <define name="specification">
103
+ <element name="specification">
104
+ <ref name="RequirementSubpart"/>
105
+ </element>
106
+ </define>
107
+ <define name="verification">
108
+ <element name="verification">
109
+ <ref name="RequirementSubpart"/>
110
+ </element>
111
+ </define>
112
+ <define name="import">
113
+ <element name="import">
114
+ <ref name="RequirementSubpart"/>
115
+ </element>
116
+ </define>
117
+ <define name="description">
118
+ <element name="description">
119
+ <ref name="RequirementSubpart"/>
120
+ </element>
121
+ </define>
122
+ <define name="reqt_references">
123
+ <element name="references">
124
+ <oneOrMore>
125
+ <ref name="bibitem"/>
126
+ </oneOrMore>
127
+ </element>
128
+ </define>
129
+ <define name="RequirementSubpart">
130
+ <optional>
131
+ <attribute name="type"/>
132
+ </optional>
133
+ <optional>
134
+ <attribute name="exclude">
135
+ <data type="boolean"/>
136
+ </attribute>
137
+ </optional>
138
+ <oneOrMore>
139
+ <ref name="BasicBlock"/>
140
+ </oneOrMore>
141
+ </define>
142
+ <define name="ObligationType">
143
+ <choice>
144
+ <value>requirement</value>
145
+ <value>recommendation</value>
146
+ <value>permission</value>
147
+ </choice>
148
+ </define>
149
+ <define name="classification">
150
+ <element name="classification">
151
+ <ref name="classification_tag"/>
152
+ <ref name="classification_value"/>
153
+ </element>
154
+ </define>
155
+ <define name="classification_tag">
156
+ <element name="tag">
157
+ <text/>
158
+ </element>
159
+ </define>
160
+ <define name="classification_value">
161
+ <element name="value">
162
+ <text/>
163
+ </element>
164
+ </define>
165
+ </grammar>
data/lib/relaton_ietf.rb CHANGED
@@ -12,3 +12,14 @@ require "relaton_ietf/hash_converter"
12
12
  # end
13
13
 
14
14
  require "relaton/provider_ietf"
15
+
16
+ module RelatonIetf
17
+ # Returns hash of XML reammar
18
+ # @return [String]
19
+ def self.grammar_hash
20
+ gem_path = File.expand_path "..", __dir__
21
+ grammars_path = File.join gem_path, "grammars", "*"
22
+ grammars = Dir[grammars_path].sort.map { |gp| File.read gp }.join
23
+ Digest::MD5.hexdigest grammars
24
+ end
25
+ end
@@ -30,5 +30,11 @@ module RelatonIetf
30
30
  item_hash = ::RelatonIetf::HashConverter.hash_to_bib(hash)
31
31
  ::RelatonIetf::IetfBibliographicItem.new item_hash
32
32
  end
33
+
34
+ # Returns hash of XML grammar
35
+ # @return [String]
36
+ def grammar_hash
37
+ @grammar_hash ||= ::RelatonIetf.grammar_hash
38
+ end
33
39
  end
34
40
  end
@@ -62,12 +62,19 @@ module RelatonIetf
62
62
  date: dates(reference),
63
63
  series: series(reference),
64
64
  keyword: reference.xpath("front/keyword").map(&:text),
65
+ doctype: doctype(reference[:anchor])
65
66
  )
66
67
  end
67
68
  # rubocop:enable Metrics/MethodLength
68
69
 
69
70
  private
70
71
 
72
+ # @param anchor [String]
73
+ # @return [String]
74
+ def doctype(anchor)
75
+ anchor =~ /I-D/ ? "internet-draft" : "rfc"
76
+ end
77
+
71
78
  def link(reference, url)
72
79
  l = []
73
80
  l << { type: "xml", content: url } if url
@@ -80,7 +87,6 @@ module RelatonIetf
80
87
  def ietf_item(**attrs)
81
88
  attrs[:fetched] = Date.today.to_s unless attrs.delete(:is_relation)
82
89
  attrs[:script] = ["Latn"]
83
- attrs[:doctype] = "standard"
84
90
  RelatonIetf::IetfBibliographicItem.new **attrs
85
91
  end
86
92
 
@@ -111,10 +117,12 @@ module RelatonIetf
111
117
  doc = Nokogiri::HTML get_page(uri)
112
118
  ietf_item(
113
119
  id: reference,
120
+ title: [content: ""],
114
121
  docid: [RelatonBib::DocumentIdentifier.new(type: "IETF", id: reference)],
115
122
  language: ["en"],
116
123
  link: [{ type: "src", content: uri }],
117
124
  relation: fetch_relations(doc),
125
+ doctype: "rfc"
118
126
  )
119
127
  end
120
128
 
@@ -1,3 +1,3 @@
1
1
  module RelatonIetf
2
- VERSION = "0.6.10".freeze
2
+ VERSION = "0.7.0".freeze
3
3
  end
data/relaton_ietf.gemspec CHANGED
@@ -39,6 +39,7 @@ Gem::Specification.new do |spec|
39
39
  spec.add_development_dependency "simplecov"
40
40
  spec.add_development_dependency "vcr"
41
41
  spec.add_development_dependency "webmock"
42
+ spec.add_development_dependency "ruby-jing"
42
43
 
43
- spec.add_dependency "relaton-bib", "~> 0.3.0"
44
+ spec.add_dependency "relaton-bib", "~> 0.4.0"
44
45
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: relaton-ietf
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.10
4
+ version: 0.7.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: 2019-11-11 00:00:00.000000000 Z
11
+ date: 2019-12-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -150,20 +150,34 @@ dependencies:
150
150
  - - ">="
151
151
  - !ruby/object:Gem::Version
152
152
  version: '0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: ruby-jing
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
153
167
  - !ruby/object:Gem::Dependency
154
168
  name: relaton-bib
155
169
  requirement: !ruby/object:Gem::Requirement
156
170
  requirements:
157
171
  - - "~>"
158
172
  - !ruby/object:Gem::Version
159
- version: 0.3.0
173
+ version: 0.4.0
160
174
  type: :runtime
161
175
  prerelease: false
162
176
  version_requirements: !ruby/object:Gem::Requirement
163
177
  requirements:
164
178
  - - "~>"
165
179
  - !ruby/object:Gem::Version
166
- version: 0.3.0
180
+ version: 0.4.0
167
181
  description: "RelatonIetf: retrieve IETF Standards for bibliographic use \nusing the
168
182
  BibliographicItem model.\n\nFormerly known as rfcbib.\n"
169
183
  email:
@@ -172,19 +186,26 @@ executables: []
172
186
  extensions: []
173
187
  extra_rdoc_files: []
174
188
  files:
189
+ - ".github/workflows/macos.yml"
190
+ - ".github/workflows/ubuntu.yml"
191
+ - ".github/workflows/windows.yml"
175
192
  - ".gitignore"
176
193
  - ".hound.yml"
177
194
  - ".rspec"
178
195
  - ".rubocop.yml"
179
- - ".travis.yml"
180
196
  - Gemfile
181
197
  - Gemfile.lock
182
198
  - LICENSE.txt
183
199
  - README.adoc
184
200
  - Rakefile
185
- - appveyor.yml
186
201
  - bin/console
187
202
  - bin/setup
203
+ - grammars/basicdoc.rng
204
+ - grammars/biblio.rng
205
+ - grammars/ietf.rng
206
+ - grammars/isodoc.rng
207
+ - grammars/isostandard.rng
208
+ - grammars/reqt.rng
188
209
  - lib/relaton/provider_ietf.rb
189
210
  - lib/relaton_ietf.rb
190
211
  - lib/relaton_ietf/hash_converter.rb
data/.travis.yml DELETED
@@ -1,18 +0,0 @@
1
- # Auto-generated !!! Do not edit it manually
2
- # use ci-master https://github.com/metanorma/metanorma-build-scripts
3
- language: ruby
4
- cache: bundler
5
- os:
6
- - linux
7
- - osx
8
- rvm:
9
- - 2.6
10
- - 2.5
11
- - 2.4
12
- - ruby-head
13
- before_install:
14
- - gem install bundler -v "~> 2"
15
- - bundle update
16
- matrix:
17
- allow_failures:
18
- - rvm: ruby-head
data/appveyor.yml DELETED
@@ -1,37 +0,0 @@
1
- # Auto-generated !!! Do not edit it manually
2
- # use ci-master https://github.com/metanorma/metanorma-build-scripts
3
- version: '{build}'
4
-
5
- cache:
6
- - vendor/bundle
7
-
8
- environment:
9
- matrix:
10
- - RUBY_VERSION: 26
11
- - RUBY_VERSION: 25
12
- - RUBY_VERSION: 24
13
- - RUBY_VERSION: _trunk
14
-
15
- matrix:
16
- allow_failures:
17
- - RUBY_VERSION: _trunk
18
-
19
- install:
20
- - ps: . { iwr -useb https://raw.githubusercontent.com/metanorma/metanorma-build-scripts/master/appveyor.ps1 } | iex
21
- - refreshenv
22
-
23
- build_script:
24
- - set PATH=C:\Ruby%RUBY_VERSION%\bin;%PATH%
25
- - set GIT_TERMINAL_PROMPT=0
26
- - gem install bundler -v "~> 2"
27
- - bundle config --local path vendor/bundle
28
- - bundle update
29
- - bundle install
30
-
31
- before_test:
32
- - ruby -v
33
- - gem -v
34
- - bundle -v
35
-
36
- test_script:
37
- - bundle exec rake