module Joya

the Joya module

Constants

GEM_NAME_XPATH

xpath pattern to scrap gem names of a rubygems user

GEM_VERSION_PATTERN

Attributes

author[RW]

gems author

gems[RW]

author's gems

Public Class Methods

base_dir() click to toggle source

directory where gems will be unpacked

# File lib/joya.rb, line 119
def base_dir
  "gems-#{author}"
end
Also aliased as: directory
directory()
Alias for: base_dir
fetch_gem_names() click to toggle source

fetch gem names from a given rubygems author

# File lib/joya.rb, line 105
def fetch_gem_names
  site=Nokogiri::HTML(open_rubygems)
  @gems=site.xpath(GEM_NAME_XPATH).text.gsub(/\s+/," ").split
end
make_dir() click to toggle source

makes base_dir

# File lib/joya.rb, line 125
def make_dir
  FileUtils.mkdir base_dir
rescue Errno::EEXIST
end
open_rubygems() click to toggle source

open the rubygems url

# File lib/joya.rb, line 111
def open_rubygems
  URI.open(url)
rescue OpenURI::HTTPError
  puts "HTTPError: Could not find rubygems of #{author}"
  exit
end
print_and_quit() click to toggle source

print user gems and exit

unpack_all() click to toggle source

install missing gems and unpack them in base_dir

# File lib/joya.rb, line 65
def unpack_all
  Dir.chdir base_dir
  total=gems.size
  digits=total.to_s.size
  puts "#{total} gems found"
  puts "Downloading into #{base_dir}/"
  interrupted = false
  gems.each_with_index do |jem,i|
    printf("[%#{digits}d/%#{digits}d] Unpacking %s\n", i+1, total, jem)
    Joya::Gem.install(jem) unless jem.gem_installed?
    Joya::Gem.unpack(jem)
  end
rescue LocalJumpError
ensure
  Dir.chdir '..'
end