Class: Fastlane::Flint::Utils

Inherits:
Object
  • Object
show all
Defined in:
lib/fastlane/plugin/flint/helper/utils.rb

Class Method Summary collapse

Class Method Details

.activate(keystore_name, alias_name, password, keystore_properties_path) ⇒ Object



13
14
15
16
17
18
19
20
21
# File 'lib/fastlane/plugin/flint/helper/utils.rb', line 13

def self.activate(keystore_name, alias_name, password, keystore_properties_path)
  template = File.read("#{Flint::ROOT}/assets/KeystorePropertiesTemplate")
  template.gsub!("[[STORE_FILE]]", keystore_name)
  template.gsub!("[[KEY_ALIAS]]", alias_name)
  template.gsub!("[[PASSWORD]]", password)
  File.write(keystore_properties_path, template)

  # We could test that the required lines are added to build.gradle
end

.get_keystore_info(item_path, password) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/fastlane/plugin/flint/helper/utils.rb', line 34

def self.get_keystore_info(item_path, password)
  cmd = 
  begin
    output = IO.popen("keytool -list -v -keystore '#{item_path}' -storepass '#{password}'")
    lines = output.readlines
    output.close
    raise lines.join unless $?.exitstatus == 0
  rescue => ex
    raise ex
  end

  return lines
end

.import(item_path, target_path, keystore_name, alias_name, password) ⇒ Object



9
10
11
# File 'lib/fastlane/plugin/flint/helper/utils.rb', line 9

def self.import(item_path, target_path, keystore_name, alias_name, password)
  FileUtils.cp(item_path, target_path)
end

.installed?(item_path, target_path) ⇒ Boolean

Returns:

  • (Boolean)


23
24
25
26
27
28
29
30
31
32
# File 'lib/fastlane/plugin/flint/helper/utils.rb', line 23

def self.installed?(item_path, target_path)
  if File.exist?(target_path)
    installed_digest = Digest::MD5.hexdigest File.read target_path
    item_digest = Digest::MD5.hexdigest File.read item_path

    return installed_digest == item_digest
  end

  return false
end