Top Level Namespace
Defined Under Namespace
Modules: SantasLittleHelper
Instance Method Summary
collapse
Instance Method Details
#linux? ⇒ Boolean
44
45
46
|
# File 'lib/santas_little_helper.rb', line 44
def linux?
ruby_platform?(:linux)
end
|
#mac? ⇒ Boolean
47
48
49
|
# File 'lib/santas_little_helper.rb', line 47
def mac?
ruby_platform?(:mac)
end
|
#ruby_implementation ⇒ Object
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) At this point it’s essentially just an alias fro platform & platform?, since it queries RUBY_PLATFORM, but this may change in the future In the future I may start using RUBY_ENGINE
58
59
60
|
# File 'lib/santas_little_helper.rb', line 58
def ruby_implementation
ruby_platform
end
|
#ruby_implementation?(written_in = '') ⇒ Boolean
61
62
63
|
# File 'lib/santas_little_helper.rb', line 61
def ruby_implementation?(written_in='')
ruby_platform?(written_in)
end
|
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/santas_little_helper.rb', line 13
def ruby_platform
case RUBY_PLATFORM
when /win32|mswin|mingw/
'windows'
when /linux/
'linux'
when /darwin/
'mac'
when /java/
'jruby'
when /i386|x86_64|x86/
'mri'
else
nil
end
end
|
35
36
37
38
|
# File 'lib/santas_little_helper.rb', line 35
def ruby_platform?(os='')
os.to_s.match(ruby_platform) ? true : false
end
|
#ruby_version ⇒ Object
In case ruby ever reaches version 19 :-) or some 2.19 :-) only matching 1.9 at the begining of the line Returns an integer for easy version comparison 200 > 187 ( Version two is newer :-) ) if ruby_version > 187 , install new version of the gem.
75
76
77
|
# File 'lib/santas_little_helper.rb', line 75
def ruby_version
RUBY_VERSION.gsub(/[^0-9]/,'').to_i
end
|
#ruby_version?(version_to_check) ⇒ Boolean
78
79
80
81
82
83
|
# File 'lib/santas_little_helper.rb', line 78
def ruby_version?(version_to_check)
version_to_check = version_to_check.to_s.gsub(/[^0-9]/,'')
RUBY_VERSION.gsub(/[^0-9]/,'')[0..(version_to_check.size-1)] == version_to_check[0..(version_to_check.size-1)]
end
|
#windows? ⇒ Boolean
These are just aliases for convinience, I really doubt somebody would use them System Wide on an object for any other purpose.
41
42
43
|
# File 'lib/santas_little_helper.rb', line 41
def windows?
ruby_platform?(:windows)
end
|