Class: Gemvault::GemEntry
- Inherits:
-
Object
- Object
- Gemvault::GemEntry
- Defined in:
- lib/gemvault/gem_entry.rb
Overview
Value object for one gem's identity (name, version, platform) and the time it was stored in a vault. Equality, hashing, and to_h come from Data.
Constant Summary collapse
- RUBY_PLATFORM_NAME =
"ruby".freeze
Class Method Summary collapse
-
.from_spec(spec, created_at: nil) ⇒ Object
Builds an entry from a Gem::Specification (or any object with
name,version, andplatform), stringifying the version and platform.
Instance Method Summary collapse
- #filename ⇒ Object
- #full_name ⇒ Object
-
#initialize(name:, version:, platform: RUBY_PLATFORM_NAME, created_at: nil) ⇒ GemEntry
constructor
A new instance of GemEntry.
- #ruby_platform? ⇒ Boolean
- #same_identity_as?(other) ⇒ Boolean
- #to_s ⇒ Object
Constructor Details
#initialize(name:, version:, platform: RUBY_PLATFORM_NAME, created_at: nil) ⇒ GemEntry
Returns a new instance of GemEntry.
14 15 16 |
# File 'lib/gemvault/gem_entry.rb', line 14 def initialize(name:, version:, platform: RUBY_PLATFORM_NAME, created_at: nil) super end |
Class Method Details
.from_spec(spec, created_at: nil) ⇒ Object
Builds an entry from a Gem::Specification (or any object with
name, version, and platform), stringifying the version and platform.
10 11 12 |
# File 'lib/gemvault/gem_entry.rb', line 10 def self.from_spec(spec, created_at: nil) new(name: spec.name, version: spec.version.to_s, platform: spec.platform.to_s, created_at:) end |
Instance Method Details
#filename ⇒ Object
24 |
# File 'lib/gemvault/gem_entry.rb', line 24 def filename = "#{full_name}.gem" |
#full_name ⇒ Object
20 21 22 |
# File 'lib/gemvault/gem_entry.rb', line 20 def full_name ruby_platform? ? "#{name}-#{version}" : "#{name}-#{version}-#{platform}" end |
#ruby_platform? ⇒ Boolean
18 |
# File 'lib/gemvault/gem_entry.rb', line 18 def ruby_platform? = platform == RUBY_PLATFORM_NAME |
#same_identity_as?(other) ⇒ Boolean
26 27 28 |
# File 'lib/gemvault/gem_entry.rb', line 26 def same_identity_as?(other) name == other.name && version == other.version && platform == other.platform end |
#to_s ⇒ Object
30 31 32 |
# File 'lib/gemvault/gem_entry.rb', line 30 def to_s ruby_platform? ? "#{name}-#{version}" : "#{name}-#{version} (#{platform})" end |