Class: TaxGenerator::Application
- Inherits:
-
Object
- Object
- TaxGenerator::Application
- Includes:
- ApplicationHelper
- Defined in:
- lib/tax_generator/application.rb
Overview
class used run the processsor
Instance Attribute Summary collapse
-
#opts ⇒ Slop::Options
The options that are used for command line access.
Class Method Summary collapse
-
.app_logger ⇒ Logger
returns the logger used to log messages and errors.
Instance Method Summary collapse
-
#directory_options ⇒ void
sets the directory options for command line access.
-
#file_options ⇒ void
sets the file options for command line access.
-
#initialize ⇒ void
constructor
method used to initialize the application, by initializing the options for command line access.
-
#parse_options ⇒ Hash
returns the options list as a hash after parsing command line arguments.
-
#run(options = {}) ⇒ void
receives a list of options that are used to determine the input files and output and input folders.
-
#setup_command_line_options ⇒ void
sets the command line options.
-
#setup_help ⇒ void
sets the help menu for command line access.
-
#setup_version ⇒ void
sets the version of the gem available to be displayed from command line.
Methods included from ApplicationHelper
create_directories, elements_with_content, erb_template, execute_with_rescue, format_error, log_error, log_message, nokogiri_xml, rescue_interrupt, root, set_celluloid_exception_handling
Constructor Details
#initialize ⇒ void
method used to initialize the application, by initializing the options for command line access
20 21 22 23 |
# File 'lib/tax_generator/application.rb', line 20 def initialize @opts = Slop::Options.new @opts. = 'usage: tax_generator [options] ...' end |
Instance Attribute Details
#opts ⇒ Slop::Options
Returns the options that are used for command line access.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/tax_generator/application.rb', line 8 class Application include TaxGenerator::ApplicationHelper attr_reader :opts # method used to initialize the application, by initializing the options for command line # access # # # @return [void] # # @api public def initialize @opts = Slop::Options.new @opts. = 'usage: tax_generator [options] ...' end # 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 def run( = {}) execute_with_rescue do = .present? ? : processor = TaxGenerator::Processor.new() processor.work end end # returns the logger used to log messages and errors # # @return [Logger] # # @api public def self.app_logger @logger ||= Logger.new($stdout) end # returns the options list as a hash after parsing command line arguments # # @return [Hash] # # @api public def parser = Slop::Parser.new(@opts) result = parser.parse(ARGV.dup) result.to_hash end # sets the directory options for command line access # # @return [void] # # @api public def @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 # sets the file options for command line access # # @return [void] # # @api public def @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 # sets the version of the gem available to be displayed from command line # # @return [void] # # @api public def setup_version @opts.on '--version', 'The destinations file name' do puts TaxGenerator.gem_version exit end end # sets the help menu for command line access # # @return [void] # # @api public def setup_help @opts.on '--help', 'print the help' do puts @opts exit end end # sets the command line options # # @return [void] # # @api public def setup_version setup_help end end |
Class Method Details
.app_logger ⇒ Logger
returns the logger used to log messages and errors
49 50 51 |
# File 'lib/tax_generator/application.rb', line 49 def self.app_logger @logger ||= Logger.new($stdout) end |
Instance Method Details
#directory_options ⇒ void
This method returns an undefined value.
sets the directory options for command line access
70 71 72 73 74 75 |
# File 'lib/tax_generator/application.rb', line 70 def @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 ⇒ void
This method returns an undefined value.
sets the file options for command line access
82 83 84 85 86 87 |
# File 'lib/tax_generator/application.rb', line 82 def @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 ⇒ Hash
returns the options list as a hash after parsing command line arguments
58 59 60 61 62 63 |
# File 'lib/tax_generator/application.rb', line 58 def parser = Slop::Parser.new(@opts) result = parser.parse(ARGV.dup) result.to_hash end |
#run(options = {}) ⇒ void
This method returns an undefined value.
receives a list of options that are used to determine the input files and output and input folders
36 37 38 39 40 41 42 |
# File 'lib/tax_generator/application.rb', line 36 def run( = {}) execute_with_rescue do = .present? ? : processor = TaxGenerator::Processor.new() processor.work end end |
#setup_command_line_options ⇒ void
This method returns an undefined value.
sets the command line options
118 119 120 121 122 123 |
# File 'lib/tax_generator/application.rb', line 118 def setup_version setup_help end |
#setup_help ⇒ void
This method returns an undefined value.
sets the help menu for command line access
106 107 108 109 110 111 |
# 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 ⇒ void
This method returns an undefined value.
sets the version of the gem available to be displayed from command line
94 95 96 97 98 99 |
# 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 |