bolognese 1.3.22 → 1.3.23

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
  SHA256:
3
- metadata.gz: 6f0b3ae062da59208e0933c28aa7fc266c158e5ded512fc498e07b55898713e4
4
- data.tar.gz: e9202fc2dc2a88cbbc258e7081c1a25f4197f970a9f126c63d42fbdef9521a02
3
+ metadata.gz: 38e5618ef936043343d626fd3d2132f434b77d6a3d804050729298d9802d229f
4
+ data.tar.gz: 5bdcf0488f713a428f5a233b2c1e6609530bf235dd04f63230b79573ca99b308
5
5
  SHA512:
6
- metadata.gz: a3fc245466c70cdc2851c8419a79d807281f7b3413ae9b77816b32136f87a36b61ee4f74254a41352d5f27de9dc01492d95e9bf9addc822c39ae6c5f4f610cf8
7
- data.tar.gz: 4c4f11a09dc1d0f6fee3ec0011f7e1bcdd1f58818b4acf36ae4d0761cfaa20c06b671f3efea02bd3a1bb3dcb90eaa42dde249a1af510c1b25713c8b165bef26d
6
+ metadata.gz: e240077996789a428a196e177791aa01b619277fd85795ac0d39afe31c6e91519d175bf8f8673788d1f506bad01b11ee8b8ec0ff3a54d3c9d35e2226d8a01623
7
+ data.tar.gz: d700ea3fce0f63573f03e71bb8107f7c5e5fee4fa8fe9eba2797f6e2aaf056444009b6d37507d2238e8e72eeea2b15fb7ca6ab3358a184dbaf084ece83828f9b
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bolognese (1.3.22)
4
+ bolognese (1.3.23)
5
5
  activesupport (>= 4.2.5, < 6)
6
6
  benchmark_methods (~> 0.7)
7
7
  bibtex-ruby (~> 4.1)
@@ -50,7 +50,7 @@ GEM
50
50
  concurrent-ruby (1.0.5)
51
51
  crack (0.4.3)
52
52
  safe_yaml (~> 1.0.0)
53
- crass (1.0.4)
53
+ crass (1.0.5)
54
54
  csl (1.5.0)
55
55
  namae (~> 1.0)
56
56
  csl-styles (1.0.1.9)
@@ -37,6 +37,7 @@ module Bolognese
37
37
  hsh = @from.present? ? send("get_" + @from, id: id, sandbox: options[:sandbox]) : {}
38
38
  string = hsh.fetch("string", nil)
39
39
  elsif input.present? && File.exist?(input)
40
+ filename = File.basename(input)
40
41
  ext = File.extname(input)
41
42
  if %w(.bib .ris .xml .json).include?(ext)
42
43
  hsh = {
@@ -48,7 +49,7 @@ module Bolognese
48
49
  "client_id" => options[:client_id],
49
50
  "content_url" => options[:content_url] }
50
51
  string = IO.read(input)
51
- @from = from || find_from_format(string: string, ext: ext)
52
+ @from = from || find_from_format(string: string, filename: filename, ext: ext)
52
53
  else
53
54
  $stderr.puts "File type #{ext} not supported"
54
55
  exit 1
@@ -322,11 +322,11 @@ module Bolognese
322
322
  "WebSite" => "misc"
323
323
  }
324
324
 
325
- def find_from_format(id: nil, string: nil, ext: nil)
325
+ def find_from_format(id: nil, string: nil, ext: nil, filename: nil)
326
326
  if id.present?
327
327
  find_from_format_by_id(id)
328
328
  elsif ext.present?
329
- find_from_format_by_ext(string, ext: ext)
329
+ find_from_format_by_filename(filename) || find_from_format_by_ext(string, ext: ext)
330
330
  elsif string.present?
331
331
  find_from_format_by_string(string)
332
332
  else
@@ -349,6 +349,12 @@ module Bolognese
349
349
  end
350
350
  end
351
351
 
352
+ def find_from_format_by_filename(filename)
353
+ if filename == "package.json"
354
+ "npm"
355
+ end
356
+ end
357
+
352
358
  def find_from_format_by_ext(string, options={})
353
359
  if options[:ext] == ".bib"
354
360
  "bibtex"
@@ -1,3 +1,3 @@
1
1
  module Bolognese
2
- VERSION = "1.3.22"
2
+ VERSION = "1.3.23"
3
3
  end
@@ -5,10 +5,10 @@ module Bolognese
5
5
  module CodemetaWriter
6
6
  def codemeta
7
7
  return nil unless valid? || show_errors
8
-
8
+
9
9
  hsh = {
10
10
  "@context" => id.present? ? "https://raw.githubusercontent.com/codemeta/codemeta/master/codemeta.jsonld" : nil,
11
- "@type" => types["schemaOrg"],
11
+ "@type" => types.present? ? types["schemaOrg"] : nil,
12
12
  "@id" => normalize_doi(doi),
13
13
  "identifier" => to_schema_org_identifiers(identifiers),
14
14
  "codeRepository" => url,
@@ -5,11 +5,11 @@ module Bolognese
5
5
  module SchemaOrgWriter
6
6
  def schema_hsh
7
7
  { "@context" => "http://schema.org",
8
- "@type" => types["schemaOrg"],
8
+ "@type" => types.present? ? types["schemaOrg"] : nil,
9
9
  "@id" => normalize_doi(doi),
10
10
  "identifier" => to_schema_org_identifiers(identifiers),
11
11
  "url" => url,
12
- "additionalType" => types["resourceType"],
12
+ "additionalType" => types.present? ? types["resourceType"] : nil,
13
13
  "name" => parse_attributes(titles, content: "title", first: true),
14
14
  "author" => to_schema_org_creators(creators),
15
15
  "editor" => to_schema_org_contributors(contributors),
@@ -35,8 +35,8 @@ module Bolognese
35
35
  "@reverse" => reverse.presence,
36
36
  "contentUrl" => Array.wrap(content_url).unwrap,
37
37
  "schemaVersion" => schema_version,
38
- "periodical" => (types["schemaOrg"] != "Dataset") && container.present? ? to_schema_org(container) : nil,
39
- "includedInDataCatalog" => (types["schemaOrg"] == "Dataset") && container.present? ? to_schema_org_container(container, type: "Dataset") : nil,
38
+ "periodical" => types.present? ? ((types["schemaOrg"] != "Dataset") && container.present? ? to_schema_org(container) : nil) : nil,
39
+ "includedInDataCatalog" => types.present? ? ((types["schemaOrg"] == "Dataset") && container.present? ? to_schema_org_container(container, type: "Dataset") : nil) : nil,
40
40
  "publisher" => publisher.present? ? { "@type" => "Organization", "name" => publisher } : nil,
41
41
  "funder" => to_schema_org_funder(funding_references),
42
42
  "provider" => agency.present? ? { "@type" => "Organization", "name" => agency } : nil
@@ -50,6 +50,17 @@ describe Bolognese::CLI do
50
50
  end
51
51
  end
52
52
 
53
+ context "find_from_format_by_filename" do
54
+ let(:subject) do
55
+ described_class.new
56
+ end
57
+
58
+ it "npm" do
59
+ filename = "package.json"
60
+ expect(subject.find_from_format_by_filename(filename)).to eq("npm")
61
+ end
62
+ end
63
+
53
64
  context "find_from_format_by_string" do
54
65
  let(:subject) do
55
66
  described_class.new
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.3.22
4
+ version: 1.3.23
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-10-15 00:00:00.000000000 Z
11
+ date: 2019-10-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: maremma