cirneco 0.9.6 → 0.9.7

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: f35d4ea11c44fd904f46aae63e5e53aa6dd1a325
4
- data.tar.gz: b01455feaf57ffe51ad042afbc0a28538f370f0e
3
+ metadata.gz: a076d3229005058b8f3eeacf32ecdd2048d3cf18
4
+ data.tar.gz: 7888a9e22e1a0afd420b0c318b9097db3b7c83e9
5
5
  SHA512:
6
- metadata.gz: a4d9912d6b480825080b5d397ef3e164d4cf6345706725436b5beb2559e0a7cce8ed90b6ca6fa8ca6eefc6020858f180d0bf32eb8b33e631d8a41f79fa9b2375
7
- data.tar.gz: 1fa32c6b1dc571a47d40962dd663ed64ef07d6f9b43bd1ada267c2d805866f470a62fc2907ce77f25609796ed998ace5161482d5401fe7102d2be892ca68cda1
6
+ metadata.gz: ceb15a12b36cb89d7fe9fb5e94c664754bfaad8c04453451482c6f0c82d76fd7d0d797b84dcbdb8aea7e8d428491441485dc0f442adffcb3bd462c18145e8b4d
7
+ data.tar.gz: ff0f87808efa4785a5128b6a1973bb4fd85edd74be9616fc5c6ce3a9e9a9406df68014bcf16961f9eea0d781b1597d5977dc6cf308e727ec71145b8937292a75
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cirneco (0.9.6)
4
+ cirneco (0.9.7)
5
5
  activesupport (~> 4.2, >= 4.2.5)
6
6
  base32-crockford-checksum (~> 0.2.2)
7
7
  bergamasco (~> 0.3)
@@ -122,4 +122,4 @@ DEPENDENCIES
122
122
  webmock (~> 1.22, >= 1.22.3)
123
123
 
124
124
  BUNDLED WITH
125
- 1.12.5
125
+ 1.13.6
data/lib/cirneco/utils.rb CHANGED
@@ -180,11 +180,11 @@ module Cirneco
180
180
  def generate_metadata_for_work(url, options={})
181
181
  doc = Nokogiri::HTML(open(url))
182
182
  json = doc.at_xpath("//script[@type='application/ld+json']")
183
- return "Error: no schema.org metadata found" unless json.present?
183
+ return { "error" => "Error: no schema.org metadata found" } unless json.present?
184
184
 
185
185
  metadata = ActiveSupport::JSON.decode(json.text)
186
186
 
187
- return "Error: required metadata missing" unless ["name", "author", "publisher", "datePublished", "@type"].all? { |k| metadata.key? k }
187
+ return { "error" => "Error: required metadata missing" } unless ["name", "author", "publisher", "datePublished", "@type"].all? { |k| metadata.key? k }
188
188
 
189
189
  # required metadata
190
190
  if /(http|https):\/\/(dx\.)?doi\.org\/(\w+)/.match(metadata["@id"])
@@ -300,11 +300,11 @@ module Cirneco
300
300
  def generate_metadata_for_jats(url, options={})
301
301
  doc = Nokogiri::HTML(open(url))
302
302
  json = doc.at_xpath("//script[@type='application/ld+json']")
303
- return "Error: no schema.org metadata found" unless json.present?
303
+ return { "error" => "Error: no schema.org metadata found" } unless json.present?
304
304
 
305
305
  metadata = ActiveSupport::JSON.decode(json.text)
306
306
 
307
- return "Error: required metadata missing" unless ["name", "author", "publisher", "datePublished", "@type"].all? { |k| metadata.key? k }
307
+ return { "error" => "Error: required metadata missing" } unless ["name", "author", "publisher", "datePublished", "@type"].all? { |k| metadata.key? k }
308
308
 
309
309
  # required metadata
310
310
  if /(http|https):\/\/(dx\.)?doi\.org\/(\w+)/.match(metadata["@id"])
@@ -1,3 +1,3 @@
1
1
  module Cirneco
2
- VERSION = "0.9.6"
2
+ VERSION = "0.9.7"
3
3
  end
data/spec/utils_spec.rb CHANGED
@@ -172,12 +172,12 @@ describe Cirneco::DataCenter, vcr: true, :order => :defined do
172
172
 
173
173
  it 'should generate metadata for work no JSON-LD' do
174
174
  filepath = fixture_path + 'cool-dois-no-json-ld/index.html'
175
- expect(subject.generate_metadata_for_work(filepath)).to eq("Error: no schema.org metadata found")
175
+ expect(subject.generate_metadata_for_work(filepath)).to eq("error"=>"Error: no schema.org metadata found")
176
176
  end
177
177
 
178
178
  it 'should generate metadata for work missing required metadata' do
179
179
  filepath = fixture_path + 'cool-dois-missing-metadata/index.html'
180
- expect(subject.generate_metadata_for_work(filepath)).to eq("Error: required metadata missing")
180
+ expect(subject.generate_metadata_for_work(filepath)).to eq("error"=>"Error: required metadata missing")
181
181
  end
182
182
 
183
183
  it 'should post_metadata_for_work' do
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.9.6
4
+ version: 0.9.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Fenner