Module: Pod::Downloader
- Defined in:
- lib/cocoapods-downloader.rb,
lib/cocoapods-downloader/api.rb,
lib/cocoapods-downloader/git.rb,
lib/cocoapods-downloader/scp.rb,
lib/cocoapods-downloader/base.rb,
lib/cocoapods-downloader/http.rb,
lib/cocoapods-downloader/mercurial.rb,
lib/cocoapods-downloader/subversion.rb,
lib/cocoapods-downloader/gem_version.rb,
lib/cocoapods-downloader/remote_file.rb,
lib/cocoapods-downloader/api_exposable.rb
Defined Under Namespace
Modules: API, APIExposable Classes: Base, DownloaderError, Git, Http, Mercurial, RemoteFile, Scp, Subversion
Constant Summary collapse
- VERSION =
Returns Downloader’s version, following [semver](semver.org).
'2.1'.freeze
Class Method Summary collapse
- .class_for_options(options) ⇒ Object
-
.downloader_class_by_key ⇒ Hash{Symbol=>Class}
The concrete classes of the supported strategies by key.
-
.for_target(target_path, options) ⇒ Downloader::Base
A concrete downloader according to the options.
- .options_to_sym(options) ⇒ Object
-
.preprocess_options(options) ⇒ Hash<Symbol,String>
Have the concrete strategy preprocess options.
-
.strategy_from_options(options) ⇒ Symbol, Nil
Identifies the concrete strategy for the given options.
Class Method Details
.class_for_options(options) ⇒ Object
85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/cocoapods-downloader.rb', line 85 def self.() if .nil? || .empty? raise DownloaderError, 'No source URL provided.' end strategy = () unless strategy raise DownloaderError, 'Unsupported download strategy ' \ "`#{.inspect}`." end # Explicit return for multiple params, rubocop thinks it's useless but it's not return strategy, downloader_class_by_key[strategy] # rubocop:disable Style/RedundantReturn end |
.downloader_class_by_key ⇒ Hash{Symbol=>Class}
Returns The concrete classes of the supported strategies by key.
21 22 23 24 25 26 27 28 29 |
# File 'lib/cocoapods-downloader.rb', line 21 def self.downloader_class_by_key { :git => Git, :hg => Mercurial, :http => Http, :scp => Scp, :svn => Subversion, } end |
.for_target(target_path, options) ⇒ Downloader::Base
Returns A concrete downloader according to the options.
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/cocoapods-downloader.rb', line 49 def self.for_target(target_path, ) = () if target_path.nil? raise DownloaderError, 'No target path provided.' end strategy, klass = () url = [strategy] = .dup .delete(strategy) klass.new(target_path, url, ) end |
.options_to_sym(options) ⇒ Object
81 82 83 |
# File 'lib/cocoapods-downloader.rb', line 81 def self.() Hash[.map { |k, v| [k.to_sym, v] }] end |
.preprocess_options(options) ⇒ Hash<Symbol,String>
Have the concrete strategy preprocess options
72 73 74 75 76 77 |
# File 'lib/cocoapods-downloader.rb', line 72 def self.() = () _, klass = () klass.() end |
.strategy_from_options(options) ⇒ Symbol, Nil
Identifies the concrete strategy for the given options.
39 40 41 42 43 44 |
# File 'lib/cocoapods-downloader.rb', line 39 def self.() common = downloader_class_by_key.keys & .keys if common.count == 1 common.first end end |