Platform 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/platform.rb +27 -52
- metadata +1 -1
data/lib/platform.rb
CHANGED
@@ -39,60 +39,35 @@
|
|
39
39
|
# ruby platform.rb
|
40
40
|
#
|
41
41
|
module Platform
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
OS = :unix
|
48
|
-
IMPL = :linux
|
49
|
-
elsif RUBY_PLATFORM =~ /freebsd/i
|
50
|
-
OS = :unix
|
51
|
-
IMPL = :freebsd
|
52
|
-
elsif RUBY_PLATFORM =~ /netbsd/i
|
53
|
-
OS = :unix
|
54
|
-
IMPL = :netbsd
|
55
|
-
elsif RUBY_PLATFORM =~ /mswin/i
|
56
|
-
OS = :win32
|
57
|
-
IMPL = :mswin
|
58
|
-
elsif RUBY_PLATFORM =~ /cygwin/i
|
59
|
-
OS = :unix
|
60
|
-
IMPL = :cygwin
|
61
|
-
elsif RUBY_PLATFORM =~ /mingw/i
|
62
|
-
OS = :win32
|
63
|
-
IMPL = :mingw
|
64
|
-
elsif RUBY_PLATFORM =~ /bccwin/i
|
65
|
-
OS = :win32
|
66
|
-
IMPL = :bccwin
|
67
|
-
elsif RUBY_PLATFORM =~ /wince/i
|
68
|
-
OS = :win32
|
69
|
-
IMPL = :wince
|
70
|
-
elsif RUBY_PLATFORM =~ /vms/i
|
71
|
-
OS = :vms
|
72
|
-
IMPL = :vms
|
73
|
-
elsif RUBY_PLATFORM =~ /os2/i
|
74
|
-
OS = :os2
|
75
|
-
IMPL = :os2 # maybe there is some better choice here?
|
76
|
-
else
|
77
|
-
OS = :unknown
|
78
|
-
IMPL = :unknown
|
79
|
-
end
|
80
|
-
|
42
|
+
|
43
|
+
# Each platform is defined as
|
44
|
+
# [ /regex/, ::OS, ::IMPL ]
|
45
|
+
# define them from most to least specific and
|
46
|
+
# [ /.*/, :unknown, :unknown ] should always come last
|
81
47
|
# whither AIX, SOLARIS, and the other unixen?
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
48
|
+
PLATFORMS = [
|
49
|
+
[ /darwin/i, :unix, :macosx ],
|
50
|
+
[ /linux/i, :unix, :linux ],
|
51
|
+
[ /freebsd/i, :unix, :freebsd ],
|
52
|
+
[ /netbsd/i, :unix, :netbsd ],
|
53
|
+
[ /cygwin/i, :hybrid, :cygwin ],
|
54
|
+
[ /mingw/i, :win32, :mingw ],
|
55
|
+
[ /bccwin/i, :win32, :bccwin ],
|
56
|
+
[ /vms/i, :vms, :vms ],
|
57
|
+
[ /os2/i, :os2, :os2 ],
|
58
|
+
[ /.*/, :unknwon, :unknown ]
|
59
|
+
]
|
60
|
+
x, OS, IMPL = PLATFORMS.find { |p| RUBY_PLATFORM =~ /#{p[0]}/ }
|
61
|
+
|
95
62
|
# What about AMD, Turion, Motorola, etc..?
|
63
|
+
ARCHS = [
|
64
|
+
[ /i\d86/, :x86 ],
|
65
|
+
[ /ia64/, :ia64 ],
|
66
|
+
[ /powerpc/, :powerpc ],
|
67
|
+
[ /alpha/, :alpha ],
|
68
|
+
[ /.*/, :unknown ]
|
69
|
+
]
|
70
|
+
x, ARCH = ARCHS.find { |a| RUBY_PLATFORM =~ /#{a[0]}/}
|
96
71
|
|
97
72
|
end
|
98
73
|
|