Class: Vanagon::Component::Source
- Inherits:
-
Object
- Object
- Vanagon::Component::Source
- Defined in:
- lib/vanagon/component/source.rb,
lib/vanagon/component/source/git.rb,
lib/vanagon/component/source/http.rb,
lib/vanagon/component/source/local.rb,
lib/vanagon/component/source/rewrite.rb
Defined Under Namespace
Classes: Git, Http, Local, Rewrite
Constant Summary collapse
- SUPPORTED_PROTOCOLS =
%w[file http https git].freeze
Class Method Summary collapse
-
.source(uri, **options) ⇒ Vanagon::Component::Source
Basic factory to hand back the correct Source subtype to the component.
Class Method Details
.source(uri, **options) ⇒ Vanagon::Component::Source
Basic factory to hand back the correct Vanagon::Component::Source subtype to the component
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/vanagon/component/source.rb', line 18 def source(uri, **) # First we try git if Vanagon::Component::Source::Git.valid_remote?(uri) return Vanagon::Component::Source::Git.new uri, sum: [:sum], ref: [:ref], workdir: [:workdir] end # Then we try HTTP if Vanagon::Component::Source::Http.valid_url?(uri) return Vanagon::Component::Source::Http.new uri, sum: [:sum], workdir: [:workdir], # Default sum_type is md5 if unspecified: sum_type: [:sum_type] || "md5" end # Then we try local if Vanagon::Component::Source::Local.valid_file?(uri) return Vanagon::Component::Source::Local.new uri, workdir: [:workdir] end # Failing all of that, we give up raise Vanagon::Error, "Unknown file type: '#{uri}'; cannot continue" end |