Class: Upstart::Exporter

Inherits:
Object
  • Object
show all
Includes:
Errors, ExporterHelpers
Defined in:
lib/upstart-exporter.rb,
lib/upstart-exporter/version.rb,
lib/upstart-exporter/templates.rb,
lib/upstart-exporter/exporter_helpers.rb,
lib/upstart-exporter/expanded_exporter.rb

Defined Under Namespace

Modules: Errors, ExporterHelpers, Options Classes: Error, ExpandedExporter, Templates

Constant Summary collapse

VERSION =
"2.1.1"

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ExporterHelpers

#app_cmd, #app_name, #export_cmd_helper, #helper_cmd_conf, #upstart_cmd_conf

Methods included from Errors

#error

Constructor Details

#initialize(command_line_args) ⇒ Exporter

Returns a new instance of Exporter.



17
18
19
20
21
22
# File 'lib/upstart-exporter.rb', line 17

def initialize(command_line_args)
  global_options = Options::Global.new
  command_line_options = Options::CommandLine.new(command_line_args)
  @options = global_options.merge(command_line_options)
  ensure_dirs
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



15
16
17
# File 'lib/upstart-exporter.rb', line 15

def options
  @options
end

Instance Method Details

#clearObject



36
37
38
39
40
41
42
43
44
# File 'lib/upstart-exporter.rb', line 36

def clear
  FileUtils.rm(upstart_conf) if FileTest.file?(upstart_conf)
  Dir[upstart_cmd_conf('*')].each do |f|
    FileUtils.rm(f)
  end
  Dir[helper_cmd_conf('*')].each do |f|
    FileUtils.rm(f)
  end
end

#exportObject



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/upstart-exporter.rb', line 24

def export
  clear
  export_app
  if options[:commands]['version'] && options[:commands]['version'] == 2
    ExpandedExporter.export(options)
  else
    options[:commands].each do |cmd_name, cmd|
      export_command(cmd_name, cmd)
    end
  end
end