host-os 0.1.0 → 0.2.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 +4 -4
- data/.yardopts +7 -0
- data/LICENSE +1 -1
- data/README.md +1 -3
- data/lib/host-os/support.rb +23 -18
- data/lib/host-os/version.rb +1 -1
- data/lib/host-os.rb +40 -57
- metadata +7 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8259f7f3965b419b1c41233b4e6a1a2726b78662f5506e3d397a0cab916ea5bc
|
4
|
+
data.tar.gz: a0dabfba2f2ac721b422d62c0eb297ca42e0942215399974f43061dded676ba3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f554e8e5562e7c1bc5d58bd45422529e3838bb6e21cfc132b3f3010c639ed78c9928f2433868091e540ac50553b578245afc77e52fa63463520f3dd81f33cb2b
|
7
|
+
data.tar.gz: 2210f64c92376f4f498e4d3d3041bb36a1f5a2c2eb592c6686540f21c037d979e0a72251d973ad94e0c6995e54bb8d2a4cce9bbfa66dd0855e0aa567cc33d816
|
data/.yardopts
ADDED
data/LICENSE
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
BSD 3-Clause License
|
2
2
|
|
3
|
-
Copyright (c) 2017-
|
3
|
+
Copyright (c) 2017-2025, Mike Blumtritt. All rights reserved.
|
4
4
|
|
5
5
|
Redistribution and use in source and binary forms, with or without
|
6
6
|
modification, are permitted provided that the following conditions are met:
|
data/README.md
CHANGED
@@ -1,6 +1,4 @@
|
|
1
|
-
# HostOS
|
2
|
-
|
3
|
-

