cocoapods-downloader 1.1.3 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

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
- SHA1:
3
- metadata.gz: 39f931857e0e88b2b1bfbd27f1444194e1f0964f
4
- data.tar.gz: 04825acb584a9417a5dae4fa01a328e4233b5e82
2
+ SHA256:
3
+ metadata.gz: f02617513ce98885a2e44e42744ea310ca79783239ecfde7d8bd8c692ff2db96
4
+ data.tar.gz: 787a49a14bd36a61a0d360289bc4a5631d6b36dbd47418c41450502d002fdd65
5
5
  SHA512:
6
- metadata.gz: 8fbd2e3973f247c1a86243b1c5ab2bf00717cc928f55c8c71f5465001f1120c88c3e81bd7316847c3e7acb8fd15df300890408b9b60eaabdb615ae3cccd3584c
7
- data.tar.gz: b5aadb492243642b60dece83d37a16968aaf997af47f94b1d56af92bc0bb091d1b2243aabf6ac1746b3b0866f56af232572c05b9f2ce08f661a520642e2175f2
6
+ metadata.gz: d2ce0b3149460f0398a8dc7c799eac8d7a0ac72bdb6f6728f990baeec133204a7ee63c282c232ee4c526f4f16704f7a7532a2d568035bb019abee097c3805e63
7
+ data.tar.gz: 4cdfd86c52e403cc13816e627a695086e49d179f8710173a76e55be623300e03c704c6090e083b2385d197b408cfec3a827b45b810b72a886f7cf226a9708b49
@@ -33,6 +33,7 @@ The downloader class supports the following option keys:
33
33
  - svn: revision, tag, folder, externals
34
34
  - hg: revision, tag, branch
35
35
  - http: type, flatten
36
+ - scp: type, flatten
36
37
  - bzr: revision, tag
37
38
 
38
39
  The downloader also provides hooks which allow to customize its output or the way in which the commands are executed
@@ -9,6 +9,7 @@ module Pod
9
9
  autoload :Git, 'cocoapods-downloader/git'
10
10
  autoload :Http, 'cocoapods-downloader/http'
11
11
  autoload :Mercurial, 'cocoapods-downloader/mercurial'
12
+ autoload :Scp, 'cocoapods-downloader/scp'
12
13
  autoload :Subversion, 'cocoapods-downloader/subversion'
13
14
 
14
15
  # Denotes the error generated by a Downloader
@@ -24,6 +25,7 @@ module Pod
24
25
  :git => Git,
25
26
  :hg => Mercurial,
26
27
  :http => Http,
28
+ :scp => Scp,
27
29
  :svn => Subversion,
28
30
  }
29
31
  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.1.3'.freeze
6
+ VERSION = '1.2.0'.freeze
7
7
  end
8
8
  end
@@ -1,180 +1,15 @@
1
- require 'zlib'
2
- require 'fileutils'
3
- require 'uri'
1
+ require 'cocoapods-downloader/remote_file'
4
2
 
5
3
  module Pod
6
4
  module Downloader
7
- class Http < Base
8
- def self.options
9
- [:type, :flatten, :sha1, :sha256]
10
- end
11
-
12
- class UnsupportedFileTypeError < StandardError; end
13
-
5
+ class Http < RemoteFile
14
6
  private
15
7
 
16
8
  executable :curl
