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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2a97afd214e3aceac748c30b3b350d230eca0dfb
4
- data.tar.gz: 80436c321a4cd0655fd44a2b7648280251e6869b
3
+ metadata.gz: 4c34a24e63743974fc6a09dca95d8dbdef85f592
4
+ data.tar.gz: a12199e846b5c1598e181126d6c20f9c40341a79
5
5
  SHA512:
6
- metadata.gz: a2e388b9fb5f4e59ff38874bb1370483d3bc2f79ea1b156fcd95c0b11949c06d4786b3308ea7fca169d88eadba9a99a7cc1b272bfd4494a537a9ba2f0f435456
7
- data.tar.gz: 3a9f34c02b0c261a1e0ee2c17f6cffaf0be849b30580892ff01ba7af811499135857e368cd499eb584ae0a7d61bee98ce3bb72454ecf4c04ce620a3b46d0c0db
6
+ metadata.gz: b4fab385944d35dd6da5b1c39732e3196f88dc1c673e83ecc0c815256f66c2a8dd902fe6ea7eb9e8ff5f9dc0105a1cca3f17a68524a98b16e94ffbc99696202b
7
+ data.tar.gz: 75783a83adabd791461eefb29b5810f636b848c1578daeecff977a650820339ef3bb62cb718e1f9201e7c1d619ccbe5d18f8414a65e5f6897c88ababd737d118
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bolognese (0.6.1)
4
+ bolognese (0.6.2)
5
5
  activesupport (~> 4.2, >= 4.2.5)
6
6
  bibtex-ruby (~> 4.1)
7
7
  builder (~> 3.2, >= 3.2.2)
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
- if provider.present?
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
- if provider.present?
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
@@ -183,8 +183,8 @@ module Bolognese
183
183
  end
184
184
 
185
185
  def funder
186
- f = Array.wrap(program_metadata).find { |a| a["name"] == "fundref" } || {}
187
- Array.wrap(f.fetch("assertion", [])).select { |a| a["name"] == "fundgroup" }.map do |f|
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
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Bolognese
2
- VERSION = "0.6.1"
2
+ VERSION = "0.6.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bolognese
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Fenner