Class: Sprinkle::Package::Package
Overview
Instance Attribute Summary collapse
Instance Method Summary
collapse
-
#apt(*names, &block) ⇒ Object
-
#bsd_port(port, &block) ⇒ Object
-
#deb(*names, &block) ⇒ Object
-
#freebsd_pkg(*names, &block) ⇒ Object
-
#gem(name, options = {}, &block) ⇒ Object
-
#initialize(name, metadata = {}, &block) ⇒ Package
constructor
A new instance of Package.
-
#mac_port(port, &block) ⇒ Object
-
#openbsd_pkg(*names, &block) ⇒ Object
-
#opensolaris_pkg(*names, &block) ⇒ Object
-
#process(deployment, roles) ⇒ Object
-
#process_verifications(deployment, roles, pre = false) ⇒ Object
-
#push_text(text, path, options = {}, &block) ⇒ 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
Returns a new instance of 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
143
144
145
|
# File 'lib/sprinkle/package.rb', line 143
def apt(*names, &block)
@installer = Sprinkle::Installers::Apt.new(self, *names, &block)
end
|
#bsd_port(port, &block) ⇒ Object
135
136
137
|
# File 'lib/sprinkle/package.rb', line 135
def bsd_port(port, &block)
@installer = Sprinkle::Installers::BsdPort.new(self, port, &block)
end
|
#deb(*names, &block) ⇒ Object
147
148
149
|
# File 'lib/sprinkle/package.rb', line 147
def deb(*names, &block)
@installer = Sprinkle::Installers::Deb.new(self, *names, &block)
end
|
#freebsd_pkg(*names, &block) ⇒ Object
123
124
125
|
# File 'lib/sprinkle/package.rb', line 123
def freebsd_pkg(*names, &block)
@installer = Sprinkle::Installers::FreebsdPkg.new(self, *names, &block)
end
|
#gem(name, options = {}, &block) ⇒ Object
159
160
161
162
|
# File 'lib/sprinkle/package.rb', line 159
def gem(name, options = {}, &block)
@recommends << :rubygems
@installer = Sprinkle::Installers::Gem.new(self, name, options, &block)
end
|
#mac_port(port, &block) ⇒ Object
139
140
141
|
# File 'lib/sprinkle/package.rb', line 139
def mac_port(port, &block)
@installer = Sprinkle::Installers::MacPort.new(self, port, &block)
end
|
#openbsd_pkg(*names, &block) ⇒ Object
127
128
129
|
# File 'lib/sprinkle/package.rb', line 127
def openbsd_pkg(*names, &block)
@installer = Sprinkle::Installers::OpenbsdPkg.new(self, *names, &block)
end
|
#opensolaris_pkg(*names, &block) ⇒ Object
131
132
133
|
# File 'lib/sprinkle/package.rb', line 131
def opensolaris_pkg(*names, &block)
@installer = Sprinkle::Installers::OpensolarisPkg.new(self, *names, &block)
end
|
#process(deployment, roles) ⇒ Object
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
|
# File 'lib/sprinkle/package.rb', line 181
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
203
204
205
206
207
208
209
210
211
212
213
214
215
216
|
# File 'lib/sprinkle/package.rb', line 203
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
|
#push_text(text, path, options = {}, &block) ⇒ Object
173
174
175
|
# File 'lib/sprinkle/package.rb', line 173
def push_text(text, path, options = {}, &block)
@installer = Sprinkle::Installers::PushText.new(self, text, path, options, &block)
end
|
#rake(name, options = {}, &block) ⇒ Object
169
170
171
|
# File 'lib/sprinkle/package.rb', line 169
def rake(name, options = {}, &block)
@installer = Sprinkle::Installers::Rake.new(self, name, options, &block)
end
|
#requires(*packages) ⇒ Object
218
219
220
221
|
# File 'lib/sprinkle/package.rb', line 218
def requires(*packages)
@dependencies << packages
@dependencies.flatten!
end
|
#rpm(*names, &block) ⇒ Object
151
152
153
|
# File 'lib/sprinkle/package.rb', line 151
def rpm(*names, &block)
@installer = Sprinkle::Installers::Rpm.new(self, *names, &block)
end
|
#source(source, options = {}, &block) ⇒ Object
164
165
166
167
|
# File 'lib/sprinkle/package.rb', line 164
def source(source, options = {}, &block)
@recommends << :build_essential
@installer = Sprinkle::Installers::Source.new(self, source, options, &block)
end
|
248
|
# File 'lib/sprinkle/package.rb', line 248
def to_s; @name; end
|
#tree(depth = 1, &block) ⇒ Object
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
|
# File 'lib/sprinkle/package.rb', line 228
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
177
178
179
|
# File 'lib/sprinkle/package.rb', line 177
def verify(description = '', &block)
@verifications << Sprinkle::Verify.new(self, description, &block)
end
|
#yum(*names, &block) ⇒ Object
155
156
157
|
# File 'lib/sprinkle/package.rb', line 155
def yum(*names, &block)
@installer = Sprinkle::Installers::Yum.new(self, *names, &block)
end
|