os 0.3.3 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/VERSION +1 -1
  2. data/lib/os.rb +62 -50
  3. data/spec/spec.os.rb +13 -6
  4. metadata +2 -2
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.3
1
+ 0.4.0
data/lib/os.rb CHANGED
@@ -1,58 +1,70 @@
1
1
  class OS
2
2
 
3
- # treat cygwin as linux
4
- # also treat IronRuby on mono as...linux
5
-
6
- if RUBY_PLATFORM =~ /cygwin/ # i386-cygwin
7
- WINDOZE = false
8
- elsif ENV['OS'] == 'Windows_NT'
9
- WINDOZE = true
10
- else
11
- WINDOZE = false
12
- end
13
-
14
- # OS.windows?
15
- # true if on windows [and/or jruby]
16
- # false if on linux or cygwin
17
- def self.windows?
18
- WINDOZE
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
- def self.bits
47
- BITS
48
- end
23
+ # true for linux, os x, cygwin
24
+ def self.posix?
25
+ !OS.windows?
26
+ end
49
27
 
50
- def self.java?
51
- if RUBY_PLATFORM =~ /java/
52
- true
53
- else
54
- false
55
- end
56
- end
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
@@ -1,7 +1,5 @@
1
1
  require 'rubygems' if RUBY_VERSION < '1.9'
2
- # try to help sane gem out a bit
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.linux? == false
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.linux? == true
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.3.3
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: 2009-12-30 00:00:00 -07:00
12
+ date: 2010-01-13 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency