class Travis::Conditions::V1::Eval
Public Instance Methods
apply()
click to toggle source
# File lib/travis/conditions/v1/eval.rb, line 5 def apply !!evl(sexp) end
Private Instance Methods
and(lft, rgt)
click to toggle source
# File lib/travis/conditions/v1/eval.rb, line 24 def and(lft, rgt) evl(lft) && evl(rgt) end
blank(value)
click to toggle source
# File lib/travis/conditions/v1/eval.rb, line 93 def blank(value) !present(value) end
call(name, args)
click to toggle source
# File lib/travis/conditions/v1/eval.rb, line 77 def call(name, args) send(name.to_s.downcase, *args.map { |arg| evl(arg) }) end
cast(obj)
click to toggle source
# File lib/travis/conditions/v1/eval.rb, line 105 def cast(obj) case obj.to_s.downcase when 'false' false when 'true' true else obj end end
concat(*args)
click to toggle source
# File lib/travis/conditions/v1/eval.rb, line 85 def concat(*args) args.inject('') { |str, arg| str + arg.to_s } end
env(key = nil)
click to toggle source
# File lib/travis/conditions/v1/eval.rb, line 81 def env(key = nil) data.env(key) end
eq(lft, rgt)
click to toggle source
# File lib/travis/conditions/v1/eval.rb, line 28 def eq(lft, rgt) evl(lft) == evl(rgt) end
evl(expr)
click to toggle source
# File lib/travis/conditions/v1/eval.rb, line 11 def evl(expr) expr = send(*expr) if expr.is_a?(Array) cast(expr) end
false(value)
click to toggle source
# File lib/travis/conditions/v1/eval.rb, line 101 def false(value) !value end
in(lft, rgt)
click to toggle source
# File lib/travis/conditions/v1/eval.rb, line 45 def in(lft, rgt) rgt = rgt.map { |rgt| evl(rgt) } rgt.include?(evl(lft)) end
is(lft, rgt)
click to toggle source
# File lib/travis/conditions/v1/eval.rb, line 54 def is(lft, rgt) send(rgt, evl(lft)) end
is_not(lft, rgt)
click to toggle source
# File lib/travis/conditions/v1/eval.rb, line 58 def is_not(lft, rgt) not evl([:is, lft, rgt]) end
match(lft, rgt)
click to toggle source
# File lib/travis/conditions/v1/eval.rb, line 36 def match(lft, rgt) lft, rgt = evl(lft), evl(rgt) lft && rgt && lft =~ rgt end
not(lft)
click to toggle source
# File lib/travis/conditions/v1/eval.rb, line 16 def not(lft) !evl(lft) end
not_eq(lft, rgt)
click to toggle source
# File lib/travis/conditions/v1/eval.rb, line 32 def not_eq(lft, rgt) not eq(lft, rgt) end
not_in(lft, rgt)
click to toggle source
# File lib/travis/conditions/v1/eval.rb, line 50 def not_in(lft, rgt) not evl([:in, lft, rgt]) end
not_match(lft, rgt)
click to toggle source
# File lib/travis/conditions/v1/eval.rb, line 41 def not_match(lft, rgt) not match(lft, rgt) end
or(lft, rgt)
click to toggle source
# File lib/travis/conditions/v1/eval.rb, line 20 def or(lft, rgt) evl(lft) || evl(rgt) end
present(value)
click to toggle source
# File lib/travis/conditions/v1/eval.rb, line 89 def present(value) value.respond_to?(:empty?) ? !value.empty? : !!value end
reg(expr)
click to toggle source
# File lib/travis/conditions/v1/eval.rb, line 66 def reg(expr) str = evl(expr) Regexp.new(str) if str rescue RegexpError => e raise ArgumentError.new("Invalid regular expression: /#{str}/") end
true(value)
click to toggle source
# File lib/travis/conditions/v1/eval.rb, line 97 def true(value) !!value end
val(str)
click to toggle source
# File lib/travis/conditions/v1/eval.rb, line 62 def val(str) str end
var(name)
click to toggle source
# File lib/travis/conditions/v1/eval.rb, line 73 def var(name) data[name] end