|
1
|
+
# HostOS 
|
4
2
|
|
5
3
|
HostOS is a module that offers details about the host operating system, the current Ruby interpreter, and the environment currently in use.
|
6
4
|
|
data/lib/host-os/support.rb
CHANGED
@@ -32,8 +32,8 @@ module HostOS
|
|
32
32
|
# @!method app_config_path(app_name)
|
33
33
|
# @param app_name [String] name of the application
|
34
34
|
# @return [String] absolute name of the directory
|
35
|
-
# Determines the name of the directory where application specific data
|
36
|
-
# be stored.
|
35
|
+
# Determines the name of the directory where application specific data
|
36
|
+
# should be stored.
|
37
37
|
# @note This method is only available on Windows and Posix-compatible
|
38
38
|
# systems.
|
39
39
|
|
@@ -129,19 +129,31 @@ module HostOS
|
|
129
129
|
|
130
130
|
def find_suggested_thread_count
|
131
131
|
count = ENV['TC'].to_i
|
132
|
-
count
|
132
|
+
return count if count > 0
|
133
|
+
begin
|
134
|
+
require('etc') unless defined?(Etc)
|
135
|
+
Etc.nprocessors
|
136
|
+
rescue LoadError
|
137
|
+
4
|
138
|
+
end
|
133
139
|
end
|
134
140
|
|
135
141
|
def find_temp_dir
|
136
142
|
return Dir.tmpdir if defined?(Dir.tmpdir)
|
137
|
-
as_dir('TMPDIR') || as_dir('TMP') || as_dir('TEMP')
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
143
|
+
ret = as_dir('TMPDIR') || as_dir('TMP') || as_dir('TEMP')
|
144
|
+
return ret if ret
|
145
|
+
ret =
|
146
|
+
begin
|
147
|
+
require('etc') unless defined?(Etc)
|
148
|
+
Etc.systmpdir
|
149
|
+
rescue LoadError
|
150
|
+
"#{ENV['LOCALAPPDATA']}/Temp"
|
151
|
+
end
|
152
|
+
as_dir('system temp', ret) || as_dir('/tmp', '/tmp') || as_dir('.', '.')
|
153
|
+
end
|
154
|
+
|
155
|
+
def as_dir(name, dirname = nil)
|
156
|
+
dirname ||= ENV[name]
|
145
157
|
return if dirname.nil? || dirname.empty?
|
146
158
|
dirname = File.expand_path(dirname)
|
147
159
|
stat = File.stat(dirname)
|
@@ -153,13 +165,6 @@ module HostOS
|
|
153
165
|
rescue SystemCallError
|
154
166
|
nil
|
155
167
|
end
|
156
|
-
|
157
|
-
def with_etc(default)
|
158
|
-
require('etc') unless defined?(Etc)
|
159
|
-
yield
|
160
|
-
rescue LoadError
|
161
|
-
default
|
162
|
-
end
|
163
168
|
end
|
164
169
|
end
|
165
170
|
|
data/lib/host-os/version.rb
CHANGED
data/lib/host-os.rb
CHANGED
@@ -8,11 +8,11 @@
|
|
8
8
|
module HostOS
|
9
9
|
module Helper
|
10
10
|
def is?(what)
|
11
|
-
|
12
|
-
|
11
|
+
id == what ||
|
12
|
+
(id == (defined?(what.to_sym) ? what.to_sym : what.to_s.to_sym))
|
13
13
|
end
|
14
14
|
|
15
|
-
|
15
|
+
private
|
16
16
|
|
17
17
|
def respond_to_missing?(name, _include_all = false)
|
18
18
|
(name[-1] == '?') || super
|
@@ -78,10 +78,8 @@ module HostOS
|
|
78
78
|
|
79
79
|
def identify
|
80
80
|
found =
|
81
|
-
|
82
|
-
ENV['
|
83
|
-
ENV['ENV']
|
84
|
-
)
|
81
|
+
ENV['RAILS_ENV'] || ENV['RACK_ENV'] || ENV['ENVIRONMENT'] ||
|
82
|
+
ENV['ENV']
|
85
83
|
return :production if found.nil? || found.empty?
|
86
84
|
found.downcase.tr(' -', '__').to_sym
|
87
85
|
end
|
@@ -113,8 +111,8 @@ module HostOS
|
|
113
111
|
end
|
114
112
|
|
115
113
|
# @attribute [r] mri?
|
116
|
-
# @return [true, false] whether the interpreter is the Yukihiro
|
117
|
-
# C-based (default) Ruby Interpreter
|
114
|
+
# @return [true, false] whether the interpreter is the Yukihiro
|
115
|
+
# Matsumoto's C-based (default) Ruby Interpreter
|
118
116
|
def mri?
|
119
117
|
ID == :mri
|
120
118
|
end
|
@@ -122,8 +120,8 @@ module HostOS
|
|
122
120
|
alias default? mri?
|
123
121
|
|
124
122
|
# @attribute [r] cardinal?
|
125
|
-
# @return [true, false] whether the interpreter is the Parrot based
|
126
|
-
# interpreter
|
123
|
+
# @return [true, false] whether the interpreter is the Parrot based
|
124
|
+
# Cardinal interpreter
|
127
125
|
def cardinal?
|
128
126
|
ID == :cardinal
|
129
127
|
end
|
@@ -138,7 +136,8 @@ module HostOS
|
|
138
136
|
alias java? jruby?
|
139
137
|
|
140
138
|
# @attribute [r] rbx?
|
141
|
-
# @return [true, false] whether the interpreter is the Rubinius
|
139
|
+
# @return [true, false] whether the interpreter is the Rubinius
|
140
|
+
# Interpreter
|
142
141
|
def rbx?
|
143
142
|
ID == :rbx
|
144
143
|
end
|
@@ -171,22 +170,7 @@ module HostOS
|
|
171
170
|
|
172
171
|
# @!visibility private
|
173
172
|
def to_s
|
174
|
-
|
175
|
-
when :mri
|
176
|
-
'CRuby'
|
177
|
-
when :ree
|
178
|
-
'Enterprise Ruby'
|
179
|
-
when :cardinal
|
180
|
-
'Cardinal'
|
181
|
-
when :jruby
|
182
|
-
'JRuby'
|
183
|
-
when :rby
|
184
|
-
'Rubinius'
|
185
|
-
when :truffleruby
|
186
|
-
'TruffleRuby'
|
187
|
-
else
|
188
|
-
ID.to_s.upcase
|
189
|
-
end
|
173
|
+
NAMES[ID] || ID.to_s.upcase
|
190
174
|
end
|
191
175
|
|
192
176
|
# @!method is?(what)
|
@@ -209,6 +193,17 @@ module HostOS
|
|
209
193
|
|
210
194
|
# @return [Symbol] interpreter identifier
|
211
195
|
ID = identify
|
196
|
+
|
197
|
+
NAMES = {
|
198
|
+
cardinal: 'Cardinal',
|
199
|
+
jruby: 'JRuby',
|
200
|
+
mri: 'CRuby',
|
201
|
+
rby: 'Rubinius',
|
202
|
+
ree: 'Enterprise Ruby',
|
203
|
+
truffleruby: 'TruffleRuby'
|
204
|
+
}.compare_by_identity.freeze
|
205
|
+
|
206
|
+
private_constant :NAMES
|
212
207
|
end
|
213
208
|
|
214
209
|
extend Helper
|
@@ -298,34 +293,7 @@ module HostOS
|
|
298
293
|
|
299
294
|
# @!visibility private
|
300
295
|
def to_s
|
301
|
-
|
302
|
-
when :linux
|
303
|
-
'Linux'
|
304
|
-
when :macosx
|
305
|
-
'MacOSX'
|
306
|
-
when :freebsd
|
307
|
-
'FreeBSD'
|
308
|
-
when :netbsd
|
309
|
-
'NetBSD'
|
310
|
-
when :openbsd
|
311
|
-
'OpenBSD'
|
312
|
-
when :dragonfly
|
313
|
-
'Dragonly'
|
314
|
-
when :sunis
|
315
|
-
'SunOS'
|
316
|
-
when :mswin
|
317
|
-
'MSWin'
|
318
|
-
when :mingw
|
319
|
-
'MinGW'
|
320
|
-
when :bccwin
|
321
|
-
'BCCWin'
|
322
|
-
when :wince
|
323
|
-
'WinCE'
|
324
|
-
when :windows, :cygwin
|
325
|
-
ID.to_s.capitalize
|
326
|
-
else
|
327
|
-
ID.to_s.upcase
|
328
|
-
end
|
296
|
+
NAMES[ID] || ID.to_s.upcase
|
329
297
|
end
|
330
298
|
|
331
299
|
private
|
@@ -335,7 +303,7 @@ module HostOS
|
|
335
303
|
id = RbConfig::CONFIG['host_os'].downcase
|
336
304
|
id, type, normalized =
|
337
305
|
[
|
338
|
-
['linux', :unix],
|
306
|
+
['linux', :unix, :linux],
|
339
307
|
['arch', :unix, :linux],
|
340
308
|
['darwin', :unix, :macosx],
|
341
309
|
['mac', :unix, :macosx],
|
@@ -364,4 +332,19 @@ module HostOS
|
|
364
332
|
end
|
365
333
|
|
366
334
|
ID, TYPE = identify
|
335
|
+
NAMES = {
|
336
|
+
bccwin: 'BCCWin',
|
337
|
+
cygwin: 'Cygwin',
|
338
|
+
dragonfly: 'Dragonly',
|
339
|
+
freebsd: 'FreeBSD',
|
340
|
+
linux: 'Linux',
|
341
|
+
macosx: 'MacOSX',
|
342
|
+
mingw: 'MinGW',
|
343
|
+
mswin: 'MSWin',
|
344
|
+
netbsd: 'NetBSD',
|
345
|
+
openbsd: 'OpenBSD',
|
346
|
+
sunos: 'SunOS',
|
347
|
+
wince: 'WinCE',
|
348
|
+
windows: 'Windows'
|
349
|
+
}.compare_by_identity.freeze
|
367
350
|
end
|
metadata
CHANGED
@@ -1,26 +1,25 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: host-os
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Blumtritt
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
12
11
|
dependencies: []
|
13
12
|
description: |
|
14
13
|
This gem helps you write environment-specific code in a clean way.
|
15
14
|
It provides a simple API to get information about the operating system,
|
16
15
|
the current Ruby interpreter, and the configured environment.
|
17
|
-
email:
|
18
16
|
executables: []
|
19
17
|
extensions: []
|
20
18
|
extra_rdoc_files:
|
21
|
-
- README.md
|
22
19
|
- LICENSE
|
20
|
+
- README.md
|
23
21
|
files:
|
22
|
+
- ".yardopts"
|
24
23
|
- LICENSE
|
25
24
|
- README.md
|
26
25
|
- examples/current.rb
|
@@ -36,23 +35,21 @@ metadata:
|
|
36
35
|
bug_tracker_uri: https://github.com/mblumtritt/host-os/issues
|
37
36
|
documentation_uri: https://rubydoc.info/gems/host-os
|
38
37
|
rubygems_mfa_required: 'true'
|
39
|
-
post_install_message:
|
40
38
|
rdoc_options: []
|
41
39
|
require_paths:
|
42
40
|
- lib
|
43
41
|
required_ruby_version: !ruby/object:Gem::Requirement
|
44
42
|
requirements:
|
45
|
-
- - "
|
43
|
+
- - ">="
|
46
44
|
- !ruby/object:Gem::Version
|
47
|
-
version: '2.
|
45
|
+
version: '2.7'
|
48
46
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
49
47
|
requirements:
|
50
48
|
- - ">="
|
51
49
|
- !ruby/object:Gem::Version
|
52
50
|
version: '0'
|
53
51
|
requirements: []
|
54
|
-
rubygems_version: 3.
|
55
|
-
signing_key:
|
52
|
+
rubygems_version: 3.6.9
|
56
53
|
specification_version: 4
|
57
54
|
summary: This module offers details on the host OS, the present Ruby interpreter and
|
58
55
|
environment.
|