Class: GemInstaller::RubyGem
- Inherits:
-
Object
- Object
- GemInstaller::RubyGem
- Includes:
- Comparable
- Defined in:
- lib/geminstaller/ruby_gem.rb
Instance Attribute Summary collapse
-
#check_for_upgrade ⇒ Object
Returns the value of attribute check_for_upgrade.
-
#fix_dependencies ⇒ Object
Returns the value of attribute fix_dependencies.
-
#install_options ⇒ Object
Returns the value of attribute install_options.
-
#name ⇒ Object
Returns the value of attribute name.
-
#no_autogem ⇒ Object
Returns the value of attribute no_autogem.
-
#platform ⇒ Object
Returns the value of attribute platform.
-
#prefer_binary_platform ⇒ Object
Returns the value of attribute prefer_binary_platform.
-
#uninstall_options ⇒ Object
Returns the value of attribute uninstall_options.
-
#version ⇒ Object
Returns the value of attribute version.
Class Method Summary collapse
Instance Method Summary collapse
- #<=>(other) ⇒ Object
-
#initialize(name, opts = {}) ⇒ RubyGem
constructor
A new instance of RubyGem.
- #regexp_escaped_name ⇒ Object
Constructor Details
#initialize(name, opts = {}) ⇒ RubyGem
Returns a new instance of RubyGem.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/geminstaller/ruby_gem.rb', line 6 def initialize(name, opts={}) @name = name #TODO: the following logic could probably be more concise, but I'm not sure right now @version = GemInstaller::RubyGem.default_version if opts[:version] != "" && opts[:version] != nil @version = opts[:version] end if GemInstaller::RubyGemsVersionChecker.matches?('<=0.9.5') @platform = 'ruby' end if opts[:platform] != "" && opts[:platform] != nil @platform = opts[:platform] end = opts[:install_options] ||= [] = opts[:uninstall_options] ||= [] @check_for_upgrade = opts[:check_for_upgrade] == true ? true : false @fix_dependencies = opts[:fix_dependencies] == true ? true : false @no_autogem = opts[:no_autogem] == true ? true : false if GemInstaller::RubyGemsVersionChecker.matches?('>=0.9.5') warn("The 'prefer_binary_platform' option is deprecated on RubyGems >= 0.9.5, and has no effect") unless opts[:prefer_binary_platorm].nil? else @prefer_binary_platform = opts[:prefer_binary_platorm] == false ? false : true end end |
Instance Attribute Details
#check_for_upgrade ⇒ Object
Returns the value of attribute check_for_upgrade.
4 5 6 |
# File 'lib/geminstaller/ruby_gem.rb', line 4 def check_for_upgrade @check_for_upgrade end |
#fix_dependencies ⇒ Object
Returns the value of attribute fix_dependencies.
4 5 6 |
# File 'lib/geminstaller/ruby_gem.rb', line 4 def fix_dependencies @fix_dependencies end |
#install_options ⇒ Object
Returns the value of attribute install_options.
4 5 6 |
# File 'lib/geminstaller/ruby_gem.rb', line 4 def end |
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/geminstaller/ruby_gem.rb', line 4 def name @name end |
#no_autogem ⇒ Object
Returns the value of attribute no_autogem.
4 5 6 |
# File 'lib/geminstaller/ruby_gem.rb', line 4 def no_autogem @no_autogem end |
#platform ⇒ Object
Returns the value of attribute platform.
4 5 6 |
# File 'lib/geminstaller/ruby_gem.rb', line 4 def platform @platform end |
#prefer_binary_platform ⇒ Object
Returns the value of attribute prefer_binary_platform.
4 5 6 |
# File 'lib/geminstaller/ruby_gem.rb', line 4 def prefer_binary_platform @prefer_binary_platform end |
#uninstall_options ⇒ Object
Returns the value of attribute uninstall_options.
4 5 6 |
# File 'lib/geminstaller/ruby_gem.rb', line 4 def end |
#version ⇒ Object
Returns the value of attribute version.
4 5 6 |
# File 'lib/geminstaller/ruby_gem.rb', line 4 def version @version end |
Class Method Details
.default_platform ⇒ Object
35 36 37 38 39 40 41 42 43 |
# File 'lib/geminstaller/ruby_gem.rb', line 35 def self.default_platform if GemInstaller::RubyGemsVersionChecker.matches?('>0.9.5') Gem::Platform::CURRENT else # Not sure if this is actually required for RubyGems <=0.9.5, but it # was the original value in GemInstaller <=0.3.0, and makes the tests pass 'ruby' end end |
.default_version ⇒ Object
31 32 33 |
# File 'lib/geminstaller/ruby_gem.rb', line 31 def self.default_version '> 0.0.0' end |
Instance Method Details
#<=>(other) ⇒ Object
45 46 47 48 49 50 51 52 |
# File 'lib/geminstaller/ruby_gem.rb', line 45 def <=>(other) compare = @name <=> other.name return compare if compare != 0 compare = @version <=> other.version # TODO: this should use rubygems version comparison, not string comparison return compare if compare != 0 return 0 if (@platform == nil && other.platform == nil) return @platform <=> other.platform end |
#regexp_escaped_name ⇒ Object
54 55 56 |
# File 'lib/geminstaller/ruby_gem.rb', line 54 def regexp_escaped_name Regexp.escape(@name) end |