Class: Sigstore::BundleType

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/sigstore/models.rb

Constant Summary collapse

BUNDLE_0_1 =
new("application/vnd.dev.sigstore.bundle+json;version=0.1")
BUNDLE_0_2 =
new("application/vnd.dev.sigstore.bundle+json;version=0.2")
BUNDLE_0_3 =
new("application/vnd.dev.sigstore.bundle.v0.3+json")
VERSIONS =
[BUNDLE_0_1, BUNDLE_0_2, BUNDLE_0_3].freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(media_type) ⇒ BundleType

Returns a new instance of BundleType.



50
51
52
# File 'lib/sigstore/models.rb', line 50

def initialize(media_type)
  @media_type = media_type
end

Instance Attribute Details

#media_typeObject (readonly)

Returns the value of attribute media_type.



48
49
50
# File 'lib/sigstore/models.rb', line 48

def media_type
  @media_type
end

Class Method Details

.from_media_type(media_type) ⇒ Object



60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/sigstore/models.rb', line 60

def self.from_media_type(media_type)
  case media_type
  when BUNDLE_0_1.media_type
    BUNDLE_0_1
  when BUNDLE_0_2.media_type
    BUNDLE_0_2
  when BUNDLE_0_3.media_type, "application/vnd.dev.sigstore.bundle+json;version=0.3"
    BUNDLE_0_3
  else
    raise Error::InvalidBundle, "Unsupported bundle format: #{media_type.inspect}"
  end
end

Instance Method Details

#<=>(other) ⇒ Object



73
74
75
# File 'lib/sigstore/models.rb', line 73

def <=>(other)
  VERSIONS.index(self) <=> VERSIONS.index(other)
end