Class: Travis::Rollout

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

Defined Under Namespace

Classes: ByPercent, ByValue, Env, Redis, RedisNoop

Constant Summary collapse

VERSION =
"0.0.2"

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, args, &block) ⇒ Rollout

Returns a new instance of Rollout.



81
82
83
84
85
86
87
# File 'lib/travis/rollout.rb', line 81

def initialize(name, args, &block)
  @name  = name
  @args  = args
  @block = block
  @redis = Redis.new(name, args.delete(:redis) )
  @env   = Env.new(name)
end

Instance Attribute Details

#argsObject (readonly)

Returns the value of attribute args.



79
80
81
# File 'lib/travis/rollout.rb', line 79

def args
  @args
end

#blockObject (readonly)

Returns the value of attribute block.



79
80
81
# File 'lib/travis/rollout.rb', line 79

def block
  @block
end

#envObject (readonly)

Returns the value of attribute env.



79
80
81
# File 'lib/travis/rollout.rb', line 79

def env
  @env
end

#nameObject (readonly)

Returns the value of attribute name.



79
80
81
# File 'lib/travis/rollout.rb', line 79

def name
  @name
end

#redisObject (readonly)

Returns the value of attribute redis.



79
80
81
# File 'lib/travis/rollout.rb', line 79

def redis
  @redis
end

Class Method Details

.matches?(*all) ⇒ Boolean

Returns:

  • (Boolean)


75
76
77
# File 'lib/travis/rollout.rb', line 75

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

.run(*all, &block) ⇒ Object



70
71
72
73
# File 'lib/travis/rollout.rb', line 70

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

Instance Method Details

#matches?Boolean

Returns:

  • (Boolean)


93
94
95
# File 'lib/travis/rollout.rb', line 93

def matches?
  enabled? and (by_value? or by_percent?)
end

#runObject



89
90
91
# File 'lib/travis/rollout.rb', line 89

def run
  block.call || true
end