Class: Capistrano::Command::Tree

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/capistrano/command.rb

Defined Under Namespace

Classes: Branch, ConditionBranch

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (Tree) initialize(config) {|_self| ... }

A new instance of Tree

Yields:

  • (_self)

Yield Parameters:



98
99
100
101
102
# File 'lib/capistrano/command.rb', line 98

def initialize(config)
  @configuration = config
  @branches = []
  yield self if block_given?
end

Instance Attribute Details

- (Object) branches (readonly)

Returns the value of attribute branches



14
15
16
# File 'lib/capistrano/command.rb', line 14

def branches
  @branches
end

- (Object) configuration (readonly)

Returns the value of attribute configuration



13
14
15
# File 'lib/capistrano/command.rb', line 13

def configuration
  @configuration
end

- (Object) fallback (readonly)

Returns the value of attribute fallback



15
16
17
# File 'lib/capistrano/command.rb', line 15

def fallback
  @fallback
end

Instance Method Details

- (Object) branches_for(server)



112
113
114
115
116
117
118
119
120
121
122
# File 'lib/capistrano/command.rb', line 112

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

- (Object) each {|fallback| ... }

Yields:

  • (fallback)


124
125
126
127
128
# File 'lib/capistrano/command.rb', line 124

def each
  branches.each { |branch| yield branch }
  yield fallback if fallback
  return self
end

- (Object) else(command, &block)



108
109
110
# File 'lib/capistrano/command.rb', line 108

def else(command, &block)
  @fallback = Branch.new(command, {}, block)
end

- (Object) when(condition, command, options = {}, &block)



104
105
106
# File 'lib/capistrano/command.rb', line 104

def when(condition, command, options={}, &block)
  branches << ConditionBranch.new(configuration, condition, command, options, block)
end