os 1.1.0 → 1.1.4
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 +4 -4
- data/ChangeLog +15 -0
- data/Gemfile.lock +0 -9
- data/README.md +104 -0
- data/Rakefile +9 -3
- data/VERSION +1 -1
- data/lib/os.rb +4 -3
- data/os.gemspec +5 -5
- metadata +4 -4
- data/README.rdoc +0 -78
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8ceda108b09b3210f4cab0b411d8fe76bb69c74b3054a86e15ba533074086ffe
|
|
4
|
+
data.tar.gz: c59bede2a6e772a83b13543951b7824a1811c376c1e313e16ec20e96a37f7986
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b574706218e68b4ce5d9d9c82abb967032ec5fa1d4363c268cbd89e3261955de0d8e0c56834d6e813c06b23900cade81087b86ff52f166418ab339d03ced7197
|
|
7
|
+
data.tar.gz: 6a692f3db11e912c795a66450a1e2ae70e9819c2f079b956584339f0be0b7241204cacf10153dd8e57e2b9ab4eb9730603d323ddfa801509774f24279435733c
|
data/ChangeLog
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
1.1.4
|
|
2
|
+
Fix circular dependency
|
|
3
|
+
|
|
4
|
+
1.1.2
|
|
5
|
+
Make rss_bytes return bytes in linux/OS X, like it always should have
|
|
6
|
+
|
|
7
|
+
1.1.1
|
|
8
|
+
fix skip blank lines in OS#parse_os_release
|
|
9
|
+
|
|
10
|
+
1.1.0
|
|
11
|
+
Add app_config_path method
|
|
12
|
+
Cleans up dev dependency specs
|
|
13
|
+
Detect underlying Docker containers method
|
|
14
|
+
Add Linux-specific OS#parse_os_release method
|
|
15
|
+
|
|
1
16
|
1.0.1
|
|
2
17
|
add within docker method
|
|
3
18
|
|
data/Gemfile.lock
CHANGED
|
@@ -9,14 +9,6 @@ GEM
|
|
|
9
9
|
diff-lcs (1.1.3)
|
|
10
10
|
power_assert (1.0.2)
|
|
11
11
|
rake (0.9.6)
|
|
12
|
-
rspec (2.5.0)
|
|
13
|
-
rspec-core (~> 2.5.0)
|
|
14
|
-
rspec-expectations (~> 2.5.0)
|
|
15
|
-
rspec-mocks (~> 2.5.0)
|
|
16
|
-
rspec-core (2.5.2)
|
|
17
|
-
rspec-expectations (2.5.0)
|
|
18
|
-
diff-lcs (~> 1.1.2)
|
|
19
|
-
rspec-mocks (2.5.0)
|
|
20
12
|
test-unit (3.2.3)
|
|
21
13
|
power_assert
|
|
22
14
|
|
|
@@ -25,7 +17,6 @@ PLATFORMS
|
|
|
25
17
|
x86-mingw32
|
|
26
18
|
|
|
27
19
|
DEPENDENCIES
|
|
28
|
-
os!
|
|
29
20
|
rake (~> 0.8)
|
|
30
21
|
rspec (~> 2.5.0)
|
|
31
22
|
test-unit (~> 3)
|
data/README.md
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
The OS gem allows for some easy telling if you're on windows or not.
|
|
2
|
+
|
|
3
|
+
```ruby
|
|
4
|
+
require 'os'
|
|
5
|
+
|
|
6
|
+
>> OS.windows?
|
|
7
|
+
=> true # or OS.doze?
|
|
8
|
+
|
|
9
|
+
>> OS.bits
|
|
10
|
+
=> 32
|
|
11
|
+
|
|
12
|
+
>> OS.java?
|
|
13
|
+
=> true # if you're running in jruby. Also OS.jruby?
|
|
14
|
+
|
|
15
|
+
>> OS.ruby_bin
|
|
16
|
+
=> "c:\ruby18\bin\ruby.exe" # or "/usr/local/bin/ruby" or what not
|
|
17
|
+
|
|
18
|
+
>> OS.posix?
|
|
19
|
+
=> false # true for linux, os x, cygwin
|
|
20
|
+
|
|
21
|
+
>> OS.mac? # or OS.osx? or OS.x?
|
|
22
|
+
=> false
|
|
23
|
+
|
|
24
|
+
>> OS.dev_null
|
|
25
|
+
=> "NUL" # or "/dev/null" depending on which platform
|
|
26
|
+
|
|
27
|
+
>> OS.rss_bytes
|
|
28
|
+
=> 12300033 # number of rss bytes this process is using currently. Basically "total in memory footprint" (doesn't include RAM used by the process that's in swap/page file)
|
|
29
|
+
|
|
30
|
+
>> puts OS.report
|
|
31
|
+
==> # a yaml report of helpful values
|
|
32
|
+
---
|
|
33
|
+
arch: x86_64-darwin10.6.0
|
|
34
|
+
target_os: darwin10.6.0
|
|
35
|
+
target_vendor: apple
|
|
36
|
+
target_cpu: x86_64
|
|
37
|
+
target: x86_64-apple-darwin10.6.0
|
|
38
|
+
host_os: darwin10.6.0
|
|
39
|
+
host_vendor: apple
|
|
40
|
+
host_cpu: i386
|
|
41
|
+
host: i386-apple-darwin10.6.0
|
|
42
|
+
RUBY_PLATFORM: x86_64-darwin10.6.0
|
|
43
|
+
|
|
44
|
+
>> OS.cpu_count
|
|
45
|
+
=> 2 # number of cores, doesn't include hyper-threaded cores.
|
|
46
|
+
|
|
47
|
+
>> OS.open_file_command
|
|
48
|
+
=> "start" # or open on mac, or xdg-open on linux (all designed to open a file)
|
|
49
|
+
|
|
50
|
+
>> OS::Underlying.windows?
|
|
51
|
+
=> true # true for cygwin or MRI, whereas OS.windows? is false for cygwin
|
|
52
|
+
|
|
53
|
+
>> OS::Underlying.bsd?
|
|
54
|
+
=> true # true for OS X
|
|
55
|
+
|
|
56
|
+
>> OS::Underlying.docker?
|
|
57
|
+
=> false # true if running inside a Docker container
|
|
58
|
+
|
|
59
|
+
>> pp OS.parse_os_release
|
|
60
|
+
==> # A hash of details on the current Linux distro (or an exception if not Linux)
|
|
61
|
+
{:NAME=>"Ubuntu",
|
|
62
|
+
:VERSION=>"18.04.4 LTS (Bionic Beaver)",
|
|
63
|
+
:ID=>"ubuntu",
|
|
64
|
+
:ID_LIKE=>"debian",
|
|
65
|
+
:PRETTY_NAME=>"Ubuntu 18.04.4 LTS",
|
|
66
|
+
:VERSION_ID=>"18.04",
|
|
67
|
+
:HOME_URL=>"https://www.ubuntu.com/",
|
|
68
|
+
:SUPPORT_URL=>"https://help.ubuntu.com/",
|
|
69
|
+
:BUG_REPORT_URL=>"https://bugs.launchpad.net/ubuntu/",
|
|
70
|
+
:PRIVACY_POLICY_URL=>
|
|
71
|
+
"https://www.ubuntu.com/legal/terms-and-policies/privacy-policy",
|
|
72
|
+
:VERSION_CODENAME=>"bionic",
|
|
73
|
+
:UBUNTU_CODENAME=>"bionic"}
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
If there are any other features you'd like, let me know, I'll do what I can to add them :)
|
|
77
|
+
|
|
78
|
+
http://github.com/rdp/os for feedback et al
|
|
79
|
+
|
|
80
|
+
Related projects:
|
|
81
|
+
|
|
82
|
+
rubygems:
|
|
83
|
+
|
|
84
|
+
```ruby
|
|
85
|
+
Gem::Platform.local
|
|
86
|
+
Gem.ruby
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
The reason Gem::Platform.local felt wrong to me is that it treated cygwin as windows--which for most build environments, is wrong. Hence the creation of this gem.
|
|
90
|
+
|
|
91
|
+
the facets gem (has a class similar to rubygems, above)
|
|
92
|
+
|
|
93
|
+
```ruby
|
|
94
|
+
require 'facets/platform'
|
|
95
|
+
Platform.local
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
the ["platform" gem](http://rubydoc.info/github/ffi/ffi/master/FFI/Platform), itself (a different gem)
|
|
99
|
+
|
|
100
|
+
```ruby
|
|
101
|
+
FFI::Platform::OS
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
License: MIT (see LICENSE file)
|
data/Rakefile
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
require 'rubygems' if RUBY_VERSION < '1.9.0'
|
|
2
2
|
|
|
3
|
+
# HOW TO DEPLOY
|
|
4
|
+
# bump VERSION file manually
|
|
5
|
+
# rake release seems all messed up, doesn't publish it anyway...
|
|
3
6
|
# 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
|
-
# #
|
|
7
|
+
# then manually edit os.gemspec remove duplicatee rspecs, circular dependency on os? HUH?
|
|
8
|
+
# # then gem build os.gemspec
|
|
9
|
+
# rake build doesn't work???
|
|
10
|
+
# sooo...
|
|
11
|
+
# ...gem push os-1.1.2.gem
|
|
6
12
|
|
|
7
13
|
begin
|
|
8
14
|
require 'jeweler'
|
|
@@ -16,7 +22,7 @@ begin
|
|
|
16
22
|
gem.license = "MIT"
|
|
17
23
|
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
|
18
24
|
# gem.add_development_dependency "fast_require"
|
|
19
|
-
gem.add_development_dependency "rspec", ">= 2.0"
|
|
25
|
+
# gem.add_development_dependency "rspec", ">= 2.0"
|
|
20
26
|
end
|
|
21
27
|
rescue LoadError => e
|
|
22
28
|
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler #{e}"
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
1.1.
|
|
1
|
+
1.1.4
|
data/lib/os.rb
CHANGED
|
@@ -155,15 +155,15 @@ class OS
|
|
|
155
155
|
end
|
|
156
156
|
processes = wmi.ExecQuery("select * from win32_process where ProcessId = #{Process.pid}")
|
|
157
157
|
memory_used = nil
|
|
158
|
-
# only allow for one...
|
|
158
|
+
# only allow for one process...
|
|
159
159
|
for process in processes
|
|
160
|
-
raise if memory_used
|
|
160
|
+
raise "multiple processes same pid?" if memory_used
|
|
161
161
|
memory_used = process.WorkingSetSize.to_i
|
|
162
162
|
end
|
|
163
163
|
memory_used
|
|
164
164
|
end
|
|
165
165
|
elsif OS.posix? # linux [though I've heard it works in OS X]
|
|
166
|
-
`ps -o rss= -p #{Process.pid}`.to_i # in
|
|
166
|
+
`ps -o rss= -p #{Process.pid}`.to_i * 1024 # in kiloBytes
|
|
167
167
|
else
|
|
168
168
|
raise 'unknown rss for this platform'
|
|
169
169
|
end
|
|
@@ -288,6 +288,7 @@ class OS
|
|
|
288
288
|
|
|
289
289
|
File.read('/etc/os-release').each_line do |line|
|
|
290
290
|
parsed_line = line.chomp.tr('"', '').split('=')
|
|
291
|
+
next if parsed_line.empty?
|
|
291
292
|
output[parsed_line[0].to_sym] = parsed_line[1]
|
|
292
293
|
end
|
|
293
294
|
output
|
data/os.gemspec
CHANGED
|
@@ -2,22 +2,22 @@
|
|
|
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.1.
|
|
5
|
+
# stub: os 1.1.4 ruby lib
|
|
6
6
|
|
|
7
7
|
Gem::Specification.new do |s|
|
|
8
8
|
s.name = "os".freeze
|
|
9
|
-
s.version = "1.1.
|
|
9
|
+
s.version = "1.1.4"
|
|
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 = "2021-11-07"
|
|
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 = [
|
|
18
18
|
"ChangeLog",
|
|
19
19
|
"LICENSE",
|
|
20
|
-
"README.
|
|
20
|
+
"README.md"
|
|
21
21
|
]
|
|
22
22
|
s.files = [
|
|
23
23
|
".autotest",
|
|
@@ -26,7 +26,7 @@ Gem::Specification.new do |s|
|
|
|
26
26
|
"Gemfile",
|
|
27
27
|
"Gemfile.lock",
|
|
28
28
|
"LICENSE",
|
|
29
|
-
"README.
|
|
29
|
+
"README.md",
|
|
30
30
|
"Rakefile",
|
|
31
31
|
"VERSION",
|
|
32
32
|
"autotest/discover.rb",
|
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.1.
|
|
4
|
+
version: 1.1.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- rdp
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date:
|
|
12
|
+
date: 2021-11-07 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: rake
|
|
@@ -61,7 +61,7 @@ extensions: []
|
|
|
61
61
|
extra_rdoc_files:
|
|
62
62
|
- ChangeLog
|
|
63
63
|
- LICENSE
|
|
64
|
-
- README.
|
|
64
|
+
- README.md
|
|
65
65
|
files:
|
|
66
66
|
- ".autotest"
|
|
67
67
|
- ".document"
|
|
@@ -69,7 +69,7 @@ files:
|
|
|
69
69
|
- Gemfile
|
|
70
70
|
- Gemfile.lock
|
|
71
71
|
- LICENSE
|
|
72
|
-
- README.
|
|
72
|
+
- README.md
|
|
73
73
|
- Rakefile
|
|
74
74
|
- VERSION
|
|
75
75
|
- autotest/discover.rb
|
data/README.rdoc
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
The OS gem allows for some easy telling if you're on windows or not.
|
|
2
|
-
|
|
3
|
-
require 'os'
|
|
4
|
-
|
|
5
|
-
>> OS.windows?
|
|
6
|
-
=> true # or OS.doze?
|
|
7
|
-
|
|
8
|
-
>> OS.bits
|
|
9
|
-
=> 32
|
|
10
|
-
|
|
11
|
-
>> OS.java?
|
|
12
|
-
=> true # if you're running in jruby. Also OS.jruby?
|
|
13
|
-
|
|
14
|
-
>> OS.ruby_bin
|
|
15
|
-
=> "c:\ruby18\bin\ruby.exe" # or "/usr/local/bin/ruby" or what not
|
|
16
|
-
|
|
17
|
-
>> OS.posix?
|
|
18
|
-
=> false # true for linux, os x, cygwin
|
|
19
|
-
|
|
20
|
-
>> OS.mac? # or OS.osx? or OS.x?
|
|
21
|
-
=> false
|
|
22
|
-
|
|
23
|
-
>> OS.dev_null
|
|
24
|
-
=> "NUL" # or "/dev/null" depending on which platform
|
|
25
|
-
|
|
26
|
-
>> OS.rss_bytes
|
|
27
|
-
=> 12300033 # number of rss bytes this process is using currently. Basically "total in memory footprint" (doesn't include RAM used by the process that's in swap/page file)
|
|
28
|
-
|
|
29
|
-
>> puts OS.report
|
|
30
|
-
==> # a yaml report of helpful values
|
|
31
|
-
---
|
|
32
|
-
arch: x86_64-darwin10.6.0
|
|
33
|
-
target_os: darwin10.6.0
|
|
34
|
-
target_vendor: apple
|
|
35
|
-
target_cpu: x86_64
|
|
36
|
-
target: x86_64-apple-darwin10.6.0
|
|
37
|
-
host_os: darwin10.6.0
|
|
38
|
-
host_vendor: apple
|
|
39
|
-
host_cpu: i386
|
|
40
|
-
host: i386-apple-darwin10.6.0
|
|
41
|
-
RUBY_PLATFORM: x86_64-darwin10.6.0
|
|
42
|
-
|
|
43
|
-
>> OS.cpu_count
|
|
44
|
-
=> 2 # number of cores, doesn't include hyper-threaded cores.
|
|
45
|
-
|
|
46
|
-
>> OS.open_file_command
|
|
47
|
-
=> "start" # or open on mac, or xdg-open on linux (all designed to open a file)
|
|
48
|
-
|
|
49
|
-
>> OS::Underlying.windows?
|
|
50
|
-
=> true # true for cygwin or MRI, whereas OS.windows? is false for cygwin
|
|
51
|
-
|
|
52
|
-
>> OS::Underlying.bsd?
|
|
53
|
-
=> true # true for OS X
|
|
54
|
-
|
|
55
|
-
>> OS::Underlying.docker?
|
|
56
|
-
=> false # true if running inside a Docker container
|
|
57
|
-
|
|
58
|
-
If there are any other features you'd like, let me know, I'll do what I can to add them :)
|
|
59
|
-
|
|
60
|
-
http://github.com/rdp/os for feedback et al
|
|
61
|
-
|
|
62
|
-
Related projects:
|
|
63
|
-
|
|
64
|
-
rubygems:
|
|
65
|
-
Gem::Platform.local
|
|
66
|
-
Gem.ruby
|
|
67
|
-
The reason Gem::Platform.local felt wrong to me is that it treated cygwin as windows--which for most build environments, is wrong. Hence the creation of this gem.
|
|
68
|
-
|
|
69
|
-
the facets gem (has a class similar to rubygems, above)
|
|
70
|
-
require 'facets/platform'
|
|
71
|
-
Platform.local
|
|
72
|
-
|
|
73
|
-
the "platform" gem, itself (a different gem)
|
|
74
|
-
|
|
75
|
-
FFI::Platform::OS
|
|
76
|
-
http://rubydoc.info/github/ffi/ffi/master/FFI/Platform
|
|
77
|
-
|
|
78
|
-
License: MIT (see LICENSE file)
|