cocoapods-downloader 1.0.1 → 1.1.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: d8df150bd67da7e8424cae5644448b45f49d43a8
4
- data.tar.gz: 6e7017b3e107271f64eadbda72f8cab72f056906
3
+ metadata.gz: ec3aeaa63a0bde59b725c1bedb3197803ef16bec
4
+ data.tar.gz: 73b1647fe1560d7c110479a9c65e43e1554754c9
5
5
  SHA512:
6
- metadata.gz: 2c359fccdfc8a646e95950af5c933a47605934b37b5899f23a17e6e4993b79ecf5c0f4cf30e3e0ccc1415cb5a4a0a3e482b32498b5c4e8d1959428bbc6c78538
7
- data.tar.gz: f0e31cfad49785e06b6bbdeb00e30bd9609587b368242187533282eda683f7783b9c6d31b0bac9e59af4e2169ef89dfef356d6bb0cda116dfca8164d2204f073
6
+ metadata.gz: f9dd8ff98b0af317733a9b56ff1d62eb657c9e0520d61112c31e182fe10ec71b03ac17be17653f4e29d66dfb13abcce13ec6ca9a3f83055ce4edbb98264c3ca3
7
+ data.tar.gz: ae72d264ad1ea26b4c914b1865b861eecd3456a4c73cc4fee41022ed0b772d59586d429f516fffdea246e623f046f950b3666ea96a4f28be85911de484d0f691
@@ -19,6 +19,7 @@ require 'cocoapods-downloader'
19
19
 
20
20
  target_path = './Downloads/MyDownload'
21
21
  options = { :git => 'example.com' }
22
+ options = Pod::Downloader.preprocess_options(options)
22
23
  downloader = Pod::Downloader.for_target(target_path, options)
23
24
  downloader.cache_root = '~/Library/Caches/APPNAME'
24
25
  downloader.max_cache_size = 500
@@ -47,12 +47,42 @@ module Pod
47
47
  # options.
48
48
  #
49
49
  def self.for_target(target_path, options)
50
- options = Hash[options.map { |k, v| [k.to_sym, v] }]
50
+ options = options_to_sym(options)
51
51
 
52
52
  if target_path.nil?
53
53
  raise DownloaderError, 'No target path provided.'
54
54
  end
55
55
 
56
+ strategy, klass = class_for_options(options)
57
+
58
+ url = options[strategy]
59
+ sub_options = options.dup
60
+ sub_options.delete(strategy)
61
+
62
+ klass.new(target_path, url, sub_options)
63
+ end
64
+
65
+ # Have the concrete strategy preprocess options
66
+ #
67
+ # @param [Hash<Symbol,String>] options
68
+ # The request options to preprocess
69
+ #
70
+ # @return [Hash<Symbol,String>] the new options
71
+ #
72
+ def self.preprocess_options(options)
73
+ options = options_to_sym(options)
74
+
75
+ _, klass = class_for_options(options)
76
+ klass.preprocess_options(options)
77
+ end
78
+
79
+ private_class_method
80
+
81
+ def self.options_to_sym(options)
82
+ Hash[options.map { |k, v| [k.to_sym, v] }]
83
+ end
84
+
85
+ def self.class_for_options(options)
56
86
  if options.nil? || options.empty?
57
87
  raise DownloaderError, 'No source URL provided.'
58
88
  end
@@ -63,11 +93,8 @@ module Pod
63
93
  "`#{options.inspect}`."
64
94
  end
65
95
 
66
- url = options[strategy]
67
- sub_options = options.dup
68
- sub_options.delete(strategy)
69
- klass = downloader_class_by_key[strategy]
70
- klass.new(target_path, url, sub_options)
96
+ # Explicit return for multiple params, rubocop thinks it's useless but it's not
97
+ return strategy, downloader_class_by_key[strategy] # rubocop:disable Style/RedundantReturn
71
98
  end
72
99
  end
73
100
  end
@@ -12,6 +12,9 @@ module Pod
12
12
  raise 'Only a module *or* is required, not both.'
13
13
  end
14
14
  include mod
15
+ # TODO: Try to find a nicer way to do this
16
+ # See https://github.com/CocoaPods/cocoapods-downloader/pull/57
17
+ extend mod
15
18
  end
16
19
 
17
20
  alias override_api expose_api
@@ -154,6 +154,20 @@ module Pod
154
154
  execute_command(name.to_s, command.flatten, true)
155
155
  end
156
156
  end
157
+
158
+ # preprocess download options
159
+ #
160
+ # Usage of this method is optional. concrete strategies should not
161
+ # assume options are preprocessed for correct execution.
162
+ #
163
+ # @param [Hash<Symbol,String>] options
164
+ # The request options to preprocess
165
+ #
166
+ # @return [Hash<Symbol,String>] the new options
167
+ #
168
+ def self.preprocess_options(options)
169
+ options
170
+ end
157
171
  end
158
172
  end
159
173
  end
@@ -3,6 +3,6 @@ module Pod
3
3
  # @return [String] Downloader’s version, following
4
4
  # [semver](http://semver.org).
5
5
  #
6
- VERSION = '1.0.1'.freeze
6
+ VERSION = '1.1.0'.freeze
7
7
  end
8
8
  end
@@ -22,6 +22,23 @@ module Pod
22
22
  end
23
23
  end
24
24
 
25
+ def self.preprocess_options(options)
26
+ return options unless options[:branch]
27
+
28
+ command = ['ls-remote',
29
+ options[:git],
30
+ options[:branch]]
31
+ output = Git.execute_command('git', command)
32
+ match = /^([a-z0-9]*)\t.*/.match(output)
33
+
34
+ return options if match.nil?
35
+
36
+ options[:commit] = match[1]
37
+ options.delete(:branch)
38
+
39
+ options
40
+ end
41
+
25
42
  private
26
43
 
27
44
  # @!group Base class hooks
@@ -90,7 +90,7 @@ module Pod
90
90
  end
91
91
 
92
92
  def download_file(full_filename)
93
- curl! '-f', '-L', '-o', full_filename, url, '--create-dirs', '--netrc'
93
+ curl! '-f', '-L', '-o', full_filename, url, '--create-dirs', '--netrc-optional'
94
94
  end
95
95
 
96
96
  def extract_with_type(full_filename, type = :zip)
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: 1.0.1
4
+ version: 1.1.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: 2016-06-24 00:00:00.000000000 Z
12
+ date: 2016-07-11 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description:
15
15
  email:
@@ -41,17 +41,17 @@ require_paths:
41
41
  - lib
42
42
  required_ruby_version: !ruby/object:Gem::Requirement
43
43
  requirements:
44
- - - ">="
44
+ - - '>='
45
45
  - !ruby/object:Gem::Version
46
46
  version: 2.0.0
47
47
  required_rubygems_version: !ruby/object:Gem::Requirement
48
48
  requirements:
49
- - - ">="
49
+ - - '>='
50
50
  - !ruby/object:Gem::Version
51
51
  version: '0'
52
52
  requirements: []
53
53
  rubyforge_project:
54
- rubygems_version: 2.6.6
54
+ rubygems_version: 2.6.5
55
55
  signing_key:
56
56
  specification_version: 3
57
57
  summary: A small library for downloading files from remotes in a folder.