Class: TerraspaceBundler::Mod::Props
- Inherits:
-
Object
- Object
- TerraspaceBundler::Mod::Props
- Extended by:
- Memoist
- Includes:
- TB::Util::Logging, Concerns::NotationConcern
- Defined in:
- lib/terraspace_bundler/mod/props.rb,
lib/terraspace_bundler/mod/props/typer.rb,
lib/terraspace_bundler/mod/props/extension.rb
Defined Under Namespace
Modules: Extension Classes: Typer
Instance Attribute Summary collapse
-
#source ⇒ Object
readonly
Returns the value of attribute source.
Instance Method Summary collapse
- #build ⇒ Object
-
#clone_with(url) ⇒ Object
apply clone_with option if set.
-
#git_source_url ⇒ Object
git_source_url is normalized.
- #http_source_url ⇒ Object
-
#initialize(params = {}) ⇒ Props
constructor
A new instance of Props.
- #name ⇒ Object
- #registry ⇒ Object
- #typer ⇒ Object
-
#url ⇒ Object
url is normalized.
Methods included from Concerns::NotationConcern
#clean_notation, #ref, #remove_notations, #remove_ref_notation, #remove_subfolder_notation, #subfolder
Constructor Details
#initialize(params = {}) ⇒ Props
Returns a new instance of Props.
12 13 14 15 16 |
# File 'lib/terraspace_bundler/mod/props.rb', line 12 def initialize(params={}) @params = params @options = params[:options] @source, @version = @options[:source], @options[:version] end |
Instance Attribute Details
#source ⇒ Object (readonly)
Returns the value of attribute source.
11 12 13 |
# File 'lib/terraspace_bundler/mod/props.rb', line 11 def source @source end |
Instance Method Details
#build ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/terraspace_bundler/mod/props.rb', line 22 def build unless @source logger.error "ERROR: The source option must be set for the #{name} mod in the Terrafile".color(:red) exit 1 end o = @options.merge( name: name, type: type, url: url, ) o[:subfolder] ||= subfolder(@source) o[:ref] ||= ref(@source) o end |
#clone_with(url) ⇒ Object
apply clone_with option if set
53 54 55 56 57 58 59 60 61 |
# File 'lib/terraspace_bundler/mod/props.rb', line 53 def clone_with(url) with = @options[:clone_with] || TB.config.clone_with return url unless with if with == 'https' url.sub(/.*@(.*):/,'https://\1/') else # git@ url.sub(%r{http[s]?://(.*?)/},'git@\1:') end end |
#git_source_url ⇒ Object
git_source_url is normalized
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/terraspace_bundler/mod/props.rb', line 69 def git_source_url if @source.include?('http') || @source.include?(':') # Examples: # mod "pet1", source: "https://github.com/tongueroo/pet" # mod "pet2", source: "[email protected]:tongueroo/pet" # mod "pet3", source: "[email protected]:tongueroo/pet" # mod "pet4", source: "[email protected]:tongueroo/pet" # mod "example3", source: "git::https://example.com/example-module.git" # # sub to allow for generic git repo notiation @source.sub('git::','') else # Examples: # mod "pet", source: "tongueroo/pet" # Or: # org "tongueroo" # mod "pet", source: "pet" org_source = @source.include?('/') ? @source : "#{TB.config.org}/#{@source}" # adds inferred org "#{TB.config.base_clone_url}#{org_source}" end end |
#http_source_url ⇒ Object
63 64 65 66 |
# File 'lib/terraspace_bundler/mod/props.rb', line 63 def http_source_url source = Http::Source.new(@params) source.url end |
#name ⇒ Object
18 19 20 |
# File 'lib/terraspace_bundler/mod/props.rb', line 18 def name remove_notations(@params[:args].first) end |
#registry ⇒ Object
96 97 98 |
# File 'lib/terraspace_bundler/mod/props.rb', line 96 def registry Registry.new(@source, @version) end |
#typer ⇒ Object
91 92 93 |
# File 'lib/terraspace_bundler/mod/props.rb', line 91 def typer Typer.new(self) end |
#url ⇒ Object
url is normalized
38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/terraspace_bundler/mod/props.rb', line 38 def url url = case type when 'registry' registry.github_url when 'local' source when 'http' http_source_url else # git git_source_url end remove_notations(clone_with(url)) end |