xcocoapods 1.5.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (124) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +6303 -0
  3. data/LICENSE +28 -0
  4. data/README.md +80 -0
  5. data/bin/pod +56 -0
  6. data/bin/sandbox-pod +168 -0
  7. data/lib/cocoapods.rb +73 -0
  8. data/lib/cocoapods/command.rb +175 -0
  9. data/lib/cocoapods/command/cache.rb +28 -0
  10. data/lib/cocoapods/command/cache/clean.rb +90 -0
  11. data/lib/cocoapods/command/cache/list.rb +69 -0
  12. data/lib/cocoapods/command/env.rb +66 -0
  13. data/lib/cocoapods/command/init.rb +128 -0
  14. data/lib/cocoapods/command/install.rb +45 -0
  15. data/lib/cocoapods/command/ipc.rb +19 -0
  16. data/lib/cocoapods/command/ipc/list.rb +40 -0
  17. data/lib/cocoapods/command/ipc/podfile.rb +31 -0
  18. data/lib/cocoapods/command/ipc/podfile_json.rb +30 -0
  19. data/lib/cocoapods/command/ipc/repl.rb +51 -0
  20. data/lib/cocoapods/command/ipc/spec.rb +29 -0
  21. data/lib/cocoapods/command/ipc/update_search_index.rb +24 -0
  22. data/lib/cocoapods/command/lib.rb +11 -0
  23. data/lib/cocoapods/command/lib/create.rb +105 -0
  24. data/lib/cocoapods/command/lib/lint.rb +121 -0
  25. data/lib/cocoapods/command/list.rb +39 -0
  26. data/lib/cocoapods/command/options/project_directory.rb +36 -0
  27. data/lib/cocoapods/command/options/repo_update.rb +34 -0
  28. data/lib/cocoapods/command/outdated.rb +140 -0
  29. data/lib/cocoapods/command/repo.rb +29 -0
  30. data/lib/cocoapods/command/repo/add.rb +103 -0
  31. data/lib/cocoapods/command/repo/lint.rb +82 -0
  32. data/lib/cocoapods/command/repo/list.rb +93 -0
  33. data/lib/cocoapods/command/repo/push.rb +281 -0
  34. data/lib/cocoapods/command/repo/remove.rb +36 -0
  35. data/lib/cocoapods/command/repo/update.rb +28 -0
  36. data/lib/cocoapods/command/setup.rb +103 -0
  37. data/lib/cocoapods/command/spec.rb +112 -0
  38. data/lib/cocoapods/command/spec/cat.rb +51 -0
  39. data/lib/cocoapods/command/spec/create.rb +283 -0
  40. data/lib/cocoapods/command/spec/edit.rb +87 -0
  41. data/lib/cocoapods/command/spec/env_spec.rb +53 -0
  42. data/lib/cocoapods/command/spec/lint.rb +137 -0
  43. data/lib/cocoapods/command/spec/which.rb +43 -0
  44. data/lib/cocoapods/command/update.rb +101 -0
  45. data/lib/cocoapods/config.rb +347 -0
  46. data/lib/cocoapods/core_overrides.rb +1 -0
  47. data/lib/cocoapods/downloader.rb +190 -0
  48. data/lib/cocoapods/downloader/cache.rb +233 -0
  49. data/lib/cocoapods/downloader/request.rb +86 -0
  50. data/lib/cocoapods/downloader/response.rb +16 -0
  51. data/lib/cocoapods/executable.rb +222 -0
  52. data/lib/cocoapods/external_sources.rb +57 -0
  53. data/lib/cocoapods/external_sources/abstract_external_source.rb +205 -0
  54. data/lib/cocoapods/external_sources/downloader_source.rb +30 -0
  55. data/lib/cocoapods/external_sources/path_source.rb +55 -0
  56. data/lib/cocoapods/external_sources/podspec_source.rb +54 -0
  57. data/lib/cocoapods/gem_version.rb +5 -0
  58. data/lib/cocoapods/generator/acknowledgements.rb +107 -0
  59. data/lib/cocoapods/generator/acknowledgements/markdown.rb +44 -0
  60. data/lib/cocoapods/generator/acknowledgements/plist.rb +94 -0
  61. data/lib/cocoapods/generator/app_target_helper.rb +244 -0
  62. data/lib/cocoapods/generator/bridge_support.rb +22 -0
  63. data/lib/cocoapods/generator/constant.rb +19 -0
  64. data/lib/cocoapods/generator/copy_resources_script.rb +230 -0
  65. data/lib/cocoapods/generator/dummy_source.rb +31 -0
  66. data/lib/cocoapods/generator/embed_frameworks_script.rb +215 -0
  67. data/lib/cocoapods/generator/header.rb +103 -0
  68. data/lib/cocoapods/generator/info_plist_file.rb +116 -0
  69. data/lib/cocoapods/generator/module_map.rb +99 -0
  70. data/lib/cocoapods/generator/prefix_header.rb +60 -0
  71. data/lib/cocoapods/generator/umbrella_header.rb +46 -0
  72. data/lib/cocoapods/hooks_manager.rb +132 -0
  73. data/lib/cocoapods/installer.rb +703 -0
  74. data/lib/cocoapods/installer/analyzer.rb +972 -0
  75. data/lib/cocoapods/installer/analyzer/analysis_result.rb +87 -0
  76. data/lib/cocoapods/installer/analyzer/locking_dependency_analyzer.rb +98 -0
  77. data/lib/cocoapods/installer/analyzer/pod_variant.rb +67 -0
  78. data/lib/cocoapods/installer/analyzer/pod_variant_set.rb +157 -0
  79. data/lib/cocoapods/installer/analyzer/podfile_dependency_cache.rb +54 -0
  80. data/lib/cocoapods/installer/analyzer/sandbox_analyzer.rb +240 -0
  81. data/lib/cocoapods/installer/analyzer/specs_state.rb +84 -0
  82. data/lib/cocoapods/installer/analyzer/target_inspection_result.rb +53 -0
  83. data/lib/cocoapods/installer/analyzer/target_inspector.rb +260 -0
  84. data/lib/cocoapods/installer/installation_options.rb +158 -0
  85. data/lib/cocoapods/installer/pod_source_installer.rb +202 -0
  86. data/lib/cocoapods/installer/pod_source_preparer.rb +77 -0
  87. data/lib/cocoapods/installer/podfile_validator.rb +139 -0
  88. data/lib/cocoapods/installer/post_install_hooks_context.rb +132 -0
  89. data/lib/cocoapods/installer/pre_install_hooks_context.rb +51 -0
  90. data/lib/cocoapods/installer/source_provider_hooks_context.rb +34 -0
  91. data/lib/cocoapods/installer/user_project_integrator.rb +250 -0
  92. data/lib/cocoapods/installer/user_project_integrator/target_integrator.rb +463 -0
  93. data/lib/cocoapods/installer/user_project_integrator/target_integrator/xcconfig_integrator.rb +146 -0
  94. data/lib/cocoapods/installer/xcode.rb +8 -0
  95. data/lib/cocoapods/installer/xcode/pods_project_generator.rb +416 -0
  96. data/lib/cocoapods/installer/xcode/pods_project_generator/aggregate_target_installer.rb +181 -0
  97. data/lib/cocoapods/installer/xcode/pods_project_generator/app_host_installer.rb +84 -0
  98. data/lib/cocoapods/installer/xcode/pods_project_generator/file_references_installer.rb +334 -0
  99. data/lib/cocoapods/installer/xcode/pods_project_generator/pod_target_installer.rb +777 -0
  100. data/lib/cocoapods/installer/xcode/pods_project_generator/pod_target_integrator.rb +116 -0
  101. data/lib/cocoapods/installer/xcode/pods_project_generator/target_installation_result.rb +86 -0
  102. data/lib/cocoapods/installer/xcode/pods_project_generator/target_installer.rb +256 -0
  103. data/lib/cocoapods/installer/xcode/pods_project_generator/target_installer_helper.rb +68 -0
  104. data/lib/cocoapods/installer/xcode/target_validator.rb +147 -0
  105. data/lib/cocoapods/open-uri.rb +33 -0
  106. data/lib/cocoapods/project.rb +414 -0
  107. data/lib/cocoapods/resolver.rb +585 -0
  108. data/lib/cocoapods/resolver/lazy_specification.rb +79 -0
  109. data/lib/cocoapods/sandbox.rb +404 -0
  110. data/lib/cocoapods/sandbox/file_accessor.rb +444 -0
  111. data/lib/cocoapods/sandbox/headers_store.rb +146 -0
  112. data/lib/cocoapods/sandbox/path_list.rb +220 -0
  113. data/lib/cocoapods/sandbox/pod_dir_cleaner.rb +85 -0
  114. data/lib/cocoapods/sandbox/podspec_finder.rb +23 -0
  115. data/lib/cocoapods/sources_manager.rb +157 -0
  116. data/lib/cocoapods/target.rb +261 -0
  117. data/lib/cocoapods/target/aggregate_target.rb +338 -0
  118. data/lib/cocoapods/target/build_settings.rb +1075 -0
  119. data/lib/cocoapods/target/pod_target.rb +559 -0
  120. data/lib/cocoapods/user_interface.rb +459 -0
  121. data/lib/cocoapods/user_interface/error_report.rb +187 -0
  122. data/lib/cocoapods/user_interface/inspector_reporter.rb +109 -0
  123. data/lib/cocoapods/validator.rb +981 -0
  124. metadata +533 -0
@@ -0,0 +1 @@
1
+ require 'cocoapods/sources_manager'
@@ -0,0 +1,190 @@
1
+ require 'cocoapods-downloader'
2
+ require 'claide/informative_error'
3
+ require 'fileutils'
4
+ require 'tmpdir'
5
+
6
+ module Pod
7
+ module Downloader
8
+ require 'cocoapods/downloader/cache'
9
+ require 'cocoapods/downloader/request'
10
+ require 'cocoapods/downloader/response'
11
+
12
+ # Downloads a pod from the given `request` to the given `target` location.
13
+ #
14
+ # @return [Response] The download response for this download.
15
+ #
16
+ # @param [Request] request
17
+ # the request that describes this pod download.
18
+ #
19
+ # @param [Pathname,Nil] target
20
+ # the location to which this pod should be downloaded. If `nil`,
21
+ # then the pod will only be cached.
22
+ #
23
+ # @param [Boolean] can_cache
24
+ # whether caching is allowed.
25
+ #
26
+ # @param [Pathname,Nil] cache_path
27
+ # the path used to cache pod downloads.
28
+ #
29
+ def self.download(
30
+ request,
31
+ target,
32
+ can_cache: true,
33
+ cache_path: Config.instance.cache_root + 'Pods'
34
+ )
35
+ can_cache &&= !Config.instance.skip_download_cache
36
+
37
+ request = preprocess_request(request)
38
+
39
+ if can_cache
40
+ raise ArgumentError, 'Must provide a `cache_path` when caching.' unless cache_path
41
+ cache = Cache.new(cache_path)
42
+ result = cache.download_pod(request)
43
+ else
44
+ raise ArgumentError, 'Must provide a `target` when caching is disabled.' unless target
45
+
46
+ require 'cocoapods/installer/pod_source_preparer'
47
+ result, = download_request(request, target)
48
+ Installer::PodSourcePreparer.new(result.spec, result.location).prepare!
49
+ end
50
+
51
+ if target && result.location && target != result.location
52
+ UI.message "Copying #{request.name} from `#{result.location}` to #{UI.path target}", '> ' do
53
+ FileUtils.rm_rf target
54
+ FileUtils.cp_r(result.location, target)
55
+ end
56
+ end
57
+ result
58
+ end
59
+
60
+ # Performs the download from the given `request` to the given `target` location.
61
+ #
62
+ # @return [Response, Hash<String,Specification>]
63
+ # The download response for this download, and the specifications
64
+ # for this download grouped by name.
65
+ #
66
+ # @param [Request] request
67
+ # the request that describes this pod download.
68
+ #
69
+ # @param [Pathname,Nil] target
70
+ # the location to which this pod should be downloaded. If `nil`,
71
+ # then the pod will only be cached.
72
+ #
73
+ def self.download_request(request, target)
74
+ result = Response.new
75
+ result.checkout_options = download_source(target, request.params)
76
+ result.location = target
77
+
78
+ if request.released_pod?
79
+ result.spec = request.spec
80
+ podspecs = { request.name => request.spec }
81
+ else
82
+ podspecs = Sandbox::PodspecFinder.new(target).podspecs
83
+ podspecs[request.name] = request.spec if request.spec
84
+ podspecs.each do |name, spec|
85
+ if request.name == name
86
+ result.spec = spec
87
+ end
88
+ end
89
+ end
90
+
91
+ [result, podspecs]
92
+ end
93
+
94
+ private
95
+
96
+ # Downloads a pod with the given `params` to `target`.
97
+ #
98
+ # @param [Pathname] target
99
+ #
100
+ # @param [Hash<Symbol,String>] params
101
+ #
102
+ # @return [Hash] The checkout options required to re-download this exact
103
+ # same source.
104
+ #
105
+ def self.download_source(target, params)
106
+ FileUtils.rm_rf(target)
107
+ downloader = Downloader.for_target(target, params)
108
+ downloader.download
109
+ target.mkpath
110
+
111
+ if downloader.options_specific?
112
+ params
113
+ else
114
+ downloader.checkout_options
115
+ end
116
+ end
117
+
118
+ # Return a new request after preprocessing by the downloader
119
+ #
120
+ # @param [Request] request
121
+ # the request that needs preprocessing
122
+ #
123
+ # @return [Request] the preprocessed request
124
+ #
125
+ def self.preprocess_request(request)
126
+ Request.new(
127
+ :spec => request.spec,
128
+ :released => request.released_pod?,
129
+ :name => request.name,
130
+ :params => Downloader.preprocess_options(request.params))
131
+ end
132
+
133
+ public
134
+
135
+ class DownloaderError; include CLAide::InformativeError; end
136
+
137
+ class Base
138
+ override_api do
139
+ def execute_command(executable, command, raise_on_failure = false)
140
+ Executable.execute_command(executable, command, raise_on_failure)
141
+ rescue CLAide::InformativeError => e
142
+ raise DownloaderError, e.message
143
+ end
144
+
145
+ # Indicates that an action will be performed. The action is passed as a
146
+ # block.
147
+ #
148
+ # @param [String] message
149
+ # The message associated with the action.
150
+ #
151
+ # @yield The action, this block is always executed.
152
+ #
153
+ # @return [void]
154
+ #
155
+ def ui_action(message)
156
+ UI.section(" > #{message}", '', 1) do
157
+ yield
158
+ end
159
+ end
160
+
161
+ # Indicates that a minor action will be performed. The action is passed
162
+ # as a block.
163
+ #
164
+ # @param [String] message
165
+ # The message associated with the action.
166
+ #
167
+ # @yield The action, this block is always executed.
168
+ #
169
+ # @return [void]
170
+ #
171
+ def ui_sub_action(message)
172
+ UI.section(" > #{message}", '', 2) do
173
+ yield
174
+ end
175
+ end
176
+
177
+ # Prints an UI message.
178
+ #
179
+ # @param [String] message
180
+ # The message associated with the action.
181
+ #
182
+ # @return [void]
183
+ #
184
+ def ui_message(message)
185
+ UI.puts message
186
+ end
187
+ end
188
+ end
189
+ end
190
+ end
@@ -0,0 +1,233 @@
1
+ require 'fileutils'
2
+ require 'tmpdir'
3
+
4
+ module Pod
5
+ module Downloader
6
+ # The class responsible for managing Pod downloads, transparently caching
7
+ # them in a cache directory.
8
+ #
9
+ class Cache
10
+ # @return [Pathname] The root directory where this cache store its
11
+ # downloads.
12
+ #
13
+ attr_reader :root
14
+
15
+ # Initialize a new instance
16
+ #
17
+ # @param [Pathname,String] root
18
+ # see {#root}
19
+ #
20
+ def initialize(root)
21
+ @root = Pathname(root)
22
+ ensure_matching_version
23
+ end
24
+
25
+ # Downloads the Pod from the given `request`
26
+ #
27
+ # @param [Request] request
28
+ # the request to be downloaded.
29
+ #
30
+ # @return [Response] the response from downloading `request`
31
+ #
32
+ def download_pod(request)
33
+ cached_pod(request) || uncached_pod(request)
34
+ rescue Informative
35
+ raise
36
+ rescue
37
+ UI.puts("\n[!] Error installing #{request.name}".red)
38
+ raise
39
+ end
40
+
41
+ # @return [Hash<String, Hash<Symbol, String>>]
42
+ # A hash whose keys are the pod name
43
+ # And values are a hash with the following keys:
44
+ # :spec_file : path to the spec file
45
+ # :name : name of the pod
46
+ # :version : pod version
47
+ # :release : boolean to tell if that's a release pod
48
+ # :slug : the slug path where the pod cache is located
49
+ #
50
+ def cache_descriptors_per_pod
51
+ specs_dir = root + 'Specs'
52
+ release_specs_dir = specs_dir + 'Release'
53
+ return {} unless specs_dir.exist?
54
+
55
+ spec_paths = specs_dir.find.select { |f| f.fnmatch('*.podspec.json') }
56
+ spec_paths.reduce({}) do |hash, spec_path|
57
+ spec = Specification.from_file(spec_path)
58
+ hash[spec.name] ||= []
59
+ is_release = spec_path.to_s.start_with?(release_specs_dir.to_s)
60
+ request = Downloader::Request.new(:spec => spec, :released => is_release)
61
+ hash[spec.name] << {
62
+ :spec_file => spec_path,
63
+ :name => spec.name,
64
+ :version => spec.version,
65
+ :release => is_release,
66
+ :slug => root + request.slug,
67
+ }
68
+ hash
69
+ end
70
+ end
71
+
72
+ private
73
+
74
+ # Ensures the cache on disk was created with the same CocoaPods version as
75
+ # is currently running.
76
+ #
77
+ # @return [Void]
78
+ #
79
+ def ensure_matching_version
80
+ version_file = root + 'VERSION'
81
+ version = version_file.read.strip if version_file.file?
82
+
83
+ root.rmtree if version != Pod::VERSION && root.exist?
84
+ root.mkpath
85
+
86
+ version_file.open('w') { |f| f << Pod::VERSION }
87
+ end
88
+
89
+ # @param [Request] request
90
+ # the request to be downloaded.
91
+ #
92
+ # @param [Hash<Symbol,String>] slug_opts
93
+ # the download options that should be used in constructing the
94
+ # cache slug for this request.
95
+ #
96
+ # @return [Pathname] The path for the Pod downloaded from the given
97
+ # `request`.
98
+ #
99
+ def path_for_pod(request, slug_opts = {})
100
+ root + request.slug(slug_opts)
101
+ end
102
+
103
+ # @param [Request] request
104
+ # the request to be downloaded.
105
+ #
106
+ # @param [Hash<Symbol,String>] slug_opts
107
+ # the download options that should be used in constructing the
108
+ # cache slug for this request.
109
+ #
110
+ # @return [Pathname] The path for the podspec downloaded from the given
111
+ # `request`.
112
+ #
113
+ def path_for_spec(request, slug_opts = {})
114
+ path = root + 'Specs' + request.slug(slug_opts)
115
+ path.sub_ext('.podspec.json')
116
+ end
117
+
118
+ # @param [Request] request
119
+ # the request to be downloaded.
120
+ #
121
+ # @return [Response] The download response for the given `request` that
122
+ # was found in the download cache.
123
+ #
124
+ def cached_pod(request)
125
+ cached_spec = cached_spec(request)
126
+ path = path_for_pod(request)
127
+
128
+ return unless cached_spec && path.directory?
129
+ spec = request.spec || cached_spec
130
+ Response.new(path, spec, request.params)
131
+ end
132
+
133
+ # @param [Request] request
134
+ # the request to be downloaded.
135
+ #
136
+ # @return [Specification] The cached specification for the given
137
+ # `request`.
138
+ #
139
+ def cached_spec(request)
140
+ path = path_for_spec(request)
141
+ path.file? && Specification.from_file(path)
142
+ rescue JSON::ParserError
143
+ nil
144
+ end
145
+
146
+ # @param [Request] request
147
+ # the request to be downloaded.
148
+ #
149
+ # @return [Response] The download response for the given `request` that
150
+ # was not found in the download cache.
151
+ #
152
+ def uncached_pod(request)
153
+ in_tmpdir do |target|
154
+ result, podspecs = download(request, target)
155
+ result.location = nil
156
+
157
+ podspecs.each do |name, spec|
158
+ destination = path_for_pod(request, :name => name, :params => result.checkout_options)
159
+ copy_and_clean(target, destination, spec)
160
+ write_spec(spec, path_for_spec(request, :name => name, :params => result.checkout_options))
161
+ if request.name == name
162
+ result.location = destination
163
+ end
164
+ end
165
+
166
+ result
167
+ end
168
+ end
169
+
170
+ def download(request, target)
171
+ Downloader.download_request(request, target)
172
+ end
173
+
174
+ # Performs the given block inside a temporary directory,
175
+ # which is removed at the end of the block's scope.
176
+ #
177
+ # @return [Object] The return value of the given block
178
+ #
179
+ def in_tmpdir(&blk)
180
+ tmpdir = Pathname(Dir.mktmpdir)
181
+ blk.call(tmpdir)
182
+ ensure
183
+ FileUtils.remove_entry(tmpdir, :force => true) if tmpdir && tmpdir.exist?
184
+ end
185
+
186
+ # Copies the `source` directory to `destination`, cleaning the directory
187
+ # of any files unused by `spec`.
188
+ #
189
+ # @param [Pathname] source
190
+ #
191
+ # @param [Pathname] destination
192
+ #
193
+ # @param [Specification] spec
194
+ #
195
+ # @return [Void]
196
+ #
197
+ def copy_and_clean(source, destination, spec)
198
+ specs_by_platform = group_subspecs_by_platform(spec)
199
+ destination.parent.mkpath
200
+ FileUtils.rm_rf(destination)
201
+ FileUtils.cp_r(source, destination)
202
+ Pod::Installer::PodSourcePreparer.new(spec, destination).prepare!
203
+ Sandbox::PodDirCleaner.new(destination, specs_by_platform).clean!
204
+ end
205
+
206
+ def group_subspecs_by_platform(spec)
207
+ specs_by_platform = {}
208
+ [spec, *spec.recursive_subspecs].each do |ss|
209
+ ss.available_platforms.each do |platform|
210
+ specs_by_platform[platform] ||= []
211
+ specs_by_platform[platform] << ss
212
+ end
213
+ end
214
+ specs_by_platform
215
+ end
216
+
217
+ # Writes the given `spec` to the given `path`.
218
+ #
219
+ # @param [Specification] spec
220
+ # the specification to be written.
221
+ #
222
+ # @param [Pathname] path
223
+ # the path the specification is to be written to.
224
+ #
225
+ # @return [Void]
226
+ #
227
+ def write_spec(spec, path)
228
+ path.dirname.mkpath
229
+ path.open('w') { |f| f.write spec.to_pretty_json }
230
+ end
231
+ end
232
+ end
233
+ end
@@ -0,0 +1,86 @@
1
+ require 'digest'
2
+
3
+ module Pod
4
+ module Downloader
5
+ # This class represents a download request for a given Pod.
6
+ #
7
+ class Request
8
+ # @return [Specification,Nil] The specification for the pod whose download
9
+ # is being requested.
10
+ #
11
+ attr_reader :spec
12
+
13
+ # @return [Boolean] Whether this download request is for a released pod.
14
+ #
15
+ attr_reader :released_pod
16
+ alias_method :released_pod?, :released_pod
17
+
18
+ # @return [String] The name of the pod whose dowload is being requested.
19
+ #
20
+ attr_reader :name
21
+
22
+ # @return [Hash<Symbol, String>] The download parameters for this request.
23
+ #
24
+ attr_reader :params
25
+
26
+ # Initialize a new instance
27
+ #
28
+ # @param [Specification,Nil] spec
29
+ # see {#spec}
30
+ #
31
+ # @param [Boolean] released
32
+ # see {#released_pod}
33
+ #
34
+ # @param [String,Nil] name
35
+ # see {#name}
36
+ #
37
+ # @param [Hash<Symbol,String>,Nil] params
38
+ # see {#params}
39
+ #
40
+ def initialize(spec: nil, released: false, name: nil, params: false)
41
+ @released_pod = released
42
+ @spec = spec
43
+ @params = spec ? (spec.source && spec.source.dup) : params
44
+ @name = spec ? spec.name : name
45
+
46
+ validate!
47
+ end
48
+
49
+ # @param [String] name
50
+ # the name of the pod being downloaded.
51
+ #
52
+ # @param [Hash<#to_s, #to_s>] params
53
+ # the download parameters of the pod being downloaded.
54
+ #
55
+ # @param [Specification] spec
56
+ # the specification of the pod being downloaded.
57
+ #
58
+ # @return [String] The slug used to store the files resulting from this
59
+ # download request.
60
+ #
61
+ def slug(name: self.name, params: self.params, spec: self.spec)
62
+ checksum = spec && spec.checksum && '-' << spec.checksum[0, 5]
63
+ if released_pod?
64
+ "Release/#{name}/#{spec.version}#{checksum}"
65
+ else
66
+ opts = params.to_a.sort_by(&:first).map { |k, v| "#{k}=#{v}" }.join('-')
67
+ digest = Digest::MD5.hexdigest(opts)
68
+ "External/#{name}/#{digest}#{checksum}"
69
+ end
70
+ end
71
+
72
+ private
73
+
74
+ # Validates that the given request is well-formed.
75
+ #
76
+ # @return [Void]
77
+ #
78
+ def validate!
79
+ raise ArgumentError, 'Requires a name' unless name
80
+ raise ArgumentError, 'Must give a spec for a released download request' if released_pod? && !spec
81
+ raise ArgumentError, 'Requires a version if released' if released_pod? && !spec.version
82
+ raise ArgumentError, 'Requires params' unless params
83
+ end
84
+ end
85
+ end
86
+ end