Created
January 16, 2009 07:32
-
-
Save kaichen/47859 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/ruby -w | |
# File: ryaourt | |
# | |
# A utility script let you can install rubygems as archlinux's aur package manager yaourt. | |
# | |
# Usge: | |
# | |
# $ ryaourt gem_you_want_to_query | |
# | |
# Example: | |
# [ ~ ]$ ryaourt rspec | |
# 1 ateam-rspec_merb_helpers | |
# 2 dcadenas-rspec2rr | |
# 3 dchelimsky-dchelimsky-rspec | |
# 4 dchelimsky-dchelimsky-rspec-rails | |
# 5 dchelimsky-rspec | |
# 6 dchelimsky-rspec-rails | |
# 7 gregwebs-rspec_multi_matchers | |
# 8 jcnetdev-rspec-rails | |
# 9 jferris-rspec_macros | |
# 10 laurynasl-rspec_merb_helpers | |
# 11 mig-rspec_abandoner | |
# 12 niessner-rspec_controller_macros | |
# 13 nofxx-rspec_spinner | |
# 14 rspec | |
# 15 rspec-ext | |
# 16 rspec-fixture | |
# 17 rspec-rails | |
# 18 rspec_generator | |
# 19 rspec_hpricot_matchers | |
# 20 rspec_spinner | |
# 21 saturnflyer-rspec-rails-matchers | |
# 22 spicycode_rspec_extensions | |
# 23 waves-rspec | |
# ==> Enter n° (separated by blanks, or a range) of rubygems to be installed | |
# ==> ---------------------------------------------- | |
# ==>14 17 | |
# Installing rspec, rspec-rails now, please waite. | |
# Updating class cache with 4957 classes... | |
# Successfully installed rspec-1.1.12 | |
# Successfully installed rspec-rails-1.1.12 | |
# 2 gems installed | |
# Installing ri documentation for rspec-1.1.12... | |
# Installing ri documentation for rspec-rails-1.1.12... | |
# Installing RDoc documentation for rspec-1.1.12... | |
# Installing RDoc documentation for rspec-rails-1.1.12... | |
def gem_search(query) | |
list = `gem search --no-version --remote #{query}` | |
list.split("\n") | |
end | |
def display_list(list) | |
list.each_with_index { |item, index| printf "%4d\s\s%s\n", index, item } | |
end | |
def install_gems(gems, gems_list) | |
gem_names = gems.split(" ").inject([]) do |names, g| | |
names << gems_list.slice(g.to_i - 1) | |
end | |
printf "Installing #{gem_names.join(', ').reverse.sub(' ,', ' dna ').reverse} now, please waite.\n" | |
printf `sudo gem install -r #{gem_names.join(' ')}` | |
end | |
def display_tips | |
printf "==> Enter n° (separated by blanks) of rubygems to be installed\n" | |
printf "==> ----------------------------------------------\n" | |
printf "==>" | |
end | |
def main(query) | |
result_list = gem_search(query) | |
display_list(result_list) | |
display_tips | |
input = STDIN.readline | |
unless input.nil? || input.empty? | |
install_gems(input, result_list) | |
end | |
end | |
if $0 == __FILE__ | |
main(ARGV[0]) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment