Skip to content

Commit

Permalink
Implemented downloader.
Browse files Browse the repository at this point in the history
  • Loading branch information
James Campbell committed Mar 15, 2016
1 parent 3cf3595 commit 67e6900
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 22 deletions.
20 changes: 15 additions & 5 deletions lib/cocoapods-deploy/deploy_downloader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 16,32 @@ def download(config)
end

def download_source(config)
# TODO: Method for looping through dependency
source = ExternalSources.from_dependency(dependency, config.podfile.defined_in_file)
source.fetch(config.sandbox)
source.fetch
end

def download_podspec(config)
dependencies_for_sources(config).each do |dep|
puts "woo #{dep}"
source = ExternalSources.from_dependency(dep, config.podfile.defined_in_file)
source.fetch(config.sandbox)
source.fetch
end
end

private
def podfile_sources(config)
return ["https://github.com/CocoaPods/CocoaPods.git"] if config.podfile.sources.empty?
return config.podfile.sources
end

def dependencies_for_sources(config)
[]
podfile_sources(config).map do |source|
filename = File.basename(source, ".*")
raw_url = File.join( File.dirname(source), filename )
root_url = "#{raw_url}/raw"
source = @dependency.external_source[:podspec].gsub('{root-url}', root_url)

Dependency.new(@dependency.name, {:podspec => source})
end
end
end
end
18 changes: 1 addition & 17 deletions spec/deploy_downloader_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 16,13 @@ module Pod
Config.instance.stubs(:podfile).returns(@podfile)

@source = MockExternalSource.new
ExternalSources.stubs(:from_dependency).returns(@source)
end

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

ExternalSources.stubs(:from_dependency).returns(@source)
@source.expects(:fetch)

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

ExternalSources.expects(:from_dependency).with(expected_dependency, @podfile.defined_in_file)
ExternalSources.stubs(:from_dependency).returns(@source)
@source.expects(:fetch)

downloader.download(Config.instance)
end

it "should download source from external repo" do
dependency = Dependency.new("AFNetworking", { :podspec => "{root-url}/master/Specs/AFNetworking/1.0/AFNetworking.podspec.json"})
downloader = DeployDownloader.new(dependency)
expected_dependency = Dependency.new("AFNetworking", { :podspec => "http://github.com/CocoaPods/Specs.git/master/Specs/AFNetworking/1.0/AFNetworking.podspec.json"})

ExternalSources.expects(:from_dependency).with(expected_dependency, @podfile.defined_in_file)
ExternalSources.stubs(:from_dependency).returns(@source)
@source.expects(:fetch)

downloader.download(Config.instance)
end
end
Expand Down

0 comments on commit 67e6900

Please sign in to comment.