Class: MetaCon::Stat

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

Class Method Summary collapse

Class Method Details

.curr(opts = [], proj = nil) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/metacon/stat.rb', line 15

def self.curr(opts=[], proj=nil)
  proj ||= $proj
  $cli.cfail 'Not a metacon project. Use `metacon init`' and exit(5) unless proj.valid
  state = proj.current_state
  os = state[:os] == proj.this_os ? '.' : state[:os]
  host = state[:host] == proj.this_host ? '.' : state[:host]
  if opts.size == 0
    puts "/#{state[:rtc]}/#{state[:role]}/#{os}/#{host}/"
  else
    # TODO: check for valid types
    opts.each{|o| puts state[o.to_sym]}
  end
end

.handle(cmd, opts) ⇒ Object



3
4
5
6
7
8
# File 'lib/metacon/stat.rb', line 3

def self.handle(cmd, opts)
  case cmd
  when :stat; stat(opts)
  when :curr; curr(opts)
  end
end

.stat(opts) ⇒ Object



10
11
12
13
# File 'lib/metacon/stat.rb', line 10

def self.stat(opts)
  puts '(not yet implemented)'
  puts curr(opts)
end