Class: Pod::Command::Spec
- Inherits:
-
Pod::Command
- Object
- CLAide::Command
- Pod::Command
- Pod::Command::Spec
- Defined in:
- lib/cocoapods/command/spec.rb,
lib/cocoapods/command/spec/cat.rb,
lib/cocoapods/command/spec/edit.rb,
lib/cocoapods/command/spec/lint.rb,
lib/cocoapods/command/spec/which.rb,
lib/cocoapods/command/spec/create.rb
Defined Under Namespace
Classes: Cat, Create, Edit, Lint, Which
Instance Method Summary collapse
-
#all_paths_from_set(set, specific_version = nil) ⇒ String
private
Of spec paths one on each line.
-
#get_path_of_spec(spec, version_filter = false) ⇒ Pathname
private
The absolute path or paths of the given podspec.
-
#pathname_from_spec(spec, _source) ⇒ Pathname
private
The absolute path of the given spec and source.
-
#spec_and_source_from_set(set) ⇒ Specification, Source
private
The highest known specification with it's source of the given set.
- #validate_regex!(query) ⇒ Object private
Methods inherited from Pod::Command
#ensure_master_spec_repo_exists!, ensure_not_root_or_allowed!, git_version, #initialize, #installer_for_config, options, report_error, run, #verify_lockfile_exists!, verify_minimum_git_version!, #verify_podfile_exists!, verify_xcode_license_approved!
Methods included from Pod::Config::Mixin
Constructor Details
This class inherits a constructor from Pod::Command
Instance Method Details
#all_paths_from_set(set, specific_version = nil) ⇒ String (private)
Returns of spec paths one on each line.
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/cocoapods/command/spec.rb', line 73 def all_paths_from_set(set, specific_version = nil) paths = '' sources = set.sources sources.each do |source| versions = source.versions(set.name) if specific_version versions = versions.select { |v| v.version == specific_version } end versions.each do |version| spec = source.specification(set.name, version) paths += "#{pathname_from_spec(spec, source)}\n" end end raise Informative, "Can't find spec for #{set.name}." if paths.empty? paths end |
#get_path_of_spec(spec, version_filter = false) ⇒ Pathname (private)
Returns the absolute path or paths of the given podspec.
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/cocoapods/command/spec.rb', line 43 def get_path_of_spec(spec, version_filter = false) sets = config.sources_manager.search_by_name(spec) if sets.count == 1 set = sets.first elsif sets.map(&:name).include?(spec) set = sets.find { |s| s.name == spec } else names = sets.map(&:name) * ', ' raise Informative, "More than one spec found for '#{spec}':\n#{names}" end if version_filter.is_a? String all_paths_from_set(set, version_filter).split(/\n/).first elsif version_filter == true all_paths_from_set(set) else best_spec, spec_source = spec_and_source_from_set(set) pathname_from_spec(best_spec, spec_source) end end |
#pathname_from_spec(spec, _source) ⇒ Pathname (private)
Returns the absolute path of the given spec and source.
67 68 69 |
# File 'lib/cocoapods/command/spec.rb', line 67 def pathname_from_spec(spec, _source) Pathname(spec.defined_in_file) end |
#spec_and_source_from_set(set) ⇒ Specification, Source (private)
Returns the highest known specification with it's source of the given set.
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/cocoapods/command/spec.rb', line 99 def spec_and_source_from_set(set) sources = set.sources best_source = best_version = nil sources.each do |source| versions = source.versions(set.name) versions.each do |version| if !best_version || version > best_version best_source = source best_version = version end end end if !best_source || !best_version raise Informative, "Unable to locate highest known specification for `#{set.name}'" end [best_source.specification(set.name, best_version), best_source] end |
#validate_regex!(query) ⇒ Object (private)
27 28 29 30 31 |
# File 'lib/cocoapods/command/spec.rb', line 27 def validate_regex!(query) /#{query}/ rescue RegexpError help! 'A valid regular expression is required.' end |