Class: FPM::Fry::Plugin::Alternatives::DSL

Inherits:
Struct
  • Object
show all
Defined in:
lib/fpm/fry/plugin/alternatives.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(b, a = {}) ⇒ DSL

Returns a new instance of DSL.



10
11
12
# File 'lib/fpm/fry/plugin/alternatives.rb', line 10

def initialize( b, a = {})
  super
end

Instance Attribute Details

#alternativesObject

Returns the value of attribute alternatives

Returns:

  • (Object)

    the current value of alternatives



8
9
10
# File 'lib/fpm/fry/plugin/alternatives.rb', line 8

def alternatives
  @alternatives
end

#builderObject

Returns the value of attribute builder

Returns:

  • (Object)

    the current value of builder



8
9
10
# File 'lib/fpm/fry/plugin/alternatives.rb', line 8

def builder
  @builder
end

Instance Method Details

#[]=(name, options = {}, value) ⇒ Object



14
15
16
17
18
19
20
21
22
# File 'lib/fpm/fry/plugin/alternatives.rb', line 14

def []=(name, options={}, value)
  name = name.to_s
  if value.kind_of? String
    options = normalize(name, options.merge(path: value) )
  else
    options = normalize(name, options.merge(value) )
  end
  alternatives[name] = options
end

#add(name, value, options = {}) ⇒ Object



24
25
26
# File 'lib/fpm/fry/plugin/alternatives.rb', line 24

def add(name, value, options={})
  self[name, options] = value
end

#finish!Object



28
29
30
31
32
33
34
35
# File 'lib/fpm/fry/plugin/alternatives.rb', line 28

def finish!
  install   = alternatives.map{|_,v|   install_command(v) }
  uninstall = alternatives.map{|_,v| uninstall_command(v) }
  builder.plugin('script_helper') do
    after_install_or_upgrade(*install)
    before_remove_entirely(*uninstall)
  end
end