lib/plugin.rb in cocoapods-keys-1.0.2 vs lib/plugin.rb in cocoapods-keys-1.1.0
- old
+ new
@@ -2,13 +2,13 @@
module CocoaPodsKeys
class << self
def podspec_for_current_project(spec_contents)
local_user_options = user_options || {}
- project = local_user_options.fetch("project", CocoaPodsKeys::NameWhisperer.get_project_name)
+ project = local_user_options.fetch("project") { CocoaPodsKeys::NameWhisperer.get_project_name }
keyring = KeyringLiberator.get_keyring_named(project) || KeyringLiberator.get_keyring(Dir.getwd)
- raise Pod::Informative, "Could not load keyring" unless keyring
+ raise Pod::Informative, "Could not load keyring" unless keyring
key_master = KeyMaster.new(keyring)
spec_contents.gsub!(/%%SOURCE_FILES%%/, "#{key_master.name}.{h,m}")
spec_contents.gsub!(/%%PROJECT_NAME%%/, project)
end
@@ -26,29 +26,40 @@
def podfile
Pod::Config.instance.podfile
end
def user_options
- podfile.plugins["cocoapods-keys"]
+ options = podfile.plugins["cocoapods-keys"]
+ # Until CocoaPods provides a HashWithIndifferentAccess, normalize the hash keys here.
+ # See https://github.com/CocoaPods/CocoaPods/issues/3354
+ options.inject({}) do |normalized_hash, (key, value)|
+ normalized_hash[key.to_s] = value
+ normalized_hash
+ end
end
end
end
module Pod
class Installer
alias_method :install_before_cocoapods_keys!, :install!
def install!
- CocoaPodsKeys.setup
+ CocoaPodsKeys.setup if validates_for_keys
+
install_before_cocoapods_keys!
end
+ def validates_for_keys
+ Pod::Config.instance.podfile.plugins["cocoapods-keys"] != nil
+ end
+
class Analyzer
class SandboxAnalyzer
alias_method :pod_state_before_cocoapods_keys, :pod_state
- def pod_state(pod)
+ def pod_state(pod)
if pod == 'Keys'
# return :added if we were, otherwise assume the Keys have :changed since last install, following my mother's "Better Safe than Sorry" principle.
return :added if pod_added?(pod)
:changed
else
@@ -58,14 +69,14 @@
end
end
end
class Specification
- class << self
+ class << self
alias_method :from_string_before_cocoapods_keys, :from_string
def from_string(spec_contents, path, subspec_name = nil)
- if path.to_s.include? "Keys.podspec"
+ if path.basename.to_s =~ /\AKeys.podspec(?:.json)\Z/
CocoaPodsKeys.podspec_for_current_project(spec_contents)
end
from_string_before_cocoapods_keys(spec_contents, path, subspec_name)
end
end