fedux_org-stdlib 0.6.48 → 0.6.50
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/Gemfile +1 -0
- data/Gemfile.lock +5 -1
- data/lib/fedux_org_stdlib/support_information.rb +126 -0
- data/lib/fedux_org_stdlib/version.rb +1 -1
- data/spec/support_information_spec.rb +14 -0
- metadata +4 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e36cbb86b6e9ed576270aa374bed8503f2a6b500
|
4
|
+
data.tar.gz: 7a2e7d2417bcfc93e5698e85b9f309827a845e84
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eca15dfe51988a7a8d6ebc434acc221efbc579eb2fda0c196e97268d27be00c4fb78fdebabf09aa63b75354f331ee0f9d9c0c3bdcbbb38239f9a73e2779af716
|
7
|
+
data.tar.gz: d6e57129ef8ff2f0cc89287c7f6aff9a867fa4b1fbab00704e1427fa97576967cad3812e9ce02ac7a975b57029b12bcee333ab6d64766089b6bb078b0cdc5aaa
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
fedux_org-stdlib (0.6.
|
4
|
+
fedux_org-stdlib (0.6.49)
|
5
5
|
activesupport
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
|
+
CFPropertyList (2.2.8)
|
10
11
|
activesupport (4.1.4)
|
11
12
|
i18n (~> 0.6, >= 0.6.9)
|
12
13
|
json (~> 1.7, >= 1.7.7)
|
@@ -49,6 +50,8 @@ GEM
|
|
49
50
|
diff-lcs (1.2.5)
|
50
51
|
docile (1.1.5)
|
51
52
|
erubis (2.7.0)
|
53
|
+
facter (2.1.0)
|
54
|
+
CFPropertyList (~> 2.2.6)
|
52
55
|
ffi (1.9.3)
|
53
56
|
filegen (0.4.3)
|
54
57
|
activesupport
|
@@ -152,6 +155,7 @@ DEPENDENCIES
|
|
152
155
|
coveralls
|
153
156
|
cucumber
|
154
157
|
erubis
|
158
|
+
facter
|
155
159
|
fedux_org-stdlib!
|
156
160
|
filegen
|
157
161
|
fuubar
|
@@ -0,0 +1,126 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require_library %w{ facter }
|
3
|
+
|
4
|
+
module FeduxOrgStdlib
|
5
|
+
class SupportInformation
|
6
|
+
private
|
7
|
+
|
8
|
+
attr_reader :logger
|
9
|
+
|
10
|
+
public
|
11
|
+
|
12
|
+
def initialize(logger: FeduxOrgStdlib::Logging::Logger.new)
|
13
|
+
@logger = logger
|
14
|
+
end
|
15
|
+
|
16
|
+
# Output support information as string
|
17
|
+
#
|
18
|
+
# @return [String]
|
19
|
+
# The available information
|
20
|
+
def to_s
|
21
|
+
result = []
|
22
|
+
|
23
|
+
max_field_length = determine_max_field_length(facter_fields)
|
24
|
+
|
25
|
+
result << format("%#{max_field_length}s | %s", 'Information', 'Value')
|
26
|
+
result << format("%s + %s", '-' * max_field_length, '-' * 40)
|
27
|
+
result.concat system_information.sort_by { |key, value| key }.map { |key, value| format("%#{max_field_length}s | %s", key, value) }
|
28
|
+
|
29
|
+
result << ""
|
30
|
+
result << ""
|
31
|
+
result << ""
|
32
|
+
|
33
|
+
max_field_length = determine_max_field_length(rubygems_information.keys)
|
34
|
+
|
35
|
+
result << format("%#{max_field_length}s | %s", 'Information', 'Value')
|
36
|
+
result << format("%s + %s", '-' * max_field_length, '-' * 40)
|
37
|
+
result.concat rubygems_information.sort_by { |key, value| key }.map { |key, value| format("%#{max_field_length}s | %s", key, value) }
|
38
|
+
|
39
|
+
result << ""
|
40
|
+
result << ""
|
41
|
+
result << ""
|
42
|
+
|
43
|
+
max_field_length = determine_max_field_length(installed_rubygems.keys)
|
44
|
+
|
45
|
+
result << format("%#{max_field_length}s | %s", 'Name', 'version')
|
46
|
+
result << format("%s + %s", '-' * max_field_length, '-' * 40)
|
47
|
+
result.concat installed_rubygems.sort_by { |key, value| key }.map { |key, value| format("%#{max_field_length}s | %s", key, value) }
|
48
|
+
|
49
|
+
result.join "\n"
|
50
|
+
end
|
51
|
+
|
52
|
+
private
|
53
|
+
|
54
|
+
def rubygems_information
|
55
|
+
result = {}
|
56
|
+
result[:ruby] = Gem.ruby
|
57
|
+
result[:ruby_engine] = Gem.ruby_engine
|
58
|
+
result[:ruby_api_version] = Gem.ruby_engine
|
59
|
+
result[:rubygems_version] = Gem.rubygems_version
|
60
|
+
|
61
|
+
result
|
62
|
+
end
|
63
|
+
|
64
|
+
def installed_rubygems
|
65
|
+
result = {}
|
66
|
+
Gem::Specification.find_all.each_with_object(result) { |e, a| a[e.name] = e.version }
|
67
|
+
|
68
|
+
result
|
69
|
+
end
|
70
|
+
|
71
|
+
def system_information
|
72
|
+
Timeout::timeout(10) do
|
73
|
+
Facter.to_hash.keep_if { |key,_| facter_fields.include?(key.to_s) }
|
74
|
+
end
|
75
|
+
rescue Timeout::Error
|
76
|
+
logger.warn 'Getting environment information took to long. Please make sure the name resolver is available. This might cause the latency.'
|
77
|
+
{}
|
78
|
+
end
|
79
|
+
|
80
|
+
def determine_max_field_length(list)
|
81
|
+
list.inject(0) { |memo, f| memo = f.size if f.size > memo ; memo}
|
82
|
+
end
|
83
|
+
|
84
|
+
def facter_fields
|
85
|
+
%w[
|
86
|
+
architecture
|
87
|
+
filesystems
|
88
|
+
hardwareisa
|
89
|
+
hardwaremodel
|
90
|
+
is_virtual
|
91
|
+
kernel
|
92
|
+
kernelmajversion
|
93
|
+
kernelrelease
|
94
|
+
kernelversion
|
95
|
+
memoryfree
|
96
|
+
memoryfree_mb
|
97
|
+
memorysize
|
98
|
+
memorysize_mb
|
99
|
+
memorytotal
|
100
|
+
operatingsystem
|
101
|
+
operatingsystemrelease
|
102
|
+
osfamily
|
103
|
+
path
|
104
|
+
physicalprocessorcount
|
105
|
+
processor0
|
106
|
+
processor1
|
107
|
+
processorcount
|
108
|
+
ps
|
109
|
+
rubysitedir
|
110
|
+
rubyversion
|
111
|
+
selinux
|
112
|
+
swapfree
|
113
|
+
swapfree_mb
|
114
|
+
swapsize
|
115
|
+
swapsize_mb
|
116
|
+
timezone
|
117
|
+
uptime
|
118
|
+
uptime_days
|
119
|
+
uptime_hours
|
120
|
+
uptime_seconds
|
121
|
+
virtual
|
122
|
+
]
|
123
|
+
end
|
124
|
+
|
125
|
+
end
|
126
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
require 'fedux_org_stdlib/support_information'
|
4
|
+
|
5
|
+
RSpec.describe SupportInformation do
|
6
|
+
context '#to_s' do
|
7
|
+
it 'returns support information as string' do
|
8
|
+
info = SupportInformation.new
|
9
|
+
expect(info.to_s).to include 'kernelversion'
|
10
|
+
expect(info.to_s).to include 'rubyversion'
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fedux_org-stdlib
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.50
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Max Meyer
|
@@ -126,6 +126,7 @@ files:
|
|
126
126
|
- lib/fedux_org_stdlib/require_files.rb
|
127
127
|
- lib/fedux_org_stdlib/shell_language_detector.rb
|
128
128
|
- lib/fedux_org_stdlib/shell_language_detector/language.rb
|
129
|
+
- lib/fedux_org_stdlib/support_information.rb
|
129
130
|
- lib/fedux_org_stdlib/template_directory.rb
|
130
131
|
- lib/fedux_org_stdlib/template_directory/exceptions.rb
|
131
132
|
- lib/fedux_org_stdlib/version.rb
|
@@ -181,6 +182,7 @@ files:
|
|
181
182
|
- spec/support/reporting.rb
|
182
183
|
- spec/support/rspec.rb
|
183
184
|
- spec/support/string.rb
|
185
|
+
- spec/support_information_spec.rb
|
184
186
|
- spec/template_directory_spec.rb
|
185
187
|
- spec/template_file_spec.rb
|
186
188
|
- spec/version_management/library_builder_spec.rb
|
@@ -254,6 +256,7 @@ test_files:
|
|
254
256
|
- spec/support/reporting.rb
|
255
257
|
- spec/support/rspec.rb
|
256
258
|
- spec/support/string.rb
|
259
|
+
- spec/support_information_spec.rb
|
257
260
|
- spec/template_directory_spec.rb
|
258
261
|
- spec/template_file_spec.rb
|
259
262
|
- spec/version_management/library_builder_spec.rb
|