Attempt to require the custom export class.

This commit is contained in:
Chris Lowder
2012-01-17 14:59:57 +00:00
parent d54b46806c
commit 84c49ae2b8
2 changed files with 4 additions and 1 deletions

View File

@@ -47,10 +47,13 @@ class Foreman::CLI < Thor
check_procfile!
begin
require "foreman/export/#{ format.tr('-', '_') }"
classy_format = classify(format)
formatter = constantize("Foreman::Export::#{ classy_format }")
rescue NameError => ex
error "Unknown export format: #{format} (no class Foreman::Export::#{ classy_format })."
rescue LoadError => ex
error "Unknown export format: #{format} (unable to load file 'foreman/export/#{ format.tr('-', '_') }')."
end
formatter.new(engine, options).export(location)

View File

@@ -51,7 +51,7 @@ describe "Foreman::CLI", :fakefs do
describe "with an invalid formatter" do
it "prints an error" do
mock_error(subject, "Unknown export format: invalidformatter.") do
mock_error(subject, "Unknown export format: invalidformatter (unable to load file 'foreman/export/invalidformatter').") do
subject.export("invalidformatter")
end
end