Class: Capistrano::Command::Tree
- Inherits:
-
Object
- Object
- Capistrano::Command::Tree
- Includes:
- Enumerable
- Defined in:
- lib/capistrano/command.rb
Defined Under Namespace
Classes: Branch, ConditionBranch
Instance Attribute Summary collapse
-
#branches ⇒ Object
readonly
Returns the value of attribute branches.
-
#configuration ⇒ Object
readonly
Returns the value of attribute configuration.
-
#fallback ⇒ Object
readonly
Returns the value of attribute fallback.
Instance Method Summary collapse
- #branches_for(server) ⇒ Object
- #each {|fallback| ... } ⇒ Object
- #else(command, &block) ⇒ Object
-
#initialize(config) {|_self| ... } ⇒ Tree
constructor
A new instance of Tree.
- #when(condition, command, options = {}, &block) ⇒ Object
Constructor Details
#initialize(config) {|_self| ... } ⇒ Tree
Returns a new instance of Tree.
97 98 99 100 101 |
# File 'lib/capistrano/command.rb', line 97 def initialize(config) @configuration = config @branches = [] yield self if block_given? end |
Instance Attribute Details
#branches ⇒ Object (readonly)
Returns the value of attribute branches.
13 14 15 |
# File 'lib/capistrano/command.rb', line 13 def branches @branches end |
#configuration ⇒ Object (readonly)
Returns the value of attribute configuration.
12 13 14 |
# File 'lib/capistrano/command.rb', line 12 def configuration @configuration end |
#fallback ⇒ Object (readonly)
Returns the value of attribute fallback.
14 15 16 |
# File 'lib/capistrano/command.rb', line 14 def fallback @fallback end |
Instance Method Details
#branches_for(server) ⇒ Object
111 112 113 114 115 116 117 118 119 120 121 |
# File 'lib/capistrano/command.rb', line 111 def branches_for(server) seen_last = false matches = branches.select do |branch| success = !seen_last && !branch.skip? && branch.match(server) seen_last = success && branch.last? success end matches << fallback if matches.empty? && fallback return matches end |
#each {|fallback| ... } ⇒ Object
123 124 125 126 127 |
# File 'lib/capistrano/command.rb', line 123 def each branches.each { |branch| yield branch } yield fallback if fallback return self end |
#else(command, &block) ⇒ Object
107 108 109 |
# File 'lib/capistrano/command.rb', line 107 def else(command, &block) @fallback = Branch.new(command, {}, block) end |
#when(condition, command, options = {}, &block) ⇒ Object
103 104 105 |
# File 'lib/capistrano/command.rb', line 103 def when(condition, command, ={}, &block) branches << ConditionBranch.new(configuration, condition, command, , block) end |