bergamasco 0.2.3 → 0.2.4

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: e0cf1655e4bdd865a5fd7136bc2aecbe6fd9934f
4
- data.tar.gz: 0b8adf4ba9a2e730775284901bcd755b477dc9bb
3
+ metadata.gz: 4d0569cf27c3e1b39f7f627e8e444904c4d559ac
4
+ data.tar.gz: b35abe4ff49c530007e5b67648d0d5fba612334f
5
5
  SHA512:
6
- metadata.gz: 22d8606fd89ca6a98b67904be181150ccc0fb87abf481d338ec6c19cd8ee41204659acb32e705f461e26f4433494134135ac8477e39430926ba5bf742456243d
7
- data.tar.gz: 6edaba580e43f7131e721cf6df3b9f9b5c27debce5039f2cf345c3805d38c347bd0da6e623075b41e51e5f06d6f70b7c5c3bdcb5060d3b52dc2d4442235fef6f
6
+ metadata.gz: ca6e9010494aa2cd9a0e1fbf8a0ea371a40fc074ea5ec5616e079211baa171961cc02ee1f52594b6957f18f9a74a3de50dd0ec9035d801a0ed16fb7061eea825
7
+ data.tar.gz: 7ac8ff15b82f376686abd7c50a6c604165542a511b3613eb1e2ead5321597f83f92e827ebae5c8d1452c4e7ab492fdc5d73077f5dfbd0a2629dfdff6658acb8d
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bergamasco (0.2.3)
4
+ bergamasco (0.2.4)
5
5
  activesupport (~> 4.2, >= 4.2.5)
6
6
  addressable (~> 2.3.8)
7
7
  builder (~> 3.2, >= 3.2.2)
@@ -37,7 +37,7 @@ module Bergamasco
37
37
  end
38
38
 
39
39
  def self.read_yaml_for_doi_metadata(filepath, options={})
40
- keys = options[:keys] || ["title", "author", "date", "tags"]
40
+ keys = options[:keys] || ["title", "author", "date", "tags", "summary", "doi", "type", "version", "citation"]
41
41
  unless File.exist?(filepath)
42
42
  parentdir = Pathname.new(filepath).parent
43
43
  FileUtils.mkdir_p parentdir
@@ -51,7 +51,7 @@ module Bergamasco
51
51
  content = YAML_FRONT_MATTER_REGEXP.match(file).post_match
52
52
  html = render_html(content, options)
53
53
  metadata["summary"] = Bergamasco::Summarize.summary_from_html(html, options)
54
- metadata["related_identifiers"] = extract_references(html, options)
54
+ metadata["citation"] = extract_references(html)
55
55
  metadata["date"] = metadata["date"].iso8601
56
56
  metadata
57
57
  end
@@ -70,25 +70,9 @@ module Bergamasco
70
70
  end
71
71
 
72
72
  # expects a references list generated by pandoc
73
- def self.extract_references(html, options={})
73
+ def self.extract_references(html)
74
74
  doc = Nokogiri::HTML(html)
75
- doc.xpath('//div[@id="refs"]/div/@id').map do |ref|
76
- id = ref.value[4..-1]
77
-
78
- if /(http|https):\/\/(dx\.)?doi\.org\/(\w+)/.match(id)
79
- uri = Addressable::URI.parse(id)
80
- id = uri.path[1..-1].upcase
81
- type = "DOI"
82
- else
83
- type = "URL"
84
- end
85
-
86
- {
87
- value: id,
88
- related_identifier_type: type,
89
- relation_type: "References"
90
- }
91
- end
75
+ doc.xpath('//div[@id="refs"]/div/@id').map { |ref| ref.value[4..-1] }
92
76
  end
93
77
  end
94
78
  end
@@ -1,3 +1,3 @@
1
1
  module Bergamasco
2
- VERSION = "0.2.3"
2
+ VERSION = "0.2.4"
3
3
  end
@@ -53,12 +53,7 @@ describe Bergamasco::Markdown do
53
53
  filepath = fixture_path + 'cool-dois.html.md'
54
54
  separator = "READMORE"
55
55
  metadata = subject.read_yaml_for_doi_metadata(filepath, separator: separator, csl: 'spec/apa.csl', bibliography: 'spec/references.bib')
56
- expect(metadata["related_identifiers"]).to eq([{:value=>"https://www.w3.org/Provider/Style/URI",
57
- :related_identifier_type=>"URL",
58
- :relation_type=>"References"},
59
- { :value=>"10.1371/JOURNAL.PONE.0115253",
60
- :related_identifier_type=>"DOI",
61
- :relation_type=>"References" }])
56
+ expect(metadata["citation"]).to eq(["https://www.w3.org/Provider/Style/URI", "https://doi.org/10.1371/journal.pone.0115253"])
62
57
  end
63
58
 
64
59
  it 'should write yaml' do
@@ -88,12 +83,7 @@ describe Bergamasco::Markdown do
88
83
  filepath = fixture_path + 'cool-dois.html.md'
89
84
  file = IO.read(filepath)
90
85
  html = subject.render_html(file, skip_yaml_header: true, csl: 'spec/apa.csl', bibliography: 'spec/references.bib')
91
- refs = subject.extract_references(html, skip_yaml_header: true, csl: 'spec/apa.csl', bibliography: 'spec/references.bib')
92
- expect(refs).to eq([{:value=>"https://www.w3.org/Provider/Style/URI",
93
- :related_identifier_type=>"URL",
94
- :relation_type=>"References"},
95
- { :value=>"10.1371/JOURNAL.PONE.0115253",
96
- :related_identifier_type=>"DOI",
97
- :relation_type=>"References" }])
86
+ refs = subject.extract_references(html)
87
+ expect(refs).to eq(["https://www.w3.org/Provider/Style/URI", "https://doi.org/10.1371/journal.pone.0115253"])
98
88
  end
99
89
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bergamasco
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Fenner