stoplight-admin 0.2.7 → 0.2.8

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 591bff575f74531655bad33fdccab13615dffe72
4
- data.tar.gz: fad7754c050b9643d5ae2e7423e07f32f16620b5
3
+ metadata.gz: 0879fc696fce33c32c2afe1769e837be1cdd1b82
4
+ data.tar.gz: 6d29c9e9f672519c8ea867ff62accbae2f945206
5
5
  SHA512:
6
- metadata.gz: 4a86a43423fda60ba5a3b308eb14a2d4f19870fcccfd4bb2e9ff00f161fc5623a10a574d9b7a5a673b4a84a8980512e8f9abe37f47ae815ee1b0598f5c6311b2
7
- data.tar.gz: 7221b3349992ab825d843ae5904e84fa5a239b01daffcae38ba779344cfce700f9f08a1ea0b5c9c9e18a0affea720e49f3480253871536ffde067f74c716260f
6
+ metadata.gz: 161081a2c5ca3ba61857098396552adcfda01561553382140802feb8987b456f58971a0781a4440bf863f1d43ddfb932290edee5da312d955b964bf629449865
7
+ data.tar.gz: 231234d5c87992008f5d93af1e221ccdbaa25b15d1b77fbc82282888bcddbefac795136041d2e7e7d777357e4d6e4a9f38098e853b361219f9e59dea5383f55d
data/README.md CHANGED
@@ -18,7 +18,7 @@ First you'll need a `Gemfile`:
18
18
  ``` rb
19
19
  source 'https://rubygems.org'
20
20
 
21
- gem 'stoplight-admin', '~> 0.2.7'
21
+ gem 'stoplight-admin', '~> 0.2.8'
22
22
  ```
23
23
 
24
24
  Run [Bundler][3] to install the dependencies:
@@ -7,6 +7,12 @@ require 'stoplight'
7
7
  module Sinatra
8
8
  module StoplightAdmin
9
9
  module Helpers
10
+ COLORS = [
11
+ GREEN = Stoplight::DataStore::COLOR_GREEN,
12
+ YELLOW = Stoplight::DataStore::COLOR_YELLOW,
13
+ RED = Stoplight::DataStore::COLOR_RED
14
+ ].freeze
15
+
10
16
  def data_store
11
17
  return @data_store if defined?(@data_store)
12
18
  @data_store = Stoplight.data_store = settings.data_store
@@ -20,13 +26,13 @@ module Sinatra
20
26
  end
21
27
 
22
28
  def light_info(light)
23
- green = Stoplight.data_store.green?(light)
24
- attempts = green ? 0 : data_store.get_attempts(light)
25
- failures = green ? [] : data_store.get_failures(light)
29
+ color = Stoplight.data_store.get_color(light)
30
+ attempts = color == GREEN ? 0 : data_store.get_attempts(light)
31
+ failures = color == GREEN ? [] : data_store.get_failures(light)
26
32
 
