Class: Rctl::Ctl

Inherits:
Object
  • Object
show all
Defined in:
lib/rctl.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Ctl

Returns a new instance of Ctl.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/rctl.rb', line 8

def initialize(options = {})
  if(options[:config])
    @commands = YAML.load_file(options[:config])
  else
    if(!File.exists? "~/.rctl.rc.yml")
      @commands = YAML.load_file(Pathname(__FILE__) + '../rctl/default_config.yml')
      File.open(File.expand_path("~/.rctl.rc.yml"), 'w') do |file|
        YAML.dump(@commands, file)
      end
    else
      @commands = YAML.load_file("~/.rctl.rc.yml")
    end
  end
  @start_order = define_start_order
end

Instance Attribute Details

#commandsObject (readonly)

Returns the value of attribute commands.



6
7
8
# File 'lib/rctl.rb', line 6

def commands
  @commands
end

Instance Method Details

#generate(command = :start, services = {}) ⇒ Object

launch command on selected services. return 0 if everything went ok.



26
27
28
# File 'lib/rctl.rb', line 26

def generate(command = :start, services = {})
  generate_command(command, services)
end