Class: CocoaPodsKeys::KeyringLiberator
- Inherits:
-
Object
- Object
- CocoaPodsKeys::KeyringLiberator
- Defined in:
- lib/keyring_liberator.rb
Class Method Summary collapse
- .get_all_keyrings ⇒ Object
- .get_all_keyrings_named(name) ⇒ Object
- .get_current_keyring(name, cwd) ⇒ Object
- .get_keyring(path) ⇒ Object
- .get_keyring_named(name) ⇒ Object
-
.keys_dir ⇒ Object
Gets given a gives back a Keyring for the project by basically parsing it out of ~/.cocoapods/keys/“pathMD5”.yml.
- .prompt_if_already_existing(keyring) ⇒ Object
- .save_keyring(keyring) ⇒ Object
- .yaml_path_for_path(path) ⇒ Object
Class Method Details
.get_all_keyrings ⇒ Object
56 57 58 59 60 61 62 63 |
# File 'lib/keyring_liberator.rb', line 56 def self.get_all_keyrings return [] unless keys_dir.directory? rings = [] Pathname.glob(keys_dir + '*.yml').each do |path| rings << get_keyring_at_path(path) end rings end |
.get_all_keyrings_named(name) ⇒ Object
32 33 34 |
# File 'lib/keyring_liberator.rb', line 32 def self.get_all_keyrings_named(name) get_all_keyrings.find_all { |k| k.name == name } end |
.get_current_keyring(name, cwd) ⇒ Object
27 28 29 30 |
# File 'lib/keyring_liberator.rb', line 27 def self.get_current_keyring(name, cwd) found_by_name = name && get_all_keyrings.find { |k| k.name == name && k.path == cwd.to_s } found_by_name || KeyringLiberator.get_keyring(cwd) end |
.get_keyring(path) ⇒ Object
19 20 21 |
# File 'lib/keyring_liberator.rb', line 19 def self.get_keyring(path) get_keyring_at_path(yaml_path_for_path(path)) end |
.get_keyring_named(name) ⇒ Object
23 24 25 |
# File 'lib/keyring_liberator.rb', line 23 def self.get_keyring_named(name) get_all_keyrings.find { |k| k.name == name } end |
.keys_dir ⇒ Object
Gets given a gives back a Keyring for the project by basically parsing it out of ~/.cocoapods/keys/“pathMD5”.yml
10 11 12 |
# File 'lib/keyring_liberator.rb', line 10 def self.keys_dir Pathname('~/.cocoapods/keys/'). end |
.prompt_if_already_existing(keyring) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/keyring_liberator.rb', line 36 def self.prompt_if_already_existing(keyring) keyrings = get_all_keyrings_named(keyring.name) already_exists = File.exist?(yaml_path_for_path(keyring.path)) if !already_exists && keyrings.any? { |existing_keyring| File.exist?(yaml_path_for_path(existing_keyring.path)) } ui = Pod::UserInterface ui.puts "About to create a duplicate keyring file for project #{keyring.name.green}" ui.puts 'Entries in your Apple Keychain will be shared between both projects.' ui.puts "\nPress enter to continue, or `ctrl + c` to cancel" ui.gets end end |
.save_keyring(keyring) ⇒ Object
48 49 50 51 52 53 54 |
# File 'lib/keyring_liberator.rb', line 48 def self.save_keyring(keyring) keys_dir.mkpath if !ENV['TRAVIS'] && !ENV['TEAMCITY_VERSION'] && !ENV['CIRCLECI'] prompt_if_already_existing(keyring) end yaml_path_for_path(keyring.path).open('w') { |f| f.write(YAML.dump(keyring.to_hash)) } end |
.yaml_path_for_path(path) ⇒ Object
14 15 16 17 |
# File 'lib/keyring_liberator.rb', line 14 def self.yaml_path_for_path(path) sha = Digest::MD5.hexdigest(path.to_s) keys_dir + (sha + '.yml') end |