Module: PDK::Template::Fetcher
- Defined in:
- lib/pdk/template/fetcher.rb,
lib/pdk/template/fetcher/git.rb,
lib/pdk/template/fetcher/local.rb
Defined Under Namespace
Classes: AbstractFetcher, Git, Local
Class Method Summary collapse
-
.instance(uri, options = {}) ⇒ PDK::Template::Fetcher::AbstractTemplateFetcher
Returns a Template Fetcher implementation for the given Template URI.
-
.with(uri, options = {}) {|fetcher| ... } ⇒ void
Creates an instance of a PDK::Template::Fetcher::AbstractTemplateFetcher object with the path or URL to the template and the block of code to run to be run while the template is fetched.
Class Method Details
.instance(uri, options = {}) ⇒ PDK::Template::Fetcher::AbstractTemplateFetcher
Returns a Template Fetcher implementation for the given Template URI
14 15 16 17 18 |
# File 'lib/pdk/template/fetcher.rb', line 14 def self.instance(uri, = {}) return Git.new(uri, ) if Git.fetchable?(uri, ) Local.new(uri, ) end |
.with(uri, options = {}) {|fetcher| ... } ⇒ void
This method returns an undefined value.
Creates an instance of a PDK::Template::Fetcher::AbstractTemplateFetcher object with the path or URL to the template and the block of code to run to be run while the template is fetched.
The fetched directory is only guaranteed to be available on disk within the scope of the block passed to this method.
38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/pdk/template/fetcher.rb', line 38 def self.with(uri, = {}) raise ArgumentError, format('%{class_name}.with must be passed a block.', class_name: name) unless block_given? fetcher = instance(uri, ) begin fetcher.fetch! yield fetcher ensure # If the the path is temporary, clean it up PDK::Util::Filesystem.rm_rf(fetcher.path) if fetcher.temporary end nil end |