Class: KnapsackPro::Crypto::BranchEncryptor

Inherits:
Object
  • Object
show all
Defined in:
lib/knapsack_pro/crypto/branch_encryptor.rb

Constant Summary collapse

NON_ENCRYPTABLE_BRANCHES =
%w(develop development dev master staging)

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(branch) ⇒ BranchEncryptor

Returns a new instance of BranchEncryptor.



14
15
16
# File 'lib/knapsack_pro/crypto/branch_encryptor.rb', line 14

def initialize(branch)
  @branch = branch
end

Class Method Details

.call(branch) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/knapsack_pro/crypto/branch_encryptor.rb', line 6

def self.call(branch)
  if KnapsackPro::Config::Env.branch_encrypted?
    new(branch).call
  else
    branch
  end
end

Instance Method Details

#callObject



18
19
20
21
22
23
24
# File 'lib/knapsack_pro/crypto/branch_encryptor.rb', line 18

def call
  if NON_ENCRYPTABLE_BRANCHES.include?(branch)
    branch
  else
    Digestor.salt_hexdigest(branch)[0..6]
  end
end