Sha256: ebab9393181f1b6d076b886bcfc4f1a16ccc94842df5cb2a0e1043dae9a8dec1

Contents?: true

Size: 1.03 KB

Versions: 5

Compression:

Stored size: 1.03 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?('::')
        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

5 entries across 5 versions & 1 rubygems

Version Path
terraspace-bundler-0.4.4 lib/terraspace_bundler/mod/props/typer.rb
terraspace-bundler-0.4.3 lib/terraspace_bundler/mod/props/typer.rb
terraspace-bundler-0.4.2 lib/terraspace_bundler/mod/props/typer.rb
terraspace-bundler-0.4.1 lib/terraspace_bundler/mod/props/typer.rb
terraspace-bundler-0.4.0 lib/terraspace_bundler/mod/props/typer.rb