relaton-ietf 0.1.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/Gemfile.lock +13 -13
- data/README.adoc +13 -0
- data/lib/relaton/provider_ietf.rb +15 -0
- data/lib/relaton_ietf.rb +2 -0
- data/lib/relaton_ietf/ietf_bibliographi_item.rb +7 -0
- data/lib/relaton_ietf/scrapper.rb +14 -3
- data/lib/relaton_ietf/version.rb +1 -1
- data/relaton_ietf.gemspec +1 -1
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 33879fa83239ce32ea3250fed0bd411ed656fc7303bbff65dbb5d5ecb747ea94
|
4
|
+
data.tar.gz: 1b83f019952a45692196cb5b96907cda925c47961d979ad8ba4f49a5d8c027da
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3eaba13be94a5c8dd3e0708cc2dee4d92f96195f0c08796a6123f61e17455845eca11e053eb8b0e1e26fd01f49954ab14ee1702b8d4b95a95215b37ddbaa4afa
|
7
|
+
data.tar.gz: 6fde3c29eb5e8109b6cb38d4f5937022bb67dae504568a45a9e000c1a172541a1f9f00efe027516f7d49de85251af4d56d99a2a4c2da79714c02c25a923e03ec
|
data/Gemfile.lock
CHANGED
@@ -2,7 +2,7 @@ PATH
|
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
4
|
relaton-ietf (0.1.0)
|
5
|
-
relaton-iso-bib (~> 0.
|
5
|
+
relaton-iso-bib (~> 0.2.0)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
@@ -15,9 +15,9 @@ GEM
|
|
15
15
|
safe_yaml (~> 1.0.0)
|
16
16
|
debase (0.2.2)
|
17
17
|
debase-ruby_core_source (>= 0.10.2)
|
18
|
-
debase-ruby_core_source (0.10.
|
18
|
+
debase-ruby_core_source (0.10.5)
|
19
19
|
diff-lcs (1.3)
|
20
|
-
docile (1.3.
|
20
|
+
docile (1.3.2)
|
21
21
|
equivalent-xml (0.6.0)
|
22
22
|
nokogiri (>= 1.4.3)
|
23
23
|
hashdiff (0.4.0)
|
@@ -35,28 +35,28 @@ GEM
|
|
35
35
|
pry (~> 0.10)
|
36
36
|
public_suffix (3.1.0)
|
37
37
|
rake (10.5.0)
|
38
|
-
relaton-bib (0.
|
38
|
+
relaton-bib (0.2.0)
|
39
39
|
addressable
|
40
40
|
nokogiri (~> 1.8.4)
|
41
|
-
relaton-iso-bib (0.
|
41
|
+
relaton-iso-bib (0.2.0)
|
42
42
|
isoics (~> 0.1.6)
|
43
43
|
nokogiri (~> 1.8.4)
|
44
|
-
relaton-bib (~> 0.
|
44
|
+
relaton-bib (~> 0.2.0)
|
45
45
|
ruby_deep_clone (~> 0.8.0)
|
46
46
|
rspec (3.8.0)
|
47
47
|
rspec-core (~> 3.8.0)
|
48
48
|
rspec-expectations (~> 3.8.0)
|
49
49
|
rspec-mocks (~> 3.8.0)
|
50
|
-
rspec-core (3.8.
|
50
|
+
rspec-core (3.8.1)
|
51
51
|
rspec-support (~> 3.8.0)
|
52
|
-
rspec-expectations (3.8.
|
52
|
+
rspec-expectations (3.8.4)
|
53
53
|
diff-lcs (>= 1.2.0, < 2.0)
|
54
54
|
rspec-support (~> 3.8.0)
|
55
|
-
rspec-mocks (3.8.
|
55
|
+
rspec-mocks (3.8.1)
|
56
56
|
diff-lcs (>= 1.2.0, < 2.0)
|
57
57
|
rspec-support (~> 3.8.0)
|
58
|
-
rspec-support (3.8.
|
59
|
-
ruby-debug-ide (0.
|
58
|
+
rspec-support (3.8.2)
|
59
|
+
ruby-debug-ide (0.7.0)
|
60
60
|
rake (>= 0.8.1)
|
61
61
|
ruby_deep_clone (0.8.0)
|
62
62
|
safe_yaml (1.0.5)
|
@@ -66,10 +66,10 @@ GEM
|
|
66
66
|
simplecov-html (~> 0.10.0)
|
67
67
|
simplecov-html (0.10.2)
|
68
68
|
vcr (5.0.0)
|
69
|
-
webmock (3.
|
69
|
+
webmock (3.6.0)
|
70
70
|
addressable (>= 2.3.6)
|
71
71
|
crack (>= 0.3.2)
|
72
|
-
hashdiff
|
72
|
+
hashdiff (>= 0.4.0, < 2.0.0)
|
73
73
|
|
74
74
|
PLATFORMS
|
75
75
|
ruby
|
data/README.adoc
CHANGED
@@ -115,6 +115,19 @@ item.to_xml bibdata: true
|
|
115
115
|
</bibdata>"
|
116
116
|
----
|
117
117
|
|
118
|
+
=== Parse a file locally
|
119
|
+
|
120
|
+
[source,ruby]
|
121
|
+
----
|
122
|
+
item = Relaton::Provider::Ietf.from_rfcxml File.read("rfc.xml")
|
123
|
+
=> #<RelatonIetf::IetfBibliographicItem:0x007fa8cda79ab8
|
124
|
+
...
|
125
|
+
|
126
|
+
item.to_xml bibdata: true
|
127
|
+
=>"<bibdata>
|
128
|
+
...
|
129
|
+
----
|
130
|
+
|
118
131
|
== Contributing
|
119
132
|
|
120
133
|
Bug reports and pull requests are welcome on GitHub at https://github.com/metanorma/relaton-ietf.
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Relaton
|
2
|
+
module Provider
|
3
|
+
class Ietf
|
4
|
+
class << self
|
5
|
+
# @param xml [String]
|
6
|
+
# @return [RelatonIetf::IetfBibliographicItem]
|
7
|
+
def from_rfcxml(xml)
|
8
|
+
doc = Nokogiri::XML xml
|
9
|
+
reference = doc.at "/rfc"
|
10
|
+
RelatonIetf::Scrapper.bib_item reference, "rfc"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/lib/relaton_ietf.rb
CHANGED
@@ -3,8 +3,14 @@ module RelatonIetf
|
|
3
3
|
# @return [String, NilClass]
|
4
4
|
attr_reader :doctype
|
5
5
|
|
6
|
+
# @return [Array<String>]
|
7
|
+
attr_reader :keywords
|
8
|
+
|
9
|
+
# @param doctype [String]
|
10
|
+
# @param keywords [Array<String>]
|
6
11
|
def initialize(**args)
|
7
12
|
@doctype = args.delete :doctype
|
13
|
+
@keywords = args.delete(:keywords) || []
|
8
14
|
super
|
9
15
|
end
|
10
16
|
|
@@ -17,6 +23,7 @@ module RelatonIetf
|
|
17
23
|
if opts[:bibdata]
|
18
24
|
b.ext do
|
19
25
|
b.doctype doctype if doctype
|
26
|
+
keywords.each { |k| b.keyword k }
|
20
27
|
end
|
21
28
|
end
|
22
29
|
end
|
@@ -51,8 +51,6 @@ module RelatonIetf
|
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
54
|
-
private
|
55
|
-
|
56
54
|
# rubocop:disable Metrics/MethodLength
|
57
55
|
|
58
56
|
# @return [RelatonIetf::IetfBibliographicItem]
|
@@ -66,14 +64,18 @@ module RelatonIetf
|
|
66
64
|
script: ["Latn"],
|
67
65
|
link: [{ type: "src", content: reference[:target] }],
|
68
66
|
titles: titles(reference),
|
67
|
+
abstract: abstracts(reference),
|
69
68
|
contributors: contributors(reference),
|
70
69
|
dates: dates(reference),
|
71
70
|
series: series(reference),
|
72
71
|
doctype: doctype,
|
72
|
+
keywords: reference.xpath("front/keyword").map(&:text),
|
73
73
|
)
|
74
74
|
end
|
75
75
|
# rubocop:enable Metrics/MethodLength
|
76
76
|
|
77
|
+
private
|
78
|
+
|
77
79
|
# @return [String]
|
78
80
|
def language(reference)
|
79
81
|
reference[:lang] || "en"
|
@@ -85,6 +87,15 @@ module RelatonIetf
|
|
85
87
|
[{ content: title.text, language: language(reference), script: "Latn" }]
|
86
88
|
end
|
87
89
|
|
90
|
+
def abstracts(ref)
|
91
|
+
ref.xpath("./front/abstract").map do |a|
|
92
|
+
RelatonBib::FormattedString.new(
|
93
|
+
content: a.text.gsub(/\\n\\t{2,4}/, " ").strip,
|
94
|
+
language: language(ref), script: "Latn"
|
95
|
+
)
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
88
99
|
# @return [Array<Hash>]
|
89
100
|
def contributors(reference)
|
90
101
|
persons(reference) + organizations(reference)
|
@@ -205,7 +216,7 @@ module RelatonIetf
|
|
205
216
|
# @return [Array<RelatonBib::DocumentIdentifier>]
|
206
217
|
#
|
207
218
|
def docids(reference)
|
208
|
-
id = reference[:anchor].sub(/^(RFC)/, "\\1 ")
|
219
|
+
id = (reference[:anchor] || reference[:docName]).sub(/^(RFC)/, "\\1 ")
|
209
220
|
ret = []
|
210
221
|
ret << RelatonBib::DocumentIdentifier.new(type: "IETF", id: id)
|
211
222
|
ret + reference.xpath("./seriesinfo").map do |si|
|
data/lib/relaton_ietf/version.rb
CHANGED
data/relaton_ietf.gemspec
CHANGED
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.
|
4
|
+
version: 0.5.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-06-
|
11
|
+
date: 2019-06-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -156,14 +156,14 @@ dependencies:
|
|
156
156
|
requirements:
|
157
157
|
- - "~>"
|
158
158
|
- !ruby/object:Gem::Version
|
159
|
-
version: 0.
|
159
|
+
version: 0.2.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: 0.
|
166
|
+
version: 0.2.0
|
167
167
|
description: "RelatonIetf: retrieve IETF Standards for bibliographic use \nusing the
|
168
168
|
BibliographicItem model.\n\nFormerly known as rfcbib.\n"
|
169
169
|
email:
|
@@ -186,6 +186,7 @@ files:
|
|
186
186
|
- bin/console
|
187
187
|
- bin/setup
|
188
188
|
- lib/relaton/processor.rb
|
189
|
+
- lib/relaton/provider_ietf.rb
|
189
190
|
- lib/relaton_ietf.rb
|
190
191
|
- lib/relaton_ietf/ietf_bibliographi_item.rb
|
191
192
|
- lib/relaton_ietf/ietf_bibliography.rb
|
@@ -213,7 +214,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
213
214
|
version: '0'
|
214
215
|
requirements: []
|
215
216
|
rubyforge_project:
|
216
|
-
rubygems_version: 2.6
|
217
|
+
rubygems_version: 2.7.6
|
217
218
|
signing_key:
|
218
219
|
specification_version: 4
|
219
220
|
summary: 'RelatonIetf: retrieve IETF Standards for bibliographic use using the BibliographicItem
|