bolognese 0.6.1 → 0.6.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/bolognese/cli.rb +3 -25
- data/lib/bolognese/crossref.rb +2 -2
- data/lib/bolognese/utils.rb +17 -0
- data/lib/bolognese/version.rb +1 -1
- 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: 4c34a24e63743974fc6a09dca95d8dbdef85f592
|
4
|
+
data.tar.gz: a12199e846b5c1598e181126d6c20f9c40341a79
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b4fab385944d35dd6da5b1c39732e3196f88dc1c673e83ecc0c815256f66c2a8dd902fe6ea7eb9e8ff5f9dc0105a1cca3f17a68524a98b16e94ffbc99696202b
|
7
|
+
data.tar.gz: 75783a83adabd791461eefb29b5810f636b848c1578daeecff977a650820339ef3bb62cb718e1f9201e7c1d619ccbe5d18f8414a65e5f6897c88ababd737d118
|
data/Gemfile.lock
CHANGED
data/lib/bolognese/cli.rb
CHANGED
@@ -30,19 +30,8 @@ module Bolognese
|
|
30
30
|
def read(id)
|
31
31
|
id = normalize_id(id)
|
32
32
|
provider = find_provider(id)
|
33
|
-
output = options[:as] || "schema_org"
|
34
33
|
|
35
|
-
|
36
|
-
p = case provider
|
37
|
-
when "crossref" then Crossref.new(id: id)
|
38
|
-
when "datacite" then Datacite.new(id: id, schema_version: options[:schema_version])
|
39
|
-
else SchemaOrg.new(id: id)
|
40
|
-
end
|
41
|
-
|
42
|
-
puts p.send(output)
|
43
|
-
else
|
44
|
-
puts "not implemented"
|
45
|
-
end
|
34
|
+
set_metadata(id: id, provider: provider, as: options[:as], schema_version: options[:schema_version])
|
46
35
|
end
|
47
36
|
|
48
37
|
desc "open file", "read metadata from file"
|
@@ -54,22 +43,11 @@ module Bolognese
|
|
54
43
|
$stderr.puts "File type #{ext} not supported"
|
55
44
|
exit 1
|
56
45
|
end
|
46
|
+
|
57
47
|
string = IO.read(file)
|
58
48
|
provider = "bibtex"
|
59
|
-
output = options[:as] || "schema_org"
|
60
49
|
|
61
|
-
|
62
|
-
p = case provider
|
63
|
-
when "crossref" then Crossref.new(id: id)
|
64
|
-
when "datacite" then Datacite.new(id: id, schema_version: options[:schema_version])
|
65
|
-
when "bibtex" then Bibtex.new(string: string)
|
66
|
-
else SchemaOrg.new(id: id)
|
67
|
-
end
|
68
|
-
|
69
|
-
puts p.send(output)
|
70
|
-
else
|
71
|
-
puts "not implemented"
|
72
|
-
end
|
50
|
+
set_metadata(string: string, provider: provider, as: options[:as], schema_version: options[:schema_version])
|
73
51
|
end
|
74
52
|
end
|
75
53
|
end
|
data/lib/bolognese/crossref.rb
CHANGED
@@ -183,8 +183,8 @@ module Bolognese
|
|
183
183
|
end
|
184
184
|
|
185
185
|
def funder
|
186
|
-
|
187
|
-
Array.wrap(
|
186
|
+
fundref = Array.wrap(program_metadata).find { |a| a["name"] == "fundref" } || {}
|
187
|
+
Array.wrap(fundref.fetch("assertion", [])).select { |a| a["name"] == "fundgroup" }.map do |f|
|
188
188
|
{ "@type" => "Organization",
|
189
189
|
"@id" => normalize_id(f.dig("assertion", "assertion", "__content__")),
|
190
190
|
"name" => f.dig("assertion", "__content__").strip }.compact
|
data/lib/bolognese/utils.rb
CHANGED
@@ -1,5 +1,22 @@
|
|
1
1
|
module Bolognese
|
2
2
|
module Utils
|
3
|
+
def set_metadata(id: nil, string: nil, provider: nil, **options)
|
4
|
+
output = options[:as] || "schema_org"
|
5
|
+
|
6
|
+
if provider.present?
|
7
|
+
p = case provider
|
8
|
+
when "crossref" then Crossref.new(id: id)
|
9
|
+
when "datacite" then Datacite.new(id: id, schema_version: options[:schema_version])
|
10
|
+
when "bibtex" then Bibtex.new(string: string)
|
11
|
+
else SchemaOrg.new(id: id)
|
12
|
+
end
|
13
|
+
|
14
|
+
puts p.send(output)
|
15
|
+
else
|
16
|
+
puts "not implemented"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
3
20
|
def orcid_from_url(url)
|
4
21
|
Array(/\Ahttp:\/\/orcid\.org\/(.+)/.match(url)).last
|
5
22
|
end
|
data/lib/bolognese/version.rb
CHANGED