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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b79577420d68acf9fe29a87460bc11392bdb341b
4
- data.tar.gz: 8e0897edbbd07ff9d34cc5b38fa6c5fb283251f8
3
+ metadata.gz: 6d25a0884369e841925bac38f6bbeb3b7790d48c
4
+ data.tar.gz: 6408f829c40940f06ce392354aec25ebc8e60585
5
5
  SHA512:
6
- metadata.gz: 6151ae77c05e8bb81d8f84255bc8d96cc603763d9250d91398b96ddc652af5ab90fdc392deb37b23e61fedf24c412ed993f112e59be120f0e57e36aa276345f8
7
- data.tar.gz: 3ae7b137adb6918ee72d22eea2ab78f058161fb20d6e289a21e893af9c83576c98744b94b2e52e1e5317e525e92bb1ecf147ad21c067c0b6777b3c4072355492
6
+ metadata.gz: 1a750ad1c2f9396cc6eb200783d141159538e4fe815804a0ffdbcf2c8a279dda426d52997afb7e9d17d66ca56b699998e94f91e5d79537002a9348c38cb350cd
7
+ data.tar.gz: 485343087a69b16061854e02ceaab1f620a7f035c75d1b0a796056d03d48fd65b14cc43cacf091f0aa870a4c008272ebf15bde69a88adc52660dccd1d55fb1b9
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cirneco (0.8.5)
4
+ cirneco (0.8.6)
5
5
  activesupport (~> 4.2, >= 4.2.5)
6
6
  base32-crockford-checksum (~> 0.2.2)
7
7
  bergamasco (~> 0.3)
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']")
@@ -1,3 +1,3 @@
1
1
  module Cirneco
2
- VERSION = "0.8.5"
2
+ VERSION = "0.8.6"
3
3
  end
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)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cirneco
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.5
4
+ version: 0.8.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Fenner