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, clo) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/metacon/stat.rb', line 23

def self.curr(opts=[], proj=nil, clo)
  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, clo, opts) ⇒ Object



5
6
7
8
9
10
# File 'lib/metacon/stat.rb', line 5

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

.stat(opts, clo) ⇒ Object



12
13
14
15
16
17
18
19
20
21
# File 'lib/metacon/stat.rb', line 12

def self.stat(opts, clo)
  # TODO:
  #   - git-stat summary
  #   - stuff from full_context
  #   - stat for each loader
  puts '(not yet implemented)'
  #puts curr(opts, nil, clo)
  require 'pp'
  pp $proj.full_context
end