Class: GemInstaller::ValidPlatformSelector
- Inherits:
-
Object
- Object
- GemInstaller::ValidPlatformSelector
- Defined in:
- lib/geminstaller/valid_platform_selector.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
writeonly
Sets the attribute options.
-
#output_filter ⇒ Object
writeonly
Sets the attribute output_filter.
-
#ruby_platform ⇒ Object
writeonly
Sets the attribute ruby_platform.
Instance Method Summary collapse
- #binary_platform_substring ⇒ Object
- #select(gem_platform = nil, exact_platform_match = false) ⇒ Object
Instance Attribute Details
#options=(value) ⇒ Object (writeonly)
Sets the attribute options
3 4 5 |
# File 'lib/geminstaller/valid_platform_selector.rb', line 3 def (value) @options = value end |
#output_filter=(value) ⇒ Object (writeonly)
Sets the attribute output_filter
3 4 5 |
# File 'lib/geminstaller/valid_platform_selector.rb', line 3 def output_filter=(value) @output_filter = value end |
#ruby_platform=(value) ⇒ Object (writeonly)
Sets the attribute ruby_platform
3 4 5 |
# File 'lib/geminstaller/valid_platform_selector.rb', line 3 def ruby_platform=(value) @ruby_platform = value end |
Instance Method Details
#binary_platform_substring ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/geminstaller/valid_platform_selector.rb', line 36 def binary_platform_substring return ['686-darwin'] if @ruby_platform =~ /686-darwin/ return ['cygwin'] if @ruby_platform =~ /cygwin/ return ['powerpc'] if @ruby_platform =~ /powerpc/ return ['i386-mswin32','mswin32'] if @ruby_platform =~ /mswin/ return ['386-linux'] if @ruby_platform =~ /386-linux/ return ['486-linux'] if @ruby_platform =~ /486-linux/ return ['586-linux'] if @ruby_platform =~ /586-linux/ return ['686-linux'] if @ruby_platform =~ /686-linux/ return ['solaris'] if @ruby_platform =~ /solaris/ return nil end |
#select(gem_platform = nil, exact_platform_match = false) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/geminstaller/valid_platform_selector.rb', line 5 def select(gem_platform = nil, exact_platform_match = false) if GemInstaller::RubyGemsVersionChecker.matches?('>=0.9.5') # valid_platform_selector is not used for RubyGems >= 0.9.5 raise RuntimeError.new("Internal GemInstaller Error: ValidPlatformSelector should not be used for RubyGems >= 0.9.5") end @ruby_platform ||= RUBY_PLATFORM return [@ruby_platform] if gem_platform == Gem::Platform::CURRENT return [gem_platform] if exact_platform_match valid_platforms = [] valid_platforms += binary_platform_substring if binary_platform_substring if @options[:prefer_binary_platform] == false # put ruby first if prefer_binary_platform is false valid_platforms.unshift('ruby') else # leave binary platform first if prefer_binary_platform is false or nil valid_platforms << 'ruby' end if gem_platform and !valid_platforms.include?(gem_platform) # only prepend the gem_platform as the first choice if # 1. it is not nil # 2. it is not already in the list # 3. it is not 'ruby' valid_platforms.unshift(gem_platform) end = "Selecting valid platform(s): @ruby_platform='#{@ruby_platform}', gem_platform='#{gem_platform}', valid_platforms='#{valid_platforms.inspect}'" @output_filter.geminstaller_output(:debug,"#{}\n") valid_platforms end |