Class: Doc::Configurator::Ruby::PathInfo
- Inherits:
-
Struct
- Object
- Struct
- Doc::Configurator::Ruby::PathInfo
- Includes:
- Comparable
- Defined in:
- lib/doc/configurator/ruby/path_info.rb
Instance Attribute Summary collapse
-
#full_version ⇒ Object
Returns the value of attribute full_version.
-
#name ⇒ Object
Returns the value of attribute name.
-
#parts ⇒ Object
Returns the value of attribute parts.
-
#path ⇒ Object
Returns the value of attribute path.
-
#type ⇒ Object
Returns the value of attribute type.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#full_version ⇒ Object
Returns the value of attribute full_version
4 5 6 |
# File 'lib/doc/configurator/ruby/path_info.rb', line 4 def full_version @full_version end |
#name ⇒ Object
Returns the value of attribute name
4 5 6 |
# File 'lib/doc/configurator/ruby/path_info.rb', line 4 def name @name end |
#parts ⇒ Object
Returns the value of attribute parts
4 5 6 |
# File 'lib/doc/configurator/ruby/path_info.rb', line 4 def parts @parts end |
#path ⇒ Object
Returns the value of attribute path
4 5 6 |
# File 'lib/doc/configurator/ruby/path_info.rb', line 4 def path @path end |
#type ⇒ Object
Returns the value of attribute type
4 5 6 |
# File 'lib/doc/configurator/ruby/path_info.rb', line 4 def type @type end |
Class Method Details
.for_path(path) ⇒ Object
10 11 12 13 14 15 16 17 |
# 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) ⇒ Object
6 7 8 |
# 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 |
Instance Method Details
#<=>(other) ⇒ Object
28 29 30 |
# File 'lib/doc/configurator/ruby/path_info.rb', line 28 def <=>(other) sort_by <=> other.sort_by end |
#===(other) ⇒ Object
32 33 34 |
# File 'lib/doc/configurator/ruby/path_info.rb', line 32 def ===(other) parts === other.parts end |
#sort_by ⇒ Object
23 24 25 |
# File 'lib/doc/configurator/ruby/path_info.rb', line 23 def sort_by @sort_by ||= [parts, type_priority] end |
#type_priority ⇒ Object
19 20 21 |
# 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 |