relaton-w3c 1.3.2 → 1.6.pre1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/macos.yml +2 -0
- data/README.adoc +32 -22
- data/lib/relaton_w3c/hit_collection.rb +5 -2
- data/lib/relaton_w3c/scrapper.rb +8 -4
- data/lib/relaton_w3c/version.rb +1 -1
- data/relaton_w3c.gemspec +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 25d49fa941d5b6aeff2f14a9307eeba5f8c87ad18dbc5e7c9f4660d7a4e97731
|
4
|
+
data.tar.gz: e89d352bb1f7dcc88e84ea0a56009171fa6dd02fa47c80d895c274564e01a375
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b24ebff9a4d5265b9b236d1c0c6c22fa5d4d588118260479d9b9e021ba8569afa508312448805bb75fb32b474c53815102d03cf2259e1218bb2af767640e53f6
|
7
|
+
data.tar.gz: c60dc6d4602228745e27341bc4d39545694282e912b0df2f338291fdbc08e6b84134b8149911266ad88367ff482da4ea1d92835c2d1650433ff0320e5cf28172
|
data/.github/workflows/macos.yml
CHANGED
@@ -32,6 +32,8 @@ jobs:
|
|
32
32
|
- name: Update gems
|
33
33
|
run: |
|
34
34
|
sudo gem install bundler --force
|
35
|
+
ruby -v | grep 2.5 && bundle config set build.debase --with-cflags="-Wno-error=implicit-function-declaration"
|
36
|
+
ruby -v | grep 2.5 && bundle config set build.ruby-debug-ide --with-cflags="-Wno-error=implicit-function-declaration"
|
35
37
|
bundle install --jobs 4 --retry 3
|
36
38
|
- name: Run specs
|
37
39
|
run: |
|
data/README.adoc
CHANGED
@@ -10,7 +10,7 @@ Add this line to your application's Gemfile:
|
|
10
10
|
|
11
11
|
[source,ruby]
|
12
12
|
----
|
13
|
-
gem '
|
13
|
+
gem 'relaton-w3c'
|
14
14
|
----
|
15
15
|
|
16
16
|
And then execute:
|
@@ -19,14 +19,16 @@ And then execute:
|
|
19
19
|
|
20
20
|
Or install it yourself as:
|
21
21
|
|
22
|
-
$ gem install
|
22
|
+
$ gem install relaton-w3c
|
23
23
|
|
24
24
|
== Usage
|
25
25
|
|
26
26
|
=== Search for a standard using keywords
|
27
27
|
|
28
|
+
[source,ruby]
|
28
29
|
----
|
29
30
|
require 'relaton_w3c'
|
31
|
+
=> true
|
30
32
|
|
31
33
|
hits = RelatonW3c::W3cBibliography.search("W3C JSON-LD 1.1")
|
32
34
|
=> <RelatonW3c::HitCollection:0x007f93b5e4ff48 @ref=W3C JSON-LD 1.1 @fetched=false>
|
@@ -38,40 +40,43 @@ item = hits[0].fetch
|
|
38
40
|
|
39
41
|
=== XML serialization
|
40
42
|
|
43
|
+
[source,ruby]
|
41
44
|
----
|
42
45
|
item.to_xml
|
43
|
-
=> "<bibitem type="standard">
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
46
|
+
=> "<bibitem id="CR-json-ld11-20200316" type="standard">
|
47
|
+
<fetched>2020-04-07</fetched>
|
48
|
+
<title type="main" format="text/plain" language="en" script="Latn">JSON-LD 1.1</title>
|
49
|
+
<title format="text/plain" language="en" script="Latn">A JSON-based Serialization for Linked Data</title>
|
50
|
+
<uri type="src">https://www.w3.org/TR/2020/CR-json-ld11-20200316/</uri>
|
51
|
+
<date type="published">
|
52
|
+
<on>2020</on>
|
53
|
+
</date>
|
54
|
+
...
|
52
55
|
</bibitem>"
|
53
56
|
----
|
54
57
|
|
55
58
|
With argument `bibdata: true` it ouputs XML wrapped by `bibdata` element and adds flavour `ext` element.
|
56
59
|
|
60
|
+
[source,ruby]
|
57
61
|
----
|
58
62
|
item.to_xml bibdata: true
|
59
63
|
=> "<bibdata type="standard">
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
64
|
+
<fetched>2020-04-07</fetched>
|
65
|
+
<title type="main" format="text/plain" language="en" script="Latn">JSON-LD 1.1</title>
|
66
|
+
<title format="text/plain" language="en" script="Latn">A JSON-based Serialization for Linked Data</title>
|
67
|
+
<uri type="src">https://www.w3.org/TR/2020/CR-json-ld11-20200316/</uri>
|
68
|
+
<date type="published">
|
69
|
+
<on>2020</on>
|
70
|
+
</date>
|
71
|
+
...
|
72
|
+
<ext>
|
73
|
+
<doctype>candidateRecommendation</doctype>
|
74
|
+
</ext>
|
71
75
|
</bibdata>"
|
72
76
|
----
|
73
77
|
|
74
78
|
=== Get document by title
|
79
|
+
[source,ruby]
|
75
80
|
----
|
76
81
|
RelatonW3c::W3cBibliography.get "W3C JSON-LD 1.1"
|
77
82
|
[relaton-w3c] ("W3C JSON-LD 1.1") fetching...
|
@@ -81,6 +86,7 @@ RelatonW3c::W3cBibliography.get "W3C JSON-LD 1.1"
|
|
81
86
|
----
|
82
87
|
|
83
88
|
=== Get document by title and type
|
89
|
+
[source,ruby]
|
84
90
|
----
|
85
91
|
RelatonW3c::W3cBibliography.get "W3C Candidate Recommendation JSON-LD 1.1"
|
86
92
|
[relaton-w3c] ("W3C Candidate Recommendation JSON-LD 1.1") fetching...
|
@@ -90,6 +96,7 @@ RelatonW3c::W3cBibliography.get "W3C Candidate Recommendation JSON-LD 1.1"
|
|
90
96
|
----
|
91
97
|
|
92
98
|
=== Get document by title and short type
|
99
|
+
[source,ruby]
|
93
100
|
----
|
94
101
|
RelatonW3c::W3cBibliography.get "W3C CR JSON-LD 1.1"
|
95
102
|
[relaton-w3c] ("W3C CR JSON-LD 1.1") fetching...
|
@@ -99,6 +106,7 @@ RelatonW3c::W3cBibliography.get "W3C CR JSON-LD 1.1"
|
|
99
106
|
----
|
100
107
|
|
101
108
|
=== Get document by title, type, and date
|
109
|
+
[source,ruby]
|
102
110
|
----
|
103
111
|
RelatonW3c::W3cBibliography.get "W3C WD JSON-LD 1.1 2019-10-18"
|
104
112
|
[relaton-w3c] ("W3C WD JSON-LD 1.1 2019-10-18") fetching...
|
@@ -108,6 +116,7 @@ RelatonW3c::W3cBibliography.get "W3C WD JSON-LD 1.1 2019-10-18"
|
|
108
116
|
----
|
109
117
|
|
110
118
|
=== Create bibliographic item from XML
|
119
|
+
[source,ruby]
|
111
120
|
----
|
112
121
|
RelatonW3c::XMLParser.from_xml File.read('spec/fixtures/cr_json_ld11.xml')
|
113
122
|
=> #<RelatonW3c::W3cBibliographicItem:0x007f9381efce98
|
@@ -115,6 +124,7 @@ RelatonW3c::XMLParser.from_xml File.read('spec/fixtures/cr_json_ld11.xml')
|
|
115
124
|
----
|
116
125
|
|
117
126
|
=== Create bibliographic item from YAML
|
127
|
+
[source,ruby]
|
118
128
|
----
|
119
129
|
hash = YAML.load_file 'spec/fixtures/cr_json_ld11.yml'
|
120
130
|
=> {"title"=>
|
@@ -17,7 +17,7 @@ module RelatonW3c
|
|
17
17
|
}.freeze
|
18
18
|
DOMAIN = "https://www.w3.org"
|
19
19
|
DATADIR = File.expand_path(".relaton/w3c", Dir.home).freeze
|
20
|
-
DATAFILE = File.expand_path("
|
20
|
+
DATAFILE = File.expand_path("bibliography.yml", DATADIR).freeze
|
21
21
|
|
22
22
|
# @param ref [String] reference to search
|
23
23
|
def initialize(ref)
|
@@ -46,9 +46,12 @@ module RelatonW3c
|
|
46
46
|
title ||= title_date
|
47
47
|
result = data.select do |hit|
|
48
48
|
(hit["title"].casecmp?(title) ||
|
49
|
-
hit["link"].split("/").last.match?(
|
49
|
+
hit["link"].split("/").last.match?(/-#{title}-/)) &&
|
50
50
|
type_date_filter(hit, type, date)
|
51
51
|
end
|
52
|
+
if result.empty?
|
53
|
+
result = data.select { |h| h["link"].split("/").last.match? /#{title}/ }
|
54
|
+
end
|
52
55
|
result.map { |h| Hit.new(h, self) }
|
53
56
|
end
|
54
57
|
|
data/lib/relaton_w3c/scrapper.rb
CHANGED
@@ -48,13 +48,16 @@ module RelatonW3c
|
|
48
48
|
def fetch_title(hit, doc) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
|
49
49
|
titles = []
|
50
50
|
if doc
|
51
|
-
title = doc.at("
|
52
|
-
|
51
|
+
title = doc.at("//*[contains(@id, 'title')]")&.text
|
52
|
+
if title && !title.empty?
|
53
|
+
titles << { content: title.gsub(/\n/, " "), type: "main" }
|
54
|
+
end
|
53
55
|
subtitle = doc.at(
|
54
56
|
"//h2[@id='subtitle']|//p[contains(@class, 'subline')]"
|
55
57
|
)&.text
|
56
58
|
titles << { content: subtitle, tipe: "subtitle" } if subtitle
|
57
|
-
|
59
|
+
end
|
60
|
+
if titles.empty? && hit["title"]
|
58
61
|
titles << { content: hit["title"], type: "main" }
|
59
62
|
end
|
60
63
|
titles.map do |t|
|
@@ -70,7 +73,8 @@ module RelatonW3c
|
|
70
73
|
def fetch_abstract(doc)
|
71
74
|
return [] unless doc
|
72
75
|
|
73
|
-
content = doc.at("//h2[.='Abstract']/following-sibling::p"
|
76
|
+
content = doc.at("//h2[.='Abstract']/following-sibling::p",
|
77
|
+
"//div[@class='abstract']/p").text
|
74
78
|
[RelatonBib::FormattedString.new(content: content, language: "en",
|
75
79
|
script: "Latn")]
|
76
80
|
end
|
data/lib/relaton_w3c/version.rb
CHANGED
data/relaton_w3c.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: relaton-w3c
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.6.pre1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-11-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: debase
|
@@ -114,14 +114,14 @@ dependencies:
|
|
114
114
|
requirements:
|
115
115
|
- - ">="
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version: 1.
|
117
|
+
version: 1.6.pre
|
118
118
|
type: :runtime
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
122
|
- - ">="
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version: 1.
|
124
|
+
version: 1.6.pre
|
125
125
|
description: 'RelatonIso: retrieve W3C Standards for bibliographic using the IsoBibliographicItem
|
126
126
|
model'
|
127
127
|
email:
|
@@ -173,9 +173,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
173
173
|
version: 2.4.0
|
174
174
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
175
175
|
requirements:
|
176
|
-
- - "
|
176
|
+
- - ">"
|
177
177
|
- !ruby/object:Gem::Version
|
178
|
-
version:
|
178
|
+
version: 1.3.1
|
179
179
|
requirements: []
|
180
180
|
rubygems_version: 3.0.6
|
181
181
|
signing_key:
|