Class: Fragile::Application
- Inherits:
-
Object
- Object
- Fragile::Application
- Includes:
- PipelineManager, PluginManager
- Defined in:
- lib/fragile/application.rb
Constant Summary collapse
- DEFAULT_FILE_NAME =
"Pipefile"
Instance Attribute Summary collapse
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
Instance Method Summary collapse
- #handle_options ⇒ Object
-
#initialize ⇒ Application
constructor
A new instance of Application.
- #load_recipe_file ⇒ Object
- #run ⇒ Object
Methods included from PluginManager
Methods included from PipelineManager
#define_pipeline, #pipeline_exist?, #pipelines, #run_pipeline
Constructor Details
#initialize ⇒ Application
Returns a new instance of Application.
23 24 25 26 27 |
# File 'lib/fragile/application.rb', line 23 def initialize @recipe_file = File.join(Dir.pwd, DEFAULT_FILE_NAME) @logger = Logger.new(STDOUT) @logger.level = Logger::WARN end |
Instance Attribute Details
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
21 22 23 |
# File 'lib/fragile/application.rb', line 21 def logger @logger end |
Instance Method Details
#handle_options ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/fragile/application.rb', line 40 def opts = OptionParser.new do |opts| opts.version = Fragile::VERSION opts. = "fragile [-f RECIPE_FILE] {options} targets..." opts.separator "" opts.separator "Options are ..." opts.on_tail("-h", "--help", "-H", "Display this help message.") do puts opts exit end opts.on("-f", "--recipefile=RECIPE_FILE", "Recipe file path"){|v| @recipe_file = v} opts.on("-V", "--verbose", "Show detail log"){|v| @logger.level = Logger::DEBUG} end opts.parse!(ARGV) unless 0 < ARGV.count puts opts exit end end |
#load_recipe_file ⇒ Object
35 36 37 38 |
# File 'lib/fragile/application.rb', line 35 def load_recipe_file load @recipe_file self.logger.info "#{@recipe_file} was loaded." end |
#run ⇒ Object
29 30 31 32 33 |
# File 'lib/fragile/application.rb', line 29 def run load_recipe_file run_pipeline(ARGV) end |