Skip to content

Commit

Permalink
by default don't show validation errors. #76
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Fenner committed Oct 15, 2019
1 parent 5c451c1 commit 559d6fa
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions lib/bolognese/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def __print_version
method_option :regenerate, :type => :boolean, :force => false
method_option :style, aliases: "-s", default: "apa"
method_option :locale, aliases: "-l", default: "en-US"
method_option :ignore_errors, aliases: "-e", default: nil
method_option :show_errors, :type => :boolean, :force => false
def convert(input)
metadata = Metadata.new(input: input,
from: options[:from],
Expand All @@ -38,10 +38,10 @@ def convert(input)
locale: options[:locale])
to = options[:to] || "schema_org"

if metadata.valid? || options[:ignore_errors]
puts metadata.send(to)
else
if options[:show_errors] && !metadata.valid?
$stderr.puts metadata.errors
else
puts metadata.send(to)
end
end

Expand Down
4 changes: 2 additions & 2 deletions spec/cli_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -180,13 +180,13 @@

it 'to datacite invalid' do
file = fixture_path + "datacite_missing_creator.xml"
subject.options = { to: "datacite" }
subject.options = { to: "datacite", show_errors: "true" }
expect { subject.convert file }.to output("4:0: ERROR: Element '{http://datacite.org/schema/kernel-4}creators': Missing child element(s). Expected is ( {http://datacite.org/schema/kernel-4}creator ).\n").to_stderr
end

it 'to datacite invalid ignore errors' do
file = fixture_path + "datacite_missing_creator.xml"
subject.options = { to: "datacite", ignore_errors: "true" }
subject.options = { to: "datacite" }
expect { subject.convert file }.to output(/http:\/\/datacite.org\/schema\/kernel-4/).to_stdout
end
end
Expand Down

0 comments on commit 559d6fa

Please sign in to comment.