Class: Spork::GemHelpers::GemPath

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/spork/gem_helpers.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(p) ⇒ GemPath

Returns a new instance of GemPath.



7
8
9
10
11
# File 'lib/spork/gem_helpers.rb', line 7

def initialize(p)
  @path = p
  @name, @version = File.basename(p).scan(/^(.+?)-([^-]+)$/).flatten
  @version_numbers = @version.split(/[^0-9]+/).map(&:to_i)
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/spork/gem_helpers.rb', line 5

def name
  @name
end

#pathObject (readonly)

Returns the value of attribute path.



5
6
7
# File 'lib/spork/gem_helpers.rb', line 5

def path
  @path
end

#versionObject (readonly)

Returns the value of attribute version.



5
6
7
# File 'lib/spork/gem_helpers.rb', line 5

def version
  @version
end

#version_numbersObject (readonly)

Returns the value of attribute version_numbers.



5
6
7
# File 'lib/spork/gem_helpers.rb', line 5

def version_numbers
  @version_numbers
end

Instance Method Details

#<=>(other) ⇒ Object



13
14
15
16
# File 'lib/spork/gem_helpers.rb', line 13

def <=>(other)
  raise "Not comparable gem paths ('#{name}' is not '#{other.name}')" unless name == other.name
  @version_numbers <=> other.version_numbers
end