Module: Request::Branches

Defined in:
lib/travis/model/request/branches.rb

Instance Method Summary collapse

Instance Method Details

#branch_excluded?(branch) ⇒ Boolean

Returns:

  • (Boolean)


7
8
9
# File 'lib/travis/model/request/branches.rb', line 7

def branch_excluded?(branch)
  excluded_branches && excluded_branches.include?(branch)
end

#branch_included?(branch) ⇒ Boolean

Returns:

  • (Boolean)


3
4
5
# File 'lib/travis/model/request/branches.rb', line 3

def branch_included?(branch)
  !included_branches || included_branches.include?(branch)
end

#branches_configObject



19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/travis/model/request/branches.rb', line 19

def branches_config
  case config.try(:[], :branches)
  when String
    { :only => config[:branches].split(',').map(&:strip) }
  when Array
    { :only => config[:branches] }
  when Hash
    config[:branches] # TODO should split :only and :except values if these are strings. maybe use a specialized Hashr class.
  else
    {}
  end
end

#excluded_branchesObject



15
16
17
# File 'lib/travis/model/request/branches.rb', line 15

def excluded_branches
  branches_config[:except]
end

#included_branchesObject



11
12
13
# File 'lib/travis/model/request/branches.rb', line 11

def included_branches
  branches_config[:only]
end