lib/plugin.rb in cocoapods-keys-1.6.0 vs lib/plugin.rb in cocoapods-keys-1.6.1

- old
+ new

@@ -4,14 +4,19 @@ module CocoaPodsKeys class << self include FileUtils - def setup + # Register for the pre-install hooks to setup & run Keys + Pod::HooksManager.register('cocoapods-keys', :pre_install) do |context, options| + CocoaPodsKeys.setup(context.podfile, options) + end + + def setup(podfile, options) require 'preinstaller' - unless PreInstaller.new(user_options).setup + unless PreInstaller.new(options).setup raise Pod::Informative, 'Could not load key data' end installation_root = Pod::Config.instance.installation_root keys_path = installation_root.+('Pods/CocoaPodsKeys/') @@ -20,11 +25,11 @@ mkdir_p keys_path podspec_path = Pathname(__dir__) + '../templates' + 'Keys.podspec.json' cp podspec_path, keys_path # Get all the keys - local_user_options = user_options || {} + local_user_options = options || {} project = local_user_options.fetch('project') { CocoaPodsKeys::NameWhisperer.get_project_name } keyring = KeyringLiberator.get_current_keyring(project, Dir.getwd) || Keyring.new(project, Dir.getwd, local_user_options['keys']) @@ -37,20 +42,20 @@ File.write(interface_file, key_master.interface) File.write(implementation_file, key_master.implementation) # Add our template podspec - add_keys_to_pods(keys_path.relative_path_from(installation_root), user_options) + add_keys_to_pods(podfile, keys_path.relative_path_from(installation_root), options) # Remove the shared scheme for this pod Pod::HooksManager.register('cocoapods-keys', :post_install) do shared_scheme_path = 'Pods/Pods.xcodeproj/xcshareddata/xcschemes/Keys.xcscheme' FileUtils.rm(shared_scheme_path) if File.exist?(shared_scheme_path) end end - def add_keys_to_pods(keys_path, options) + def add_keys_to_pods(podfile, keys_path, options) keys_targets = options['target'] || options['targets'] if keys_targets # Get a list of targets, even if only one was specified keys_target_list = ([] << keys_targets).flatten @@ -71,36 +76,8 @@ else # otherwise let it go in global podfile.pod 'Keys', :path => keys_path.to_path end - end - - private - - def podfile - Pod::Config.instance.podfile - end - - def user_options - options = podfile.plugins['cocoapods-keys'] - # Until CocoaPods provides a HashWithIndifferentAccess, normalize the hash keys here. - # See https://github.com/CocoaPods/CocoaPods/issues/3354 - options.with_indifferent_access - end - end -end - -module Pod - class Installer - alias_method :install_before_cocoapods_keys!, :install! - - def install! - CocoaPodsKeys.setup if validates_for_keys - install_before_cocoapods_keys! - end - - def validates_for_keys - podfile && podfile.plugins && !podfile.plugins['cocoapods-keys'].nil? end end end