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.



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

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

Class Method Details

.call(test_suite, test_files) ⇒ Object



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

def self.call(test_suite, test_files)
  return test_files unless KnapsackPro::Config::Env.test_files_encrypted?

  new(test_suite.calculate_test_files.test_files, test_files).call
end

Instance Method Details

#callObject



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

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