Skip to content

Commit

Permalink
Merge pull request #5 from jcampbell05/f/MultipleSourcesSupport
Browse files Browse the repository at this point in the history
F/multiple sources support
  • Loading branch information
jcampbell05 committed Mar 15, 2016
2 parents c12f6ea 4939b5e commit 732b64b
Show file tree
Hide file tree
Showing 13 changed files with 116 additions and 50 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 1,7 @@
PATH
remote: .
specs:
cocoapods-deploy (0.0.5)
cocoapods-deploy (0.0.6)

GEM
remote: https://rubygems.org/
Expand Down
4 changes: 2 additions & 2 deletions cocoapods-deploy.gemspec
Original file line number Diff line number Diff line change
@@ -1,9 1,9 @@
# -*- encoding: utf-8 -*-
# stub: cocoapods-deploy 0.0.5 ruby lib
# stub: cocoapods-deploy 0.0.6 ruby lib

Gem::Specification.new do |s|
s.name = "cocoapods-deploy"
s.version = "0.0.5"
s.version = "0.0.6"

s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.require_paths = ["lib"]
Expand Down
6 changes: 4 additions & 2 deletions lib/cocoapods-deploy/command/deploy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 97,9 @@ def install_sources_for_lockfile
def install_sources_for_pod(pod)
transformer = DeployTransformer.new(config.lockfile, config.sandbox)
dep = transformer.transform_dependency_name(pod)
source = ExternalSources.from_dependency(dep, config.podfile.defined_in_file)
source.fetch(config.sandbox)

downloader = DeployDownloader.new(dep)
downloader.download(config)
end

# Triggers the CocoaPods install process
Expand All @@ -111,6 112,7 @@ def run
setup_environment
verify_environment

# TODO: BDD Patch
apply_resolver_patch

install_sources_for_lockfile
Expand Down
52 changes: 52 additions & 0 deletions lib/cocoapods-deploy/deploy_downloader.rb
Original file line number Diff line number Diff line change
@@ -0,0 1,52 @@
module Pod
class DeployDownloader

attr_accessor :dependency

def initialize(dependency)
@dependency = dependency
end

def download(config)
if @dependency.external_source.key?(:podspec)
download_podspec(config)
else
download_source(config)
end
end

def download_source(config)
source = ExternalSources.from_dependency(dependency, config.podfile.defined_in_file)
source.fetch
end

def download_podspec(config)
dependencies_for_sources(config).each do |dep|
source = ExternalSources.from_dependency(dep, config.podfile.defined_in_file)

begin
return source.fetch
rescue
end
end

raise Informative, "Failed to deploy podspec for `#{@dependency.name}`."
end

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
2 changes: 1 addition & 1 deletion lib/cocoapods-deploy/deploy_transformer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 64,7 @@ def parse_dependency(name_or_hash)
end

def podspec_url(pod, version)
"https://raw.githubusercontent.com/CocoaPods/Specs/master/Specs/#{pod}/#{version}/#{pod}.podspec.json"
"{root-url}/master/Specs/#{pod}/#{version}/#{pod}.podspec.json"
end

def collect_podspec_dependencies(name_or_hash)
Expand Down
2 changes: 1 addition & 1 deletion lib/cocoapods-deploy/gem_version.rb
Original file line number Diff line number Diff line change
@@ -1,3 1,3 @@
module CocoapodsDeploy
VERSION = "0.0.5"
VERSION = "0.0.6"
end
1 change: 1 addition & 0 deletions lib/cocoapods_plugin.rb
Original file line number Diff line number Diff line change
@@ -1,4 1,5 @@
require 'cocoapods-deploy/deploy_analyzer'
require 'cocoapods-deploy/deploy_downloader'
require 'cocoapods-deploy/deploy_installer'
require 'cocoapods-deploy/deploy_transformer'
require 'cocoapods-deploy/command'
6 changes: 0 additions & 6 deletions spec/command/deploy_installer_spec.rb

This file was deleted.

29 changes: 4 additions & 25 deletions spec/command/deploy_spec.rb
Original file line number Diff line number Diff line change
@@ -1,13 1,5 @@
require File.expand_path('../../spec_helper', __FILE__)

class MockExternalSource
def initialize
end

def fetch
end
end

module Pod
describe Command::Deploy do

Expand Down Expand Up @@ -122,30 114,17 @@ module Pod
@transformer.stubs(:transform_dependency_name).with("Google/Analytics").returns(@dependency)
DeployTransformer.stubs(:new).returns(@transformer)

