os 1.0.0 → 1.1.0
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.
- checksums.yaml +5 -5
- data/ChangeLog +3 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +15 -10
- data/README.rdoc +3 -0
- data/Rakefile +5 -2
- data/VERSION +1 -1
- data/lib/os.rb +36 -0
- data/os.gemspec +11 -4
- data/spec/os_spec.rb +20 -4
- metadata +33 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: e244d18c5f73cd59e53bbad8432687377e660f83122ceaf9c0bec6605fa1944c
|
|
4
|
+
data.tar.gz: 124c84467cf346ab9d24dc2853938deb6fea0c0d4d7235d1e6591ad9f732e6d0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d1cb09a1f1fa56c5c669cec11c19209b80cc00a6b409a358fc4f3a217bf6b50e02944be480fca3f4836e29905af6bcb98b68d43a96327f771275e5294becf901
|
|
7
|
+
data.tar.gz: b0631f672df0de823538583b577418b8e243c1a588bca03cdeb3af8c1e89b44216f9ae91df7030430040d471e91f998348cd97ab560a4343618f1916502344e1
|
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
|
+
2.1.4
|
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
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
require 'rubygems' if RUBY_VERSION < '1.9.0'
|
|
2
2
|
|
|
3
3
|
# Don't forget to run rake gemspec with each release! ... I think...
|
|
4
|
+
# then manually edit os.gemspec remove duplicatee rspecs, circular dependency? HUH?
|
|
5
|
+
# # also, to release, run gem release pkg/XXXX
|
|
4
6
|
|
|
5
7
|
begin
|
|
6
8
|
require 'jeweler'
|
|
@@ -11,12 +13,13 @@ begin
|
|
|
11
13
|
gem.email = "rogerpack2005@gmail.com"
|
|
12
14
|
gem.homepage = "http://github.com/rdp/os"
|
|
13
15
|
gem.authors = ["rdp", "David McCullars"]
|
|
16
|
+
gem.license = "MIT"
|
|
14
17
|
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
|
15
18
|
# gem.add_development_dependency "fast_require"
|
|
16
19
|
gem.add_development_dependency "rspec", ">= 2.0"
|
|
17
20
|
end
|
|
18
|
-
rescue LoadError
|
|
19
|
-
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
|
21
|
+
rescue LoadError => e
|
|
22
|
+
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler #{e}"
|
|
20
23
|
end
|
|
21
24
|
|
|
22
25
|
require 'rspec/core/rake_task'
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
1.
|
|
1
|
+
1.1.0
|
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,38 @@ 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
|
+
|
|
285
|
+
def self.parse_os_release
|
|
286
|
+
if OS.linux? && File.exist?('/etc/os-release')
|
|
287
|
+
output = {}
|
|
288
|
+
|
|
289
|
+
File.read('/etc/os-release').each_line do |line|
|
|
290
|
+
parsed_line = line.chomp.tr('"', '').split('=')
|
|
291
|
+
output[parsed_line[0].to_sym] = parsed_line[1]
|
|
292
|
+
end
|
|
293
|
+
output
|
|
294
|
+
else
|
|
295
|
+
raise "File /etc/os-release doesn't exists or not Linux"
|
|
296
|
+
end
|
|
297
|
+
end
|
|
298
|
+
|
|
263
299
|
class << self
|
|
264
300
|
alias :doze? :windows? # a joke name but I use it and like it :P
|
|
265
301
|
alias :jruby? :java?
|
data/os.gemspec
CHANGED
|
@@ -2,16 +2,16 @@
|
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
|
4
4
|
# -*- encoding: utf-8 -*-
|
|
5
|
-
# stub: os 1.
|
|
5
|
+
# stub: os 1.1.0 ruby lib
|
|
6
6
|
|
|
7
7
|
Gem::Specification.new do |s|
|
|
8
8
|
s.name = "os".freeze
|
|
9
|
-
s.version = "1.
|
|
9
|
+
s.version = "1.1.0"
|
|
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 = "
|
|
14
|
+
s.date = "2020-03-31"
|
|
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,18 +38,25 @@ 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.
|
|
41
|
+
s.licenses = ["MIT".freeze]
|
|
42
|
+
s.rubygems_version = "2.7.6".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
|
if s.respond_to? :specification_version then
|
|
45
46
|
s.specification_version = 4
|
|
46
47
|
|
|
47
48
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
|
49
|
+
s.add_development_dependency(%q<rake>.freeze, ["~> 0.8"])
|
|
50
|
+
s.add_development_dependency(%q<test-unit>.freeze, ["~> 3"])
|
|
48
51
|
s.add_development_dependency(%q<rspec>.freeze, [">= 2.0"])
|
|
49
52
|
else
|
|
53
|
+
s.add_dependency(%q<rake>.freeze, ["~> 0.8"])
|
|
54
|
+
s.add_dependency(%q<test-unit>.freeze, ["~> 3"])
|
|
50
55
|
s.add_dependency(%q<rspec>.freeze, [">= 2.0"])
|
|
51
56
|
end
|
|
52
57
|
else
|
|
58
|
+
s.add_dependency(%q<rake>.freeze, ["~> 0.8"])
|
|
59
|
+
s.add_dependency(%q<test-unit>.freeze, ["~> 3"])
|
|
53
60
|
s.add_dependency(%q<rspec>.freeze, [">= 2.0"])
|
|
54
61
|
end
|
|
55
62
|
end
|
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.
|
|
4
|
+
version: 1.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- rdp
|
|
@@ -9,8 +9,36 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date:
|
|
12
|
+
date: 2020-03-31 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'
|
|
28
|
+
- !ruby/object:Gem::Dependency
|
|
29
|
+
name: test-unit
|
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
|
31
|
+
requirements:
|
|
32
|
+
- - "~>"
|
|
33
|
+
- !ruby/object:Gem::Version
|
|
34
|
+
version: '3'
|
|
35
|
+
type: :development
|
|
36
|
+
prerelease: false
|
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
38
|
+
requirements:
|
|
39
|
+
- - "~>"
|
|
40
|
+
- !ruby/object:Gem::Version
|
|
41
|
+
version: '3'
|
|
14
42
|
- !ruby/object:Gem::Dependency
|
|
15
43
|
name: rspec
|
|
16
44
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -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.
|
|
102
|
+
rubygems_version: 2.7.6
|
|
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
|