cirneco 0.8.5 → 0.8.6
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/Gemfile.lock +1 -1
- data/lib/cirneco/utils.rb +9 -0
- data/lib/cirneco/version.rb +1 -1
- data/spec/utils_spec.rb +6 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6d25a0884369e841925bac38f6bbeb3b7790d48c
|
4
|
+
data.tar.gz: 6408f829c40940f06ce392354aec25ebc8e60585
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1a750ad1c2f9396cc6eb200783d141159538e4fe815804a0ffdbcf2c8a279dda426d52997afb7e9d17d66ca56b699998e94f91e5d79537002a9348c38cb350cd
|
7
|
+
data.tar.gz: 485343087a69b16061854e02ceaab1f620a7f035c75d1b0a796056d03d48fd65b14cc43cacf091f0aa870a4c008272ebf15bde69a88adc52660dccd1d55fb1b9
|
data/Gemfile.lock
CHANGED
data/lib/cirneco/utils.rb
CHANGED
@@ -168,6 +168,15 @@ module Cirneco
|
|
168
168
|
end.join("\n")
|
169
169
|
end
|
170
170
|
|
171
|
+
def get_urls_for_works(url)
|
172
|
+
doc = Nokogiri::HTML(open(url))
|
173
|
+
json = doc.at_xpath("//script[@type='application/ld+json']")
|
174
|
+
return [url] unless json.present?
|
175
|
+
|
176
|
+
metadata = ActiveSupport::JSON.decode(json.text)
|
177
|
+
metadata.fetch("hasPart", []).map { |p| p["@id"] } + [url]
|
178
|
+
end
|
179
|
+
|
171
180
|
def generate_metadata_for_work(url, options={})
|
172
181
|
doc = Nokogiri::HTML(open(url))
|
173
182
|
json = doc.at_xpath("//script[@type='application/ld+json']")
|
data/lib/cirneco/version.rb
CHANGED
data/spec/utils_spec.rb
CHANGED
@@ -108,6 +108,12 @@ describe Cirneco::DataCenter, vcr: true, :order => :defined do
|
|
108
108
|
end
|
109
109
|
|
110
110
|
context "mint and hide DOIs" do
|
111
|
+
it 'get urls for works' do
|
112
|
+
filepath = fixture_path + 'index.html'
|
113
|
+
response = subject.get_urls_for_works(filepath)
|
114
|
+
expect(response.length).to eq(66)
|
115
|
+
end
|
116
|
+
|
111
117
|
it 'should mint for url' do
|
112
118
|
filepath = fixture_path + 'cool-dois.html'
|
113
119
|
response = subject.mint_doi_for_url(filepath, options)
|