hud 2.1.0 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/hud/version.rb +1 -1
  3. data/lib/hud.rb +35 -29
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 510809be4205ebd4d8af9a8a7f83948bf0040d41ca203a7ef38b27ab8f6f9318
4
- data.tar.gz: 79af03a89812d9d2b8c20b1a39edb44c5334e5abf7b9bfbac7ca0741e75f3641
3
+ metadata.gz: cd14aa710d44347443dcb1e30575b50c873a22d051f20281bb5d1aa33b00fb82
4
+ data.tar.gz: e6af8ae9a8703fa028f88b1d2d379080abec3864eec58fa9244fc5ac3f28f071
5
5
  SHA512:
6
- metadata.gz: 072c31cc873cb7506d8b6336251469a4f91da953902a08c3bfb6b2932d549850b62d792a62cb292a48dc96b277294c4312bcaee82d9b1c871153059bc51a3e6c
7
- data.tar.gz: e8f9666535a6597bd940136d89f5338bcd7b1a75c94362d74290925f78f48d785ed674d1cbea5b3443b4cdf0d53e5b46b2f02afe1a83334c6bf7ee27f4fed702
6
+ metadata.gz: f05b56d9e6d079724b108fd6f060268c220333c5cb90c6ca8249cd5bf3b77037be0c23e6b288fb77ddb4cc0e5d9f2d9e890c29393e256e26fea23a07de687862
7
+ data.tar.gz: 6b260356cd613124088dbc77ea4dd0ff5ad9944862e5324a4ceb4b865eefc0098d97dbe4902d3623a599f5b256123b866afb0922dd4144caebb3210c5fe8411b
data/lib/hud/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Hud
2
- VERSION = '2.1.0'
2
+ VERSION = '2.2.0'
3
3
  end
data/lib/hud.rb CHANGED
@@ -17,31 +17,34 @@ module Hud
17
17
  configuration.components_dirs = []
18
18
  yield(configuration)
19
19
  end
20
- module Middleware
20
+ module Middleware
21
21
 
22
22
  def self.included(base)
23
23
  base.use Middleware::Version
24
24
  #base.use Middleware::Environment
25
25
  end
26
-
26
+
27
27
  class Version
28
28
  def initialize(app)
29
29
  @app = app
30
30
  manifest_path = File.join('config', 'manifest.yml')
31
31
  @version = YAML.load_file(manifest_path)['version']
32
32
  end
33
-
33
+
34
34
  def call(env)
35
35
  status, headers, response = @app.call(env)
36
-
37
- response_body = ''
38
- response.each { |part| response_body << part }
39
- version_div = "<div style='position:fixed; bottom:0; right:0; z-index:9999; background-color:rgba(255, 255, 255, 0.7); padding:5px;'>Version: #{@version}</div>"
40
- response_body.sub!("</body>", "#{version_div}</body>")
41
- headers["Content-Length"] = response_body.bytesize.to_s
42
-
43
- response = [response_body]
44
-
36
+
37
+
38
+ if ENV['HUD_SHOW_VERSION']
39
+ response_body = ''
40
+ response.each { |part| response_body << part }
41
+ version_div = "<div style='position:fixed; bottom:0; right:0; z-index:9999; background-color:rgba(255, 255, 255, 0.7); padding:5px;'>Version: #{@version}</div>"
42
+ response_body.sub!("</body>", "#{version_div}</body>")
43
+ headers["Content-Length"] = response_body.bytesize.to_s
44
+
45
+ response = [response_body]
46
+ end
47
+
45
48
  [status, headers, response]
46
49
  end
47
50
  end
@@ -49,29 +52,32 @@ module Hud
49
52
  def initialize(app)
50
53
  @app = app
51
54
  end
52
-
55
+
53
56
  def call(env)
54
57
  status, headers, response = @app.call(env)
55
-
56
- color = 'green'
57
- color = 'orange' if ENV['HARBR_ENV'] == "next" or ENV['RACK_ENV'] == "staging"
58
- color = 'red' if ENV['HARBR_ENV'] == "live" && env["HTTP_HOST"].include?("harbr.zero2one.ee")
59
-
60
- response_body = ''
61
- response.each { |part| response_body << part }
62
- indicator_div = "<div style='position:fixed; top:0; z-index:9999; height:30px; width:100%; background-color:#{color}; z-index:9999;'>#{ENV['HARBR_ENV']&.upcase} ENVIRONMENT</div>"
63
- response_body.sub!("<body>", "<body>#{indicator_div}")
64
- headers["Content-Length"] = response_body.bytesize.to_s
65
-
58
+
59
+
60
+ if ENV['HUD_SHOW_ENVIROMENT']
61
+ color = 'green'
62
+ color = 'orange' if ENV['HUD_ENV'] == "next"
63
+ color = 'red' if ENV['HUD_ENV'] == "live"
64
+
65
+ response_body = ''
66
+ response.each { |part| response_body << part }
67
+ indicator_div = "<div style='position:fixed; top:0; z-index:9999; height:30px; width:100%; background-color:#{color}; z-index:9999;'>#{ENV['HARBR_ENV']&.upcase} ENVIRONMENT</div>"
68
+ response_body.sub!("<body>", "<body>#{indicator_div}")
69
+ headers["Content-Length"] = response_body.bytesize.to_s
70
+ end
71
+
66
72
  response = [response_body]
67
-
68
-
73
+
74
+
69
75
  [status, headers, response]
70
76
  end
71
77
  end
72
78
 
73
79
  end
74
-
80
+
75
81
 
76
82
  class Display
77
83
  module Helpers
@@ -154,14 +160,14 @@ module Hud
154
160
  class Screen < Rack::App
155
161
  include Hud::Middleware
156
162
  include Hud::Display::Helpers
157
-
163
+
158
164
  apply_extensions :logger
159
165
  apply_extensions :front_end
160
166
 
161
167
  helpers do
162
168
  include Hud::Display::Helpers
163
169
  end
164
-
170
+
165
171
  end
166
172
 
167
173
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hud
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Delaney Kuldvee Burke
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-02-08 00:00:00.000000000 Z
11
+ date: 2024-02-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler