os 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +12 -13
- data/VERSION +1 -1
- data/lib/os.rb +19 -3
- data/spec/go.rb +3 -0
- data/spec/{os_spec.rb → spec.os.rb} +10 -0
- metadata +4 -3
data/README.rdoc
CHANGED
@@ -1,17 +1,16 @@
|
|
1
|
-
|
1
|
+
OS
|
2
2
|
|
3
|
-
Description goes here.
|
4
3
|
|
5
|
-
|
6
|
-
|
7
|
-
* Fork the project.
|
8
|
-
* Make your feature addition or bug fix.
|
9
|
-
* Add tests for it. This is important so I don't break it in a
|
10
|
-
future version unintentionally.
|
11
|
-
* Commit, do not mess with rakefile, version, or history.
|
12
|
-
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
13
|
-
* Send me a pull request. Bonus points for topic branches.
|
4
|
+
The OS gem allows for some easy telling if you're on windows or not.
|
14
5
|
|
15
|
-
|
6
|
+
require 'os'
|
7
|
+
>> OS.windows?
|
8
|
+
=> true
|
9
|
+
|
10
|
+
>> OS.bits
|
11
|
+
=> 32
|
12
|
+
|
13
|
+
If there are any other features you'd like, let me know.
|
14
|
+
|
15
|
+
github.com/rdp/os
|
16
16
|
|
17
|
-
Copyright (c) 2009 rdp. See LICENSE for details.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
data/lib/os.rb
CHANGED
@@ -2,7 +2,11 @@ class OS
|
|
2
2
|
|
3
3
|
require 'rbconfig'
|
4
4
|
host_os = RbConfig::CONFIG['host_os']
|
5
|
-
|
5
|
+
if host_os =~ /mswin|mingw/
|
6
|
+
WINDOZE = true
|
7
|
+
else
|
8
|
+
WINDOZE = false
|
9
|
+
end
|
6
10
|
|
7
11
|
# OS.windows?
|
8
12
|
# true if on windows [and/or jruby]
|
@@ -14,12 +18,24 @@ class OS
|
|
14
18
|
if host_os =~ /32/
|
15
19
|
BITS = 32
|
16
20
|
else
|
17
|
-
|
18
|
-
|
21
|
+
if host_os =~ /64/
|
22
|
+
BITS = 64
|
23
|
+
else # cygwin
|
24
|
+
if (1<<32).class == Fixnum
|
25
|
+
BITS = 64
|
26
|
+
else
|
27
|
+
BITS = 32
|
28
|
+
end
|
29
|
+
end
|
19
30
|
end
|
20
31
|
|
32
|
+
|
21
33
|
def self.bits
|
22
34
|
BITS
|
23
35
|
end
|
24
36
|
|
37
|
+
def self.java?
|
38
|
+
RUBY_PLATFORM =~ /java/
|
39
|
+
end
|
40
|
+
|
25
41
|
end
|
data/spec/go.rb
ADDED
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'rubygems' if RUBY_VERSION < '1.9'
|
1
2
|
require 'sane'
|
2
3
|
require_rel '../lib/os'
|
3
4
|
require 'spec/autorun'
|
@@ -8,6 +9,7 @@ describe "OS" do
|
|
8
9
|
if RUBY_PLATFORM =~ /mingw|mswin/
|
9
10
|
assert OS.windows? == true
|
10
11
|
else
|
12
|
+
puts OS.windows?
|
11
13
|
assert OS.windows? == false
|
12
14
|
end
|
13
15
|
end
|
@@ -17,4 +19,12 @@ describe "OS" do
|
|
17
19
|
assert OS.bits == 32
|
18
20
|
end
|
19
21
|
end
|
22
|
+
|
23
|
+
it "should know if you're on java" do
|
24
|
+
if RUBY_PLATFORM == 'java'
|
25
|
+
assert OS.java?
|
26
|
+
else
|
27
|
+
assert !OS.java?
|
28
|
+
end
|
29
|
+
end
|
20
30
|
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.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- rdp
|
@@ -47,7 +47,7 @@ files:
|
|
47
47
|
- Rakefile
|
48
48
|
- VERSION
|
49
49
|
- lib/os.rb
|
50
|
-
- spec/
|
50
|
+
- spec/spec.os.rb
|
51
51
|
has_rdoc: true
|
52
52
|
homepage: http://github.com/rdp/os
|
53
53
|
licenses: []
|
@@ -77,4 +77,5 @@ signing_key:
|
|
77
77
|
specification_version: 3
|
78
78
|
summary: Simple and easy way to know if you're on windows or not (reliably), as well as how many bits the OS is, etc.
|
79
79
|
test_files:
|
80
|
-
- spec/
|
80
|
+
- spec/go.rb
|
81
|
+
- spec/spec.os.rb
|