Class: TapDance::Definition
- Inherits:
-
Object
- Object
- TapDance::Definition
- Defined in:
- lib/tap_dance/definition.rb
Instance Attribute Summary collapse
-
#brews ⇒ Object
Returns the value of attribute brews.
-
#taps ⇒ Object
Returns the value of attribute taps.
Instance Method Summary collapse
- #brew(*args) ⇒ Object
- #execute(upgrade = false) ⇒ Object
-
#initialize(taps = [], brews = []) ⇒ Definition
constructor
A new instance of Definition.
- #tap(*args) ⇒ Object
- #tap_named(name) ⇒ Object
Constructor Details
#initialize(taps = [], brews = []) ⇒ Definition
Returns a new instance of Definition.
11 12 13 14 |
# File 'lib/tap_dance/definition.rb', line 11 def initialize(taps=[], brews=[]) @taps = taps @brews = brews end |
Instance Attribute Details
#brews ⇒ Object
Returns the value of attribute brews.
9 10 11 |
# File 'lib/tap_dance/definition.rb', line 9 def brews @brews end |
#taps ⇒ Object
Returns the value of attribute taps.
8 9 10 |
# File 'lib/tap_dance/definition.rb', line 8 def taps @taps end |
Instance Method Details
#brew(*args) ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/tap_dance/definition.rb', line 24 def brew(*args) if args.last.is_a? Hash args.last.merge!(:definition => self) end @brews << Brew.new(*args) @brews.last end |
#execute(upgrade = false) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/tap_dance/definition.rb', line 36 def execute(upgrade=false) for tap in @taps do TapDance.ui.confirm "Tapping \"#{tap}\"" TapDance.ui.detail tap.entap end for brew in @brews do unless upgrade TapDance.ui.confirm "Installing \"#{brew}\"" TapDance.ui.detail brew.install else TapDance.ui.confirm "Upgrading \"#{brew}\"" TapDance.ui.detail brew.upgrade end end end |
#tap(*args) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/tap_dance/definition.rb', line 16 def tap(*args) if args.last.is_a? Hash args.last.merge!(:definition => self) end @taps << Tap.new(*args) @taps.last end |
#tap_named(name) ⇒ Object
32 33 34 |
# File 'lib/tap_dance/definition.rb', line 32 def tap_named(name) @taps.find { |t| t.name.to_s == name.to_s } end |