Sha256: 64c2f5d9a96ca765954f6019ad74727c0d5f3aaaabc344ba09a4680d36ed154a

Contents?: true

Size: 1.21 KB

Versions: 1

Compression:

Stored size: 1.21 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
    include TerraspaceBundler::Dsl::Concern

    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 : "#{dsl.global[: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

1 entries across 1 versions & 1 rubygems

Version Path
terraspace-bundler-0.2.0 lib/terraspace_bundler/mod/props_builder.rb