Skip to content

Commit 67e6900

Browse files
author
James Campbell
committed
Implemented downloader.
1 parent 3cf3595 commit 67e6900

File tree

2 files changed

+16
-22
lines changed

2 files changed

+16
-22
lines changed

lib/cocoapods-deploy/deploy_downloader.rb

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,32 @@ def download(config)
1616
end
1717

1818
def download_source(config)
19-
# TODO: Method for looping through dependency
2019
source = ExternalSources.from_dependency(dependency, config.podfile.defined_in_file)
21-
source.fetch(config.sandbox)
20+
source.fetch
2221
end
2322

2423
def download_podspec(config)
2524
dependencies_for_sources(config).each do |dep|
25+
puts "woo #{dep}"
2626
source = ExternalSources.from_dependency(dep, config.podfile.defined_in_file)
27-
source.fetch(config.sandbox)
27+
source.fetch
2828
end
2929
end
3030

31-
private
31+
def podfile_sources(config)
32+
return ["https://github.com/CocoaPods/CocoaPods.git"] if config.podfile.sources.empty?
33+
return config.podfile.sources
34+
end
3235

3336
def dependencies_for_sources(config)
34-
[]
37+
podfile_sources(config).map do |source|
38+
filename = File.basename(source, ".*")
39+
raw_url = File.join( File.dirname(source), filename )
40+
root_url = "#{raw_url}/raw"
41+
source = @dependency.external_source[:podspec].gsub('{root-url}', root_url)
42+
43+
Dependency.new(@dependency.name, {:podspec => source})
44+
end
3545
end
3646
end
3747
end

spec/deploy_downloader_spec.rb

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ module Pod
1616
Config.instance.stubs(:podfile).returns(@podfile)
1717

1818
@source = MockExternalSource.new
19+
ExternalSources.stubs(:from_dependency).returns(@source)
1920
end
2021

2122
it "should external source outside of repo" do
2223
dependency = Dependency.new("AFNetworking", { :git => "https://github.com/gowalla/AFNetworking.git"})
2324
downloader = DeployDownloader.new(dependency)
2425

25-
ExternalSources.stubs(:from_dependency).returns(@source)
2626
@source.expects(:fetch)
2727

2828
downloader.download(Config.instance)
@@ -31,24 +31,8 @@ module Pod
3131
it "should download source from main repo" do
3232
dependency = Dependency.new("AFNetworking", { :podspec => "{root-url}/master/Specs/AFNetworking/1.0/AFNetworking.podspec.json"})
3333
downloader = DeployDownloader.new(dependency)
34-
expected_dependency = Dependency.new("AFNetworking", { :podspec => "http://github.com/My/Repo.git/master/Specs/AFNetworking/1.0/AFNetworking.podspec.json"})
3534

36-
ExternalSources.expects(:from_dependency).with(expected_dependency, @podfile.defined_in_file)
3735
ExternalSources.stubs(:from_dependency).returns(@source)
38-
@source.expects(:fetch)
39-
40-
downloader.download(Config.instance)
41-
end
42-
43-
it "should download source from external repo" do
44-
dependency = Dependency.new("AFNetworking", { :podspec => "{root-url}/master/Specs/AFNetworking/1.0/AFNetworking.podspec.json"})
45-
downloader = DeployDownloader.new(dependency)
46-
expected_dependency = Dependency.new("AFNetworking", { :podspec => "http://github.com/CocoaPods/Specs.git/master/Specs/AFNetworking/1.0/AFNetworking.podspec.json"})
47-
48-
ExternalSources.expects(:from_dependency).with(expected_dependency, @podfile.defined_in_file)
49-
ExternalSources.stubs(:from_dependency).returns(@source)
50-
@source.expects(:fetch)
51-
5236
downloader.download(Config.instance)
5337
end
5438
end

0 commit comments

Comments
 (0)