Class: Fragile::Application

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

Instance Attribute Summary collapse

Attributes included from PluginManager

#plugin_dir

Instance Method Summary collapse

Methods included from PluginManager

#create_plugin, #load_plugins

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
58
59
60
61
62
# File 'lib/fragile/application.rb', line 38

def handle_options
  opts = OptionParser.new
  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
    @plugin_dir ||= File.join(File::expand_path(File.dirname(@recipe_file)), "plugins")
  }
  opts.on("-p", "--plugindir=plugin_dir", "Plugin directory") { |v|
    @plugin_dir = File::expand_path(v)
  }
  opts.on("-V", "--verbose", "Show detail log") { |v| @logger.level = Logger::DEBUG }
  opts.parse!(ARGV)

  unless 0 < ARGV.count
    puts opts
    exit
  end
end

#load_recipe_fileObject



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

def load_recipe_file
  load @recipe_file
end

#runObject



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

def run
  handle_options
  load_plugins
  load_recipe_file
  run_pipeline(ARGV)
end