stoplight-admin 0.2.8 → 0.2.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0879fc696fce33c32c2afe1769e837be1cdd1b82
4
- data.tar.gz: 6d29c9e9f672519c8ea867ff62accbae2f945206
3
+ metadata.gz: 769b6e691b419f97ee606652bddd01307783f77a
4
+ data.tar.gz: c40bc731a677289cc682974d31fb82a5876d1c56
5
5
  SHA512:
6
- metadata.gz: 161081a2c5ca3ba61857098396552adcfda01561553382140802feb8987b456f58971a0781a4440bf863f1d43ddfb932290edee5da312d955b964bf629449865
7
- data.tar.gz: 231234d5c87992008f5d93af1e221ccdbaa25b15d1b77fbc82282888bcddbefac795136041d2e7e7d777357e4d6e4a9f38098e853b361219f9e59dea5383f55d
6
+ metadata.gz: e4aa180eefdde7aa5f8f1b2bcdb4e8260f1971893dfeff4a0a799104a800deaf1257f49d0db69c91cbc6efa02c6cebca20d7f7207c375b7f300f65953ab383f4
7
+ data.tar.gz: 49de8912aa8db7aabc672e4d7adec280a2a7b85df30b11e02d785f716e17a1b6ded2a4a5cc5652f1f79267abbe32d3b8f9f82e0dbb950e90bb1a62601b695fae
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.8'
21
+ gem 'stoplight-admin', '~> 0.2.9'
22
22
  ```
23
23
 
24
24
  Run [Bundler][3] to install the dependencies:
@@ -8,14 +8,14 @@ module Sinatra
8
8
  module StoplightAdmin
9
9
  module Helpers
10
10
  COLORS = [
11
- GREEN = Stoplight::DataStore::COLOR_GREEN,
12
- YELLOW = Stoplight::DataStore::COLOR_YELLOW,
13
- RED = Stoplight::DataStore::COLOR_RED
11
+ GREEN = Stoplight::Color::GREEN,
12
+ YELLOW = Stoplight::Color::YELLOW,
13
+ RED = Stoplight::Color::RED
14
14
  ].freeze
15
15
 
16
16
  def data_store
17
17
  return @data_store if defined?(@data_store)
18
- @data_store = Stoplight.data_store = settings.data_store
18
+ @data_store = Stoplight::Light.default_data_store = settings.data_store
19
19
  end
20
20
 
21
21
  def lights
@@ -26,29 +26,27 @@ module Sinatra
26
26
  end
27
27
 
28
28
  def light_info(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)
29
+ l = Stoplight::Light.new(light) {}
30
+ color = l.color
31
+ failures, state = l.data_store.get_all(l)
32
32
 
33
33
  {
34
34
  name: light,
35
35
  color: color,
36
36
  failures: failures,
37
- attempts: attempts,
38
- locked: locked?(light)
37
+ locked: locked?(state)
39
38
  }
40
39
  end
41
40
 
42
41
  def light_sort_key(light)
43
- [COLORS.index(light[:color]),
44
- light[:attempts] * -1,
42
+ [-COLORS.index(light[:color]),
45
43
  light[:name]]
46
44
  end
47
45
 
48
- def locked?(light_name)
49
- [Stoplight::DataStore::STATE_LOCKED_GREEN,
50
- Stoplight::DataStore::STATE_LOCKED_RED]
51
- .include?(data_store.get_state(light_name))
46
+ def locked?(state)
47
+ [Stoplight::State::LOCKED_GREEN,
48
+ Stoplight::State::LOCKED_RED]
49
+ .include?(state)
52
50
  end
53
51
 
54
52
  def stat_params(ls)
@@ -70,36 +68,36 @@ module Sinatra
70
68
  end
71
69
 
72
70
  def lock(light)
71
+ l = Stoplight::Light.new(light) {}
73
72
  new_state =
74
- if Stoplight.data_store.green?(light)
75
- Stoplight::DataStore::STATE_LOCKED_GREEN
73
+ case l.color
74
+ when Stoplight::Color::GREEN
75
+ Stoplight::State::LOCKED_GREEN
76
76
  else
77
- Stoplight::DataStore::STATE_LOCKED_RED
77
+ Stoplight::State::LOCKED_RED
78
78
  end
79
79
 
80
- data_store.set_state(light, new_state)
80
+ data_store.set_state(l, new_state)
81
81
  end
82
82
 
83
83
  def unlock(light)
84
- data_store.set_state(light, Stoplight::DataStore::STATE_UNLOCKED)
84
+ l = Stoplight::Light.new(light) {}
85
+ data_store.set_state(l, Stoplight::State::UNLOCKED)
85
86
  end
86
87
 
87
88
  def green(light)
88
- if data_store.get_state(light) == Stoplight::DataStore::STATE_LOCKED_RED
89
- new_state = Stoplight::DataStore::STATE_LOCKED_GREEN
90
- data_store.set_state(light, new_state)
89
+ l = Stoplight::Light.new(light) {}
90
+ if data_store.get_state(l) == Stoplight::State::LOCKED_RED
91
+ new_state = Stoplight::State::LOCKED_GREEN
92
+ data_store.set_state(l, new_state)
91
93
  end
92
94
 
93
- data_store.clear_attempts(light)
94
- data_store.clear_failures(light)
95
+ data_store.clear_failures(l)
95
96
  end
96
97
 
97
98
  def red(light)
98
- data_store.set_state(light, Stoplight::DataStore::STATE_LOCKED_RED)
99
- end
100
-
101
- def purge
102
- data_store.clear_stale
99
+ l = Stoplight::Light.new(light) {}
100
+ data_store.set_state(l, Stoplight::State::LOCKED_RED)
103
101
  end
104
102
 
105
103
  def with_lights
@@ -144,15 +142,10 @@ module Sinatra
144
142
 
145
143
  app.post '/green_all' do
146
144
  data_store.names
147
- .reject { |l| Stoplight.data_store.green?(l) }
145
+ .reject { |l| Stoplight::Light.new(l) {}.color == Stoplight::Color::GREEN }
148
146
  .each { |l| green(l) }
149
147
  redirect to('/')
150
148
  end
151
-
152
- app.post '/purge' do
153
- purge
154
- redirect to('/')
155
- end
156
149
  end
157
150
  end
158
151
 
@@ -3,12 +3,14 @@
3
3
  %p Cop lights, flashlights, spotlights, strobe lights…
4
4
 
5
5
  .main
6
- - if lights.any?
7
- .btn-group
6
+ - if lights.empty?
7
+ .alert.alert-warning{role: 'alert'}
8
+ %strong No lights found.
9
+ Ensure that your Stoplight data store is properly configured and that your Stoplight blocks have been run.
10
+ - else
11
+ .well
8
12
  %form{method: 'post', action: url('/green_all')}
9
13
  %button.btn-lg.btn.btn-success{type: 'submit', disabled: count_red + count_yellow > 0 ? nil : 'disabled'} Greenify All
10
- %form{method: 'post', action: url('/purge')}
11
- %button.btn-lg.btn.btn-default{type: 'submit'} Purge Lights
12
14
 
13
15
  .progress
14
16
  .progress-bar.progress-bar-danger{style: "width: #{percent_red}%"}
@@ -25,11 +27,9 @@
25
27
  %th Status
26
28
  %th
27
29
  %abbr{title: 'Locked lights will not change color automatically.'} Locked?
30
+ %th Name
28
31
  %th
29
32
  %abbr{title: 'Exceptions which caused the light to turn red.'} Failures
30
- %th
31
- %abbr{title: 'Number of times the light was invoked while red.'} Attempts
32
- %th Name
33
33
  %tbody
34
34
  - lights.each do |l|
35
35
  %tr
@@ -63,6 +63,8 @@
63
63
  %input{type: 'hidden', name: 'names', value: URI.escape(l[:name])}
64
64
  %button{type: 'submit', class: 'btn btn-link'}
65
65
  %span{class: 'glyphicon glyphicon-minus'}
66
+ %td.name
67
+ = l[:name]
66
68
  %td.failures
67
69
  - if l[:failures]
68
70
  %ul
@@ -75,12 +77,3 @@
75
77
  @
76
78
  %span.timestamp
77
79
  &= failure.time
78
- %td.attempts
79
- - if l[:attempts] > 0
80
- = l[:attempts]
81
- %td.name
82
- = l[:name]
83
- - else
84
- .alert.alert-warning{role: 'alert'}
85
- %strong No lights found.
86
- Ensure that your Stoplight data store is properly configured and that your Stoplight blocks have been run.
@@ -6,20 +6,11 @@
6
6
 
7
7
  %title Stoplight Admin
8
8
 
9
- %link{rel: 'stylesheet', href: '//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css'}
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'}
9
+ %link{rel: 'stylesheet', href: '//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css'}
10
+ %link{rel: 'stylesheet', href: '//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap-theme.min.css'}
11
+ %link{rel: 'shortcut icon', href: '//i.imgur.com/qvfoNuh.png'}
12
12
 
13
13
  :css
14
- body {
15
- padding-top: 70px;
16
- padding-bottom: 30px;
17
- }
18
-
19
- .progress {
20
- margin-top: 30px
21
- }
22
-
23
14
  td.indicator {
24
15
  font-size: 200%;
25
16
  }
@@ -46,7 +37,7 @@
46
37
  }
47
38
 
48
39
  %body
49
- .navbar.navbar-inverse.navbar-fixed-top{role: 'navigation'}
40
+ .navbar.navbar-inverse.navbar-static-top{role: 'navigation'}
50
41
  .container
51
42
  .navbar-header
52
43
  %a{class: 'navbar-brand', href: url('/')} Stoplight Admin
@@ -54,4 +45,4 @@
54
45
  .container{role: 'main'}
55
46
  = yield
56
47
 
57
- %script{src: '//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js'}
48
+ %script{src: '//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js'}
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = 'stoplight-admin'
5
- spec.version = '0.2.8'
5
+ spec.version = '0.2.9'
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.}
@@ -21,5 +21,5 @@ Gem::Specification.new do |spec|
21
21
  spec.add_dependency 'haml', '~> 4.0.5'
22
22
  spec.add_dependency 'redis', '~> 3.1.0'
23
23
  spec.add_dependency 'sinatra', '~> 1.4.5'
24
- spec.add_dependency 'stoplight', '~> 0.4.1'
24
+ spec.add_dependency 'stoplight', '~> 0.5.0'
25
25
  end
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.8
4
+ version: 0.2.9
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-11-05 00:00:00.000000000 Z
12
+ date: 2014-11-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -87,14 +87,14 @@ dependencies:
87
87
  requirements:
88
88
  - - ~>
89
89
  - !ruby/object:Gem::Version
90
- version: 0.4.1
90
+ version: 0.5.0
91
91
  type: :runtime
92
92
  prerelease: false
93
93
  version_requirements: !ruby/object:Gem::Requirement
94
94
  requirements:
95
95
  - - ~>
96
96
  - !ruby/object:Gem::Version
97
- version: 0.4.1
97
+ version: 0.5.0
98
98
  description: A simple administration interface for the stoplight gem.
99
99
  email:
100
100
  - camdez@gmail.com
@@ -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.2
137
+ rubygems_version: 2.4.4
138
138
  signing_key:
139
139
  specification_version: 4
140
140
  summary: A simple administration interface for the stoplight gem.