Class: Vito::Recipe
- Inherits:
-
Object
show all
- Defined in:
- lib/vito/recipe.rb,
lib/vito.rb
Overview
This is a parent class for recipes and shouldn’t be used directly.
Instance Method Summary
collapse
Constructor Details
#initialize(options, connection) ⇒ Recipe
Returns a new instance of Recipe.
5
6
7
8
9
|
# File 'lib/vito/recipe.rb', line 5
def initialize(options, connection)
@options = options
@connection = connection
@with = {}
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, args = {}) ⇒ Object
11
12
13
14
15
16
17
|
# File 'lib/vito/recipe.rb', line 11
def method_missing(name, args = {})
if with?(name.to_sym)
@with[name.to_sym]
else
raise "#{self.class.name} recipe needs to define a ##{name} method"
end
end
|
Instance Method Details
#depends_on_recipe(recipe, options = {}) ⇒ Object
39
40
41
|
# File 'lib/vito/recipe.rb', line 39
def depends_on_recipe(recipe, options = {})
Dsl::Installation.new(recipe, options, @connection).install
end
|
#install ⇒ Object
27
28
29
|
# File 'lib/vito/recipe.rb', line 27
def install
raise "#{self.class.name} recipe needs to define a #install method"
end
|
#install_os_dependencies(os_dependencies = nil) ⇒ Object
62
63
64
65
|
# File 'lib/vito/recipe.rb', line 62
def install_os_dependencies(os_dependencies = nil)
os.update_packages
os.install_dependencies(os_dependencies) if os_dependencies
end
|
#program_version(version_command) ⇒ Object
Helper methods
should be extracted later
54
55
56
|
# File 'lib/vito/recipe.rb', line 54
def program_version(version_command)
Vito::Utils::ProgramVersion.new(version_command, @connection)
end
|
#query(command) ⇒ Object
47
48
49
|
# File 'lib/vito/recipe.rb', line 47
def query(command)
@connection.query(command)
end
|
#remove ⇒ Object
31
32
33
|
# File 'lib/vito/recipe.rb', line 31
def remove
raise "#{self.class.name} recipe needs to define a #remove method"
end
|
#run_command(command) ⇒ Object
43
44
45
|
# File 'lib/vito/recipe.rb', line 43
def run_command(command)
@connection.run(command)
end
|
#update ⇒ Object
35
36
37
|
# File 'lib/vito/recipe.rb', line 35
def update
raise "#{self.class.name} recipe needs to define a #update method"
end
|
#with(name, args = {}) ⇒ Object
19
20
21
|
# File 'lib/vito/recipe.rb', line 19
def with(name, args = {})
@with[name.to_sym] = args
end
|
#with?(name) ⇒ Boolean
23
24
25
|
# File 'lib/vito/recipe.rb', line 23
def with?(name)
@with.keys.include?(name.to_sym)
end
|