17
- executable :unzip
18
- executable :tar
19
- executable :hdiutil
20
-
21
- attr_accessor :filename, :download_path
22
-
23
- def download!
24
- @filename = filename_with_type(type)
25
- @download_path = (target_path + @filename)
26
- download_file(@download_path)
27
- verify_checksum(@download_path)
28
- extract_with_type(@download_path, type)
29
- end
30
-
31
- def type
32
- if options[:type]
33
- options[:type].to_sym
34
- else
35
- type_with_url(url)
36
- end
37
- end
38
-
39
- # @note The archive is flattened if it contains only one folder and its
40
- # extension is either `tgz`, `tar`, `tbz` or the options specify
41
- # it.
42
- #
43
- # @return [Bool] Whether the archive should be flattened if it contains
44
- # only one folder.
45
- #
46
- def should_flatten?
47
- if options.key?(:flatten)
48
- true
49
- elsif [:tgz, :tar, :tbz, :txz].include?(type)
50
- true # those archives flatten by default
51
- else
52
- false # all others (actually only .zip) default not to flatten
53
- end
54
- end
55
-
56
- def type_with_url(url)
57
- case URI.parse(url).path
58
- when /\.zip$/
59
- :zip
60
- when /\.(tgz|tar\.gz)$/
61
- :tgz
62
- when /\.tar$/
63
- :tar
64
- when /\.(tbz|tar\.bz2)$/
65
- :tbz
66
- when /\.(txz|tar\.xz)$/
67
- :txz
68
- when /\.dmg$/
69
- :dmg
70
- end
71
- end
72
-
73
- def filename_with_type(type = :zip)
74
- case type
75
- when :zip
76
- 'file.zip'
77
- when :tgz
78
- 'file.tgz'
79
- when :tar
80
- 'file.tar'
81
- when :tbz
82
- 'file.tbz'
83
- when :txz
84
- 'file.txz'
85
- when :dmg
86
- 'file.dmg'
87
- else
88
- raise UnsupportedFileTypeError, "Unsupported file type: #{type}"
89
- end
90
- end
91
9
 
92
10
  def download_file(full_filename)
93
11
  curl! '-f', '-L', '-o', full_filename, url, '--create-dirs', '--netrc-optional'
94
12
  end
95
-
96
- def extract_with_type(full_filename, type = :zip)
97
- unpack_from = full_filename
98
- unpack_to = @target_path
99
- case type
100
- when :zip
101
- unzip! unpack_from, '-d', unpack_to
102
- when :tgz
103
- tar! 'xfz', unpack_from, '-C', unpack_to
104
- when :tar
105
- tar! 'xf', unpack_from, '-C', unpack_to
106
- when :tbz
107
- tar! 'xfj', unpack_from, '-C', unpack_to
108
- when :txz
109
- tar! 'xf', unpack_from, '-C', unpack_to
110
- when :dmg
111
- extract_dmg(unpack_from, unpack_to)
112
- else
113
- raise UnsupportedFileTypeError, "Unsupported file type: #{type}"
114
- end
115
-
116
- # If the archive is a tarball and it only contained a folder, move its
117
- # contents to the target (#727)
118
- #
119
- if should_flatten?
120
- contents = @target_path.children
121
- contents.delete(target_path + @filename)
122
- entry = contents.first
123
- if contents.count == 1 && entry.directory?
124
- FileUtils.move(entry.children, target_path)
125
- end
126
- end
127
- end
128
-
129
- def extract_dmg(unpack_from, unpack_to)
130
- require 'rexml/document'
131
- plist_s = hdiutil! 'attach', '-plist', '-nobrowse', unpack_from, '-mountrandom', unpack_to
132
- plist = REXML::Document.new plist_s
133
- xpath = '//key[.="mount-point"]/following-sibling::string'
134
- mount_point = REXML::XPath.first(plist, xpath).text
135
- FileUtils.cp_r(Dir.glob(mount_point + '/*'), unpack_to)
136
- hdiutil! 'detach', mount_point
137
- end
138
-
139
- def compare_hash(filename, hasher, hash)
140
- incremental_hash = hasher.new
141
-
142
- File.open(filename, 'rb') do |file|
143
- buf = ''
144
- incremental_hash << buf while file.read(1024, buf)
145
- end
146
-
147
- computed_hash = incremental_hash.hexdigest
148
-
149
- if computed_hash != hash
150
- raise DownloaderError, 'Verification checksum was incorrect, ' \
151
- "expected #{hash}, got #{computed_hash}"
152
- end
153
- end
154
-
155
- # Verify that the downloaded file matches a sha1 hash
156
- #
157
- def verify_sha1_hash(filename, hash)
158
- require 'digest/sha1'
159
- compare_hash(filename, Digest::SHA1, hash)
160
- end
161
-
162
- # Verify that the downloaded file matches a sha256 hash
163
- #
164
- def verify_sha256_hash(filename, hash)
165
- require 'digest/sha2'
166
- compare_hash(filename, Digest::SHA2, hash)
167
- end
168
-
169
- # Verify that the downloaded file matches the hash if set
170
- #
171
- def verify_checksum(filename)
172
- if options[:sha256]
173
- verify_sha256_hash(filename, options[:sha256])
174
- elsif options[:sha1]
175
- verify_sha1_hash(filename, options[:sha1])
176
- end
177
- end
178
13
  end
