Class: Travis::Rollout

Inherits:
Object
  • Object
show all
Defined in:
lib/travis/rollout.rb,
lib/travis/rollout/version.rb

Constant Summary collapse

ENVS =
%w(production staging)
VERSION =
"0.0.1"

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}, options = {}, &block) ⇒ Rollout

Returns a new instance of Rollout.



18
19
20
# File 'lib/travis/rollout.rb', line 18

def initialize(args = {}, options = {}, &block)
  @args, @options, @block = args, options, block
end

Instance Attribute Details

#argsObject (readonly)

Returns the value of attribute args.



16
17
18
# File 'lib/travis/rollout.rb', line 16

def args
  @args
end

#blockObject (readonly)

Returns the value of attribute block.



16
17
18
# File 'lib/travis/rollout.rb', line 16

def block
  @block
end

#optionsObject (readonly)

Returns the value of attribute options.



16
17
18
# File 'lib/travis/rollout.rb', line 16

def options
  @options
end

Class Method Details

.matches?(*all) ⇒ Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/travis/rollout.rb', line 12

def self.matches?(*all)
  new(*all).matches?
end

.run(*all, &block) ⇒ Object



7
8
9
10
# File 'lib/travis/rollout.rb', line 7

def self.run(*all, &block)
  rollout = new(*all, &block)
  rollout.run if rollout.matches?
end

Instance Method Details

#matches?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/travis/rollout.rb', line 26

def matches?
  production? and enabled? and (by_owner? or by_repo? or by_user? or by_percent?)
end

#runObject



22
23
24
# File 'lib/travis/rollout.rb', line 22

def run
  block.call || true
end