Class: Options
- Inherits:
-
Object
- Object
- Options
- Defined in:
- lib/it_tools/options.rb
Instance Attribute Summary collapse
-
#log ⇒ Object
Returns the value of attribute log.
-
#options ⇒ Object
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize(ops = {}) ⇒ Options
constructor
A new instance of Options.
Constructor Details
#initialize(ops = {}) ⇒ Options
Returns a new instance of Options.
6 7 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 |
# File 'lib/it_tools/options.rb', line 6 def initialize(ops = {}) @options = {} .merge! ops @log = Logger.new('log.txt') if level = @options[:debug_level] @log.level = level else @log.level = Logger::DEBUG end optparse = OptionParser.new do |opts| opts. = "Usage: pub -e <environment_to_publish_to>" @options[:debug] = false opts.on( '-d', '--debug', 'Turn on program debugging' ) do |level| [:debug] = true [:debug_level] = level end @options[:verbose] = false opts.on( '-v', '--verbose', 'Output more information' ) do @options[:verbose] = true end @options[:environment] = 'loc' opts.on( '-e', '--environment ENV', 'Publish to environment ENV. REQUIRED.' ) do |env| [:environment] = env end @options[:indexer_url] = nil opts.on( '-i', '--indexer_ulr URL', 'Submit docs to indexer with url: URL' ) do |solr_base_url| [:indexer_url] = solr_base_url end @options[:source_folder] = '.' opts.on( '-s', '--source_folder FOLDER', 'Use FOLDER as source of artifact to deploy.') do |source_folder| [:source_folder] = source_folder end opts.on( '-h', '--help', 'Display this screen' ) do puts opts exit end end optparse.parse! @log.debug "Deploying to #{[:environment]} environment." if @options[:debug] end |
Instance Attribute Details
#log ⇒ Object
Returns the value of attribute log.
5 6 7 |
# File 'lib/it_tools/options.rb', line 5 def log @log end |
#options ⇒ Object
Returns the value of attribute options.
5 6 7 |
# File 'lib/it_tools/options.rb', line 5 def @options end |