class Doc::Configurator::Ruby::PathInfo

Public Class Methods

for_path(path) click to toggle source
# File lib/doc/configurator/ruby/path_info.rb, line 10
def self.for_path(path)
  name = path.basename.to_s
  if name =~ /^ruby-(\d+\.\d+\.\d+(?:-p\d+)?)(?i:\.(tar\.(?:gz|bz2)|tgz|tbz|zip))?$/
    extension = $2 ? $2.downcase : :dir
    type = ({'tar.bz2' => 'tbz', 'tar.gz' => 'tgz'}[extension] || extension).to_sym
    new(path, name, type, $1, $1.scan(/\d+/).map(&:to_i))
  end
end
latest_matching(version, paths) click to toggle source
# File lib/doc/configurator/ruby/path_info.rb, line 6
def self.latest_matching(version, paths)
  paths.map(&method(:for_path)).compact.grep(version).sort.last
end

Public Instance Methods

<=>(other) click to toggle source
# File lib/doc/configurator/ruby/path_info.rb, line 28
def <=>(other)
  sort_by <=> other.sort_by
end
===(other) click to toggle source
# File lib/doc/configurator/ruby/path_info.rb, line 32
def ===(other)
  parts === other.parts
end
sort_by() click to toggle source
# File lib/doc/configurator/ruby/path_info.rb, line 23
def sort_by
  @sort_by ||= [parts, type_priority]
end
type_priority() click to toggle source
# File lib/doc/configurator/ruby/path_info.rb, line 19
def type_priority
  @type_priority ||= {:zip => 0, :tgz => 1, :tbz => 2, :dir => 3}[type]
end