Class: TerraspaceBundler::Mod
- Inherits:
-
Object
- Object
- TerraspaceBundler::Mod
- Extended by:
- Props::Extension
- Includes:
- Concerns::LocalConcern, Concerns::StackConcern
- Defined in:
- lib/terraspace_bundler/mod/props.rb,
lib/terraspace_bundler/mod.rb,
lib/terraspace_bundler/mod/fetcher.rb,
lib/terraspace_bundler/mod/registry.rb
Overview
Delegates to:
1. Local
2. Git
Defined Under Namespace
Modules: Concerns, Http Classes: Fetcher, Props, Registry
Instance Attribute Summary collapse
-
#branch ⇒ Object
readonly
Returns the value of attribute branch.
-
#props ⇒ Object
readonly
Returns the value of attribute props.
-
#ref ⇒ Object
readonly
Returns the value of attribute ref.
-
#tag ⇒ Object
readonly
Returns the value of attribute tag.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
-
#checkout_version ⇒ Object
support variety of options, prefer version.
- #full_repo ⇒ Object
-
#initialize(props = {}) ⇒ Mod
constructor
A new instance of Mod.
- #latest_sha ⇒ Object
-
#org ⇒ Object
github.com/tongueroo/pet - 2nd to last word [email protected]:tongueroo/pet - 2nd to last word without chars before :.
-
#repo ⇒ Object
use url instead of source because for registry modules, the repo name is different.
- #vcs_provider ⇒ Object
Methods included from Props::Extension
Methods included from Concerns::LocalConcern
Methods included from Concerns::StackConcern
#all_stacks, #all_stacks?, #array_stacks, #normalize_stacks, #stacks
Constructor Details
#initialize(props = {}) ⇒ Mod
Returns a new instance of Mod.
10 11 12 13 14 |
# File 'lib/terraspace_bundler/mod.rb', line 10 def initialize(props={}) @props = props.symbolize_keys # These props are used for version comparing by VersionComparer @version, @ref, @tag, @branch = @props[:version], @props[:ref], @props[:tag], @props[:branch] end |
Instance Attribute Details
#branch ⇒ Object (readonly)
Returns the value of attribute branch.
9 10 11 |
# File 'lib/terraspace_bundler/mod.rb', line 9 def branch @branch end |
#props ⇒ Object (readonly)
Returns the value of attribute props.
9 10 11 |
# File 'lib/terraspace_bundler/mod.rb', line 9 def props @props end |
#ref ⇒ Object (readonly)
Returns the value of attribute ref.
9 10 11 |
# File 'lib/terraspace_bundler/mod.rb', line 9 def ref @ref end |
#tag ⇒ Object (readonly)
Returns the value of attribute tag.
9 10 11 |
# File 'lib/terraspace_bundler/mod.rb', line 9 def tag @tag end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
9 10 11 |
# File 'lib/terraspace_bundler/mod.rb', line 9 def version @version end |
Instance Method Details
#checkout_version ⇒ Object
support variety of options, prefer version
17 18 19 |
# File 'lib/terraspace_bundler/mod.rb', line 17 def checkout_version @version || @ref || @tag || @branch end |
#full_repo ⇒ Object
33 34 35 |
# File 'lib/terraspace_bundler/mod.rb', line 33 def full_repo "#{org}/#{repo}" end |
#latest_sha ⇒ Object
37 38 39 40 41 |
# File 'lib/terraspace_bundler/mod.rb', line 37 def latest_sha fetcher = Fetcher.new(self).instance fetcher.run fetcher.sha end |
#org ⇒ Object
github.com/tongueroo/pet - 2nd to last word [email protected]:tongueroo/pet - 2nd to last word without chars before :
28 29 30 31 |
# File 'lib/terraspace_bundler/mod.rb', line 28 def org s = url_words[-2] # second to last word s.split(':').last # in case of [email protected]:tongueroo/pet form end |
#repo ⇒ Object
use url instead of source because for registry modules, the repo name is different
22 23 24 |
# File 'lib/terraspace_bundler/mod.rb', line 22 def repo url_words[-1].sub(/\.git$/,'') end |
#vcs_provider ⇒ Object
43 44 45 46 47 48 49 50 51 |
# File 'lib/terraspace_bundler/mod.rb', line 43 def vcs_provider if url.include?('http') # "https://github.com/org/repo" => github.com url.match(%r{http[s]?://(.*?)/})[1] else # git@ # "[email protected]:org/repo" => github.com url.match(%r{git@(.*?):})[1] end end |