Skip to content

Commit

Permalink
by default don't show errors. #76
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Fenner committed Oct 15, 2019
1 parent 13a22fd commit d36e89d
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion lib/bolognese/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ def convert(input)
from: options[:from],
regenerate: options[:regenerate],
style: options[:style],
locale: options[:locale])
locale: options[:locale],
show_errors: options[:show_errors])
to = options[:to] || "schema_org"

if options[:show_errors] && !metadata.valid?
Expand Down
2 changes: 1 addition & 1 deletion lib/bolognese/metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module Bolognese
class Metadata
include Bolognese::MetadataUtils

attr_accessor :string, :from, :sandbox, :meta, :regenerate, :issue
attr_accessor :string, :from, :sandbox, :meta, :regenerate, :issue, :show_errors
attr_reader :doc, :page_start, :page_end
attr_writer :id, :provider_id, :client_id, :doi, :identifiers, :creators, :contributors, :titles, :publisher,
:rights_list, :dates, :publication_year, :volume, :url, :version_info,
Expand Down
2 changes: 1 addition & 1 deletion lib/bolognese/writers/codemeta_writer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module Bolognese
module Writers
module CodemetaWriter
def codemeta
return nil unless valid?
return nil unless valid? || show_errors

hsh = {
"@context" => id.present? ? "https://raw.githubusercontent.com/codemeta/codemeta/master/codemeta.jsonld" : nil,
Expand Down
4 changes: 2 additions & 2 deletions spec/readers/datacite_json_reader_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,15 @@

it "SoftwareSourceCode missing_comma" do
input = fixture_path + "datacite_software_missing_comma.json"
subject = Bolognese::Metadata.new(input: input, from: "datacite_json")
subject = Bolognese::Metadata.new(input: input, from: "datacite_json", show_errors: true)
expect(subject.valid?).to be false
expect(subject.errors).to eq(["expected comma, not a string at line 4, column 11 [parse.c:381]"])
expect(subject.codemeta).to be_nil
end

it "SoftwareSourceCode overlapping_keys" do
input = fixture_path + "datacite_software_overlapping_keys.json"
subject = Bolognese::Metadata.new(input: input, from: "datacite_json")
subject = Bolognese::Metadata.new(input: input, from: "datacite_json", show_errors: true)
expect(subject.valid?).to be false
expect(subject.errors).to eq(["The same key is defined more than once: id"])
expect(subject.codemeta).to be_nil
Expand Down

0 comments on commit d36e89d

Please sign in to comment.