Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[Install/Update] Minor cleanup.

  • Loading branch information...
commit b09ccf1adacacce835af158978fe66619b0d43d9 1 parent ae569fc
@fabiopelosin fabiopelosin authored
View
24 lib/cocoapods/installer.rb
@@ -37,8 +37,9 @@ def target_installers
end.compact
end
- # Install the pods. If the resolver wants the installation of pod it is done
- # even if it exits. In any case if the pod doesn't exits it is installed.
+ # Install the Pods. If the resolver indicated that a Pod should be installed
+ # and it exits, it is removed an then reinstalled. In any case if the Pod
+ # doesn't exits it is installed.
#
# @return [void]
#
@@ -149,7 +150,7 @@ def run_post_install_hooks
# we loop over target installers instead of pods, because we yield the target installer
# to the spec post install hook.
target_installers.each do |target_installer|
- @specs_by_target[target_installer.target_definition].each do |spec|
+ specs_by_target[target_installer.target_definition].each do |spec|
spec.post_install(target_installer)
end
end
@@ -170,6 +171,15 @@ def generate_dummy_source(target_installer)
target_installer.target.source_build_phases.first << project_file
end
+ def specs_by_target
+ @specs_by_target ||= @resolver.resolve
+ end
+
+ # @return [Array<Specification>] All dependencies that have been resolved.
+ def specifications
+ specs_by_target.values.flatten
+ end
+
# @return [Array<LocalPod>] A list of LocalPod instances for each
# dependency that is not a download-only one.
def pods
@@ -188,14 +198,6 @@ def pods_by_target
result
end
- def specifications
- specs_by_target.values.flatten
- end
-
- def specs_by_target
- @specs_by_target ||= @resolver.resolve
- end
-
private
def print_title(title, only_verbose = true)
View
15 lib/cocoapods/lockfile.rb
@@ -27,19 +27,9 @@ def self.generate(podfile, specs)
#
attr_reader :to_hash
- # @param [Pathname] the path of the Lockfile.
- # If no other value is provided the Lockfile is read from this path.
- # @param [Podfile] the Podfile to use for generating the Lockfile.
- # @param [specs] the specs installed.
+ # @param [Hash] hash A Hash representation of a Lockfile.
#
def initialize(hash)
- if Version.new(hash["COCOAPODS"]) <= Version.new("0.11")
- # Convert old format to be compatible
- # - Pods:
- # - libPusher (1.0) [HEAD] -> libPusher (HEAD from 1.0)
- # - Dependencies:
- # - libPusher [HEAD] -> libPusher (HEAD)
- end
@to_hash = hash
end
@@ -217,7 +207,8 @@ def to_yaml
to_hash.to_yaml.gsub(/^--- ?\n/,"").gsub(/^([A-Z])/,"\n\\1")
end
- # @return [Dictionary] The Dictionary representation of the Lockfile.
+ # @return [Hash] The Hash representation of the Lockfile generated from
+ # a given Podfile and the list of resolved Specifications.
#
def self.generate_hash_from_podfile(podfile, specs)
hash = {}
View
29 lib/cocoapods/resolver.rb
@@ -22,17 +22,17 @@ class Resolver
#
attr_reader :lockfile
- # @return [Lockfile] The Sandbox used by the resolver to find external
+ # @return [Sandbox] The Sandbox used by the resolver to find external
# dependencies.
#
attr_reader :sandbox
- # @return [Array<Strings>] The name of the pods coming from an
- # external sources
+ # @return [Array<Strings>] The name of the pods that have an
+ # external source.
#
attr_reader :pods_from_external_sources
- # @return [Array<Set>] The set used to resolve the dependencies.
+ # @return [Array<Set>] A cache of the sets used to resolve the dependencies.
#
attr_reader :cached_sets
@@ -50,15 +50,10 @@ def initialize(podfile, lockfile, sandbox)
@podfile = podfile
@lockfile = lockfile
@sandbox = sandbox
-
@update_external_specs = true
+
@cached_sets = {}
@cached_sources = Source::Aggregate.new
- @cached_specs = {}
- @specs_by_target = {}
- @pods_from_external_sources = []
- @dependencies_podfile_incompatible = []
- @log_indent = 0;
end
# Identifies the specifications that should be installed according whether
@@ -67,6 +62,11 @@ def initialize(podfile, lockfile, sandbox)
# @return [Hash{Podfile::TargetDefinition => Array<Specification>}] specs_by_target
#
def resolve
+ @cached_specs = {}
+ @specs_by_target = {}
+ @pods_from_external_sources = []
+ @log_indent = 0;
+
if @lockfile
puts "\nFinding added, modified or removed dependencies:".green if config.verbose?
@pods_by_state = @lockfile.detect_changes_with_podfile(podfile)
@@ -137,8 +137,8 @@ def pods_to_install
end
# @return [Array<Strings>] The name of the pods that were installed
- # but don't have any dependency anymore. It returns the name
- # of the Pod stripped from subspecs.
+ # but don't have any dependency anymore. The name of the Pods are
+ # stripped from subspecs.
#
def removed_pods
return [] unless lockfile
@@ -152,8 +152,7 @@ def removed_pods
private
- # Locks the version of the previously installed pods if they are still
- # compatible and were required by the Podfile.
+ # Locks the given Pods to the version stored in the Lockfile.
#
# @return [void]
#
@@ -221,8 +220,8 @@ def find_dependency_specs(dependent_specification, dependencies, target_definiti
spec.version.head = dependency.head?
# And recursively load the dependencies of the spec.
find_dependency_specs(spec, spec.dependencies, target_definition) if spec.dependencies
- validate_platform(spec || @cached_specs[dependency.name], target_definition)
end
+ validate_platform(spec || @cached_specs[dependency.name], target_definition)
end
@log_indent -= 1
end
View
2  lib/cocoapods/specification.rb
@@ -447,7 +447,7 @@ def dependency_by_top_level_spec_name(name)
end
def to_s
- version ? "#{name} (#{version})" : name
+ "#{name} (#{version})"
end
def inspect
View
22 spec/unit/lockfile_spec.rb
@@ -164,28 +164,6 @@ def tmp_path
lockfile = Pod::Lockfile.from_file(temporary_directory + 'Podfile.lock_not_existing')
lockfile.should == nil
end
-
- xit "updates files generated by old versions of CocoaPods" do
- tmp_path = temporary_directory + 'Podfile.lock'
- text = <<-LOCKFILE.strip_heredoc
- PODS:
- - BananaLib (1.0) [HEAD]:
- - monkey (< 1.0.9, ~> 1.0.1)
- - monkey (1.0.8)
-
- DEPENDENCIES:
- - BananaLib (HEAD)
- LOCKFILE
- File.open(tmp_path, 'w') {|f| f.write(text) }
- lockfile = Pod::Lockfile.from_file(tmp_path)
- lockfile.to_hash.should == {
- "PODS"=>[
- {"BananaLib (HEAD from 1.0)" => ["monkey (< 1.0.9, ~> 1.0.1)"]},
- "monkey (1.0.8)"
- ],
- "DEPENDENCIES" => ["BananaLib (~> 1.0)"]
- }
- end
end
describe "Concerning the identification of changes in the Podfile" do
View
1  spec/unit/resolver_spec.rb
@@ -356,6 +356,7 @@ def set.specification; spec = super; spec.platform = @stubbed_platform; spec; en
@resolver.should_install?("libPusher").should.be.true
end
+ # TODO: stub the specification resolution for the sandbox
xit "it always suggests to update pods from external sources" do
podfile = Podfile.new do
platform :ios
Please sign in to comment.
Something went wrong with that request. Please try again.