Sha256: ffbbaf843ae55bd4befb5f6fa05ab57b726b323fd0cd8a0fcbc3f5c4e5643995
Contents?: true
Size: 1.38 KB
Versions: 3
Compression:
Stored size: 1.38 KB
Contents
require 'cocoapods' module CocoaPodsKeys class NameWhisperer def self.get_project_name podfile = Pod::Config.instance.podfile if podfile user_xcodeproj = xcodeproj_from_podfile(podfile) end user_xcodeproj || search_folders_for_xcodeproj end private def self.xcodeproj_from_podfile(podfile) unless podfile.target_definition_list.empty? project_path = podfile.target_definition_list.first.user_project_path File.basename(project_path, '.xcodeproj') if project_path end end def self.search_folders_for_xcodeproj ui = Pod::UserInterface xcodeprojects = Pathname.glob('**/*.xcodeproj').reject { |path| path.to_s.start_with?('Pods/') } if xcodeprojects.length == 1 Pathname(xcodeprojects.first).basename('.xcodeproj') else error_message = (xcodeprojects.length > 1) ? 'found too many' : "couldn't find any" projects = xcodeprojects.map(&:basename).join(' ') ui.puts 'CocoaPods-Keys ' + error_message + ' Xcode projects (' + projects + '). Please give a name for this project.' answer = '' loop do ui.print ' > ' answer = ui.gets.strip break unless answer.empty? end answer end end private_class_method :xcodeproj_from_podfile private_class_method :search_folders_for_xcodeproj end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
cocoapods-keys-2.0.0 | lib/name_whisperer.rb |
cocoapods-keys-1.7.0 | lib/name_whisperer.rb |
cocoapods-keys-1.6.1 | lib/name_whisperer.rb |