cocoapods-downloader 1.2.2 → 1.5.1

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: cf1fa4c5fb3da8df7c444f32589cb2df38e60c2eebe18f8e7ebcff0ee50bcbb7
4
- data.tar.gz: 24d3fe5d0ddbf3e5638c5781cfd09490864f4d4e673c2140de67560e819afb10
3
+ metadata.gz: 62d6e0b714faaaf66ca8228f636b34e61976252749672e04a3a6aa0445b18709
4
+ data.tar.gz: f585de6e9a7e972a89c87c98d73619798e66340d814fff06231992dfbce62e33
5
5
  SHA512:
6
- metadata.gz: bddb10ca07f8081a4f0cef416bf150b623472d81b9dbb096d854ec5a810dd30709b63a6d4c2b487b9e617a80cc34fe20191bc0193bc37aa496a36b003baa8e93
7
- data.tar.gz: 6488ab1e8081b6b24f98fb519d259e6da8d709158d645abfaf7f732749ab942c994ba4f8e93d3337e024d27854bcf9149b01271da55fe77ecc3474b050780f46
6
+ metadata.gz: 87552efe2b4e7332c9b5cfe88ea19ad1e404d4eee94ea3187f60d26e40dcd910b049f05e7246dd8a7cb210ce96658cc7703a3f9095e6ed0c49151ae9019a80a7
7
+ data.tar.gz: 8b44845a7e0da71748ff781fd15de6eb17bbca24f8fa72b76029bc65341805436d2460b6df38b092322006a5e7b2075b40a04eaad06c63cd9dcef87a69fcdfa0
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.2'.freeze
6
+ VERSION = '1.5.1'.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.dup.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
@@ -6,7 +6,7 @@ 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
@@ -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.
@@ -89,13 +93,7 @@ module Pod
89
93
  case type
90
94
  when :zip
91
95
  unzip! unpack_from, '-d', unpack_to
92
- when :tgz
93
- tar! 'xfz', unpack_from, '-C', unpack_to
94
- when :tar
95
- tar! 'xf', unpack_from, '-C', unpack_to
96
- when :tbz
97
- tar! 'xfj', unpack_from, '-C', unpack_to
98
- when :txz
96
+ when :tar, :tgz, :tbz, :txz
99
97
  tar! 'xf', unpack_from, '-C', unpack_to
100
98
  when :dmg
101
99
  extract_dmg(unpack_from, unpack_to)
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.2
4
+ version: 1.5.1
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-10-16 00:00:00.000000000 Z
12
+ date: 2021-09-07 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
@@ -37,7 +37,7 @@ 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.7
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: []