class TerraspaceBundler::Mod::Props
Attributes
source[R]
Public Class Methods
new(params={})
click to toggle source
# File lib/terraspace_bundler/mod/props.rb, line 12 def initialize(params={}) @params = params @options = params[:options] @source, @version = @options[:source], @options[:version] end
Public Instance Methods
build()
click to toggle source
# 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)
click to toggle source
apply clone_with
option if set
# 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()
click to toggle source
git_source_url
is normalized
# 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: "git@github.com:tongueroo/pet" # mod "pet3", source: "git@gitlab.com:tongueroo/pet" # mod "pet4", source: "git@bitbucket.org: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()
click to toggle source
# File lib/terraspace_bundler/mod/props.rb, line 63 def http_source_url source = Http::Source.new(@params) source.url end
name()
click to toggle source
# File lib/terraspace_bundler/mod/props.rb, line 18 def name remove_notations(@params[:args].first) end
registry()
click to toggle source
# File lib/terraspace_bundler/mod/props.rb, line 96 def registry Registry.new(@source, @version) end
typer()
click to toggle source
# File lib/terraspace_bundler/mod/props.rb, line 91 def typer Typer.new(self) end
url()
click to toggle source
url is normalized
# 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