27
33
  {
28
34
  name: light,
29
- green: green,
35
+ color: color,
30
36
  failures: failures,
31
37
  attempts: attempts,
32
38
  locked: locked?(light)
@@ -34,7 +40,7 @@ module Sinatra
34
40
  end
35
41
 
36
42
  def light_sort_key(light)
37
- [light[:green] ? 1 : 0,
43
+ [COLORS.index(light[:color]),
38
44
  light[:attempts] * -1,
39
45
  light[:name]]
40
46
  end
@@ -46,23 +52,21 @@ module Sinatra
46
52
  end
47
53
 
48
54
  def stat_params(ls)
49
- total_count = ls.size
50
- success_count = ls.count { |l| l[:green] }
51
- failure_count = total_count - success_count
52
-
53
- if total_count > 0
54
- failure_percentage = (100.0 * failure_count / total_count).ceil
55
- success_percentage = 100 - failure_percentage
56
- else
57
- failure_percentage = success_percentage = 0
58
- end
59
-
60
- {
61
- success_count: success_count,
62
- failure_count: failure_count,
63
- success_percentage: success_percentage,
64
- failure_percentage: failure_percentage
55
+ h = {
56
+ count_red: 0, count_yellow: 0, count_green: 0,
57
+ percent_red: 0, percent_yellow: 0, percent_green: 0
65
58
  }
59
+ return h if (size = ls.size).zero?
60
+
61
+ h[:count_red] = ls.count { |l| l[:color] == RED }
62
+ h[:count_yellow] = ls.count { |l| l[:color] == YELLOW }
63
+ h[:count_green] = size - h[:count_red] - h[:count_yellow]
64
+
65
+ h[:percent_red] = (100.0 * h[:count_red] / size).ceil
66
+ h[:percent_yellow] = (100.0 * h[:count_yellow] / size).ceil
67
+ h[:percent_green] = 100.0 - h[:percent_red] - h[:percent_yellow]
68
+
69
+ h
66
70
  end
67
71
 
68
72
  def lock(light)
@@ -6,15 +6,17 @@
6
6
  - if lights.any?
7
7
  .btn-group
8
8
  %form{method: 'post', action: url('/green_all')}
9
- %button.btn-lg.btn.btn-success{type: 'submit', disabled: failure_count > 0 ? nil : 'disabled'} Greenify All
9
+ %button.btn-lg.btn.btn-success{type: 'submit', disabled: count_red + count_yellow > 0 ? nil : 'disabled'} Greenify All
10
10
  %form{method: 'post', action: url('/purge')}
11
11
  %button.btn-lg.btn.btn-default{type: 'submit'} Purge Lights
12
12
 
13
13
  .progress
14
- .progress-bar.progress-bar-danger{style: "width: #{failure_percentage}%"}
15
- .span= failure_count
16
- .progress-bar.progress-bar-success{style: "width: #{success_percentage}%"}
17
- .span= success_count
14
+ .progress-bar.progress-bar-danger{style: "width: #{percent_red}%"}
15
+ .span= count_red
16
+ .progress-bar.progress-bar-warning{style: "width: #{percent_yellow}%"}
17
+ .span= count_yellow
18
+ .progress-bar.progress-bar-success{style: "width: #{percent_green}%"}
19
+ .span= count_green
18
20
 
19
21
  .lights
20
22
  %table.table.table-hover
@@ -32,12 +34,18 @@
32
34
  - lights.each do |l|
33
35
  %tr
34
36
  %td.indicator
35
- - if l[:green]
37
+ - if l[:color] == GREEN
36
38
  %form{method: 'post', action: url('/red')}
37
39
  %input{type: 'hidden', name: 'names', value: URI.escape(l[:name])}
38
40
  %button{type: 'submit', class: 'btn btn-success'}
39
41
  G
40
42
  %span.hidden-xs> REEN
43
+ - elsif l[:color] == YELLOW
44
+ %form{method: 'post', action: url('/green')}
45
+ %input{type: 'hidden', name: 'names', value: URI.escape(l[:name])}
46
+ %button{type: 'submit', class: 'btn btn-warning'}
47
+ Y
48
+ %span.hidden-xs> ELLOW
41
49
  - else
42
50
  %form{method: 'post', action: url('/green')}
43
51
  %input{type: 'hidden', name: 'names', value: URI.escape(l[:name])}
@@ -8,6 +8,7 @@
8
8
 
9
9
  %link{rel: 'stylesheet', href: '//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css'}
10
10
  %link{rel: 'stylesheet', href: '//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css'}
11
+ %link{rel: 'shortcut icon', href: 'https://i.imgur.com/qvfoNuh.png'}
11
12
 
12
13
  :css
13
14
  body {
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = 'stoplight-admin'
5
- spec.version = '0.2.7'
5
+ spec.version = '0.2.8'
6
6
  spec.authors = ['Cameron Desautels', 'Taylor Fausak']
7
7
  spec.email = %w(camdez@gmail.com taylor@fausak.me)
8
8
  spec.summary = %q{A simple administration interface for the stoplight gem.}
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stoplight-admin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.7
4
+ version: 0.2.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cameron Desautels
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-10-03 00:00:00.000000000 Z
12
+ date: 2014-11-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -134,7 +134,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
134
134
  version: '0'
135
135
  requirements: []
136
136
  rubyforge_project:
137
- rubygems_version: 2.4.1
137
+ rubygems_version: 2.4.2
138
138
  signing_key:
139
139
  specification_version: 4
140
140
  summary: A simple administration interface for the stoplight gem.