class TaxGenerator::Application
class used run the processsor
@!attribute opts
@return [Slop::Options] the options that are used for command line access
Attributes
opts[R]
Public Class Methods
app_logger()
click to toggle source
returns the logger used to log messages and errors
@return [Logger]
@api public
# File lib/tax_generator/application.rb, line 49 def self.app_logger @logger ||= Logger.new($stdout) end
new()
click to toggle source
method used to initialize the application, by initializing the options for command line access
@return [void]
@api public
# File lib/tax_generator/application.rb, line 20 def initialize @opts = Slop::Options.new @opts.banner = 'usage: tax_generator [options] ...' end
Public Instance Methods
directory_options()
click to toggle source
sets the directory options for command line access
@return [void]
@api public
# File lib/tax_generator/application.rb, line 70 def directory_options @opts.separator '' @opts.separator 'Directory options:' @opts.string '-i', '--input_dir', 'The input directory ', default: "#{root}/data/input" @opts.string '-o', '--output_dir', 'The ouput directory', default: "#{root}/data/output" end
file_options()
click to toggle source
sets the file options for command line access
@return [void]
@api public
# File lib/tax_generator/application.rb, line 82 def file_options @opts.separator '' @opts.separator 'Extra options:' @opts.string '-t', '--taxonomy_filename', 'The taxonomy file name', default: 'taxonomy.xml' @opts.string '-d', '--destinations_filename', 'The destinations file name', default: 'destinations.xml' end
parse_options()
click to toggle source
returns the options list as a hash after parsing command line arguments
@return [Hash]
@api public
# File lib/tax_generator/application.rb, line 58 def parse_options setup_command_line_options parser = Slop::Parser.new(@opts) result = parser.parse(ARGV.dup) result.to_hash end
run(options = {})
click to toggle source
receives a list of options that are used to determine the input files and output and input folders
@param [Hash] options the options that are used for command line access
@see execute_with_rescue
@see TaxGenerator::Processor#new @see TaxGenerator::Processor#work
@return [void]
@api public
# File lib/tax_generator/application.rb, line 36 def run(options = {}) execute_with_rescue do options = options.present? ? options : parse_options processor = TaxGenerator::Processor.new(options) processor.work end end
setup_command_line_options()
click to toggle source
sets the command line options
@return [void]
@api public
# File lib/tax_generator/application.rb, line 118 def setup_command_line_options directory_options file_options setup_version setup_help end
setup_help()
click to toggle source
sets the help menu for command line access
@return [void]
@api public
# File lib/tax_generator/application.rb, line 106 def setup_help @opts.on '--help', 'print the help' do puts @opts exit end end
setup_version()
click to toggle source
sets the version of the gem available to be displayed from command line
@return [void]
@api public
# File lib/tax_generator/application.rb, line 94 def setup_version @opts.on '--version', 'The destinations file name' do puts TaxGenerator.gem_version exit end end