Sha256: cdb05b5d9c313b6043eb5b607ebf9b5c061b324e96f181eed37d29ec94bd7128

Contents?: true

Size: 1.17 KB

Versions: 3

Compression:

Stored size: 1.17 KB

Contents

# Use to build mod from Terrafile entry.
# The Terrafile.lock does not need this because it's simple and just merges the data.
class TerraspaceBundler::Mod
  class PropsBuilder
    extend Memoist

    def initialize(params={})
      @params = params
      @options = params[:options]
      @source, @version = @options[:source], @options[:version]
    end

    def build
      @options.merge(
        name: name,
        source: source, # overwrite source. @options is a copy though
        type: type,
        url: url,
      )
    end

    def name
      @params[:args].first
    end

    def source
      if registry?
        @source
      else
        @source.include?('/') ? @source : "#{TB.config.org}/#{@source}"
      end
    end

    def url
      if registry?
        registry.github_url
      else
        "#{TB.config.base_clone_url}#{source}" # Note: make sure to not use @source, is org may no be added
      end
    end

    # IE: git or registry
    def type
      registry? ? "registry" : "git"
    end

    def registry?
      !@source.nil? && @source.split('/').size == 3
    end

    def registry
      Registry.new(@source, @version)
    end
    memoize :registry
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
terraspace-bundler-0.3.2 lib/terraspace_bundler/mod/props_builder.rb
terraspace-bundler-0.3.1 lib/terraspace_bundler/mod/props_builder.rb
terraspace-bundler-0.3.0 lib/terraspace_bundler/mod/props_builder.rb