os 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ChangeLog +3 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +15 -10
- data/README.rdoc +3 -0
- data/Rakefile +1 -0
- data/VERSION +1 -1
- data/lib/os.rb +22 -0
- data/os.gemspec +6 -14
- data/spec/os_spec.rb +20 -4
- metadata +37 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1477aa871c9207710b6d5ac5ffbac3d3ce68b5c6
|
4
|
+
data.tar.gz: e7ea7749f846a01f4906d4ecf1cc83692b8ddfc6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fda9a548d80869cc3fdc0fc3da2593889e0f147e845ad79ab5b7b74b23c64d3483a230778ee1d3b92b397767f45a3a498cf2f5601765d80eb1e82e4656108089
|
7
|
+
data.tar.gz: 9424bce41996a0a77429377f274df819e213ab7e1f704d2e85c96d2ddae7d681598ec463676892f3ba5e2022e1b8535b058f93fce61d0bcf84df0fd1c949b923
|
data/ChangeLog
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,29 +1,34 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
|
+
specs:
|
4
|
+
os (1.0.1)
|
3
5
|
|
4
6
|
GEM
|
5
7
|
remote: http://rubygems.org/
|
6
8
|
specs:
|
7
|
-
diff-lcs (1.1.
|
8
|
-
|
9
|
-
|
10
|
-
bundler (~> 1.0.0)
|
11
|
-
git (>= 1.2.5)
|
12
|
-
rake
|
13
|
-
rake (0.8.7)
|
9
|
+
diff-lcs (1.1.3)
|
10
|
+
power_assert (1.0.2)
|
11
|
+
rake (0.9.6)
|
14
12
|
rspec (2.5.0)
|
15
13
|
rspec-core (~> 2.5.0)
|
16
14
|
rspec-expectations (~> 2.5.0)
|
17
15
|
rspec-mocks (~> 2.5.0)
|
18
|
-
rspec-core (2.5.
|
16
|
+
rspec-core (2.5.2)
|
19
17
|
rspec-expectations (2.5.0)
|
20
18
|
diff-lcs (~> 1.1.2)
|
21
19
|
rspec-mocks (2.5.0)
|
20
|
+
test-unit (3.2.3)
|
21
|
+
power_assert
|
22
22
|
|
23
23
|
PLATFORMS
|
24
24
|
ruby
|
25
25
|
x86-mingw32
|
26
26
|
|
27
27
|
DEPENDENCIES
|
28
|
-
|
29
|
-
|
28
|
+
os!
|
29
|
+
rake (~> 0.8)
|
30
|
+
rspec (~> 2.5.0)
|
31
|
+
test-unit (~> 3)
|
32
|
+
|
33
|
+
BUNDLED WITH
|
34
|
+
1.14.5
|
data/README.rdoc
CHANGED
@@ -52,6 +52,9 @@ The OS gem allows for some easy telling if you're on windows or not.
|
|
52
52
|
>> OS::Underlying.bsd?
|
53
53
|
=> true # true for OS X
|
54
54
|
|
55
|
+
>> OS::Underlying.docker?
|
56
|
+
=> false # true if running inside a Docker container
|
57
|
+
|
55
58
|
If there are any other features you'd like, let me know, I'll do what I can to add them :)
|
56
59
|
|
57
60
|
http://github.com/rdp/os for feedback et al
|
data/Rakefile
CHANGED
@@ -11,6 +11,7 @@ begin
|
|
11
11
|
gem.email = "rogerpack2005@gmail.com"
|
12
12
|
gem.homepage = "http://github.com/rdp/os"
|
13
13
|
gem.authors = ["rdp", "David McCullars"]
|
14
|
+
gem.license = "MIT"
|
14
15
|
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
15
16
|
# gem.add_development_dependency "fast_require"
|
16
17
|
gem.add_development_dependency "rspec", ">= 2.0"
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.1
|
data/lib/os.rb
CHANGED
@@ -183,6 +183,10 @@ class OS
|
|
183
183
|
OS.host_os =~ /linux/ ? true : false
|
184
184
|
end
|
185
185
|
|
186
|
+
def self.docker?
|
187
|
+
system('grep -q docker /proc/self/cgroup') if OS.linux?
|
188
|
+
end
|
189
|
+
|
186
190
|
end
|
187
191
|
|
188
192
|
def self.cygwin?
|
@@ -260,6 +264,24 @@ class OS
|
|
260
264
|
|
261
265
|
end
|
262
266
|
|
267
|
+
def self.app_config_path(name)
|
268
|
+
if OS.doze?
|
269
|
+
if ENV['LOCALAPPDATA']
|
270
|
+
return File.join(ENV['LOCALAPPDATA'], name)
|
271
|
+
end
|
272
|
+
|
273
|
+
File.join ENV['USERPROFILE'], 'Local Settings', 'Application Data', name
|
274
|
+
elsif OS.mac?
|
275
|
+
File.join ENV['HOME'], 'Library', 'Application Support', name
|
276
|
+
else
|
277
|
+
if ENV['XDG_CONFIG_HOME']
|
278
|
+
return File.join(ENV['XDG_CONFIG_HOME'], name)
|
279
|
+
end
|
280
|
+
|
281
|
+
File.join ENV['HOME'], '.config', name
|
282
|
+
end
|
283
|
+
end
|
284
|
+
|
263
285
|
class << self
|
264
286
|
alias :doze? :windows? # a joke name but I use it and like it :P
|
265
287
|
alias :jruby? :java?
|
data/os.gemspec
CHANGED
@@ -6,12 +6,12 @@
|
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "os".freeze
|
9
|
-
s.version = "1.0.
|
9
|
+
s.version = "1.0.1"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib".freeze]
|
13
13
|
s.authors = ["rdp".freeze, "David McCullars".freeze]
|
14
|
-
s.date = "2017-
|
14
|
+
s.date = "2017-10-18"
|
15
15
|
s.description = "The OS gem allows for some useful and easy functions, like OS.windows? (=> true or false) OS.bits ( => 32 or 64) etc\"".freeze
|
16
16
|
s.email = "rogerpack2005@gmail.com".freeze
|
17
17
|
s.extra_rdoc_files = [
|
@@ -38,19 +38,11 @@ Gem::Specification.new do |s|
|
|
38
38
|
"spec/spec_helper.rb"
|
39
39
|
]
|
40
40
|
s.homepage = "http://github.com/rdp/os".freeze
|
41
|
+
s.licenses = ["MIT".freeze]
|
41
42
|
s.rubygems_version = "2.5.2".freeze
|
42
43
|
s.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.".freeze
|
43
44
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
48
|
-
s.add_development_dependency(%q<rspec>.freeze, [">= 2.0"])
|
49
|
-
else
|
50
|
-
s.add_dependency(%q<rspec>.freeze, [">= 2.0"])
|
51
|
-
end
|
52
|
-
else
|
53
|
-
s.add_dependency(%q<rspec>.freeze, [">= 2.0"])
|
54
|
-
end
|
45
|
+
s.add_development_dependency('rake', '~> 0.8')
|
46
|
+
s.add_development_dependency('rspec', '~> 2.5.0')
|
47
|
+
s.add_development_dependency('test-unit', '~> 3')
|
55
48
|
end
|
56
|
-
|
data/spec/os_spec.rb
CHANGED
@@ -119,10 +119,9 @@ describe "OS" do
|
|
119
119
|
end
|
120
120
|
|
121
121
|
it "has working cpu count method" do
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
end
|
122
|
+
cpu_count = OS.cpu_count
|
123
|
+
assert cpu_count >= 1
|
124
|
+
assert (cpu_count & (cpu_count - 1)) == 0 # CPU count is normally a power of 2
|
126
125
|
end
|
127
126
|
|
128
127
|
it "has working cpu count method with no env. variable" do
|
@@ -143,6 +142,23 @@ describe "OS" do
|
|
143
142
|
end
|
144
143
|
end
|
145
144
|
|
145
|
+
it "should provide a path to directory for application config" do
|
146
|
+
ENV.stub(:[])
|
147
|
+
|
148
|
+
if OS.mac?
|
149
|
+
ENV.stub(:[]).with('HOME').and_return('/home/user')
|
150
|
+
assert OS.app_config_path('appname') == '/home/xdg/Library/Application Support/appname'
|
151
|
+
elsif OS.doze?
|
152
|
+
# TODO
|
153
|
+
else
|
154
|
+
ENV.stub(:[]).with('HOME').and_return('/home/user')
|
155
|
+
assert OS.app_config_path('appname') == '/home/user/.config/appname'
|
156
|
+
|
157
|
+
ENV.stub(:[]).with('XDG_CONFIG_HOME').and_return('/home/xdg/.config')
|
158
|
+
assert OS.app_config_path('appname') == '/home/xdg/.config/appname'
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
146
162
|
it "should have a freebsd? method" do
|
147
163
|
if OS.host_os =~ /freebsd/
|
148
164
|
assert OS.freebsd? == true
|
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: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- rdp
|
@@ -9,22 +9,50 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-
|
12
|
+
date: 2017-10-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rake
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - "~>"
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '0.8'
|
21
|
+
type: :development
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - "~>"
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '0.8'
|
14
28
|
- !ruby/object:Gem::Dependency
|
15
29
|
name: rspec
|
16
30
|
requirement: !ruby/object:Gem::Requirement
|
17
31
|
requirements:
|
18
|
-
- - "
|
32
|
+
- - "~>"
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: 2.5.0
|
35
|
+
type: :development
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - "~>"
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: 2.5.0
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: test-unit
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - "~>"
|
19
47
|
- !ruby/object:Gem::Version
|
20
|
-
version: '
|
48
|
+
version: '3'
|
21
49
|
type: :development
|
22
50
|
prerelease: false
|
23
51
|
version_requirements: !ruby/object:Gem::Requirement
|
24
52
|
requirements:
|
25
|
-
- - "
|
53
|
+
- - "~>"
|
26
54
|
- !ruby/object:Gem::Version
|
27
|
-
version: '
|
55
|
+
version: '3'
|
28
56
|
description: The OS gem allows for some useful and easy functions, like OS.windows?
|
29
57
|
(=> true or false) OS.bits ( => 32 or 64) etc"
|
30
58
|
email: rogerpack2005@gmail.com
|
@@ -52,7 +80,8 @@ files:
|
|
52
80
|
- spec/osx_spec.rb
|
53
81
|
- spec/spec_helper.rb
|
54
82
|
homepage: http://github.com/rdp/os
|
55
|
-
licenses:
|
83
|
+
licenses:
|
84
|
+
- MIT
|
56
85
|
metadata: {}
|
57
86
|
post_install_message:
|
58
87
|
rdoc_options: []
|
@@ -70,7 +99,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
70
99
|
version: '0'
|
71
100
|
requirements: []
|
72
101
|
rubyforge_project:
|
73
|
-
rubygems_version: 2.5.2
|
102
|
+
rubygems_version: 2.5.2.3
|
74
103
|
signing_key:
|
75
104
|
specification_version: 4
|
76
105
|
summary: Simple and easy way to know if you're on windows or not (reliably), as well
|