rack-serverinfo 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rack/serverinfo.rb +63 -21
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 43d31a0259e387b22b4221ed71d3e720dcbc31bb
|
4
|
+
data.tar.gz: 6e4451af4414912abeb0f173fd0a639717a37df0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b540e6b2e0f639506a5838a4bcd47fd1f47b01edfef17cac21fcd4135b84fbbf2dee66fe6302d8078631ae8044f8a8f9d2166ada2a10e8eccbc2cf7a60a65d83
|
7
|
+
data.tar.gz: 2e4548b4f0d7b4b4270ed157f2c1accc81b5e458c1de6d7141f19f4a7edb60892fa654de3f8ddaf14b47b4757dd6d72801dd53e35cfe8260a272679979ab306d
|
data/lib/rack/serverinfo.rb
CHANGED
@@ -5,13 +5,27 @@ module Rack
|
|
5
5
|
|
6
6
|
class Serverinfo < Plastic
|
7
7
|
|
8
|
+
DatabaseYamlPath = 'config/database.yml'
|
9
|
+
|
8
10
|
def change_nokogiri_doc(doc)
|
9
11
|
return doc if request.xhr?
|
10
12
|
|
11
|
-
badge = doc.create_element 'div', style:
|
13
|
+
badge = doc.create_element 'div', style: badge_style
|
14
|
+
|
15
|
+
badge.add_child(doc.create_element('pre', server_info_text, style: pre_style))
|
16
|
+
|
17
|
+
if db_connection_config.empty?
|
18
|
+
badge.add_child(doc.create_element('pre', "DB: database.yml does not exist", style: pre_style))
|
19
|
+
else
|
20
|
+
db_detail_container = doc.create_element 'details'
|
12
21
|
|
13
|
-
|
14
|
-
|
22
|
+
db_detail_container.add_child(doc.create_element('summary', "DB: #{db_connection_config['database']}"))
|
23
|
+
|
24
|
+
db_connection_config.each do |key, value|
|
25
|
+
db_detail_container.add_child(doc.create_element('p', "#{key}: #{value}", style: "padding-left: 9.5px;margin: 0;"))
|
26
|
+
end
|
27
|
+
|
28
|
+
badge.add_child(db_detail_container)
|
15
29
|
end
|
16
30
|
|
17
31
|
append_to_body(doc, badge)
|
@@ -23,25 +37,53 @@ module Rack
|
|
23
37
|
|
24
38
|
def server_info_text
|
25
39
|
@server_info_text ||= [
|
26
|
-
"Hostname:
|
27
|
-
"User:
|
28
|
-
"
|
29
|
-
]
|
40
|
+
"Hostname: #{hostname}",
|
41
|
+
"User: #{user.name}",
|
42
|
+
"RAILS_ENV: #{rails_env}",
|
43
|
+
].join("\n")
|
44
|
+
end
|
45
|
+
|
46
|
+
def pre_style
|
47
|
+
@pre_style ||= <<-pre_style
|
48
|
+
display: block;
|
49
|
+
padding: 0 0 0 9.5px;
|
50
|
+
margin: 0;
|
51
|
+
font-size: 10px;
|
52
|
+
line-height: 12px;
|
53
|
+
word-break: break-all;
|
54
|
+
word-wrap: break-word;
|
55
|
+
white-space: pre;
|
56
|
+
white-space: pre-wrap;
|
57
|
+
background-color: black;
|
58
|
+
pre_style
|
59
|
+
end
|
60
|
+
|
61
|
+
def badge_style
|
62
|
+
@badge_style ||= [
|
63
|
+
'position: absolute',
|
64
|
+
'bottom: 10px',
|
65
|
+
'right: 10px',
|
66
|
+
'border: 4px solid red',
|
67
|
+
'padding: 5px',
|
68
|
+
'border-radius: 5px',
|
69
|
+
'background-color: black',
|
70
|
+
'opacity: 0.5',
|
71
|
+
'color: white',
|
72
|
+
'font-size: 10px',
|
73
|
+
'font-family: monospace',
|
74
|
+
].join(';')
|
30
75
|
end
|
31
76
|
|
32
|
-
def
|
33
|
-
@
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
'color: white;',
|
43
|
-
'font-size: 10px;',
|
44
|
-
].join
|
77
|
+
def db_name
|
78
|
+
@db_name ||= db_connection_config['database']
|
79
|
+
end
|
80
|
+
|
81
|
+
def db_connection_config
|
82
|
+
@db_connection_config ||= if ::File.file?(DatabaseYamlPath)
|
83
|
+
YAML.load_file(DatabaseYamlPath)[rails_env]
|
84
|
+
else
|
85
|
+
{}
|
86
|
+
end
|
45
87
|
end
|
46
88
|
|
47
89
|
def user
|
@@ -49,7 +91,7 @@ module Rack
|
|
49
91
|
end
|
50
92
|
|
51
93
|
def rails_env
|
52
|
-
@rails_env ||= ENV['RAILS_ENV']
|
94
|
+
@rails_env ||= (ENV['RAILS_ENV'] || 'not set')
|
53
95
|
end
|
54
96
|
|
55
97
|
def hostname
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-serverinfo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Roman Simecek
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-01-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack-plastic
|
@@ -80,7 +80,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
80
80
|
version: '0'
|
81
81
|
requirements: []
|
82
82
|
rubyforge_project:
|
83
|
-
rubygems_version: 2.4.
|
83
|
+
rubygems_version: 2.4.5
|
84
84
|
signing_key:
|
85
85
|
specification_version: 4
|
86
86
|
summary: Show information of the app.
|