Class: KnapsackPro::Crypto::Decryptor

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

Defined Under Namespace

Classes: TooManyEncryptedTestFilesError

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(test_files, encrypted_test_files) ⇒ Decryptor

Returns a new instance of Decryptor.



15
16
17
18
# File 'lib/knapsack_pro/crypto/decryptor.rb', line 15

def initialize(test_files, encrypted_test_files)
  @test_files = test_files
  @encrypted_test_files = encrypted_test_files
end

Class Method Details

.call(test_files, encrypted_test_files) ⇒ Object



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

def self.call(test_files, encrypted_test_files)
  if KnapsackPro::Config::Env.test_files_encrypted?
    new(test_files, encrypted_test_files).call
  else
    # those test files are not encrypted
    encrypted_test_files
  end
end

Instance Method Details

#callObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/knapsack_pro/crypto/decryptor.rb', line 20

def call
  decrypted_test_files = []

  test_files.each do |test_file|
    encrypted_path = Digestor.salt_hexdigest(test_file['path'])
    encrypted_test_file = find_encrypted_test_file(encrypted_path)
    next if encrypted_test_file.nil?

    decrypted_test_file = encrypted_test_file.dup
    decrypted_test_file['path'] = test_file['path']

    decrypted_test_files << decrypted_test_file
  end

  decrypted_test_files
end