Class: SpaceArchitect::RepoResolver
- Inherits:
-
Object
- Object
- SpaceArchitect::RepoResolver
- Defined in:
- lib/space_architect/repo_resolver.rb
Constant Summary collapse
- SCP_LIKE_PATTERN =
/\A(?:[^@\/]+@)?(?<provider>[^:\/]+):(?<path>.+)\z/- URL_PATTERN =
%r{\A[A-Za-z][A-Za-z0-9+\-.]*://}
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Instance Method Summary collapse
-
#initialize(config) ⇒ RepoResolver
constructor
A new instance of RepoResolver.
- #resolve(spec) ⇒ Object
Constructor Details
#initialize(config) ⇒ RepoResolver
Returns a new instance of RepoResolver.
12 13 14 |
# File 'lib/space_architect/repo_resolver.rb', line 12 def initialize(config) @config = config end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
10 11 12 |
# File 'lib/space_architect/repo_resolver.rb', line 10 def config @config end |
Instance Method Details
#resolve(spec) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/space_architect/repo_resolver.rb', line 16 def resolve(spec) value = spec.to_s.strip raise RepoResolutionError, "Repo cannot be blank" if value.empty? if url_like?(value) resolve_url(value) elsif (match = value.match(SCP_LIKE_PATTERN)) reference_from_parts( provider: match[:provider], path_parts: split_repo_path(match[:path]), clone_url: value, source: value ) else resolve_shorthand(value) end end |