bolognese 1.2.3 → 1.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 +4 -4
- data/Gemfile.lock +1 -1
- data/lib/bolognese/metadata.rb +8 -1
- data/lib/bolognese/readers/bibtex_reader.rb +1 -1
- data/lib/bolognese/readers/citeproc_reader.rb +1 -1
- data/lib/bolognese/readers/codemeta_reader.rb +1 -1
- data/lib/bolognese/readers/crossref_reader.rb +2 -2
- data/lib/bolognese/readers/datacite_reader.rb +1 -1
- data/lib/bolognese/readers/ris_reader.rb +1 -1
- data/lib/bolognese/readers/schema_org_reader.rb +1 -1
- data/lib/bolognese/utils.rb +1 -1
- data/lib/bolognese/version.rb +1 -1
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_crossref_metadata/mEDRA.yml +125 -0
- data/spec/readers/crossref_reader_spec.rb +16 -0
- data/spec/readers/schema_org_reader_spec.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b7dfdd5a4ed9f32ebdda67aaa28c592b045e9545d3b9fdcd42c9f0172171b95c
|
|
4
|
+
data.tar.gz: f60e08a85484127ffc5181669ed1c5fc60fd02200fb09b9064f1acca1801d434
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 29612aa1baaae799e0d6a25d6a35efb9ad2ce271511e032ae48f29a392aa41597f668854fda596f61aa27bced9fbe6382949a70719e0b9dc7e145e7aa33bb8ce
|
|
7
|
+
data.tar.gz: a931e3c075cfe2f1e67c5b4fe2a8784e579c74b12fb53771d4326ff26da2e59cf45d7872cf929d5b184ee46335e6ca23a62821ab281541b36f5913ebeb445e4b
|
data/Gemfile.lock
CHANGED
data/lib/bolognese/metadata.rb
CHANGED
|
@@ -17,10 +17,17 @@ module Bolognese
|
|
|
17
17
|
|
|
18
18
|
def initialize(input: nil, from: nil, **options)
|
|
19
19
|
id = normalize_id(input, options)
|
|
20
|
+
ra = nil
|
|
20
21
|
|
|
21
22
|
if id.present?
|
|
22
23
|
@from = from || find_from_format(id: id)
|
|
23
24
|
|
|
25
|
+
# mEDRA DOIs are found in the Crossref index
|
|
26
|
+
if @from == "medra"
|
|
27
|
+
@from = "crossref"
|
|
28
|
+
ra = "mEDRA"
|
|
29
|
+
end
|
|
30
|
+
|
|
24
31
|
# generate name for method to call dynamically
|
|
25
32
|
hsh = @from.present? ? send("get_" + @from, id: id, sandbox: options[:sandbox]) : {}
|
|
26
33
|
string = hsh.fetch("string", nil)
|
|
@@ -104,7 +111,7 @@ module Bolognese
|
|
|
104
111
|
@regenerate = options[:regenerate] || read_options.present?
|
|
105
112
|
|
|
106
113
|
# generate name for method to call dynamically
|
|
107
|
-
@meta = @from.present? ? send("read_" + @from, { string: string, sandbox: options[:sandbox], doi: options[:doi], id: id }.merge(read_options)) : {}
|
|
114
|
+
@meta = @from.present? ? send("read_" + @from, { string: string, sandbox: options[:sandbox], doi: options[:doi], id: id, ra: ra }.merge(read_options)) : {}
|
|
108
115
|
end
|
|
109
116
|
|
|
110
117
|
def id
|
|
@@ -27,7 +27,7 @@ module Bolognese
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
def read_bibtex(string: nil, **options)
|
|
30
|
-
read_options = ActiveSupport::HashWithIndifferentAccess.new(options.except(:doi, :id, :url, :sandbox, :validate))
|
|
30
|
+
read_options = ActiveSupport::HashWithIndifferentAccess.new(options.except(:doi, :id, :url, :sandbox, :validate, :ra))
|
|
31
31
|
|
|
32
32
|
meta = string.present? ? BibTeX.parse(string).first : OpenStruct.new
|
|
33
33
|
|
|
@@ -31,7 +31,7 @@ module Bolognese
|
|
|
31
31
|
return { "errors" => errors } if errors.present?
|
|
32
32
|
end
|
|
33
33
|
|
|
34
|
-
read_options = ActiveSupport::HashWithIndifferentAccess.new(options.except(:doi, :id, :url, :sandbox, :validate))
|
|
34
|
+
read_options = ActiveSupport::HashWithIndifferentAccess.new(options.except(:doi, :id, :url, :sandbox, :validate, :ra))
|
|
35
35
|
|
|
36
36
|
meta = string.present? ? Maremma.from_json(string) : {}
|
|
37
37
|
|
|
@@ -18,7 +18,7 @@ module Bolognese
|
|
|
18
18
|
return { "errors" => errors } if errors.present?
|
|
19
19
|
end
|
|
20
20
|
|
|
21
|
-
read_options = ActiveSupport::HashWithIndifferentAccess.new(options.except(:doi, :id, :url, :sandbox, :validate))
|
|
21
|
+
read_options = ActiveSupport::HashWithIndifferentAccess.new(options.except(:doi, :id, :url, :sandbox, :validate, :ra))
|
|
22
22
|
|
|
23
23
|
meta = string.present? ? Maremma.from_json(string) : {}
|
|
24
24
|
|
|
@@ -17,7 +17,7 @@ module Bolognese
|
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
def read_crossref(string: nil, **options)
|
|
20
|
-
read_options = ActiveSupport::HashWithIndifferentAccess.new(options.except(:doi, :id, :url, :sandbox, :validate))
|
|
20
|
+
read_options = ActiveSupport::HashWithIndifferentAccess.new(options.except(:doi, :id, :url, :sandbox, :validate, :ra))
|
|
21
21
|
|
|
22
22
|
if string.present?
|
|
23
23
|
m = Maremma.from_xml(string).dig("crossref_result", "query_result", "body", "query", "doi_record") || {}
|
|
@@ -125,7 +125,7 @@ module Bolognese
|
|
|
125
125
|
"funding_references" => crossref_funding_reference(program_metadata),
|
|
126
126
|
"publisher" => publisher,
|
|
127
127
|
"container" => container,
|
|
128
|
-
"agency" => "Crossref",
|
|
128
|
+
"agency" => agency = options[:ra] || "Crossref",
|
|
129
129
|
"related_identifiers" => related_identifiers,
|
|
130
130
|
"dates" => dates,
|
|
131
131
|
"publication_year" => publication_year,
|
|
@@ -47,7 +47,7 @@ module Bolognese
|
|
|
47
47
|
end
|
|
48
48
|
|
|
49
49
|
def read_datacite(string: nil, **options)
|
|
50
|
-
read_options = ActiveSupport::HashWithIndifferentAccess.new(options.except(:doi, :id, :url, :sandbox, :validate))
|
|
50
|
+
read_options = ActiveSupport::HashWithIndifferentAccess.new(options.except(:doi, :id, :url, :sandbox, :validate, :ra))
|
|
51
51
|
|
|
52
52
|
doc = Nokogiri::XML(string, nil, 'UTF-8', &:noblanks)
|
|
53
53
|
if read_options.present?
|
|
@@ -34,7 +34,7 @@ module Bolognese
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
def read_ris(string: nil, **options)
|
|
37
|
-
read_options = ActiveSupport::HashWithIndifferentAccess.new(options.except(:doi, :id, :url, :sandbox, :validate))
|
|
37
|
+
read_options = ActiveSupport::HashWithIndifferentAccess.new(options.except(:doi, :id, :url, :sandbox, :validate, :ra))
|
|
38
38
|
|
|
39
39
|
meta = ris_meta(string: string)
|
|
40
40
|
|
|
@@ -44,7 +44,7 @@ module Bolognese
|
|
|
44
44
|
return { "errors" => errors } if errors.present?
|
|
45
45
|
end
|
|
46
46
|
|
|
47
|
-
read_options = ActiveSupport::HashWithIndifferentAccess.new(options.except(:doi, :id, :url, :sandbox, :validate))
|
|
47
|
+
read_options = ActiveSupport::HashWithIndifferentAccess.new(options.except(:doi, :id, :url, :sandbox, :validate, :ra))
|
|
48
48
|
|
|
49
49
|
meta = string.present? ? Maremma.from_json(string) : {}
|
|
50
50
|
|
data/lib/bolognese/utils.rb
CHANGED
|
@@ -339,7 +339,7 @@ module Bolognese
|
|
|
339
339
|
|
|
340
340
|
if /\A(?:(http|https):\/(\/)?(dx\.)?(doi.org|handle.test.datacite.org)\/)?(doi:)?(10\.\d{4,5}\/.+)\z/.match(id)
|
|
341
341
|
ra = get_doi_ra(id)
|
|
342
|
-
%w(DataCite Crossref).include?(ra) ? ra.downcase : nil
|
|
342
|
+
%w(DataCite Crossref mEDRA).include?(ra) ? ra.downcase : nil
|
|
343
343
|
elsif /\A(?:(http|https):\/(\/)?orcid\.org\/)?(\d{4}-\d{4}-\d{4}-\d{3}[0-9X]+)\z/.match(id)
|
|
344
344
|
"orcid"
|
|
345
345
|
elsif /\A(http|https):\/(\/)?github\.com\/(.+)\z/.match(id)
|
data/lib/bolognese/version.rb
CHANGED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
---
|
|
2
|
+
http_interactions:
|
|
3
|
+
- request:
|
|
4
|
+
method: get
|
|
5
|
+
uri: https://doi.org/ra/10.3280
|
|
6
|
+
body:
|
|
7
|
+
encoding: US-ASCII
|
|
8
|
+
string: ''
|
|
9
|
+
headers:
|
|
10
|
+
User-Agent:
|
|
11
|
+
- Mozilla/5.0 (compatible; Maremma/4.2.3; mailto:info@datacite.org)
|
|
12
|
+
Accept:
|
|
13
|
+
- text/html,application/json,application/xml;q=0.9, text/plain;q=0.8,image/png,*/*;q=0.5
|
|
14
|
+
response:
|
|
15
|
+
status:
|
|
16
|
+
code: 200
|
|
17
|
+
message: ''
|
|
18
|
+
headers:
|
|
19
|
+
Date:
|
|
20
|
+
- Fri, 05 Jul 2019 05:04:20 GMT
|
|
21
|
+
Content-Type:
|
|
22
|
+
- application/json;charset=UTF-8
|
|
23
|
+
Content-Length:
|
|
24
|
+
- '51'
|
|
25
|
+
Connection:
|
|
26
|
+
- keep-alive
|
|
27
|
+
Set-Cookie:
|
|
28
|
+
- __cfduid=dbad314cd019b12966bb82d714cc7ff471562303060; expires=Sat, 04-Jul-20
|
|
29
|
+
05:04:20 GMT; path=/; domain=.doi.org; HttpOnly
|
|
30
|
+
Expect-Ct:
|
|
31
|
+
- max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
|
|
32
|
+
Server:
|
|
33
|
+
- cloudflare
|
|
34
|
+
Cf-Ray:
|
|
35
|
+
- 4f16cc2e48b4a867-CDG
|
|
36
|
+
body:
|
|
37
|
+
encoding: ASCII-8BIT
|
|
38
|
+
string: |-
|
|
39
|
+
[
|
|
40
|
+
{
|
|
41
|
+
"DOI": "10.3280",
|
|
42
|
+
"RA": "mEDRA"
|
|
43
|
+
}
|
|
44
|
+
]
|
|
45
|
+
http_version:
|
|
46
|
+
recorded_at: Fri, 05 Jul 2019 05:04:20 GMT
|
|
47
|
+
- request:
|
|
48
|
+
method: get
|
|
49
|
+
uri: https://api.crossref.org/works/10.3280/ecag2018-001005/transform/application/vnd.crossref.unixsd+xml
|
|
50
|
+
body:
|
|
51
|
+
encoding: US-ASCII
|
|
52
|
+
string: ''
|
|
53
|
+
headers:
|
|
54
|
+
User-Agent:
|
|
55
|
+
- Mozilla/5.0 (compatible; Maremma/4.2.3; mailto:info@datacite.org)
|
|
56
|
+
Accept:
|
|
57
|
+
- text/xml
|
|
58
|
+
response:
|
|
59
|
+
status:
|
|
60
|
+
code: 200
|
|
61
|
+
message: OK
|
|
62
|
+
headers:
|
|
63
|
+
Link:
|
|
64
|
+
- <http://dx.doi.org/10.3280/ecag2018-001005>; rel="canonical"
|
|
65
|
+
Access-Control-Allow-Origin:
|
|
66
|
+
- "*"
|
|
67
|
+
Access-Control-Allow-Headers:
|
|
68
|
+
- X-Requested-With
|
|
69
|
+
Content-Length:
|
|
70
|
+
- '3506'
|
|
71
|
+
Server:
|
|
72
|
+
- http-kit
|
|
73
|
+
Date:
|
|
74
|
+
- Fri, 05 Jul 2019 05:04:20 GMT
|
|
75
|
+
X-Rate-Limit-Limit:
|
|
76
|
+
- '50'
|
|
77
|
+
X-Rate-Limit-Interval:
|
|
78
|
+
- 1s
|
|
79
|
+
Connection:
|
|
80
|
+
- close
|
|
81
|
+
body:
|
|
82
|
+
encoding: ASCII-8BIT
|
|
83
|
+
string: "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<crossref_result xmlns=\"http://www.crossref.org/qrschema/3.0\"
|
|
84
|
+
version=\"3.0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.crossref.org/qrschema/3.0
|
|
85
|
+
http://www.crossref.org/schemas/crossref_query_output3.0.xsd\">\r\n <query_result>\r\n
|
|
86
|
+
\ <head>\r\n <doi_batch_id>none</doi_batch_id>\r\n </head>\r\n <body>\r\n
|
|
87
|
+
\ <query status=\"resolved\">\r\n <doi type=\"journal_article\">10.3280/ECAG2018-001005</doi>\r\n
|
|
88
|
+
\ <crm-item name=\"publisher-name\" type=\"string\">Franco Angeli</crm-item>\r\n
|
|
89
|
+
\ <crm-item name=\"prefix-name\" type=\"string\">Franco Angeli</crm-item>\r\n
|
|
90
|
+
\ <crm-item name=\"member-id\" type=\"number\">4169</crm-item>\r\n <crm-item
|
|
91
|
+
name=\"citation-id\" type=\"number\">98889375</crm-item>\r\n <crm-item
|
|
92
|
+
name=\"journal-id\" type=\"number\">215305</crm-item>\r\n <crm-item
|
|
93
|
+
name=\"deposit-timestamp\" type=\"number\">20180712142055000</crm-item>\r\n
|
|
94
|
+
\ <crm-item name=\"owner-prefix\" type=\"string\">10.3280</crm-item>\r\n
|
|
95
|
+
\ <crm-item name=\"last-update\" type=\"date\">2018-10-18T14:30:29Z</crm-item>\r\n
|
|
96
|
+
\ <crm-item name=\"created\" type=\"date\">2018-06-07T09:40:49Z</crm-item>\r\n
|
|
97
|
+
\ <crm-item name=\"citedby-count\" type=\"number\">1</crm-item>\r\n
|
|
98
|
+
\ <doi_record>\r\n <crossref xmlns=\"http://www.crossref.org/xschema/1.1\"
|
|
99
|
+
xsi:schemaLocation=\"http://www.crossref.org/xschema/1.1 http://doi.crossref.org/schemas/unixref1.1.xsd\">\r\n
|
|
100
|
+
\ <journal>\r\n <journal_metadata>\r\n <full_title>ECONOMIA
|
|
101
|
+
AGRO-ALIMENTARE</full_title>\r\n <issn media_type=\"print\">1126-1668</issn>\r\n
|
|
102
|
+
\ <issn media_type=\"electronic\">1972-4802</issn>\r\n </journal_metadata>\r\n
|
|
103
|
+
\ <journal_issue>\r\n <publication_date>\r\n <month>05</month>\r\n
|
|
104
|
+
\ <year>2018</year>\r\n </publication_date>\r\n
|
|
105
|
+
\ <issue>1</issue>\r\n </journal_issue>\r\n <journal_article
|
|
106
|
+
language=\"en\">\r\n <titles>\r\n <title>Substitutability
|
|
107
|
+
between organic and conventional poultry products and organic price premiums</title>\r\n
|
|
108
|
+
\ </titles>\r\n <contributors>\r\n <person_name
|
|
109
|
+
contributor_role=\"author\" sequence=\"first\">\r\n <given_name>Sohae
|
|
110
|
+
Eve</given_name>\r\n <surname>Oh</surname>\r\n </person_name>\r\n
|
|
111
|
+
\ <person_name contributor_role=\"author\" sequence=\"additional\">\r\n
|
|
112
|
+
\ <given_name>Tomislav</given_name>\r\n <surname>Vukina</surname>\r\n
|
|
113
|
+
\ </person_name>\r\n </contributors>\r\n <publication_date>\r\n
|
|
114
|
+
\ <month>05</month>\r\n <year>2018</year>\r\n
|
|
115
|
+
\ </publication_date>\r\n <pages>\r\n <first_page>75</first_page>\r\n
|
|
116
|
+
\ <last_page>92</last_page>\r\n </pages>\r\n
|
|
117
|
+
\ <publisher_item>\r\n <item_number item_number_type=\"article_number\">5</item_number>\r\n
|
|
118
|
+
\ </publisher_item>\r\n <doi_data>\r\n <doi>10.3280/ECAG2018-001005</doi>\r\n
|
|
119
|
+
\ <resource>http://www.francoangeli.it/riviste/Scheda_Riviste.asp?IDArticolo=61645</resource>\r\n
|
|
120
|
+
\ </doi_data>\r\n </journal_article>\r\n </journal>\r\n
|
|
121
|
+
\ </crossref>\r\n </doi_record>\r\n </query>\r\n </body>\r\n
|
|
122
|
+
\ </query_result>\r\n</crossref_result>"
|
|
123
|
+
http_version:
|
|
124
|
+
recorded_at: Fri, 05 Jul 2019 05:04:21 GMT
|
|
125
|
+
recorded_with: VCR 3.0.3
|
|
@@ -225,6 +225,22 @@ describe Bolognese::Metadata, vcr: true do
|
|
|
225
225
|
expect(subject.agency).to eq("Crossref")
|
|
226
226
|
end
|
|
227
227
|
|
|
228
|
+
it "mEDRA" do
|
|
229
|
+
input = "https://doi.org/10.3280/ecag2018-001005"
|
|
230
|
+
subject = Bolognese::Metadata.new(input: input)
|
|
231
|
+
expect(subject.valid?).to be true
|
|
232
|
+
expect(subject.identifiers).to eq([{"identifier"=>"https://doi.org/10.3280/ecag2018-001005", "identifierType"=>"DOI"}, {"identifier"=>"5", "identifierType"=>"Publisher ID"}])
|
|
233
|
+
expect(subject.url).to eq("http://www.francoangeli.it/riviste/Scheda_Riviste.asp?IDArticolo=61645")
|
|
234
|
+
expect(subject.types).to eq("bibtex"=>"article", "citeproc"=>"article-journal", "resourceType"=>"JournalArticle", "resourceTypeGeneral"=>"Text", "ris"=>"JOUR", "schemaOrg"=>"ScholarlyArticle")
|
|
235
|
+
expect(subject.creators.length).to eq(2)
|
|
236
|
+
expect(subject.creators.first).to eq("familyName"=>"Oh", "givenName"=>"Sohae Eve", "name"=>"Oh, Sohae Eve", "nameType"=>"Personal")
|
|
237
|
+
expect(subject.titles).to eq([{"title"=>"Substitutability between organic and conventional poultry products and organic price premiums"}])
|
|
238
|
+
expect(subject.dates).to eq([{"date"=>"2018-05", "dateType"=>"Issued"}, {"date"=>"2018-10-18T14:30:29Z", "dateType"=>"Updated"}])
|
|
239
|
+
expect(subject.publication_year).to eq("2018")
|
|
240
|
+
expect(subject.publisher).to eq("Franco Angeli")
|
|
241
|
+
expect(subject.agency).to eq("mEDRA")
|
|
242
|
+
end
|
|
243
|
+
|
|
228
244
|
it "multiple titles" do
|
|
229
245
|
input = "https://doi.org/10.4000/dms.865"
|
|
230
246
|
subject = Bolognese::Metadata.new(input: input)
|
|
@@ -181,7 +181,7 @@ describe Bolognese::Metadata, vcr: true do
|
|
|
181
181
|
input = fixture_path + 'schema_org_tdl_iodp_invalid_authors.json'
|
|
182
182
|
subject = Bolognese::Metadata.new(input: input)
|
|
183
183
|
expect(subject.valid?).to be false
|
|
184
|
-
|
|
184
|
+
end
|
|
185
185
|
|
|
186
186
|
it "geolocation" do
|
|
187
187
|
input = fixture_path + 'schema_org_geolocation.json'
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: bolognese
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.2.
|
|
4
|
+
version: 1.2.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Martin Fenner
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2019-07-
|
|
11
|
+
date: 2019-07-05 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: maremma
|
|
@@ -825,6 +825,7 @@ files:
|
|
|
825
825
|
- spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_crossref_metadata/date_in_future.yml
|
|
826
826
|
- spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_crossref_metadata/journal_article.yml
|
|
827
827
|
- spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_crossref_metadata/journal_article_with.yml
|
|
828
|
+
- spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_crossref_metadata/mEDRA.yml
|
|
828
829
|
- spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_crossref_metadata/missing_creator.yml
|
|
829
830
|
- spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_crossref_metadata/multiple_t.yml
|
|
830
831
|
- spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_crossref_metadata/multiple_titles.yml
|