cocoapods-downloader 1.2.1 → 1.5.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
2
  SHA256:
3
- metadata.gz: c3cdae542174cc361bd6bb136814dc4bd9c4f1d264eba8ae5d1c8abbb30b3a7e
4
- data.tar.gz: 5aa84b9a46c0180766190a51e329c12f090180a4cfe49302ca2a184534a03f13
3
+ metadata.gz: dc4fe940ffcfe1f304e30cf50212217dc821e13e3a3431e73c01af91f54139b7
4
+ data.tar.gz: e71b8009f6c2f939cac92ef1ecbff51f824e2d1ea394d5b1d9936c14d41d2c61
5
5
  SHA512:
6
- metadata.gz: 7d06b9e95f57c2a91c8e8a1610cd2df2ffbd8613fd8ec0b119b36c88095e00bc1e9d7e4b23c1cde351f2f40827afe00543300961d0234d77c3e7624f48c54b1a
7
- data.tar.gz: e94add19965a574eabb1ccfd2c1dd03fa97b8b2d131ec4d44be0fa9859b33a39db13f4a33373eef55ff0c0bd0b6f1d042cae6c1caca363c02c4e940b2ee617f2
6
+ metadata.gz: 9a3666c592eaedbd7e87a550520d6184548e9cb9d71c0b16eef51ea961a5a5b12a5803d563cb16fc1c12e07bba5892cca44520d0b9ffc38909ededee9696c86a
7
+ data.tar.gz: c7059215e47fc5bc22026ea3b5b4a502b39b24f377280e9242a61a11e317bfa73cbee6f1d6737885c5e4da6d6ca95bf62971e283241b7878b2cb943d09a7d380
data/README.markdown CHANGED
@@ -2,9 +2,10 @@
2
2
 
3
3
  A small library for downloading files from remotes in a folder.
4
4
 
