Class: AllGems::IndexBuilder
- Inherits:
-
Object
- Object
- AllGems::IndexBuilder
- Defined in:
- lib/allgems/IndexBuilder.rb
Instance Method Summary collapse
- #build_array(filter = []) ⇒ Object
-
#initialize(args = {}) ⇒ IndexBuilder
constructor
A new instance of IndexBuilder.
- #local_array ⇒ Object
Constructor Details
#initialize(args = {}) ⇒ IndexBuilder
Returns a new instance of IndexBuilder.
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_array ⇒ Object
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 |