Class: Fragile::Application

Inherits:
Object
  • Object
show all
Includes:
PipelineManager, PluginManager
Defined in:
lib/fragile/application.rb

Constant Summary collapse

DEFAULT_FILE_NAME =
"Pipefile"

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from PluginManager

#create_plugin

Methods included from PipelineManager

#define_pipeline, #pipeline_exist?, #pipelines, #run_pipeline

Constructor Details

#initializeApplication

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

#loggerObject (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_optionsObject



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 handle_options
  opts = OptionParser.new do |opts|
    opts.version = Fragile::VERSION
    opts.banner = "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_fileObject



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

#runObject



29
30
31
32
33
# File 'lib/fragile/application.rb', line 29

def run
  handle_options
  load_recipe_file
  run_pipeline(ARGV)
end