179
14
  end
180
15
  end
@@ -0,0 +1,179 @@
1
+ require 'zlib'
2
+ require 'fileutils'
3
+ require 'uri'
4
+
5
+ module Pod
6
+ module Downloader
7
+ class RemoteFile < Base
8
+ def self.options
9
+ [:type, :flatten, :sha1, :sha256]
10
+ end
11
+
12
+ class UnsupportedFileTypeError < StandardError; end
13
+
14
+ private
15
+
16
+ executable :unzip
17
+ executable :tar
18
+ executable :hdiutil
19
+
20
+ attr_accessor :filename, :download_path
21
+
22
+ def download!
23
+ @filename = filename_with_type(type)
24
+ @download_path = (target_path + @filename)
25
+ download_file(@download_path)
26
+ verify_checksum(@download_path)
27
+ extract_with_type(@download_path, type)
28
+ end
29
+
30
+ def type
31
+ if options[:type]
32
+ options[:type].to_sym
33
+ else
34
+ type_with_url(url)
35
+ end
36
+ end
37
+
38
+ # @note The archive is flattened if it contains only one folder and its
39
+ # extension is either `tgz`, `tar`, `tbz` or the options specify
40
+ # it.
41
+ #
42
+ # @return [Bool] Whether the archive should be flattened if it contains
43
+ # only one folder.
44
+ #
45
+ def should_flatten?
46
+ if options.key?(:flatten)
47
+ true
48
+ elsif [:tgz, :tar, :tbz, :txz].include?(type)
49
+ true # those archives flatten by default
50
+ else
51
+ false # all others (actually only .zip) default not to flatten
52
+ end
53
+ end
54
+
55
+ def type_with_url(url)
56
+ case URI.parse(url).path
57
+ when /\.zip$/
58
+ :zip
59
+ when /\.(tgz|tar\.gz)$/
60
+ :tgz
61
+ when /\.tar$/
62
+ :tar
63
+ when /\.(tbz|tar\.bz2)$/
64
+ :tbz
65
+ when /\.(txz|tar\.xz)$/
66
+ :txz
67
+ when /\.dmg$/
68
+ :dmg
69
+ end
70
+ end
71
+
72
+ def filename_with_type(type = :zip)
73
+ case type
74
+ when :zip
75
+ 'file.zip'
76
+ when :tgz
77
+ 'file.tgz'
78
+ when :tar
79
+ 'file.tar'
80
+ when :tbz
81
+ 'file.tbz'
82
+ when :txz
83
+ 'file.txz'
84
+ when :dmg
85
+ 'file.dmg'
86
+ else
87
+ raise UnsupportedFileTypeError, "Unsupported file type: #{type}"
88
+ end
89
+ end
90
+
91
+ def download_file(_full_filename)
92
+ raise NotImplementedError
93
+ end
94
+
95
+ def extract_with_type(full_filename, type = :zip)
96
+ unpack_from = full_filename
97
+ unpack_to = @target_path
98
+ case type
99
+ when :zip
100
+ unzip! unpack_from, '-d', unpack_to
101
+ when :tgz
102
+ tar! 'xfz', unpack_from, '-C', unpack_to
103
+ when :tar
104
+ tar! 'xf', unpack_from, '-C', unpack_to
105
+ when :tbz
106
+ tar! 'xfj', unpack_from, '-C', unpack_to
107
+ when :txz
108
+ tar! 'xf', unpack_from, '-C', unpack_to
109
+ when :dmg
110
+ extract_dmg(unpack_from, unpack_to)
111
+ else
112
+ raise UnsupportedFileTypeError, "Unsupported file type: #{type}"
113
+ end
114
+
115
+ # If the archive is a tarball and it only contained a folder, move its
116
+ # contents to the target (#727)
117
+ #
118
+ if should_flatten?
119
+ contents = @target_path.children
120
+ contents.delete(target_path + @filename)
121
+ entry = contents.first
122
+ if contents.count == 1 && entry.directory?
123
+ FileUtils.move(entry.children, target_path)
124
+ end
125
+ end
126
+ end
127
+
128
+ def extract_dmg(unpack_from, unpack_to)
129
+ require 'rexml/document'
130
+ plist_s = hdiutil! 'attach', '-plist', '-nobrowse', unpack_from, '-mountrandom', unpack_to
131
+ plist = REXML::Document.new plist_s
132
+ xpath = '//key[.="mount-point"]/following-sibling::string'
133
+ mount_point = REXML::XPath.first(plist, xpath).text
134
+ FileUtils.cp_r(Dir.glob(mount_point + '/*'), unpack_to)
135
+ hdiutil! 'detach', mount_point
136
+ end
137
+
138
+ def compare_hash(filename, hasher, hash)
139
+ incremental_hash = hasher.new
140
+
141
+ File.open(filename, 'rb') do |file|
142
+ buf = ''
143
+ incremental_hash << buf while file.read(1024, buf)
144
+ end
145
+
146
+ computed_hash = incremental_hash.hexdigest
147
+
148
+ if computed_hash != hash
149
+ raise DownloaderError, 'Verification checksum was incorrect, ' \
150
+ "expected #{hash}, got #{computed_hash}"
151
+ end
152
+ end
153
+
154
+ # Verify that the downloaded file matches a sha1 hash
155
+ #
156
+ def verify_sha1_hash(filename, hash)
157
+ require 'digest/sha1'
158
+ compare_hash(filename, Digest::SHA1, hash)
159
+ end
160
+
161
+ # Verify that the downloaded file matches a sha256 hash
162
+ #
163
+ def verify_sha256_hash(filename, hash)
164
+ require 'digest/sha2'
165
+ compare_hash(filename, Digest::SHA2, hash)
166
+ end
167
+
168
+ # Verify that the downloaded file matches the hash if set
169
+ #
170
+ def verify_checksum(filename)
171
+ if options[:sha256]
172
+ verify_sha256_hash(filename, options[:sha256])
173
+ elsif options[:sha1]
174
+ verify_sha1_hash(filename, options[:sha1])
175
+ end
176
+ end
177
+ end
178
+ end
179
+ end
@@ -0,0 +1,30 @@
1
+ require 'uri'
2
+ require 'cocoapods-downloader/remote_file'
3
+
4
+ module Pod
5
+ module Downloader
6
+ class Scp < RemoteFile
7
+ DEFAULT_PORT = 22
8
+
9
+ private
10
+
11
+ executable :scp
12
+
13
+ def download_file(full_filename)
14
+ scp! '-P', port, '-q', source, full_filename
15
+ end
16
+
17
+ def source
18
+ "#{uri.user ? uri.user + '@' : ''}#{uri.host}:'#{uri.path}'"
19
+ end
20
+
21
+ def port
22
+ uri.port || DEFAULT_PORT
23
+ end
24
+
25
+ def uri
26
+ @uri ||= URI.parse(url)
27
+ end
28
+ end
29
+ end
30
+ 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: 1.1.3
4
+ version: 1.2.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-12-17 00:00:00.000000000 Z
12
+ date: 2018-04-04 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description:
15
15
  email:
@@ -30,6 +30,8 @@ files:
30
30
  - lib/cocoapods-downloader/git.rb
31
31
  - lib/cocoapods-downloader/http.rb
32
32
  - lib/cocoapods-downloader/mercurial.rb
33
+ - lib/cocoapods-downloader/remote_file.rb
34
+ - lib/cocoapods-downloader/scp.rb
33
35
  - lib/cocoapods-downloader/subversion.rb
34
36
  homepage: https://github.com/CocoaPods/Downloader
35
37
  licenses:
@@ -51,7 +53,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
51
53
  version: '0'
52
54
  requirements: []
53
55
  rubyforge_project:
54
- rubygems_version: 2.4.5.1
56
+ rubygems_version: 2.7.6
55
57
  signing_key:
56
58
  specification_version: 3
57
59
  summary: A small library for downloading files from remotes in a folder.