Platform 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README +61 -52
- data/lib/platform.rb +108 -82
- metadata +40 -35
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 3eef1816537745be59599420d090bd8824f9cd1e
|
4
|
+
data.tar.gz: cb91dd0dd74288cc99ff1ad4da0af71634a4775b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ef7ec933175c8d6cafe1ce2d29132a5c43da83736af73daa658ea8cba74ba3bcc6a58002e03e92bf4e0fd15a4459aa115e27962dddebf8a249cba13ad886623f
|
7
|
+
data.tar.gz: 62865e48a38d01024a94c9db9c81a8d6fa7f430db5b3b48053ced116731052def556baa4840326ee398fb014fd0a0c0a5b74fd8b7ea5e440b6e662980180923b
|
data/README
CHANGED
@@ -1,52 +1,61 @@
|
|
1
|
-
#
|
2
|
-
# Platform
|
3
|
-
#
|
4
|
-
# author: Matt Mower <self@mattmower.com>
|
5
|
-
# license:
|
6
|
-
#
|
7
|
-
#
|
8
|
-
# The Platform library offers a simple, reliable, means of
|
9
|
-
# determining what platform Ruby is running on. Underlying
|
10
|
-
# Platform is the RUBY_PLATFORM constant. This library is
|
11
|
-
# parsing this constant for information. You could easily do
|
12
|
-
# this yourself. We've just taken the hassle out of it for
|
13
|
-
# you and hopefully covered a few of the more unusual cases
|
14
|
-
# you mightn't have thought of yourself.
|
15
|
-
#
|
16
|
-
# On the other hand, if you've got cases we haven't please
|
17
|
-
# mail the authors.
|
18
|
-
#
|
19
|
-
# ==Use
|
20
|
-
#
|
21
|
-
# require 'platform'
|
22
|
-
#
|
23
|
-
# defines
|
24
|
-
#
|
25
|
-
# Platform::OS
|
26
|
-
# :unix
|
27
|
-
# :
|
28
|
-
# :
|
29
|
-
# :
|
30
|
-
# :
|
31
|
-
#
|
32
|
-
#
|
33
|
-
#
|
34
|
-
# :
|
35
|
-
# :
|
36
|
-
# :
|
37
|
-
# :
|
38
|
-
# :
|
39
|
-
# :
|
40
|
-
# :
|
41
|
-
# :
|
42
|
-
# :
|
43
|
-
# :
|
44
|
-
# :
|
45
|
-
#
|
46
|
-
#
|
47
|
-
# :
|
48
|
-
# :
|
49
|
-
# :
|
50
|
-
#
|
51
|
-
#
|
52
|
-
#
|
1
|
+
#
|
2
|
+
# Platform
|
3
|
+
#
|
4
|
+
# author: Matt Mower <self@mattmower.com>
|
5
|
+
# license: MIT
|
6
|
+
#
|
7
|
+
#
|
8
|
+
# The Platform library offers a simple, reliable, means of
|
9
|
+
# determining what platform Ruby is running on. Underlying
|
10
|
+
# Platform is the RUBY_PLATFORM constant. This library is
|
11
|
+
# parsing this constant for information. You could easily do
|
12
|
+
# this yourself. We've just taken the hassle out of it for
|
13
|
+
# you and hopefully covered a few of the more unusual cases
|
14
|
+
# you mightn't have thought of yourself.
|
15
|
+
#
|
16
|
+
# On the other hand, if you've got cases we haven't please
|
17
|
+
# mail the authors.
|
18
|
+
#
|
19
|
+
# ==Use
|
20
|
+
#
|
21
|
+
# require 'platform'
|
22
|
+
#
|
23
|
+
# defines
|
24
|
+
#
|
25
|
+
# Platform::OS
|
26
|
+
# :unix
|
27
|
+
# :hybrid (e.g. Cygwin)
|
28
|
+
# :win32
|
29
|
+
# :vms
|
30
|
+
# :os2
|
31
|
+
# :unknown
|
32
|
+
#
|
33
|
+
# Platform::IMPL
|
34
|
+
# :macosx
|
35
|
+
# :linux
|
36
|
+
# :freebsd
|
37
|
+
# :netbsd
|
38
|
+
# :mswin
|
39
|
+
# :cygwin
|
40
|
+
# :mingw
|
41
|
+
# :bccwin
|
42
|
+
# :wince
|
43
|
+
# :vms
|
44
|
+
# :os2
|
45
|
+
# :solaris
|
46
|
+
# :aix
|
47
|
+
# :irix
|
48
|
+
# :hpux
|
49
|
+
# :unknown
|
50
|
+
#
|
51
|
+
# Platform::ARCH
|
52
|
+
# :x86
|
53
|
+
# :x86_64
|
54
|
+
# :ia64
|
55
|
+
# :powerpc
|
56
|
+
# :alpha
|
57
|
+
# :sparc
|
58
|
+
# :mips
|
59
|
+
# :parisc
|
60
|
+
# :unknown
|
61
|
+
#
|
data/lib/platform.rb
CHANGED
@@ -1,82 +1,108 @@
|
|
1
|
-
#
|
2
|
-
# platform.rb: naive platform detection for Ruby
|
3
|
-
# author: Matt Mower <self@mattmower.com>
|
4
|
-
#
|
5
|
-
|
6
|
-
# == Platform
|
7
|
-
#
|
8
|
-
# Platform is a simple module which parses the Ruby constant
|
9
|
-
# RUBY_PLATFORM and works out the OS, it's implementation,
|
10
|
-
# and the architecture it's running on.
|
11
|
-
#
|
12
|
-
# The motivation for writing this was coming across a case where
|
13
|
-
#
|
14
|
-
# +if RUBY_PLATFORM =~ /win/+
|
15
|
-
#
|
16
|
-
# didn't behave as expected (i.e. on powerpc-darwin-8.1.0)
|
17
|
-
#
|
18
|
-
# It is hoped that providing a library for parsing the platform
|
19
|
-
# means that we can cover all the cases and have something which
|
20
|
-
# works reliably 99% of the time.
|
21
|
-
#
|
22
|
-
# Please report any anomalies or new combinations to the author(s).
|
23
|
-
#
|
24
|
-
# == Use
|
25
|
-
#
|
26
|
-
# require "platform"
|
27
|
-
#
|
28
|
-
# defines
|
29
|
-
#
|
30
|
-
# Platform::OS (:unix,:win32,:vms,:os2)
|
31
|
-
# Platform::IMPL (:macosx,:linux,:mswin)
|
32
|
-
# Platform::ARCH (:powerpc,:x86,:alpha)
|
33
|
-
#
|
34
|
-
# if an unknown configuration is encountered any (or all) of
|
35
|
-
# these constant may have the value :unknown.
|
36
|
-
#
|
37
|
-
# To display the combination for your setup run
|
38
|
-
#
|
39
|
-
# ruby platform.rb
|
40
|
-
#
|
41
|
-
module Platform
|
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
|
47
|
-
# whither AIX, SOLARIS, and the other unixen?
|
48
|
-
PLATFORMS = [
|
49
|
-
[ /darwin/i, :unix, :macosx ],
|
50
|
-
[ /linux/i, :unix, :linux ],
|
51
|
-
[ /freebsd/i, :unix, :freebsd ],
|
52
|
-
[ /netbsd/i, :unix, :netbsd ],
|
53
|
-
[ /mswin/i, :win32, :mswin ],
|
54
|
-
[ /cygwin/i, :hybrid, :cygwin ],
|
55
|
-
[ /mingw/i, :win32, :mingw ],
|
56
|
-
[ /bccwin/i, :win32, :bccwin ],
|
57
|
-
[ /wince/i, :win32, :wince ],
|
58
|
-
[ /vms/i, :vms, :vms ],
|
59
|
-
[ /os2/i, :os2, :os2 ],
|
60
|
-
[ /solaris/i, :unix, :solaris ],
|
61
|
-
[ /
|
62
|
-
[
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
[ /
|
71
|
-
[ /
|
72
|
-
[ /
|
73
|
-
[ /
|
74
|
-
[
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
1
|
+
#
|
2
|
+
# platform.rb: naive platform detection for Ruby
|
3
|
+
# author: Matt Mower <self@mattmower.com>
|
4
|
+
#
|
5
|
+
|
6
|
+
# == Platform
|
7
|
+
#
|
8
|
+
# Platform is a simple module which parses the Ruby constant
|
9
|
+
# RUBY_PLATFORM and works out the OS, it's implementation,
|
10
|
+
# and the architecture it's running on.
|
11
|
+
#
|
12
|
+
# The motivation for writing this was coming across a case where
|
13
|
+
#
|
14
|
+
# +if RUBY_PLATFORM =~ /win/+
|
15
|
+
#
|
16
|
+
# didn't behave as expected (i.e. on powerpc-darwin-8.1.0)
|
17
|
+
#
|
18
|
+
# It is hoped that providing a library for parsing the platform
|
19
|
+
# means that we can cover all the cases and have something which
|
20
|
+
# works reliably 99% of the time.
|
21
|
+
#
|
22
|
+
# Please report any anomalies or new combinations to the author(s).
|
23
|
+
#
|
24
|
+
# == Use
|
25
|
+
#
|
26
|
+
# require "platform"
|
27
|
+
#
|
28
|
+
# defines
|
29
|
+
#
|
30
|
+
# Platform::OS (:unix,:win32,:vms,:os2)
|
31
|
+
# Platform::IMPL (:macosx,:linux,:mswin)
|
32
|
+
# Platform::ARCH (:powerpc,:x86,:alpha)
|
33
|
+
#
|
34
|
+
# if an unknown configuration is encountered any (or all) of
|
35
|
+
# these constant may have the value :unknown.
|
36
|
+
#
|
37
|
+
# To display the combination for your setup run
|
38
|
+
#
|
39
|
+
# ruby platform.rb
|
40
|
+
#
|
41
|
+
module Platform
|
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
|
47
|
+
# whither AIX, SOLARIS, and the other unixen?
|
48
|
+
PLATFORMS = [
|
49
|
+
[ /darwin/i, :unix, :macosx ],
|
50
|
+
[ /linux/i, :unix, :linux ],
|
51
|
+
[ /freebsd/i, :unix, :freebsd ],
|
52
|
+
[ /netbsd/i, :unix, :netbsd ],
|
53
|
+
[ /mswin/i, :win32, :mswin ],
|
54
|
+
[ /cygwin/i, :hybrid, :cygwin ],
|
55
|
+
[ /mingw/i, :win32, :mingw ],
|
56
|
+
[ /bccwin/i, :win32, :bccwin ],
|
57
|
+
[ /wince/i, :win32, :wince ],
|
58
|
+
[ /vms/i, :vms, :vms ],
|
59
|
+
[ /os2/i, :os2, :os2 ],
|
60
|
+
[ /solaris/i, :unix, :solaris ],
|
61
|
+
[ /aix/i, :unix, :aix ],
|
62
|
+
[ /irix/i, :unix, :irix ],
|
63
|
+
[ /hpux/i, :unix, :hpux ],
|
64
|
+
[ /.*/, :unknown, :unknown ]
|
65
|
+
]
|
66
|
+
(*), OS, IMPL = PLATFORMS.find { |p| RUBY_PLATFORM =~ /#{p[0]}/ }
|
67
|
+
|
68
|
+
# What about AMD, Turion, Motorola, etc..?
|
69
|
+
ARCHS = [
|
70
|
+
[ /i\d86/, :x86 ],
|
71
|
+
[ /x86_64/, :x86_64],
|
72
|
+
[ /ia64/, :ia64 ],
|
73
|
+
[ /powerpc/, :powerpc ],
|
74
|
+
[ /alpha/, :alpha ],
|
75
|
+
[ /sparc/i, :sparc ],
|
76
|
+
[ /mips/i, :mips ],
|
77
|
+
[ /hppa/i, :parisc ],
|
78
|
+
[ /.*/, :unknown ]
|
79
|
+
]
|
80
|
+
(*), ARCH = ARCHS.find { |a| RUBY_PLATFORM =~ /#{a[0]}/}
|
81
|
+
|
82
|
+
#
|
83
|
+
# Execute the given block of code for a specific combination (or combinations)
|
84
|
+
# of platform operating system, implementation, and architecture.
|
85
|
+
#
|
86
|
+
# e.g. Platform.invoke_if( :unix, :macosx )
|
87
|
+
#
|
88
|
+
def self.for_platform( os, impl = IMPL, arch = ARCH )
|
89
|
+
if block_given?
|
90
|
+
if Array( os ).include?( OS ) && Array( impl ).include?( IMPL ) && Array( arch ).include?( ARCH )
|
91
|
+
yield( OS, IMPL, ARCH )
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
def self.description
|
97
|
+
{
|
98
|
+
:os => OS,
|
99
|
+
:impl => IMPL,
|
100
|
+
:arch => ARCH
|
101
|
+
}
|
102
|
+
end
|
103
|
+
|
104
|
+
end
|
105
|
+
|
106
|
+
if __FILE__ == $0
|
107
|
+
puts "Platform OS=#{Platform::OS}, IMPL=#{Platform::IMPL}, ARCH=#{Platform::ARCH}"
|
108
|
+
end
|
metadata
CHANGED
@@ -1,41 +1,46 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.8.11
|
3
|
-
specification_version: 1
|
1
|
+
--- !ruby/object:Gem::Specification
|
4
2
|
name: Platform
|
5
|
-
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.4.
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
- lib
|
11
|
-
email: self@mattmower.com
|
12
|
-
homepage: http://rubyforge.org/projects/platform/
|
13
|
-
rubyforge_project:
|
14
|
-
description:
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.4.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Matt Mower
|
15
8
|
autorequire: platform
|
16
|
-
default_executable:
|
17
9
|
bindir: bin
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
- !ruby/object:Gem::Version
|
24
|
-
version: 0.0.0
|
25
|
-
version:
|
26
|
-
platform: ruby
|
27
|
-
signing_key:
|
28
|
-
cert_chain:
|
29
|
-
authors:
|
30
|
-
- Matt Mower
|
31
|
-
files:
|
32
|
-
- lib/platform.rb
|
33
|
-
- README
|
34
|
-
test_files: []
|
35
|
-
rdoc_options: []
|
36
|
-
extra_rdoc_files:
|
37
|
-
- README
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-09-05 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description:
|
14
|
+
email: self@mattmower.com
|
38
15
|
executables: []
|
39
16
|
extensions: []
|
17
|
+
extra_rdoc_files:
|
18
|
+
- README
|
19
|
+
files:
|
20
|
+
- README
|
21
|
+
- lib/platform.rb
|
22
|
+
homepage: http://rubyforge.org/projects/platform/
|
23
|
+
licenses:
|
24
|
+
- MIT
|
25
|
+
metadata: {}
|
26
|
+
post_install_message:
|
27
|
+
rdoc_options: []
|
28
|
+
require_paths:
|
29
|
+
- lib
|
30
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
35
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
40
40
|
requirements: []
|
41
|
-
|
41
|
+
rubyforge_project:
|
42
|
+
rubygems_version: 2.4.5.1
|
43
|
+
signing_key:
|
44
|
+
specification_version: 4
|
45
|
+
summary: Hopefully robust platform sensing
|
46
|
+
test_files: []
|