@source = MockExternalSource.new
@command.stubs(:transform_podfile).returns(@podfile)
@command.stubs(:install)
end

it 'should create new external source' do
ExternalSources.expects(:from_dependency).with(@dependency, @podfile.defined_in_file).returns(@source)
@source.stubs(:fetch)
@command.run
end
it 'should download source' do
downloader = DeployDownloader.new(nil)
downloader.expects(:download)

it 'should fetch source' do
ExternalSources.stubs(:from_dependency).returns(@source)
@source.expects(:fetch)
DeployDownloader.stubs(:new).returns(downloader)
@command.run
end

# TODO: Reducing duplicates

# TODO: Patches

# Figure out how to test external source here.

# Figure out how to handle location
end
end
end
Original file line number Diff line number Diff line change
@@ -1,4 1,4 @@
require File.expand_path('../../spec_helper', __FILE__)
require File.expand_path('../spec_helper', __FILE__)

module Pod
describe DeployAnalyzer do
Expand Down
38 changes: 38 additions & 0 deletions spec/deploy_downloader_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 1,38 @@
require File.expand_path('../spec_helper', __FILE__)

class MockExternalSource
def initialize
end

def fetch
end
end

module Pod
describe DeployDownloader do

before do
@podfile = Podfile.new
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)

@source.expects(:fetch)
downloader.download(Config.instance)
end

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)

@source.expects(:fetch)
downloader.download(Config.instance)
end
end
end
6 changes: 6 additions & 0 deletions spec/deploy_installer_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 1,6 @@
require File.expand_path('../spec_helper', __FILE__)

module Pod
describe DeployInstaller do
end
end
Original file line number Diff line number Diff line change
@@ -1,4 1,4 @@
require File.expand_path('../../spec_helper', __FILE__)
require File.expand_path('../spec_helper', __FILE__)

def transform_podfile(lockfile, sandbox, podfile)
transformer = Pod::DeployTransformer.new(lockfile, sandbox)
Expand Down Expand Up @@ -42,7 42,7 @@ module Pod
end

podfile = transform_podfile(lockfile, nil, original_podfile)
dependency = Dependency.new("Mixpanel", {:podspec => "https://raw.githubusercontent.com/CocoaPods/Specs/master/Specs/Mixpanel/1.0/Mixpanel.podspec.json"})
dependency = Dependency.new("Mixpanel", {:podspec => "{root-url}/master/Specs/Mixpanel/1.0/Mixpanel.podspec.json"})
podfile.dependencies.should.include dependency
end

Expand All @@ -56,7 56,7 @@ module Pod
end

podfile = transform_podfile(lockfile, nil, original_podfile)
dependency = Dependency.new("Google/Analytics", {:podspec => "https://raw.githubusercontent.com/CocoaPods/Specs/master/Specs/Google/1.0/Google.podspec.json"})
dependency = Dependency.new("Google/Analytics", {:podspec => "{root-url}/master/Specs/Google/1.0/Google.podspec.json"})
podfile.dependencies.should.include dependency
end
end
Expand Down Expand Up @@ -100,7 100,7 @@ module Pod
end

podfile = transform_podfile(lockfile, @sandbox, original_podfile)
dependency = Dependency.new("Google", {:podspec => "https://raw.githubusercontent.com/CocoaPods/Specs/master/Specs/Google/1.0/Google.podspec.json"})
dependency = Dependency.new("Google", {:podspec => "{root-url}/master/Specs/Google/1.0/Google.podspec.json"})
podfile.dependencies.should.include dependency
end

Expand All @@ -119,16 119,10 @@ module Pod
end

podfile = transform_podfile(lockfile, @sandbox, original_podfile)
dependency = Dependency.new("Mixpanel/Mixpanel", {:podspec => "https://raw.githubusercontent.com/CocoaPods/Specs/master/Specs/Mixpanel/1.0/Mixpanel.podspec.json"})
dependency = Dependency.new("Mixpanel/Mixpanel", {:podspec => "{root-url}/master/Specs/Mixpanel/1.0/Mixpanel.podspec.json"})
podfile.dependencies.should.include dependency
end
end

# TODO: Reducing duplicates

# Figure out how to test external source here.

# TODO: Test collect_podspec_dependencies as well
end
end
end

0 comments on commit 732b64b

Please sign in to comment.