Class: Pot::Installer
- Inherits:
-
Object
- Object
- Pot::Installer
- Defined in:
- lib/pot/installer.rb
Overview
Based on … Copyright © 2008-2009 Marcus Crafter [email protected]
The base class which all installers must subclass, this class makes sure all installers share some general features, which are outlined below.
Pre/Post Installation Hooks
With all installation methods you have the ability to specify multiple pre/post installation hooks. This gives you the ability to specify commands to run before and after an installation takes place. All commands by default are sudo’d so there is no need to include “sudo” in the command itself. There are three ways to specify a pre/post hook.
First, a single command:
pre :install, 'echo "Hello, World!"'
post :install, 'rm -rf /'
Second, an array of commands:
commands = ['echo "First"', 'echo "Then Another"']
pre :install, commands
post :install, commands
Third, a block which returns either a single or multiple commands:
pre :install do
amount = 7 * 3
"echo 'Before we install, lets plant #{amount} magic beans...'"
end
post :install do
['echo "Now... let's hope they sprout!", 'echo "Indeed they have!"']
end
Other Pre/Post Hooks
Some installation methods actually grant you more fine grained control of when commands are run rather than a blanket pre :install or post :install. If this is the case, it will be documented on the installation method’s corresponding documentation page.
Direct Known Subclasses
Pot::Installers::Apt, Pot::Installers::Binary, Pot::Installers::Brew, Pot::Installers::Deb, Pot::Installers::Gem, Pot::Installers::Group, Pot::Installers::Npm, Pot::Installers::PushText, Pot::Installers::Rake, Pot::Installers::ReplaceText, Pot::Installers::Runner, Pot::Installers::Source, Pot::Installers::Transfer, Pot::Installers::User
Instance Attribute Summary collapse
-
#actor ⇒ Object
:nodoc:.
-
#options ⇒ Object
:nodoc:.
-
#package ⇒ Object
:nodoc:.
-
#post(stage, *commands) ⇒ Object
:nodoc:.
-
#pre(stage, *commands) ⇒ Object
:nodoc:.
Instance Method Summary collapse
- #archives(archives) ⇒ Object
- #builds(builds) ⇒ Object
-
#commands ⇒ Object
More complicated installers that have different stages, and require pre/post commands within stages can override commands and take complete control of the install command sequence construction (eg. source based installer).
-
#initialize(package, options = {}, &block) ⇒ Installer
constructor
:nodoc:.
- #prefix(prefix) ⇒ Object
-
#process(actor) ⇒ Object
:nodoc:.
Constructor Details
Instance Attribute Details
#actor ⇒ Object
:nodoc:
45 46 47 |
# File 'lib/pot/installer.rb', line 45 def actor @actor end |
#options ⇒ Object
:nodoc:
45 46 47 |
# File 'lib/pot/installer.rb', line 45 def @options end |
#post(stage, *commands) ⇒ Object
:nodoc:
45 46 47 |
# File 'lib/pot/installer.rb', line 45 def post @post end |
#pre(stage, *commands) ⇒ Object
:nodoc:
45 46 47 |
# File 'lib/pot/installer.rb', line 45 def pre @pre end |
Instance Method Details
#archives(archives) ⇒ Object
71 72 73 |
# File 'lib/pot/installer.rb', line 71 def archives(archives) @options[:archives] = archives end |
#builds(builds) ⇒ Object
75 76 77 |
# File 'lib/pot/installer.rb', line 75 def builds(builds) @options[:builds] = builds end |
#commands ⇒ Object
More complicated installers that have different stages, and require pre/post commands within stages can override commands and take complete control of the install command sequence construction (eg. source based installer).
95 96 97 98 |
# File 'lib/pot/installer.rb', line 95 def commands commands = pre_commands(:install) + [ install_commands ] + post_commands(:install) commands.flatten end |
#prefix(prefix) ⇒ Object
67 68 69 |
# File 'lib/pot/installer.rb', line 67 def prefix(prefix) @options[:prefix] = prefix end |
#process(actor) ⇒ Object
:nodoc:
79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/pot/installer.rb', line 79 def process(actor) #:nodoc: if Pot.logger.debug? sequence = commands; sequence = sequence.join('; ') if sequence.is_a? Array Pot.logger.debug "#{@package.name} install sequence: #{sequence}\n" end unless Pot.config.testing? Pot.logger.info "--> Installing #{package.name}" actor.install(self) end end |