Class: EnvBranch::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/env_branch/base.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeBase

Returns a new instance of Base.



5
6
7
# File 'lib/env_branch/base.rb', line 5

def initialize
  @branch_name = fetch_branch_name
end

Instance Attribute Details

#branch_nameObject (readonly)

Returns the value of attribute branch_name.



3
4
5
# File 'lib/env_branch/base.rb', line 3

def branch_name
  @branch_name
end

Instance Method Details

#branch?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/env_branch/base.rb', line 26

def branch?
  !branch_name.nil?
end

#fetch_branch_nameObject

travis-ci.org:

ENV['TRAVIS_BRANCH']

circleci.com:

ENV['CIRCLE_BRANCH']


18
19
20
21
22
23
24
# File 'lib/env_branch/base.rb', line 18

def fetch_branch_name
  if ENV['TRAVIS_BRANCH'] && !ENV['TRAVIS_BRANCH'].empty?
    ENV['TRAVIS_BRANCH']
  elsif ENV['CIRCLE_BRANCH'] && !ENV['CIRCLE_BRANCH'].empty?
    ENV['CIRCLE_BRANCH']
  end
end