cocoapods-downloader 0.4.1 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of cocoapods-downloader might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8bb5278864d56f46280ea2a14a997e5d3d020b7b
4
- data.tar.gz: 2e95ec0b4373aa8a811df26f56ffb726a02b2e0b
3
+ metadata.gz: d939a67d6d36d973515d8ec5bf4cdd203f288487
4
+ data.tar.gz: 1f341084741d856cca13e86ab23cc858ea7dd692
5
5
  SHA512:
6
- metadata.gz: 665137d80ff908dd728b3a3de2c1e08b298b114ff4548035d558e27aa680fe11d73f4e5b6ccda3c381023cd43d8a89dca94900abb76ba796def8a6e58659f656
7
- data.tar.gz: aa61378e9fb2453920eee210517af935c372f60eb3988c70708672b647b675695f332f7ec16142cd0db27ae413ca6f5f3fc4b5d469c4b791870912011abe5cf0
6
+ metadata.gz: 12033cc74a68218cf549a9d31668d726cdb570292b627b04a2a9d7cb239ea9cf2e859b951c7577bac9772225be141d6de4ae74cd0571877dafd67aefafb34139
7
+ data.tar.gz: 1521f867b04670fe0c931e9dea7ab908f481846c80ec68c040733b0716718ed80c6bc046637393e01739cc095c670da71e37a4fd04d40d4e69137e0e11b90eab
data/README.markdown CHANGED
@@ -30,7 +30,7 @@ The downloader class supports the following option keys:
30
30
 
31
31
  - git: commit, tag, branch, submodules
32
32
  - svn: revision, tag, folder, externals
33
- - hg: revision
33
+ - hg: revision, tag, branch
34
34
  - http: type, flatten
35
35
  - bzr: revision, tag
36
36
 
@@ -1,31 +1,48 @@
1
1
  module Pod
2
2
  module Downloader
3
3
  require 'cocoapods-downloader/gem_version'
4
-
5
4
  require 'cocoapods-downloader/api'
6
5
  require 'cocoapods-downloader/api_exposable'
7
6
  require 'cocoapods-downloader/base'
8
7
 
8
+ autoload :Bazaar, 'cocoapods-downloader/bazaar'
9
+ autoload :Git, 'cocoapods-downloader/git'
10
+ autoload :Http, 'cocoapods-downloader/http'
11
+ autoload :Mercurial, 'cocoapods-downloader/mercurial'
12
+ autoload :Subversion, 'cocoapods-downloader/subversion'
9
13
 
10
- # @return [Hash{Symbol=>Class}] The symbol of the options array associated
11
- # with each class.
14
+ # Denotes the error generated by a Downloader
12
15
  #
13
- def self.downloader_class_by_key
14
- require 'cocoapods-downloader/git'
15
- require 'cocoapods-downloader/mercurial'
16
- require 'cocoapods-downloader/subversion'
17
- require 'cocoapods-downloader/http'
18
- require 'cocoapods-downloader/bazaar'
16
+ class DownloaderError < StandardError; end
19
17
 
18
+ # @return [Hash{Symbol=>Class}] The concrete classes of the supported
19
+ # strategies by key.
20
+ #
21
+ def self.downloader_class_by_key
20
22
  {
23
+ :bzr => Bazaar,
21
24
  :git => Git,
22
25
  :hg => Mercurial,
23
- :svn => Subversion,
24
26
  :http => Http,
25
- :bzr => Bazaar,
27
+ :svn => Subversion,
26
28
  }
27
29
  end
28
30
 
31
+ # Identifies the concrete strategy for the given options.
32
+ #
33
+ # @param [Hash{Symbol}] options
34
+ # The options for which a strategy is needed.
35
+ #
36
+ # @return [Symbol] The symbol associated with a concrete strategy.
37
+ # @return [Nil] If no suitable concrete strategy could be selected.
38
+ #
39
+ def self.strategy_from_options(options)
40
+ common = downloader_class_by_key.keys & options.keys
41
+ if common.count == 1
42
+ common.first
43
+ end
44
+ end
45
+
29
46
  # @return [Downloader::Base] A concrete downloader according to the
