Sha256: 5c1c0d05dd37ed1f5b39b3105bde8fa8f4b819d4a57c4b1ba07e79a492721eab

Contents?: true

Size: 1.08 KB

Versions: 1

Compression:

Stored size: 1.08 KB

Contents

class TerraspaceBundler::Mod::Props
  class Typer
    include TerraspaceBundler::Mod::Concerns::LocalConcern
    include TerraspaceBundler::Mod::Concerns::NotationConcern

    delegate :source, to: :props

    attr_reader :props
    def initialize(props)
      @props = props # Props.new object
    end

    # IE: git or registry
    def type
      if source.include?('ssh://')
        "git"
      elsif source.include?('::')
        source.split('::').first # IE: git:: s3:: gcs::
      elsif local?
        "local"
      elsif registry?
        "registry"
      else
        "git"
      end
    end

  private
    # dont use registry? externally. instead use type since it can miss local detection
    def registry?
      if source.nil? ||
         source.starts_with?('git@') || # git@github.com:tongueroo/pet
         source.starts_with?('http') || # https://github.com/tongueroo/pet
         source.include?('::')          # git::https:://git.example.com/pet
         return false
      end
      s = remove_notations(@props.source)
      s.split('/').size == 3 || s.split('/').size == 4
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
terraspace-bundler-0.5.0 lib/terraspace_bundler/mod/props/typer.rb