Sha256: 259d6d6e181d91d417c47f429eda2195b9228d1334761c43b3fdfcac70f2e3cf

Contents?: true

Size: 961 Bytes

Versions: 12

Compression:

Stored size: 961 Bytes

Contents

module Bosh::Bootstrap
  class PublicStemcell
    attr_reader :size

    def initialize(key, size)
      @key = key
      @size = size

      @parsed_version = key.scan(/[\d]*_?[\d]+/).first
    end

    def name
      File.basename(@key)
    end

    def version
      @parsed_version.gsub('_', '.')
    end

    def variety
      name.gsub(/(.tgz)|(bosh-stemcell-)|(#{@parsed_version})/, '').split('-').reject { |c| c.empty? }.join('-')
    end

    # @return [String] guesses ultimate stemcell name from file name
    # light-bosh-stemcell-2719-aws-xen-ubuntu-trusty-go_agent.tgz into bosh-aws-xen-ubuntu-trusty-go_agent
    def stemcell_name
      name.
        gsub(/(.tgz)|(#{@parsed_version})/, '').
        gsub(/^.*bosh-stemcell-/, 'bosh-').
        split('-').reject { |c| c.empty? }.join('-')
    end

    def url
      "#{PublicStemcells::PUBLIC_STEMCELLS_BASE_URL}/#{@key}"
    end

    def legacy?
      @key.include?('legacy')
    end

  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
bosh-bootstrap-0.18.1 lib/bosh-bootstrap/public_stemcell.rb
bosh-bootstrap-0.18.0 lib/bosh-bootstrap/public_stemcell.rb
bosh-bootstrap-0.17.1 lib/bosh-bootstrap/public_stemcell.rb
bosh-bootstrap-0.17.0 lib/bosh-bootstrap/public_stemcell.rb
bosh-bootstrap-0.16.2 lib/bosh-bootstrap/public_stemcell.rb
bosh-bootstrap-0.16.1 lib/bosh-bootstrap/public_stemcell.rb
bosh-bootstrap-0.16.0 lib/bosh-bootstrap/public_stemcell.rb
bosh-bootstrap-0.15.0 lib/bosh-bootstrap/public_stemcell.rb
bosh-bootstrap-0.14.5 lib/bosh-bootstrap/public_stemcell.rb
bosh-bootstrap-0.14.4 lib/bosh-bootstrap/public_stemcell.rb
bosh-bootstrap-0.14.3 lib/bosh-bootstrap/public_stemcell.rb
bosh-bootstrap-0.14.2 lib/bosh-bootstrap/public_stemcell.rb