Class: AllGems::IndexBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/allgems/IndexBuilder.rb

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ IndexBuilder

Returns a new instance of IndexBuilder.

Raises:

  • (ArgumentError)


3
4
5
6
# File 'lib/allgems/IndexBuilder.rb', line 3

def initialize(args={})
    raise ArgumentError.new('Expecting a Sequel::Database to be passed') unless args[:database] && args[:database].is_a?(Sequel::Database)
    @db = args[:database]
end

Instance Method Details

#build_array(filter = []) ⇒ Object



7
8
9
10
11
# File 'lib/allgems/IndexBuilder.rb', line 7

def build_array(filter=[])
    b = []
    Gem::SpecFetcher.fetcher.list(AllGems.allgems).each_pair{|uri, x| b = b | x.reject{|a|filter.include?(a)}.map{|c|{:name => c[0], :version => c[1]}}}
    b
end

#local_arrayObject



12
13
14
15
# File 'lib/allgems/IndexBuilder.rb', line 12

def local_array
    la = @db[:versions].join(:gems, :id => :gem_id).join(:platforms, :id => :versions__platform_id).select(:name, :version, :platform).all.collect{|x|x.values}
    la.map{|a| [a[0], Gem::Version.new(a[1]), a[2]]}
end