Class: Stickler::SpecLite
- Inherits:
-
Object
- Object
- Stickler::SpecLite
- Includes:
- Comparable
- Defined in:
- lib/stickler/spec_lite.rb
Overview
A lightweight version of a gemspec that only responds to name, version, platform and full_name. Many of the items in the rubygems world deal with the triplet [ name, verison, platform ] and this class encapsulates that.
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#platform ⇒ Object
readonly
Returns the value of attribute platform.
-
#platform_string ⇒ Object
readonly
Returns the value of attribute platform_string.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
-
#<=>(other) ⇒ Object
Lets be comparable!.
-
#=~(other) ⇒ Object
See if another Spec is the same as this spec.
- #file_name ⇒ Object
- #full_name ⇒ Object (also: #to_s)
-
#initialize(name, version, platform = Gem::Platform::RUBY) ⇒ SpecLite
constructor
A new instance of SpecLite.
- #name_version ⇒ Object
- #prerelease? ⇒ Boolean
- #spec_file_name ⇒ Object
- #to_a ⇒ Object
-
#to_rubygems_a ⇒ Object
Convert to the array format used by rubygems itself.
- #version_platform ⇒ Object
Constructor Details
#initialize(name, version, platform = Gem::Platform::RUBY) ⇒ SpecLite
Returns a new instance of SpecLite.
19 20 21 22 23 24 |
# File 'lib/stickler/spec_lite.rb', line 19 def initialize( name, version, platform = Gem::Platform::RUBY ) @name = name @version = Gem::Version.new( version ) @platform_string = platform.to_s @platform = Gem::Platform.new( platform ) end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
14 15 16 |
# File 'lib/stickler/spec_lite.rb', line 14 def name @name end |
#platform ⇒ Object (readonly)
Returns the value of attribute platform.
16 17 18 |
# File 'lib/stickler/spec_lite.rb', line 16 def platform @platform end |
#platform_string ⇒ Object (readonly)
Returns the value of attribute platform_string.
17 18 19 |
# File 'lib/stickler/spec_lite.rb', line 17 def platform_string @platform_string end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
15 16 17 |
# File 'lib/stickler/spec_lite.rb', line 15 def version @version end |
Instance Method Details
#<=>(other) ⇒ Object
Lets be comparable!
69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/stickler/spec_lite.rb', line 69 def <=>(other) return 0 if other.object_id == self.object_id other = coerce( other ) [ :name, :version, :platform_string ].each do |method| us, them = self.send( method ), other.send( method ) result = us.<=>( them ) return result unless 0 == result end return 0 end |
#=~(other) ⇒ Object
See if another Spec is the same as this spec
85 86 87 88 89 90 91 |
# File 'lib/stickler/spec_lite.rb', line 85 def =~(other) other = coerce( other ) return (other and self.name == other.name and self.version.to_s == other.version.to_s and self.platform_string == other.platform_string ) end |
#file_name ⇒ Object
31 32 33 |
# File 'lib/stickler/spec_lite.rb', line 31 def file_name full_name + ".gem" end |
#full_name ⇒ Object Also known as: to_s
26 27 28 |
# File 'lib/stickler/spec_lite.rb', line 26 def full_name "#{name}-#{version_platform}" end |
#name_version ⇒ Object
39 40 41 |
# File 'lib/stickler/spec_lite.rb', line 39 def name_version "#{name}-#{version}" end |
#prerelease? ⇒ Boolean
51 52 53 |
# File 'lib/stickler/spec_lite.rb', line 51 def prerelease? version.prerelease? end |
#spec_file_name ⇒ Object
35 36 37 |
# File 'lib/stickler/spec_lite.rb', line 35 def spec_file_name full_name + ".gemspec" end |
#to_a ⇒ Object
55 56 57 |
# File 'lib/stickler/spec_lite.rb', line 55 def to_a [ name, version.to_s, platform_string ] end |
#to_rubygems_a ⇒ Object
Convert to the array format used by rubygems itself
62 63 64 |
# File 'lib/stickler/spec_lite.rb', line 62 def to_rubygems_a [ name, version, platform_string ] end |
#version_platform ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/stickler/spec_lite.rb', line 43 def version_platform if platform == Gem::Platform::RUBY or platform.nil? then version.to_s else "#{version}-#{platform_string}" end end |