Class: Sprinkle::Package::Package
Overview
Instance Attribute Summary collapse
Instance Method Summary
collapse
-
#apt(*names, &block) ⇒ Object
-
#deb(*names, &block) ⇒ Object
-
#gem(name, options = {}, &block) ⇒ Object
-
#initialize(name, metadata = {}, &block) ⇒ Package
constructor
A new instance of Package.
-
#process(deployment, roles) ⇒ Object
-
#process_verifications(deployment, roles, pre = false) ⇒ Object
-
#rake(name, options = {}, &block) ⇒ Object
-
#requires(*packages) ⇒ Object
-
#rpm(*names, &block) ⇒ Object
-
#source(source, options = {}, &block) ⇒ Object
-
#to_s ⇒ Object
-
#tree(depth = 1, &block) ⇒ Object
-
#verify(description = '', &block) ⇒ Object
-
#yum(*names, &block) ⇒ Object
included, #method_missing_with_arbitrary_options
Constructor Details
#initialize(name, metadata = {}, &block) ⇒ Package
112
113
114
115
116
117
118
119
120
121
|
# File 'lib/sprinkle/package.rb', line 112
def initialize(name, metadata = {}, &block)
raise 'No package name supplied' unless name
@name = name
@provides = metadata[:provides]
@dependencies = []
@recommends = []
@verifications = []
self.instance_eval &block
end
|
Instance Attribute Details
#dependencies ⇒ Object
Returns the value of attribute dependencies.
110
111
112
|
# File 'lib/sprinkle/package.rb', line 110
def dependencies
@dependencies
end
|
#installer ⇒ Object
Returns the value of attribute installer.
110
111
112
|
# File 'lib/sprinkle/package.rb', line 110
def installer
@installer
end
|
Returns the value of attribute name.
110
111
112
|
# File 'lib/sprinkle/package.rb', line 110
def name
@name
end
|
Returns the value of attribute provides.
110
111
112
|
# File 'lib/sprinkle/package.rb', line 110
def provides
@provides
end
|
#recommends(*packages) ⇒ Object
Returns the value of attribute recommends.
110
111
112
|
# File 'lib/sprinkle/package.rb', line 110
def recommends
@recommends
end
|
#verifications ⇒ Object
Returns the value of attribute verifications.
110
111
112
|
# File 'lib/sprinkle/package.rb', line 110
def verifications
@verifications
end
|
Instance Method Details
#apt(*names, &block) ⇒ Object
123
124
125
|
# File 'lib/sprinkle/package.rb', line 123
def apt(*names, &block)
@installer = Sprinkle::Installers::Apt.new(self, *names, &block)
end
|
#deb(*names, &block) ⇒ Object
127
128
129
|
# File 'lib/sprinkle/package.rb', line 127
def deb(*names, &block)
@installer = Sprinkle::Installers::Deb.new(self, *names, &block)
end
|
#gem(name, options = {}, &block) ⇒ Object
139
140
141
142
|
# File 'lib/sprinkle/package.rb', line 139
def gem(name, options = {}, &block)
@recommends << :rubygems
@installer = Sprinkle::Installers::Gem.new(self, name, options, &block)
end
|
#process(deployment, roles) ⇒ Object
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
|
# File 'lib/sprinkle/package.rb', line 157
def process(deployment, roles)
return if meta_package?
unless @verifications.empty? || Sprinkle::OPTIONS[:force]
begin
process_verifications(deployment, roles, true)
logger.info "--> #{self.name} already installed for roles: #{roles}"
return
rescue Sprinkle::VerificationFailed => e
end
end
@installer.defaults(deployment)
@installer.process(roles)
process_verifications(deployment, roles)
end
|
#process_verifications(deployment, roles, pre = false) ⇒ Object
179
180
181
182
183
184
185
186
187
188
189
190
191
192
|
# File 'lib/sprinkle/package.rb', line 179
def process_verifications(deployment, roles, pre = false)
return if @verifications.blank?
if pre
logger.info "--> Checking if #{self.name} is already installed for roles: #{roles}"
else
logger.info "--> Verifying #{self.name} was properly installed for roles: #{roles}"
end
@verifications.each do |v|
v.defaults(deployment)
v.process(roles)
end
end
|
#rake(name, options = {}, &block) ⇒ Object
149
150
151
|
# File 'lib/sprinkle/package.rb', line 149
def rake(name, options = {}, &block)
@installer = Sprinkle::Installers::Rake.new(self, name, options, &block)
end
|
#requires(*packages) ⇒ Object
194
195
196
197
|
# File 'lib/sprinkle/package.rb', line 194
def requires(*packages)
@dependencies << packages
@dependencies.flatten!
end
|
#rpm(*names, &block) ⇒ Object
131
132
133
|
# File 'lib/sprinkle/package.rb', line 131
def rpm(*names, &block)
@installer = Sprinkle::Installers::Rpm.new(self, *names, &block)
end
|
#source(source, options = {}, &block) ⇒ Object
144
145
146
147
|
# File 'lib/sprinkle/package.rb', line 144
def source(source, options = {}, &block)
@recommends << :build_essential
@installer = Sprinkle::Installers::Source.new(self, source, options, &block)
end
|
224
|
# File 'lib/sprinkle/package.rb', line 224
def to_s; @name; end
|
#tree(depth = 1, &block) ⇒ Object
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
|
# File 'lib/sprinkle/package.rb', line 204
def tree(depth = 1, &block)
packages = []
@recommends.each do |dep|
package = PACKAGES[dep]
next unless package
block.call(self, package, depth) if block
packages << package.tree(depth + 1, &block)
end
@dependencies.each do |dep|
package = PACKAGES[dep]
raise "Package definition not found for key: #{dep}" unless package
block.call(self, package, depth) if block
packages << package.tree(depth + 1, &block)
end
packages << self
end
|
#verify(description = '', &block) ⇒ Object
153
154
155
|
# File 'lib/sprinkle/package.rb', line 153
def verify(description = '', &block)
@verifications << Sprinkle::Verify.new(self, description, &block)
end
|
#yum(*names, &block) ⇒ Object
135
136
137
|
# File 'lib/sprinkle/package.rb', line 135
def yum(*names, &block)
@installer = Sprinkle::Installers::Yum.new(self, *names, &block)
end
|