Class: PodBuilder::Command::Clean
- Inherits:
-
Object
- Object
- PodBuilder::Command::Clean
- Defined in:
- lib/pod_builder/command/clean.rb
Class Method Summary collapse
Class Method Details
.call ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/pod_builder/command/clean.rb', line 7 def self.call Configuration.check_inited PodBuilder::prepare_basepath install_update_repo = OPTIONS.fetch(:update_repos, true) installer, analyzer = Analyze.installer_at(PodBuilder::basepath, install_update_repo) all_buildable_items = Analyze.podfile_items(installer, analyzer) prebuilt_items(all_buildable_items) install_sources(all_buildable_items) puts "\n\nš done!\n".green return 0 end |
.install_sources(buildable_items) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/pod_builder/command/clean.rb', line 47 def self.install_sources(buildable_items) puts "Looking for unused sources".yellow podspec_names = buildable_items.map(&:root_name).uniq base_path = PodBuilder::basepath("Sources") paths_to_delete = [] repo_paths = Dir.glob("#{base_path}/*") repo_paths.each do |path| podspec_name = File.basename(path) if podspec_names.include?(podspec_name) next end paths_to_delete.push(path) end paths_to_delete.flatten.each do |path| confirm = ask("#{path} unused.\nDelete it? [Y/N] ") { |yn| yn.limit = 1, yn.validate = /[yn]/i } if confirm.downcase == 'y' || OPTIONS.has_key?(:no_stdin_available) PodBuilder::safe_rm_rf(path) end end end |
.prebuilt_items(buildable_items) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/pod_builder/command/clean.rb', line 22 def self.prebuilt_items(buildable_items) puts "Cleaning prebuilt folder".yellow root_names = buildable_items.map(&:root_name).uniq Dir.glob(PodBuilder::prebuiltpath("*")).each do |path| basename = File.basename(path) unless root_names.include?(basename) puts "Cleanining up `#{basename}`, no longer found among dependencies".blue PodBuilder::safe_rm_rf(path) end end puts "Cleaning dSYM folder".yellow module_names = buildable_items.map(&:module_name).uniq Dir.glob(File.join(PodBuilder::dsympath, "**/*.dSYM")).each do |path| dsym_basename = File.basename(path, ".*") dsym_basename.gsub!(/\.framework$/, "") unless module_names.include?(dsym_basename) puts "Cleanining up `#{dsym_basename}`, no longer found among dependencies".blue PodBuilder::safe_rm_rf(path) end end end |