Class: Tug::Keychain

Inherits:
Object
  • Object
show all
Defined in:
lib/tug/keychain/keychain.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(keychain_yaml) ⇒ Keychain

Returns a new instance of Keychain.



17
18
19
20
21
22
23
24
# File 'lib/tug/keychain/keychain.rb', line 17

def initialize(keychain_yaml)
  @apple_certificate          = keychain_yaml["apple_certificate"]
  @distribution_certificate   = keychain_yaml["distribution_certificate"]
  @distribution_profile       = keychain_yaml["distribution_profile"]
  @private_key                = keychain_yaml["private_key"]
  @private_key_password       = ENV['TUG_P12_PASSWORD']
  @name                       = "tug"
end

Instance Attribute Details

#apple_certificateObject (readonly)

Returns the value of attribute apple_certificate.



4
5
6
# File 'lib/tug/keychain/keychain.rb', line 4

def apple_certificate
  @apple_certificate
end

#distribution_certificateObject (readonly)

Returns the value of attribute distribution_certificate.



5
6
7
# File 'lib/tug/keychain/keychain.rb', line 5

def distribution_certificate
  @distribution_certificate
end

#distribution_profileObject (readonly)

Returns the value of attribute distribution_profile.



6
7
8
# File 'lib/tug/keychain/keychain.rb', line 6

def distribution_profile
  @distribution_profile
end

#nameObject

Returns the value of attribute name.



9
10
11
# File 'lib/tug/keychain/keychain.rb', line 9

def name
  @name
end

#private_keyObject (readonly)

Returns the value of attribute private_key.



7
8
9
# File 'lib/tug/keychain/keychain.rb', line 7

def private_key
  @private_key
end

#private_key_passwordObject

Returns the value of attribute private_key_password.



8
9
10
# File 'lib/tug/keychain/keychain.rb', line 8

def private_key_password
  @private_key_password
end

Class Method Details

.keychain(keychain_yaml) ⇒ Object



12
13
14
# File 'lib/tug/keychain/keychain.rb', line 12

def keychain(keychain_yaml)
  Tug::Keychain.new(keychain_yaml)
end

Instance Method Details

#create_keychainObject



26
27
28
# File 'lib/tug/keychain/keychain.rb', line 26

def create_keychain
  system("security create-keychain -p tug #{name}.keychain")
end

#delete_keychainObject



34
35
36
# File 'lib/tug/keychain/keychain.rb', line 34

def delete_keychain
  system("security delete-keychain #{name}.keychain")
end

#import_apple_certificateObject



38
39
40
# File 'lib/tug/keychain/keychain.rb', line 38

def import_apple_certificate
  system(import_command(apple_certificate))
end

#import_distribution_certificateObject



42
43
44
# File 'lib/tug/keychain/keychain.rb', line 42

def import_distribution_certificate
  system(import_command(distribution_certificate))
end

#import_private_keyObject



46
47
48
# File 'lib/tug/keychain/keychain.rb', line 46

def import_private_key
  system(import_command(private_key) + " -P '#{private_key_password}'")
end

#import_profileObject



50
51
52
53
# File 'lib/tug/keychain/keychain.rb', line 50

def import_profile
  FileUtils.mkdir_p "#{File.expand_path('~')}/Library/MobileDevice/Provisioning\ Profiles/"
  system("cp #{distribution_profile} #{profile_export_path}")
end

#select_keychain(keychain_name = name) ⇒ Object



30
31
32
# File 'lib/tug/keychain/keychain.rb', line 30

def select_keychain(keychain_name=name)
  system("security default-keychain -s #{keychain_name}.keychain")
end