Top Level Namespace

Defined Under Namespace

Classes: FalseClass, NilClass, TrueClass

Instance Method Summary collapse

Instance Method Details

#jruby?Boolean

I test and deploy some of the project on jruby - this makes it easier to customize my gemfiles. Works for ruby 1.8.7 & 1.9.3 & 1.9.2 on windows( 7 & xp) & linux ( debian Lenny) using rubyinstaller for windows and using mri ruby buillt from source for linux Works for jruby 1.7.0.rc1 and jruby 1.6.3 on windows (7 & xp)

Returns:

  • (Boolean)


33
34
35
# File 'lib/santas_little_helper.rb', line 33

def jruby?
  (/java/).match(RUBY_PLATFORM) ? true : false
end

#linux?Boolean

Works on Debian Sarge & Lenny and Ubuntu 9.10 running REE 1.8.7, don’t have anything else to test on.

Returns:

  • (Boolean)


19
20
21
# File 'lib/santas_little_helper.rb', line 19

def linux?
  (/linux/).match(RUBY_PLATFORM) ? true : false
end

#mac?Boolean

Works on my MacBook Pro OS 10.6 running Ruby 1.8.7 and rvm version of 1.9.1 , don’t have anything else to test on,

Returns:

  • (Boolean)


24
25
26
# File 'lib/santas_little_helper.rb', line 24

def mac?
  (/darwin/).match(RUBY_PLATFORM) ? true : false
end

#mri?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/santas_little_helper.rb', line 37

def mri?
  (/i386|x86_64|x86/).match(RUBY_PLATFORM) ? true : false
end

#version_1_8?Boolean

Returns:

  • (Boolean)


47
48
49
# File 'lib/santas_little_helper.rb', line 47

def version_1_8?
  (/^1.8./).match(RUBY_VERSION) ? true : false
end

#version_1_9?Boolean

In case ruby ever reaches version 19 :-) or some 2.19 :-) only matching 1.9 at the begining of the line

Returns:

  • (Boolean)


43
44
45
# File 'lib/santas_little_helper.rb', line 43

def version_1_9?
  (/^1.9./).match(RUBY_VERSION) ? true : false
end

#windows?Boolean

Works on Windows XP, 2003, 7 running Ruby 1.8.6 & 1.8.7 installed from RubyInstaller

Returns:

  • (Boolean)


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

def windows?
  # Can't match for just 'win' cause it will match darwin as well.
  (/win32|mswin|mingw/).match(RUBY_PLATFORM) ? true : false
end