Class: Kibou::Recipe
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
brew, brew_installed?, capture, info, outdated, package_included?, package_install, package_installed?, package_outdated?, package_upgrade, run, search, update!
Constructor Details
#initialize(name = nil) ⇒ Recipe
Returns a new instance of Recipe.
9
10
11
12
13
14
15
16
17
18
|
# File 'lib/kibou/recipe.rb', line 9
def initialize(name = nil)
if name
@name = name.to_s
@constant = @name.capitalize.camelize.constantize
@klass = @constant.new
@packages = @constant.packages
@before_tasks = @constant.before_tasks
@after_tasks = @constant.after_tasks
end
end
|
Instance Attribute Details
#after_tasks ⇒ Object
Returns the value of attribute after_tasks.
7
8
9
|
# File 'lib/kibou/recipe.rb', line 7
def after_tasks
@after_tasks
end
|
#before_tasks ⇒ Object
Returns the value of attribute before_tasks.
7
8
9
|
# File 'lib/kibou/recipe.rb', line 7
def before_tasks
@before_tasks
end
|
#constant ⇒ Object
Returns the value of attribute constant.
7
8
9
|
# File 'lib/kibou/recipe.rb', line 7
def constant
@constant
end
|
#name ⇒ Object
Returns the value of attribute name.
7
8
9
|
# File 'lib/kibou/recipe.rb', line 7
def name
@name
end
|
#packages ⇒ Object
Returns the value of attribute packages.
7
8
9
|
# File 'lib/kibou/recipe.rb', line 7
def packages
@packages
end
|
Class Method Details
.after(*args) ⇒ Object
38
39
40
|
# File 'lib/kibou/recipe.rb', line 38
def self.after(*args)
after_tasks.push *args
end
|
.after_tasks ⇒ Object
42
43
44
|
# File 'lib/kibou/recipe.rb', line 42
def self.after_tasks
@after_tasks ||= []
end
|
.before(*args) ⇒ Object
30
31
32
|
# File 'lib/kibou/recipe.rb', line 30
def self.before(*args)
before_tasks.push *args
end
|
.before_tasks ⇒ Object
34
35
36
|
# File 'lib/kibou/recipe.rb', line 34
def self.before_tasks
@before_tasks ||= []
end
|
.package(name, options = {}, &block) ⇒ Object
20
21
22
23
24
|
# File 'lib/kibou/recipe.rb', line 20
def self.package(name, options = {}, &block)
options[:ensure] ||= :installed
options[:proc] = block if block_given?
packages << Package.new(name, options)
end
|
.packages ⇒ Object
26
27
28
|
# File 'lib/kibou/recipe.rb', line 26
def self.packages
@packages ||= []
end
|
Instance Method Details
#find_package(name) ⇒ Object
46
47
48
|
# File 'lib/kibou/recipe.rb', line 46
def find_package(name)
packages.select {|package| package.name == name }.first
end
|
#run_after_tasks ⇒ Object
60
61
62
63
64
65
66
67
68
|
# File 'lib/kibou/recipe.rb', line 60
def run_after_tasks
unless after_tasks.size == 0
puts "running after tasks"
after_tasks.each do |m|
puts "---> invoking: #{m}"
@klass.send(m)
end
end
end
|
#run_before_tasks ⇒ Object
50
51
52
53
54
55
56
57
58
|
# File 'lib/kibou/recipe.rb', line 50
def run_before_tasks
unless before_tasks.size == 0
puts "running before tasks"
before_tasks.each do |m|
puts "---> invoking: #{m}"
@klass.send(m)
end
end
end
|