Skip to content

Commit

Permalink
Merge c8c332f into 2095888
Browse files Browse the repository at this point in the history
  • Loading branch information
netbe committed Nov 5, 2013
2 parents 2095888 + c8c332f commit 326872c
Show file tree
Hide file tree
Showing 7 changed files with 103 additions and 16 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Expand Up @@ -8,7 +8,7 @@ gemspec
group :development do
# To develop the deps in tandem use the `LOCAL GIT REPOS` feature of Bundler.
# For more info see http://bundler.io/git.html#local
gem 'cocoapods-core', :git => "https://github.com/CocoaPods/Core.git", :branch => 'master'
gem 'cocoapods-core', :git => "https://github.com/netbe/Core.git", :branch => 'feature/specs-sources'
gem 'xcodeproj', :git => "https://github.com/CocoaPods/Xcodeproj.git", :branch => 'master'
gem 'cocoapods-downloader', :git => "https://github.com/CocoaPods/cocoapods-downloader.git", :branch => 'master'
gem 'claide', :git => 'https://github.com/CocoaPods/CLAide.git', :branch => 'master'
Expand Down
20 changes: 10 additions & 10 deletions Gemfile.lock
Expand Up @@ -5,16 +5,6 @@ GIT
specs:
claide (0.3.2)

GIT
remote: https://github.com/CocoaPods/Core.git
revision: 26f43e2487ef158e1c01f7d2594fe6e3a1034bf0
branch: master
specs:
cocoapods-core (0.27.1)
activesupport (>= 3.2.15, < 4)
json_pure (~> 1.8)
nap (~> 0.5)

GIT
remote: https://github.com/CocoaPods/Xcodeproj.git
revision: ceae7a7be45e760830ee95a7b4481bdab6df149d
Expand Down Expand Up @@ -48,6 +38,16 @@ GIT
prettybacon (0.0.1)
bacon (~> 1.2)

GIT
remote: https://github.com/netbe/Core.git
revision: 88b3a9b4b1c01e3e2d2b5ac1efa7e1bcd06545d7
branch: feature/specs-sources
specs:
cocoapods-core (0.27.1)
activesupport (>= 3.2.15, < 4)
json_pure (~> 1.8)
nap (~> 0.5)

PATH
remote: .
specs:
Expand Down
12 changes: 10 additions & 2 deletions lib/cocoapods/installer/analyzer.rb
Expand Up @@ -152,8 +152,16 @@ def generate_podfile_state
#
def update_repositories_if_needed
unless config.skip_repo_update?
UI.section 'Updating spec repositories' do
SourcesManager.update
if podfile.sources.empty?
UI.section 'Updating spec repositories' do
SourcesManager.update
end
else
podfile.sources.each do |source|
UI.section "Updating spec repository #{source}" do
SourcesManager.update(source)
end
end
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/cocoapods/resolver.rb
Expand Up @@ -53,7 +53,7 @@ def initialize(sandbox, podfile, locked_dependencies = [])
# definition.
#
def resolve
@cached_sources = SourcesManager.aggregate
@cached_sources = SourcesManager.aggregate(true)
@cached_sets = {}
@cached_specs = {}
@specs_by_target = {}
Expand Down
44 changes: 42 additions & 2 deletions lib/cocoapods/sources_manager.rb
Expand Up @@ -8,11 +8,30 @@ class << self

include Config::Mixin


# @return [Array<Source>] the sources listed by the current Podfile.
#
def podfile_sources
sources = []
self.podfile_repos_dirs.each do |repo|
sources << Source.new(repo)
end
sources << Source.new(master_repo_dir) if sources.empty?
sources
end

# @param [Bool] podfile use podfile sources
#
# @return [Source::Aggregate] the aggregate of all the sources known to
# this installation of CocoaPods.
#
def aggregate
Source::Aggregate.new(config.repos_dir)
def aggregate(podfile = false)
if podfile
repos = podfile_repos_dirs
else
repos = config.repos_dir.children.select(&:directory?)
end
Source::Aggregate.new(repos)
end

# @return [Array<Source>] the list of all the sources known to this
Expand Down Expand Up @@ -268,8 +287,29 @@ def master_repo_functional?
master_repo_dir.exist? && repo_compatible?(master_repo_dir)
end

public

# @!group Source repos
#-----------------------------------------------------------------------#

# @return [Array<Pathname>] directories of all specified sources in Podfile
#
def podfile_repos_dirs
pathnames = []
if config.podfile
config.podfile.sources.each do |source_name|
pathnames << source_repo_dir(source_name)
end
end
pathnames
end

# @return [Pathname] the directory where a given CocoaPods source is stored.
#
def source_repo_dir(name)
config.repos_dir + name
end

end
end
end
Expand Down
23 changes: 23 additions & 0 deletions spec/unit/installer/analyzer_spec.rb
Expand Up @@ -392,7 +392,30 @@ module Pod
end

#--------------------------------------#
describe "#update_repositories_if_needed" do
it "updates the podfile repositories" do
config.skip_repo_update = false


def @podfile.sources
["netbe", "master"]
end

SourcesManager.expects(:update).with("netbe").once
SourcesManager.expects(:update).with("master").once
@analyzer.send(:update_repositories_if_needed)
end

it "updates the default repositories" do
config.skip_repo_update = false
def @podfile.sources
[]
end
SourcesManager.expects(:update).once
@analyzer.send(:update_repositories_if_needed)
end

end
end
end
end
16 changes: 16 additions & 0 deletions spec/unit/sources_manager_spec.rb
Expand Up @@ -72,6 +72,22 @@ module Pod
path = SourcesManager.search_index_path.to_s
path.should.match %r[Library/Caches/CocoaPods/search_index.yaml]
end

it "returns the sources from podfile" do
@podfile = Podfile.new do
platform :ios
source 'netbe'
source 'cocoapods'
end
SourcesManager.config.stubs(:podfile).returns(@podfile)
sources = SourcesManager.podfile_sources
sources.map(&:name).should == %w[netbe cocoapods]
end

it "returns cocoapods source if none specified" do
sources = SourcesManager.podfile_sources
sources.map(&:name).should == %w[master]
end
end

#-------------------------------------------------------------------------#
Expand Down

0 comments on commit 326872c

Please sign in to comment.