core_extended 0.0.4 → 0.0.5
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/lib/core_extended/file.rb +9 -0
- data/lib/core_extended/os.rb +33 -0
- data/lib/core_extended/version.rb +1 -1
- data/lib/core_extended.rb +6 -1
- data/spec/file_spec.rb +10 -0
- data/spec/os_spec.rb +40 -0
- metadata +8 -2
@@ -0,0 +1,33 @@
|
|
1
|
+
class OS
|
2
|
+
|
3
|
+
def self.name
|
4
|
+
RbConfig::CONFIG['host_os']
|
5
|
+
end
|
6
|
+
|
7
|
+
def self.linux?
|
8
|
+
is? /linux/
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.mac?
|
12
|
+
is? /darwin|mac os/
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.windows?
|
16
|
+
is? /mswin|msys|mingw|cygwin|bccwin|wince|emc/
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.unix?
|
20
|
+
is? /solaris|sunos|bsd/
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.unknown?
|
24
|
+
!linux? && !mac? && !windows? && !unix?
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def self.is?(regex)
|
30
|
+
!regex.match(name).nil?
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
data/lib/core_extended.rb
CHANGED
data/spec/file_spec.rb
ADDED
data/spec/os_spec.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'minitest_helper'
|
2
|
+
|
3
|
+
describe OS do
|
4
|
+
|
5
|
+
def stub_os(name)
|
6
|
+
RbConfig::CONFIG['host_os'] = name
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'Linux' do
|
10
|
+
stub_os 'linux-gnu'
|
11
|
+
OS.must_be :linux?
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'Mac' do
|
15
|
+
['darwin', 'mac os'].each do |name|
|
16
|
+
stub_os name
|
17
|
+
OS.must_be :mac?
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'Windows' do
|
22
|
+
%w(mswin msys mingw cygwin bccwin wince emc).each do |name|
|
23
|
+
stub_os name
|
24
|
+
OS.must_be :windows?
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'Unix' do
|
29
|
+
%w(solaris sunos bsd).each do |name|
|
30
|
+
stub_os name
|
31
|
+
OS.must_be :unix?
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'Unkonw' do
|
36
|
+
stub_os 'invalid_so'
|
37
|
+
OS.must_be :unknown?
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: core_extended
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-06-
|
12
|
+
date: 2013-06-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -107,12 +107,16 @@ files:
|
|
107
107
|
- Rakefile
|
108
108
|
- core_extended.gemspec
|
109
109
|
- lib/core_extended.rb
|
110
|
+
- lib/core_extended/file.rb
|
110
111
|
- lib/core_extended/marshal.rb
|
112
|
+
- lib/core_extended/os.rb
|
111
113
|
- lib/core_extended/string.rb
|
112
114
|
- lib/core_extended/version.rb
|
113
115
|
- spec/coverage_helper.rb
|
116
|
+
- spec/file_spec.rb
|
114
117
|
- spec/marshal_spec.rb
|
115
118
|
- spec/minitest_helper.rb
|
119
|
+
- spec/os_spec.rb
|
116
120
|
- spec/string_spec.rb
|
117
121
|
homepage: https://github.com/gabynaiman/core_extended
|
118
122
|
licenses:
|
@@ -141,7 +145,9 @@ specification_version: 3
|
|
141
145
|
summary: Ruby core extensions
|
142
146
|
test_files:
|
143
147
|
- spec/coverage_helper.rb
|
148
|
+
- spec/file_spec.rb
|
144
149
|
- spec/marshal_spec.rb
|
145
150
|
- spec/minitest_helper.rb
|
151
|
+
- spec/os_spec.rb
|
146
152
|
- spec/string_spec.rb
|
147
153
|
has_rdoc:
|