lib/keyring.rb in cocoapods-keys-2.2.1 vs lib/keyring.rb in cocoapods-keys-2.3.0

- old
+ new

@@ -1,6 +1,8 @@ -require 'osx_keychain' +require 'keychain' +require 'base64' +require 'json' module CocoaPodsKeys class Keyring attr_accessor :keys, :path, :name @@ -25,15 +27,21 @@ def self.keychain_prefix 'cocoapods-keys-' end def keychain - @keychain ||= OSXKeychain.new + @keychain ||= Keychain.generic_passwords end def save(key, value) - keychain[self.class.keychain_prefix + name, key] = value + item = keychain.where(service: self.class.keychain_prefix + name, account: key).first + if item + item.password = value + item.save! + else + keychain_has_keykeychain.create(service: self.class.keychain_prefix + name, password: value, account: key) + end end def keychain_data Hash[ @keys.map { |key| [key, keychain_value(key)] } @@ -51,10 +59,10 @@ has_key end def keychain_value(key) - ENV[key] || keychain[self.class.keychain_prefix + name, key] + ENV[key] || keychain.where(service: self.class.keychain_prefix + name, account: key).first.password end def camel_cased_keys Hash[keychain_data.map { |(key, value)| [key[0].downcase + key[1..-1], value] }] end