os 0.3.3 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION +1 -1
- data/lib/os.rb +62 -50
- data/spec/spec.os.rb +13 -6
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.4.0
|
data/lib/os.rb
CHANGED
@@ -1,58 +1,70 @@
|
|
1
1
|
class OS
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
end
|
20
|
-
|
21
|
-
def self.linux?
|
22
|
-
!WINDOZE
|
23
|
-
end
|
24
|
-
|
25
|
-
class << self
|
26
|
-
alias :windoze? :windows? #the joke one
|
27
|
-
end
|
28
|
-
|
29
|
-
require 'rbconfig'
|
30
|
-
host_os = RbConfig::CONFIG['host_os']
|
31
|
-
if host_os =~ /32/
|
32
|
-
BITS = 32
|
33
|
-
else
|
34
|
-
if host_os =~ /64/
|
35
|
-
BITS = 64
|
36
|
-
else # cygwin
|
37
|
-
if (1<<32).class == Fixnum
|
38
|
-
BITS = 64
|
39
|
-
else
|
40
|
-
BITS = 32
|
3
|
+
# treat cygwin as linux
|
4
|
+
# also treat IronRuby on mono as...linux
|
5
|
+
|
6
|
+
|
7
|
+
# OS.windows?
|
8
|
+
# true if on windows [and/or jruby]
|
9
|
+
# false if on linux or cygwin
|
10
|
+
def self.windows?
|
11
|
+
@windows ||= begin
|
12
|
+
if RUBY_PLATFORM =~ /cygwin/ # i386-cygwin
|
13
|
+
false
|
14
|
+
elsif ENV['OS'] == 'Windows_NT'
|
15
|
+
true
|
16
|
+
else
|
17
|
+
false
|
18
|
+
end
|
41
19
|
end
|
42
|
-
end
|
43
|
-
end
|
44
20
|
|
21
|
+
end
|
45
22
|
|
46
|
-
|
47
|
-
|
48
|
-
|
23
|
+
# true for linux, os x, cygwin
|
24
|
+
def self.posix?
|
25
|
+
!OS.windows?
|
26
|
+
end
|
49
27
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
28
|
+
class << self
|
29
|
+
alias :doze? :windows? # a joke but I use it
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.bits
|
33
|
+
@bits ||= begin
|
34
|
+
require 'rbconfig'
|
35
|
+
host_os = RbConfig::CONFIG['host_os']
|
36
|
+
if host_os =~ /32/
|
37
|
+
32
|
38
|
+
else
|
39
|
+
if host_os =~ /64/
|
40
|
+
64
|
41
|
+
else # cygwin...
|
42
|
+
if (1<<32).class == Fixnum
|
43
|
+
64
|
44
|
+
else
|
45
|
+
32
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
57
51
|
|
52
|
+
|
53
|
+
def self.java?
|
54
|
+
@java ||= begin
|
55
|
+
if RUBY_PLATFORM =~ /java/
|
56
|
+
true
|
57
|
+
else
|
58
|
+
false
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def self.ruby_exe
|
64
|
+
@ruby_exe ||= begin
|
65
|
+
require 'rbconfig'
|
66
|
+
config = RbConfig::CONFIG
|
67
|
+
File::join(config['bindir'], config['ruby_install_name']) + config['EXEEXT']
|
68
|
+
end
|
69
|
+
end
|
58
70
|
end
|
data/spec/spec.os.rb
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
require 'rubygems' if RUBY_VERSION < '1.9'
|
2
|
-
|
3
|
-
$: << File.dirname(__FILE__) + '/../lib'
|
4
|
-
require 'os'
|
2
|
+
require File.dirname(__FILE__) + '/../lib/os' # load before sane
|
5
3
|
require 'sane'
|
6
4
|
require 'spec/autorun'
|
7
5
|
|
@@ -11,11 +9,11 @@ describe "OS" do
|
|
11
9
|
if RUBY_PLATFORM =~ /mingw|mswin/
|
12
10
|
assert OS.windows? == true
|
13
11
|
assert OS.windoze? == true
|
14
|
-
assert OS.
|
12
|
+
assert OS.posix? == false
|
15
13
|
else # ltodo jruby
|
16
14
|
if RUBY_PLATFORM =~ /linux/
|
17
15
|
assert OS.windows? == false
|
18
|
-
assert OS.
|
16
|
+
assert OS.posix? == true
|
19
17
|
end
|
20
18
|
end
|
21
19
|
end
|
@@ -28,9 +26,18 @@ describe "OS" do
|
|
28
26
|
|
29
27
|
it "should know if you're on java" do
|
30
28
|
if RUBY_PLATFORM == 'java'
|
31
|
-
assert OS.java? == true
|
29
|
+
assert OS.java? == true # I want just this value...
|
32
30
|
else
|
33
31
|
assert OS.java? == false
|
34
32
|
end
|
35
33
|
end
|
34
|
+
|
35
|
+
it "should have a ruby.exe method" do
|
36
|
+
if OS.windows?
|
37
|
+
assert OS.ruby_exe.include? 'ruby.exe'
|
38
|
+
else
|
39
|
+
OS.ruby
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
36
43
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: os
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- rdp
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date:
|
12
|
+
date: 2010-01-13 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|