Skip to content

Commit

Permalink
Preparing for external source hack.
Browse files Browse the repository at this point in the history
  • Loading branch information
James Campbell committed Mar 15, 2016
1 parent 92e8b5c commit ff7d2f7
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 16 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
28 changes: 28 additions & 0 deletions lib/cocoapods-deploy/command/deploy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 44,33 @@ def transform_podfile
transformer.transform_podfile(config.podfile)
end

# Applies patch to external source so that it loops through all
# the sources when fetching to avoid 404s for pods not from
# the master repo.
#
def apply_external_source_patch
ExternalSources::PodspecSource.class_eval do
def fetch(sandbox)
title = "Fetching podspec for `#{name}` #{description}"
UI.titled_section(title, :verbose_prefix => '-> ') do
podspec_path = Pathname(podspec_uri)
is_json = podspec_path.extname == '.json'
if podspec_path.exist?
store_podspec(sandbox, podspec_path, is_json)
else
require 'cocoapods/open-uri'
begin
open(podspec_uri) { |io| store_podspec(sandbox, io.read, is_json) }
rescue OpenURI::HTTPError => e
status = e.io.status.join(' ')
raise Informative, "Failed to fetch podspec for `#{name}` at `#{podspec_uri}`.\n Error: #{status}"
end
end
end
end
end
end

# Applies patch to resolver as it needs help being pointed to use the
# local podspecs due to limitations in CocoaPods. We may be able to remove
# this in the future.
Expand Down Expand Up @@ -117,6 144,7 @@ def run
verify_environment

# TODO: BDD Patch
apply_external_source_patch
apply_resolver_patch

install_sources_for_lockfile
Expand Down
8 changes: 0 additions & 8 deletions lib/cocoapods-deploy/deploy_source.rb

This file was deleted.

4 changes: 1 addition & 3 deletions lib/cocoapods-deploy/deploy_transformer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 63,8 @@ def parse_dependency(name_or_hash)
end
end

# TODO: Modify with placeholder
# i.e {root-url}/pod/verion/pod.podspec
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
8 changes: 4 additions & 4 deletions spec/command/deploy_transformer_spec.rb
Original file line number Diff line number Diff line change
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,7 119,7 @@ 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
Expand Down

0 comments on commit ff7d2f7

Please sign in to comment.