Class: Gemstash::DB::Version
- Inherits:
-
Sequel::Model
- Object
- Sequel::Model
- Gemstash::DB::Version
- Defined in:
- lib/gemstash/db/version.rb
Overview
Sequel model for versions table.
Class Method Summary collapse
- .find_by_full_name(full_name) ⇒ Object
- .find_by_spec(gem_id, spec) ⇒ Object
- .for_spec_collection(prerelease: false) ⇒ Object
- .insert_by_spec(gem_id, spec) ⇒ Object
Instance Method Summary collapse
- #deindex ⇒ Object
- #reindex ⇒ Object
-
#to_spec ⇒ Object
This converts to the format used by /private/specs.4.8.gz.
Class Method Details
.find_by_full_name(full_name) ⇒ Object
32 33 34 35 36 37 |
# File 'lib/gemstash/db/version.rb', line 32 def self.find_by_full_name(full_name) result = self[full_name: full_name] return result if result # Try again with the default platform, in case it is implied self[full_name: "#{full_name}-ruby"] end |
.find_by_spec(gem_id, spec) ⇒ Object
26 27 28 29 30 |
# File 'lib/gemstash/db/version.rb', line 26 def self.find_by_spec(gem_id, spec) self[rubygem_id: gem_id, number: spec.version.to_s, platform: spec.platform.to_s] end |
.for_spec_collection(prerelease: false) ⇒ Object
22 23 24 |
# File 'lib/gemstash/db/version.rb', line 22 def self.for_spec_collection(prerelease: false) where(indexed: true, prerelease: prerelease).association_join(:rubygem) end |
.insert_by_spec(gem_id, spec) ⇒ Object
39 40 41 42 43 44 45 46 47 48 |
# File 'lib/gemstash/db/version.rb', line 39 def self.insert_by_spec(gem_id, spec) gem_name = Gemstash::DB::Rubygem[gem_id].name new(rubygem_id: gem_id, number: spec.version.to_s, platform: spec.platform.to_s, full_name: "#{gem_name}-#{spec.version}-#{spec.platform}", storage_id: spec.full_name, indexed: true, prerelease: spec.version.prerelease?).tap(&:save).id end |
Instance Method Details
#deindex ⇒ Object
9 10 11 |
# File 'lib/gemstash/db/version.rb', line 9 def deindex update(indexed: false) end |
#reindex ⇒ Object
13 14 15 |
# File 'lib/gemstash/db/version.rb', line 13 def reindex update(indexed: true) end |
#to_spec ⇒ Object
This converts to the format used by /private/specs.4.8.gz
18 19 20 |
# File 'lib/gemstash/db/version.rb', line 18 def to_spec [rubygem.name, Gem::Version.new(number), platform] end |