Class: Palmade::Cableguy::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/palmade/cableguy/runner.rb

Class Method Summary collapse

Class Method Details

.run(app_root, cmd, options) ⇒ Object


3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/palmade/cableguy/runner.rb', line 3

def self.run(app_root, cmd, options)
  if options[:path].nil?
    if ENV.include?("CABLING_PATH")
      options[:path] = ENV["CABLING_PATH"]
    elsif File.exist?(File.expand_path('~/cabling'))
      options[:path] = File.expand_path('~/cabling')
    elsif File.exist?("/var/cabling")
      options[:path] = "/var/cabling"
    elsif File.exist?("/etc/cabling")
      options[:path] = "/etc/cabling"
    else
      raise "You don't seem to have any paths for cabling.\n"
    end
  end

  if options[:target].nil?
    if ENV.include?("CABLING_TARGET")
      options[:target] = ENV["CABLING_TARGET"]
    else
      options[:target] = 'development'
    end
  end

  if options[:location].nil?
    if ENV.include?("CABLING_LOCATION")
      options[:location] = ENV["CABLING_LOCATION"]
    else
      options[:location] = options[:target]
    end
  end

  ca = Cabler.new(app_root, options)

  case cmd
  when 'migrate'
    ca.boot.migrate
  else
    ca.boot.configure
  end
end