Class: Pik::Implementations::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/pik/implementations.rb

Direct Known Subclasses

DevKit, IronRuby, JRuby, Ruby

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeBase

Returns a new instance of Base.



46
47
48
# File 'lib/pik/implementations.rb', line 46

def initialize
  @url = 'http://rubyforge.org'
end

Class Method Details

.find(*args) ⇒ Object



42
43
44
# File 'lib/pik/implementations.rb', line 42

def self.find(*args)
  new.find(*args)
end

Instance Method Details

#after_install(install) ⇒ Object



88
89
90
91
92
93
# File 'lib/pik/implementations.rb', line 88

def after_install(install)
  puts
  p = Pik::Add.new([install.target + 'bin'], install.config)
  p.execute
  p.close
end

#find(*args) ⇒ Object



54
55
56
57
58
59
60
61
# File 'lib/pik/implementations.rb', line 54

def find(*args)
  if args.empty?
    return most_recent
  else
    pattern = Regexp.new(Regexp.escape(args.first))
    versions.select{|v,k| v =~ pattern }.max
  end
end

#most_recent(vers = versions) ⇒ Object



63
64
65
# File 'lib/pik/implementations.rb', line 63

def most_recent(vers=versions)
  vers.max
end

#readObject



78
79
80
81
# File 'lib/pik/implementations.rb', line 78

def read
  uri = URI.parse(@url+@path)
  uri.read rescue ''
end

#subclassObject Also known as: name



83
84
85
# File 'lib/pik/implementations.rb', line 83

def subclass
  self.class.to_s.split('::').last
end

#urlObject



50
51
52
# File 'lib/pik/implementations.rb', line 50

def url
  @url + @path
end

#versionsObject



67
68
69
70
71
72
73
74
75
76
# File 'lib/pik/implementations.rb', line 67

def versions
  h = {}
  Hpricot(read).search("a") do |a|
    if a_href = a.attributes['href']
      href, link, version, rc = *a_href.match(@re)
      h["#{version}#{rc}"] =  @url + link  if version
    end
  end
  h
end