Class: Gemstash::SpecsBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/gemstash/specs_builder.rb

Overview

Builds a Marshal’ed and GZipped array of arrays containing specs as:

name, Gem::Version, platform

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(prerelease: false) ⇒ SpecsBuilder

Returns a new instance of SpecsBuilder.



29
30
31
# File 'lib/gemstash/specs_builder.rb', line 29

def initialize(prerelease: false)
  @prerelease = prerelease
end

Instance Attribute Details

#resultObject (readonly)

Returns the value of attribute result.



9
10
11
# File 'lib/gemstash/specs_builder.rb', line 9

def result
  @result
end

Class Method Details

.allObject

Used for the /private/specs.4.8.gz endpoint. Fetches non-prerelease, indexed private gems.



13
14
15
# File 'lib/gemstash/specs_builder.rb', line 13

def self.all
  new.build
end

.invalidate_storedObject



23
24
25
26
27
# File 'lib/gemstash/specs_builder.rb', line 23

def self.invalidate_stored
  storage = Gemstash::Storage.for("private").for("specs_collection")
  storage.resource("specs.4.8.gz").delete(:specs)
  storage.resource("prerelease_specs.4.8.gz").delete(:specs)
end

.prereleaseObject

Used for the /private/prerelease_specs.4.8.gz endpoint. Fetches prerelease, indexed private gems.



19
20
21
# File 'lib/gemstash/specs_builder.rb', line 19

def self.prerelease
  new(prerelease: true).build
end

Instance Method Details

#buildObject



33
34
35
36
37
38
39
40
41
# File 'lib/gemstash/specs_builder.rb', line 33

def build
  fetch_from_storage
  return result if result
  fetch_versions
  marshal
  gzip
  store_result
  result
end