Module: Fastgem

Defined in:
lib/fastgem.rb,
lib/fastgem/table.rb,
lib/fastgem/version.rb

Defined Under Namespace

Classes: Table

Constant Summary collapse

VERSION =
'0.1.8'

Class Method Summary collapse

Class Method Details

.search(q, options) ⇒ Object



5
6
7
8
9
10
11
12
13
14
# File 'lib/fastgem.rb', line 5

def self.search(q, options)
  uri = URI.parse("https://rubygems.org/api/v1/search.json?query=#{q}")
  http = Net::HTTP.new(uri.host, uri.port)
  http.use_ssl = true
  request = Net::HTTP::Get.new(uri.request_uri)
  response = http.request(request)
  results = JSON.parse(response.body)
  results = sort_downloads(results) if options[:d]
  template(results)
end