RubyGems discover (v. 0.8.0)
About
Discover&Download@Search tool for rubygems.org repository.
Warning before usage at least once you should update the database! Look in the install section for more details.
How it works (samples)
discover popular gems
require 'rudisco'
Rudisco::Gem.connect
hot_with_git_sourse = Rudisco::Gem.where('total_downloads < 2000000 ')
.where('version_downloads > 500000')
.where('sourse_code_url is not NULL')
.limit(100)
hot_with_git_sourse.each do |g|
puts "Gem name: #{g.name}"
puts "Description: #{g.description}"
puts "Sourse link: #{g.sourse_code_url}"
puts "Authors: #{g.authors}", ''
end
scout repositories
require 'rudisco'
Rudisco::Gem.connect
urls = Rudisco::Gem.all.where.not(sourse_code_url: [nil, ''])
.pluck(:sourse_code_url)
hsh = Hash.new { |hash, key| hash[key] = 0 }
urls.each do |url|
key = url.split('/')[2].downcase.to_sym
hsh[key] += 1
end
hsh.each_pair { |k, v| puts "Rubygems refers to repository #{k} with #{v} gems" }
# =>
# Rubygems refers to repository github.com with 14446 gems
# Rubygems refers to repository gitlab.com with 39 gems
# …
# Rubygems refers to repository gitcafe.com with 3 gems
# Rubygems refers to repository code.google.com with 19 gems
# Rubygems refers to repository github.org with 4 gems
# Rubygems refers to repository ruby.gfd-dennou.org with 4 gems
# …
search
require 'rudisco'
Rudisco::Gem.connect(verbose: false)
count = Rudisco::Gem.search('mit', search: [:license]).count
puts "Gems count published with MIT license: #{count}", ''
puts "Array of gem names with 'kate' or 'alice' keyword"
print Rudisco::Gem.search(/kate|alice/).each.pluck(:name)
puts '', '', "Gems with 'CRC32' keyword in a name or description."
Rudisco::Gem.search('CRC32', search: [:name, :description]).each do |g|
puts "Gem name: #{g.name}"
puts "Description: #{g.description}"
puts "Authors: #{g.authors}", ''
end
download sourses and gems
require 'rudisco'
Rudisco::Gem.connect
Rudisco::Gem.all.where('total_downloads > 4000000 ')
.where.not(sourse_code_url: [nil, ''])
.order('total_downloads DESC')
.limit(3)
.git_clone('~/downloads/rubygems/samples')
Rudisco::Gem.download('abc')
browse documentation
require 'rudisco'
Rudisco::Gem.connect
gems = Rudisco::Gem.where.not(documentation_url: [nil, ''])
.where.not(sourse_code_url: [nil, ''])
.where.not(wiki_url: [nil, ''])
.where.not(bug_tracker_url: [nil, ''])
.sample(4)
gems[0].open_documentation
gems[1].open_bug_tracker
gems[2].open_sourses
gems[3].open_wiki
Installation
From git
1. Make sure you have installed postgresql database and bin/gem, bin/gzip utilities.
2. Git clone this project
3. cd to project
4. write into your console
$ ruby samples/update.rb
5. Wait. It can be long. Sorry, but there is nothing to do with rubygems cooldown&response time. Database dump added to repository, so for now it should be much faster.
From rubygems.org
1. Install gem
gem install rudisco
2. Add to project
gem 'rudisco', '0.8.0'
require 'rudisco'
3. update database (once)
require 'rudisco'
Rudisco::Gem.connect(verbose: true)
Rudisco::Gem.update(manager: { ThreadsCount: 20 })
dependencies
/bin/gem
/bin/createuser
/bin/createdb
/bin/gzip
/bin/wget
License
MIT