30
47
  # options.
31
48
  #
@@ -34,40 +51,30 @@ module Pod
34
51
  # global options for the Downloader cache?
35
52
  #
36
53
  def self.for_target(target_path, options)
37
-
38
54
  if target_path.nil?
39
55
  raise DownloaderError, "No target path provided."
40
56
  end
41
57
 
42
58
  if options.nil? || options.empty?
43
- raise DownloaderError, "No source url provided."
59
+ raise DownloaderError, "No source URL provided."
44
60
  end
45
61
 
46
- options = options.dup
47
- klass = nil
48
- url = nil
49
- downloader_class_by_key.each do |key, key_klass|
50
- url = options.delete(key)
51
- if url
52
- klass = key_klass
53
- break
54
- end
62
+ strategy = strategy_from_options(options)
63
+ unless strategy
64
+ raise DownloaderError, "Unsupported download strategy " \
65
+ "`#{options.inspect}`."
55
66
  end
56
67
 
57
- unless klass
58
- raise DownloaderError, "Unsupported download strategy `#{options.inspect}`."
59
- end
68
+ url = options[strategy]
69
+ sub_options = options.dup
70
+ sub_options.delete(strategy)
71
+ klass = downloader_class_by_key[strategy]
60
72
 
61
73
  if klass == Git && url.to_s =~ /github.com/
62
74
  klass = GitHub
63
75
  end
64
76
 
65
- klass.new(target_path, url, options)
77
+ klass.new(target_path, url, sub_options)
66
78
  end
67
-
68
- # Denotes the error generated by a Downloader
69
- #
70
- class DownloaderError < StandardError; end
71
-
72
79
  end
73
80
  end
@@ -4,7 +4,7 @@ module Pod
4
4
  # @return [String] Downloader’s version, following
5
5
  # [semver](http://semver.org).
6
6
  #
7
- VERSION = '0.4.1'
7
+ VERSION = '0.5.0'
8
8
 
9
9
  end
10
10
  end
@@ -84,7 +84,7 @@ module Pod
84
84
  end
85
85
 
86
86
  def download_file(full_filename)
87
- curl! %|-L -o #{full_filename.shellescape} #{url} --create-dirs|
87
+ curl! %|-L -o #{full_filename.shellescape} "#{url}" --create-dirs|
88
88
  end
89
89
 
90
90
  def extract_with_type(full_filename, type=:zip)
@@ -3,11 +3,11 @@ module Pod
3
3
  class Mercurial < Base
4
4
 
5
5
  def self.options
6
- [:revision]
6
+ [:revision, :tag, :branch]
7
7
  end
8
8
 
9
9
  def options_specific?
10
- !options[:revision].nil?
10
+ !options[:revision].nil? || !options[:tag].nil?
11
11
  end
12
12
 
13
13
  def checkout_options
@@ -26,6 +26,10 @@ module Pod
26
26
  def download!
27
27
  if options[:revision]
28
28
  download_revision!
29
+ elsif options[:tag]
30
+ download_tag!
31
+ elsif options[:branch]
32
+ download_branch!
29
33
  else
30
34
  download_head!
31
35
  end
@@ -38,7 +42,14 @@ module Pod
38
42
  def download_revision!
39
43
  hg! %|clone "#{url}" --rev '#{options[:revision]}' #{@target_path.shellescape}|
40
44
  end
45
+
46
+ def download_tag!
47
+ hg! %|clone "#{url}" --updaterev '#{options[:tag]}' #{@target_path.shellescape}|
48
+ end
41
49
 
50
+ def download_branch!
51
+ hg! %|clone "#{url}" --updaterev '#{options[:branch]}' #{@target_path.shellescape}|
52
+ end
42
53
  end
43
54
  end
44
55
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cocoapods-downloader
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eloy Duran
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-03-31 00:00:00.000000000 Z
12
+ date: 2014-04-15 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description:
15
15
  email: