Skip to content

Commit f7675b5

Browse files
committed
add methods for git_package and github_package
1 parent b19f9d0 commit f7675b5

File tree

1 file changed

+29
-0
lines changed
  • lib/cocoapods-core/podfile

1 file changed

+29
-0
lines changed

lib/cocoapods-core/podfile/dsl.rb

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,35 @@ def pod(name = nil, *requirements)
306306
current_target_definition.store_pod(name, *requirements)
307307
end
308308

309+
def git_package(url, *requirements)
310+
unless url
311+
raise StandardError, 'A git package requires an URL.'
312+
end
313+
314+
options = requirements.last
315+
unless options.is_a?(Hash)
316+
options = {}
317+
requirements << options
318+
end
319+
options[:source] = url
320+
321+
name = options.delete(:name) || url.gsub(/.git$/, '').gsub(%r{^/}, '').split('/').last
322+
323+
unless name
324+
raise StandardError, "Could not infer pod name from '#{url}' and no `:name` was specified."
325+
end
326+
327+
current_target_definition.store_pod(name, *requirements)
328+
end
329+
330+
def github_package(url_fragment, *requirements)
331+
unless url_fragment
332+
raise StandardError, 'A GitHub package requires an URL fragment, e.g. `username/reponame`.'
333+
end
334+
335+
git_package("https://github.com/#{url_fragment}", *requirements)
336+
end
337+
309338
# Use just the dependencies of a Pod defined in the given podspec file.
310339
# If no arguments are passed the first podspec in the root of the Podfile
311340
# is used. It is intended to be used by the project of a library. Note:

0 commit comments

Comments
 (0)