Class: BaseChip::ListMenu

Inherits:
Menu
  • Object
show all
Includes:
Cli
Defined in:
lib/base_chip/list_menu.rb

Instance Method Summary collapse

Methods included from Cli

included

Methods inherited from Menu

#list_line, #smart_print

Methods included from Reporting

included

Instance Method Details

#actions(pattern = nil) ⇒ Object



59
60
61
62
63
64
65
66
67
68
# File 'lib/base_chip/list_menu.rb', line 59

def actions(pattern=nil)
  before(pattern)
  BaseChip.actions.each do |action|
    name = action.name
    c = action.configuration
    b = c.block
    smart_print "#{b.name}:#{c.name}:#{name}", action, b.name.to_s, c.name.to_s, name.to_s
  end
  after
end

#afterObject



30
31
32
33
34
# File 'lib/base_chip/list_menu.rb', line 30

def after
  if @table.size > 0
    print_table(@table,'=>')
  end
end

#before(pattern) ⇒ Object



21
22
23
24
25
26
27
28
29
# File 'lib/base_chip/list_menu.rb', line 21

def before(pattern)
  BaseChip.load_environment
  @table = []
  case pattern
  when /^\/(.*)\/$/ ; @pattern = /#{$1}/
  else              ; @pattern = pattern
  end
  exit unless BaseChip.project.blocks
end

#blocks(pattern = nil) ⇒ Object



39
40
41
42
43
44
45
# File 'lib/base_chip/list_menu.rb', line 39

def blocks(pattern=nil)
  before(pattern)
  BaseChip.blocks.each do |block|
    smart_print block.name.to_s, block
  end
  after
end

#configurations(pattern = nil) ⇒ Object



48
49
50
51
52
53
54
55
56
# File 'lib/base_chip/list_menu.rb', line 48

def configurations(pattern=nil)
  before(pattern)
  BaseChip.configurations.each do |configuration|
    name   = configuration.name
    b_name = configuration.block.name
    smart_print "#{b_name}:#{name}", configuration, b_name.to_s, name.to_s
  end
  after
end

#plugins(pattern = nil) ⇒ Object



107
108
109
# File 'lib/base_chip/list_menu.rb', line 107

def plugins(pattern=nil)
  fault "This feature is soon forthcoming"
end

#recipes(pattern = nil) ⇒ Object



113
114
115
116
117
118
119
120
121
# File 'lib/base_chip/list_menu.rb', line 113

def recipes(pattern=nil)
  begin
    infile = open("http://basechip.com/recipe_list#{"?name=#{pattern}" if pattern}")
  rescue OpenURI::HTTPError
    fault "Could not access basechip.com"
  end
  puts "available recipes are:"
  puts infile.read.gsub(/^/,'  ')
end

#test_lists(pattern = nil) ⇒ Object



71
72
73
74
75
76
77
78
79
80
# File 'lib/base_chip/list_menu.rb', line 71

def test_lists(pattern=nil)
  before(pattern)
  BaseChip.test_lists.each do |list|
    name = list.name
    c = list.configuration
    b = c.block
    smart_print "#{b.name}:#{c.name}:#{name}", list, b.name.to_s, c.name.to_s, name.to_s
  end
  after
end

#tests(pattern = nil) ⇒ Object



83
84
85
86
87
88
89
90
91
92
93
# File 'lib/base_chip/list_menu.rb', line 83

def tests(pattern=nil)
  before(pattern)
  BaseChip.tests.each do |test|
    name = test.name
    l = test.test_list
    c = l.configuration
    b = c.block
    smart_print "#{b.name}:#{c.name}:#{l.name}:#{name}", test, b.name.to_s, c.name.to_s, l.name.to_s, name.to_s
  end
  after
end

#tools(pattern = nil) ⇒ Object



96
97
98
99
100
101
102
103
# File 'lib/base_chip/list_menu.rb', line 96

def tools(pattern=nil)
  before(pattern)
  BaseChip.tools.each do |tool|
    name = tool.name
    smart_print [name,"used by #{tool.configuration.full_name}"], tool, name.to_s
  end
  after
end

#workload(*targets) ⇒ Object



126
127
128
129
130
131
132
133
134
135
136
137
# File 'lib/base_chip/list_menu.rb', line 126

def workload(*targets)
  if targets.empty?
    help
    fault "please specify targets"
  end
  BaseChip.load_environment
  @table = []
  BaseChip.project.dereference_workload(targets).each do |item|
    list_line item.full_name, item
  end
  after
end