Class: Fragile::Application

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

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.



21
22
23
24
25
# File 'lib/fragile/application.rb', line 21

def initialize
  @recipe_file = File.join(Dir.pwd, "Spcfile")
  @logger = Logger.new(STDOUT)
  @logger.level = Logger::WARN
end

Instance Attribute Details

#loggerObject (readonly)

Returns the value of attribute logger.



19
20
21
# File 'lib/fragile/application.rb', line 19

def logger
  @logger
end

Instance Method Details

#handle_optionsObject



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/fragile/application.rb', line 38

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



33
34
35
36
# File 'lib/fragile/application.rb', line 33

def load_recipe_file
  load @recipe_file
  self.logger.info "#{@recipe_file} was loaded."
end

#runObject



27
28
29
30
31
# File 'lib/fragile/application.rb', line 27

def run
  handle_options
  load_recipe_file
  run_pipeline(ARGV)
end