Class: Proctor::Presenter::List

Inherits:
Object
  • Object
show all
Defined in:
lib/proctor/presenter/list.rb

Instance Method Summary collapse

Constructor Details

#initialize(global, options, args) ⇒ List

Returns a new instance of List.



7
8
9
10
11
# File 'lib/proctor/presenter/list.rb', line 7

def initialize(global, options, args)
  @global  = global
  @options = options
  @args    = args
end

Instance Method Details

#handle(string) ⇒ Object



24
25
26
# File 'lib/proctor/presenter/list.rb', line 24

def handle(string)
  Digest::MD5.hexdigest(string)[0..2]
end

#puts_handle(string) ⇒ Object



28
29
30
# File 'lib/proctor/presenter/list.rb', line 28

def puts_handle(string)
  puts "#{handle(string)}: #{string}"
end

#renderObject



13
14
15
16
17
18
19
20
21
22
# File 'lib/proctor/presenter/list.rb', line 13

def render
  case @options[:type]
    when "appfiles"    then render_appfiles
    when "managers"    then render_managers
    when "services"    then render_services
    when "templates"   then render_templates
    when "node"        then render_node
    when "all"         then render_all
  end
end

#render_allObject



57
58
59
60
61
62
63
# File 'lib/proctor/presenter/list.rb', line 57

def render_all
  render_templates
  render_appfiles
  render_managers
  render_services
  render_node
end

#render_appfilesObject



37
38
39
40
# File 'lib/proctor/presenter/list.rb', line 37

def render_appfiles
  puts "[AppFiles]"
  CmdState.app_files(@global, @options, @args).each { |f| puts "#{handle(f)}: #{f}" }
end

#render_managersObject



42
43
44
45
# File 'lib/proctor/presenter/list.rb', line 42

def render_managers
  puts "[Managers]"
  CmdState.managers(@global, @options, @args).keys.each {|k| puts_handle(k)}
end

#render_nodeObject



52
53
54
55
# File 'lib/proctor/presenter/list.rb', line 52

def render_node
  puts "[Nodes]"
  CmdState.nodes(@global, @options, @args).keys.each {|k| puts_handle(k)}
end

#render_servicesObject



47
48
49
50
# File 'lib/proctor/presenter/list.rb', line 47

def render_services
  puts "[Services]"
  CmdState.services(@global, @options, @args).keys.each {|k| puts_handle(k)}
end

#render_templatesObject



32
33
34
35
# File 'lib/proctor/presenter/list.rb', line 32

def render_templates
  puts "[Templates]"
  CmdState.templates(@global, @options, @args).each {|v| puts_handle(v)}
end