diff --git a/lib/converter.rb b/lib/converter.rb index c2d42f5..94ad346 100644 --- a/lib/converter.rb +++ b/lib/converter.rb @@ -16,11 +16,12 @@ def initialize storage_dir: C_.storage_directory, logger: Logger.new(C_.conversi # @param version [String] the file version # @param filename [String] the name of the file to convert # @param action [String] the conversion to perform + # @param language [String] the file's language (defaults to 'en') # @return the converted file name - def convert doc_key, version, filename, action + def convert doc_key, version, filename, action, language=nil + language ||= 'en' doc = Document.load @storage_dir, doc_key ignore, orig_content = doc.get_file( version, filename) - language = 'en' # TODO - add to spec and upload new_content = convert_file action, orig_content, language # TODO - handling for variant formats with the same extension # probably by adding format info before suffix @@ -34,9 +35,10 @@ def convert doc_key, version, filename, action # Converts the supplied content. Nothing gets saved. # @param action [String] the conversion to perform # @param orig_content [String] the body of the file to convert - # @param language [String] the file's language + # @param language [String] the file's language (defaults to 'en') # @return [String] the converted file body - def convert_file action, orig_content, language='en' + def convert_file action, orig_content, language=nil + language ||= 'en' Heathen::Converter.new(logger:@logger).convert(action, orig_content, language) rescue Heathen::TaskNotFound => e raise InvalidAction.new( e.message ) diff --git a/lib/heathen/converter.rb b/lib/heathen/converter.rb index 11f064f..a82932d 100644 --- a/lib/heathen/converter.rb +++ b/lib/heathen/converter.rb @@ -13,7 +13,8 @@ def initialize( logger: Logger.new(nil) ) # @param content [String] the document body to be converted # @param language [String] the document langauge (defaults to 'en') # @return [String] the converted document body - def convert action, content, language='en' + def convert action, content, language=nil + language ||= 'en' job = Job.new action, content, language processor = Heathen::Processor.new job: job, logger: @logger begin diff --git a/lib/heathen/job.rb b/lib/heathen/job.rb index f1ee116..de5e4f9 100644 --- a/lib/heathen/job.rb +++ b/lib/heathen/job.rb @@ -23,11 +23,11 @@ class Job # Constructs a new job # @param action [String] the action to be performed # @param content [String] the file body - # @param language [String] the file's language + # @param language [String] the file's language (defaults to 'en') # @param sandbox_dir [String] sandbox directory for temporary files - def initialize action, content, language='en', sandbox_dir=nil + def initialize action, content, language=nil, sandbox_dir=nil @action = action - @language = language + @language = language || 'en' @original_content = content @original_mime_type = content.mime_type self.content = @original_content diff --git a/lib/legacy_converter.rb b/lib/legacy_converter.rb index 8c7101d..2a0513e 100644 --- a/lib/legacy_converter.rb +++ b/lib/legacy_converter.rb @@ -23,9 +23,10 @@ def initialize storage_dir = C_.storage_directory # Converts the given file and stores it in the legacy directory # @param action [String] the conversion to perform # @param orig_content [String] the body of the file to convert - # @param language [String] the file's language + # @param language [String] the file's language (defaults to 'en') # @return [String] the path to the converted file - def convert_file action, orig_content, language='en' + def convert_file action, orig_content, language=nil + language ||= 'en' content = Heathen::Converter.new.convert(action, orig_content, language) filename = Digest::SHA2.hexdigest content store_file filename, content