5
- [![Build Status](https://img.shields.io/travis/CocoaPods/cocoapods-downloader/master.svg?style=flat)](https://travis-ci.org/CocoaPods/cocoapods-downloader)
6
- [![Coverage](https://img.shields.io/codeclimate/coverage/github/CocoaPods/cocoapods-downloader.svg?style=flat)](https://codeclimate.com/github/CocoaPods/cocoapods-downloader)
7
- [![Code Climate](https://img.shields.io/codeclimate/github/CocoaPods/cocoapods-downloader.svg?style=flat)](https://codeclimate.com/github/CocoaPods/cocoapods-downloader)
5
+ [![Build Status](https://img.shields.io/github/workflow/status/CocoaPods/CocoaPods-Downloader/Spec)](https://github.com/CocoaPods/cocoapods-downloader/actions)
6
+ [![Gem Version](https://img.shields.io/gem/v/cocoapods-downloader)](https://rubygems.org/gems/cocoapods-downloader)
7
+ [![Maintainability](https://api.codeclimate.com/v1/badges/a99a88d28ad37a79dbf6/maintainability)](https://codeclimate.com/github/CocoaPods/cocoapods-downloader/maintainability)
8
+ [![Test Coverage](https://api.codeclimate.com/v1/badges/a99a88d28ad37a79dbf6/test_coverage)](https://codeclimate.com/github/CocoaPods/cocoapods-downloader/test_coverage)
8
9
 
9
10
  ## Install
10
11
 
@@ -121,6 +121,18 @@ module Pod
121
121
  raise 'Abstract method'
122
122
  end
123
123
 
124
+ # Returns a User-Agent string that itentifies http network requests as
125
+ # originating from CocoaPods.
126
+ # Contains version numbers from the CocoaPods Gem and the cocoapods-downloader Gem.
127
+ #
128
+ # @param [module] base_module The Base CocoaPods Module to retrieve the version number from.
129
+ # @return [String] the User-Agent string.
130
+ #
131
+ def self.user_agent_string(base_module = Pod)
132
+ pods_version = base_module.const_defined?('VERSION') ? "CocoaPods/#{base_module::VERSION} " : ''
133
+ "#{pods_version}cocoapods-downloader/#{Pod::Downloader::VERSION}"
134
+ end
135
+
124
136
  #-----------------------------------------------------------------------#
125
137
 
126
138
  # Defines two methods for an executable, based on its name. The bang
@@ -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.2.1'.freeze
6
+ VERSION = '1.5.0'.freeze
7
7
  end
8
8
  end
@@ -27,16 +27,38 @@ module Pod
27
27
  options[:git],
28
28
  options[:branch]]
29
29
  output = Git.execute_command('git', command)
30
- match = /^([a-z0-9]*)\t.*/.match(output)
30
+ match = commit_from_ls_remote output, options[:branch]
31
31
 
32
32
  return options if match.nil?
33
33
 
34
- options[:commit] = match[1]
34
+ options[:commit] = match
35
35
  options.delete(:branch)
36
36
 
37
37
  options
38
38
  end
39
39
 
40
+ # Matches a commit from the branches reported by git ls-remote.
41
+ #
42
+ # @note When there is a branch and tag with the same name, it will match
43
+ # the branch, since `refs/heads` is sorted before `refs/tags`.
44
+ #
45
+ # @param [String] output
46
+ # The output from git ls-remote.
47
+ #
48
+ # @param [String] branch_name
49
+ # The desired branch to match a commit to.
50
+ #
51
+ # @return [String] commit hash string, or nil if no match found
52
+ #
53
+ def self.commit_from_ls_remote(output, branch_name)
54
+ return nil if branch_name.nil?
55
+ encoded_branch_name = branch_name.force_encoding(Encoding::ASCII_8BIT)
56
+ match = %r{([a-z0-9]*)\trefs\/(heads|tags)\/#{Regexp.quote(encoded_branch_name)}}.match(output)
57
+ match[1] unless match.nil?
58
+ end
59
+
60
+ private_class_method :commit_from_ls_remote
61
+
40
62
  private
41
63
 
42
64
  # @!group Base class hooks
@@ -3,12 +3,31 @@ require 'cocoapods-downloader/remote_file'
3
3
  module Pod
4
4
  module Downloader
5
5
  class Http < RemoteFile
6
+ USER_AGENT_HEADER = 'User-Agent'.freeze
7
+
6
8
  private
7
9
 
8
10
  executable :curl
9
11
 
10
12
  def download_file(full_filename)
11
- curl! '-f', '-L', '-o', full_filename, url, '--create-dirs', '--netrc-optional', '--retry', '2'
13
+ parameters = ['-f', '-L', '-o', full_filename, url, '--create-dirs', '--netrc-optional', '--retry', '2']
14
+ parameters << user_agent_argument if headers.nil? ||
15
+ headers.none? { |header| header.casecmp(USER_AGENT_HEADER).zero? }
16
+
17
+ headers.each do |h|
18
+ parameters << '-H'
19
+ parameters << h
20
+ end unless headers.nil?
21
+
22
+ curl! parameters
23
+ end
24
+
25
+ # Returns a cURL command flag to add the CocoaPods User-Agent.
26
+ #
27
+ # @return [String] cURL command -A flag and User-Agent.
28
+ #
29
+ def user_agent_argument
30
+ "-A '#{Http.user_agent_string}'"
12
31
  end
13
32
  end
14
33
  end
@@ -1,12 +1,12 @@
1
- require 'zlib'
2
1
  require 'fileutils'
3
2
  require 'uri'
3
+ require 'zlib'
4
4
 
5
5
  module Pod
6
6
  module Downloader
7
7
  class RemoteFile < Base
8
8
  def self.options
9
- [:type, :flatten, :sha1, :sha256]
9
+ [:type, :flatten, :sha1, :sha256, :headers]
10
10
  end
11
11
 
12
12
  class UnsupportedFileTypeError < StandardError; end
@@ -21,7 +21,7 @@ module Pod
21
21
 
22
22
  def download!
23
23
  @filename = filename_with_type(type)
24
- @download_path = (target_path + @filename)
24
+ @download_path = target_path + @filename
25
25
  download_file(@download_path)
26
26
  verify_checksum(@download_path)
27
27
  extract_with_type(@download_path, type)
@@ -35,6 +35,10 @@ module Pod
35
35
  end
36
36
  end
37
37
 
38
+ def headers
39
+ options[:headers]
40
+ end
41
+
38
42
  # @note The archive is flattened if it contains only one folder and its
39
43
  # extension is either `tgz`, `tar`, `tbz` or the options specify
40
44
  # it.
@@ -44,7 +48,7 @@ module Pod
44
48
  #
45
49
  def should_flatten?
46
50
  if options.key?(:flatten)
47
- true
51
+ options[:flatten]
48
52
  elsif [:tgz, :tar, :tbz, :txz].include?(type)
49
53
  true # those archives flatten by default
50
54
  else
@@ -71,18 +75,8 @@ module Pod
71
75
 
72
76
  def filename_with_type(type = :zip)
73
77
  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'
78
+ when :zip, :tgz, :tar, :tbz, :txz, :dmg
79
+ "file.#{type}"
86
80
  else
87
81
  raise UnsupportedFileTypeError, "Unsupported file type: #{type}"
88
82
  end
@@ -95,16 +89,11 @@ module Pod
95
89
  def extract_with_type(full_filename, type = :zip)
96
90
  unpack_from = full_filename
97
91
  unpack_to = @target_path
92
+
98
93
  case type
99
94
  when :zip
100
95
  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
96
+ when :tar, :tgz, :tbz, :txz
108
97
  tar! 'xf', unpack_from, '-C', unpack_to
109
98
  when :dmg
110
99
  extract_dmg(unpack_from, unpack_to)
@@ -116,11 +105,17 @@ module Pod
116
105
  # contents to the target (#727)
117
106
  #
118
107
  if should_flatten?
119
- contents = @target_path.children
108
+ contents = target_path.children
120
109
  contents.delete(target_path + @filename)
121
110
  entry = contents.first
122
111
  if contents.count == 1 && entry.directory?
123
- FileUtils.move(entry.children, target_path)
112
+ tmp_entry = entry.sub_ext("#{entry.extname}.tmp")
113
+ begin
114
+ FileUtils.move(entry, tmp_entry)
115
+ FileUtils.move(tmp_entry.children, target_path)
116
+ ensure
117
+ FileUtils.remove_entry(tmp_entry)
118
+ end
124
119
  end
125
120
  end
126
121
 
metadata CHANGED
@@ -1,17 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cocoapods-downloader
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eloy Duran
8
8
  - Fabio Pelosin
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-05-25 00:00:00.000000000 Z
12
+ date: 2021-08-31 00:00:00.000000000 Z
13
13
  dependencies: []
14
- description:
14
+ description:
15
15
  email:
16
16
  - eloy.de.enige@gmail.com
17
17
  - fabiopelosin@gmail.com
@@ -33,11 +33,11 @@ files:
33
33
  - lib/cocoapods-downloader/remote_file.rb
34
34
  - lib/cocoapods-downloader/scp.rb
35
35
  - lib/cocoapods-downloader/subversion.rb
36
- homepage: https://github.com/CocoaPods/Downloader
36
+ homepage: https://github.com/CocoaPods/cocoapods-downloader
37
37
  licenses:
38
38
  - MIT
39
39
  metadata: {}
40
- post_install_message:
40
+ post_install_message:
41
41
  rdoc_options: []
42
42
  require_paths:
43
43
  - lib
@@ -45,16 +45,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
45
45
  requirements:
46
46
  - - ">="
47
47
  - !ruby/object:Gem::Version
48
- version: 2.0.0
48
+ version: 2.3.3
49
49
  required_rubygems_version: !ruby/object:Gem::Requirement
50
50
  requirements:
51
51
  - - ">="
52
52
  - !ruby/object:Gem::Version
53
53
  version: '0'
54
54
  requirements: []
55
- rubyforge_project:
56
- rubygems_version: 2.7.6
57
- signing_key:
55
+ rubygems_version: 3.2.3
56
+ signing_key:
58
57
  specification_version: 3
59
58
  summary: A small library for downloading files from remotes in a folder.
60
59
  test_files: []