Class: Divvy::Plugins::Source::SourceInstaller
- Inherits:
-
Object
- Object
- Divvy::Plugins::Source::SourceInstaller
- Defined in:
- lib/divvy/plugins/source.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#runner ⇒ Object
readonly
Returns the value of attribute runner.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
Instance Method Summary collapse
- #after(stage, &block) ⇒ Object
- #archive_name ⇒ Object
-
#base_dir ⇒ Object
:nodoc:.
- #before(stage, &block) ⇒ Object
-
#build_dir ⇒ Object
:nodoc:.
-
#initialize(runner, source, options = {}, &block) ⇒ SourceInstaller
constructor
A new instance of SourceInstaller.
- #skip(*stages) ⇒ Object
- #stage(stage, &block) ⇒ Object
Constructor Details
#initialize(runner, source, options = {}, &block) ⇒ SourceInstaller
Returns a new instance of SourceInstaller.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/divvy/plugins/source.rb', line 10 def initialize(runner, source, = {}, &block) @runner = runner @source = source @options = { :prefix => '/usr/local', :archives => '/usr/local/sources', :builds => '/usr/local/build' }.merge() @befores = {} @afters = {} @stages = { :prepare => Proc.new { prepare }, :download => Proc.new { download }, :extract => Proc.new { extract }, :configure => Proc.new { configure }, :build => Proc.new { build }, :install => Proc.new { install } } self.instance_eval(&block) unless block.nil? [:prepare, :download, :extract, :configure, :build, :install].each do |stage| puts "before #{stage}" if Divvy.verbose @befores[stage].call if @befores[stage] puts "stage #{stage}" if Divvy.verbose @stages[stage].call if @stages[stage] puts "after #{stage}" if Divvy.verbose @afters[stage].call if @afters[stage] end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(symbol, *args) ⇒ Object (private)
132 133 134 |
# File 'lib/divvy/plugins/source.rb', line 132 def method_missing(symbol, *args) runner.send(symbol, args) end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
41 42 43 |
# File 'lib/divvy/plugins/source.rb', line 41 def @options end |
#runner ⇒ Object (readonly)
Returns the value of attribute runner.
41 42 43 |
# File 'lib/divvy/plugins/source.rb', line 41 def runner @runner end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
41 42 43 |
# File 'lib/divvy/plugins/source.rb', line 41 def source @source end |
Instance Method Details
#after(stage, &block) ⇒ Object
47 48 49 |
# File 'lib/divvy/plugins/source.rb', line 47 def after(stage, &block) @afters[stage] = block end |
#archive_name ⇒ Object
70 71 72 73 74 |
# File 'lib/divvy/plugins/source.rb', line 70 def archive_name name = @source.split('/').last raise "Unable to determine archive name for source: #{source}, please update code knowledge" unless name name end |
#base_dir ⇒ Object
:nodoc:
63 64 65 66 67 68 |
# File 'lib/divvy/plugins/source.rb', line 63 def base_dir #:nodoc: if source.split('/').last =~ /(.*)\.(tar\.gz|tgz|tar\.bz2|tb2)/ return $1 end raise "Unknown base path for source archive: #{ssource}, please update code knowledge" end |
#before(stage, &block) ⇒ Object
43 44 45 |
# File 'lib/divvy/plugins/source.rb', line 43 def before(stage, &block) @befores[stage] = block end |
#build_dir ⇒ Object
:nodoc:
59 60 61 |
# File 'lib/divvy/plugins/source.rb', line 59 def build_dir #:nodoc: "#{[:builds]}/#{[:custom_dir] || base_dir}" end |
#skip(*stages) ⇒ Object
55 56 57 |
# File 'lib/divvy/plugins/source.rb', line 55 def skip(*stages) stages.each { |stage| @stages.delete(stage) } end |
#stage(stage, &block) ⇒ Object
51 52 53 |
# File 'lib/divvy/plugins/source.rb', line 51 def stage(stage, &block) @stages[stage] = block end |