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, latest: false) ⇒ SpecsBuilder

Returns a new instance of SpecsBuilder.



34
35
36
37
# File 'lib/gemstash/specs_builder.rb', line 34

def initialize(prerelease: false, latest: false)
  @prerelease = prerelease
  @latest = latest
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



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

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

.latestObject



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

def self.latest
  new(latest: true).build
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



39
40
41
42
43
44
45
46
47
# File 'lib/gemstash/specs_builder.rb', line 39

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