stoplight 2.2.1 → 3.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +13 -33
  3. data/lib/stoplight/color.rb +4 -4
  4. data/lib/stoplight/data_store/base.rb +10 -1
  5. data/lib/stoplight/data_store/memory.rb +27 -1
  6. data/lib/stoplight/data_store/redis.rb +61 -26
  7. data/lib/stoplight/data_store.rb +1 -1
  8. data/lib/stoplight/default.rb +3 -3
  9. data/lib/stoplight/error.rb +1 -1
  10. data/lib/stoplight/failure.rb +2 -2
  11. data/lib/stoplight/light/runnable.rb +16 -8
  12. data/lib/stoplight/light.rb +1 -1
  13. data/lib/stoplight/notifier/base.rb +1 -1
  14. data/lib/stoplight/notifier/bugsnag.rb +2 -2
  15. data/lib/stoplight/notifier/generic.rb +1 -1
  16. data/lib/stoplight/notifier/honeybadger.rb +2 -2
  17. data/lib/stoplight/notifier/io.rb +1 -1
  18. data/lib/stoplight/notifier/logger.rb +1 -1
  19. data/lib/stoplight/notifier/pagerduty.rb +1 -1
  20. data/lib/stoplight/notifier/raven.rb +2 -2
  21. data/lib/stoplight/notifier/rollbar.rb +1 -1
  22. data/lib/stoplight/notifier/slack.rb +1 -1
  23. data/lib/stoplight/notifier.rb +1 -1
  24. data/lib/stoplight/state.rb +4 -4
  25. data/lib/stoplight/version.rb +2 -2
  26. data/lib/stoplight.rb +2 -3
  27. data/spec/spec_helper.rb +2 -3
  28. data/spec/stoplight/color_spec.rb +1 -1
  29. data/spec/stoplight/data_store/base_spec.rb +8 -1
  30. data/spec/stoplight/data_store/memory_spec.rb +27 -1
  31. data/spec/stoplight/data_store/redis_spec.rb +37 -6
  32. data/spec/stoplight/data_store_spec.rb +1 -1
  33. data/spec/stoplight/default_spec.rb +1 -1
  34. data/spec/stoplight/error_spec.rb +1 -1
  35. data/spec/stoplight/failure_spec.rb +1 -1
  36. data/spec/stoplight/light/runnable_spec.rb +39 -9
  37. data/spec/stoplight/light_spec.rb +5 -5
  38. data/spec/stoplight/notifier/base_spec.rb +1 -1
  39. data/spec/stoplight/notifier/bugsnag_spec.rb +1 -1
  40. data/spec/stoplight/notifier/generic_spec.rb +1 -1
  41. data/spec/stoplight/notifier/honeybadger_spec.rb +1 -1
  42. data/spec/stoplight/notifier/io_spec.rb +1 -1
  43. data/spec/stoplight/notifier/logger_spec.rb +1 -1
  44. data/spec/stoplight/notifier/pagerduty_spec.rb +1 -1
  45. data/spec/stoplight/notifier/raven_spec.rb +1 -1
  46. data/spec/stoplight/notifier/rollbar_spec.rb +1 -1
  47. data/spec/stoplight/notifier/slack_spec.rb +2 -3
  48. data/spec/stoplight/notifier_spec.rb +1 -1
  49. data/spec/stoplight/state_spec.rb +1 -1
  50. data/spec/stoplight/version_spec.rb +1 -1
  51. data/spec/stoplight_spec.rb +1 -1
  52. metadata +79 -54
  53. data/lib/stoplight/notifier/hip_chat.rb +0 -43
  54. data/spec/stoplight/notifier/hip_chat_spec.rb +0 -92
@@ -1,43 +0,0 @@
1
- # coding: utf-8
2
-
3
- module Stoplight
4
- module Notifier
5
- # @see Base
6
- class HipChat < Base
7
- DEFAULT_OPTIONS = {
8
- color: 'purple',
9
- message_format: 'text',
10
- notify: true
11
- }.freeze
12
-
13
- # @return [Proc]
14
- attr_reader :formatter
15
- # @return [::HipChat::Client]
16
- attr_reader :hip_chat
17
- # @return [Hash{Symbol => Object}]
18
- attr_reader :options
19
- # @return [String]
20
- attr_reader :room
21
-
22
- # @param hip_chat [::HipChat::Client]
23
- # @param room [String]
24
- # @param formatter [Proc, nil]
25
- # @param options [Hash{Symbol => Object}]
26
- # @option options [String] :color
27
- # @option options [String] :message_format
28
- # @option options [Boolean] :notify
29
- def initialize(hip_chat, room, formatter = nil, options = {})
30
- @hip_chat = hip_chat
31
- @room = room
32
- @formatter = formatter || Default::FORMATTER
33
- @options = DEFAULT_OPTIONS.merge(options)
34
- end
35
-
36
- def notify(light, from_color, to_color, error)
37
- message = formatter.call(light, from_color, to_color, error)
38
- hip_chat[room].send('Stoplight', message, options)
39
- message
40
- end
41
- end
42
- end
43
- end
@@ -1,92 +0,0 @@
1
- # coding: utf-8
2
-
3
- require 'spec_helper'
4
-
5
- # require 'hipchat'
6
- module HipChat
7
- class Client
8
- def initialize(*)
9
- end
10
- end
11
- end
12
-
13
- RSpec.describe Stoplight::Notifier::HipChat do
14
- it 'is a class' do
15
- expect(described_class).to be_a(Class)
16
- end
17
-
18
- it 'is a subclass of Base' do
19
- expect(described_class).to be < Stoplight::Notifier::Base
20
- end
21
-
22
- describe '#formatter' do
23
- it 'is initially the default' do
24
- expect(described_class.new(nil, nil).formatter)
25
- .to eql(Stoplight::Default::FORMATTER)
26
- end
27
-
28
- it 'reads the formatter' do
29
- formatter = proc {}
30
- expect(described_class.new(nil, nil, formatter).formatter)
31
- .to eql(formatter)
32
- end
33
- end
34
-
35
- describe '#hip_chat' do
36
- it 'reads the HipChat client' do
37
- hip_chat = HipChat::Client.new('API token')
38
- expect(described_class.new(hip_chat, nil).hip_chat)
39
- .to eql(hip_chat)
40
- end
41
- end
42
-
43
- describe '#options' do
44
- it 'is initially the default' do
45
- expect(described_class.new(nil, nil).options)
46
- .to eql(Stoplight::Notifier::HipChat::DEFAULT_OPTIONS)
47
- end
48
-
49
- it 'reads the options' do
50
- options = { key: :value }
51
- expect(described_class.new(nil, nil, nil, options).options)
52
- .to eql(Stoplight::Notifier::HipChat::DEFAULT_OPTIONS.merge(options))
53
- end
54
- end
55
-
56
- describe '#room' do
57
- it 'reads the room' do
58
- room = 'Notifications'
59
- expect(described_class.new(nil, room).room).to eql(room)
60
- end
61
- end
62
-
63
- describe '#notify' do
64
- let(:light) { Stoplight::Light.new(name, &code) }
65
- let(:name) { ('a'..'z').to_a.shuffle.join }
66
- let(:code) { -> {} }
67
- let(:from_color) { Stoplight::Color::GREEN }
68
- let(:to_color) { Stoplight::Color::RED }
69
- let(:notifier) { described_class.new(hip_chat, room) }
70
- let(:hip_chat) { double(HipChat::Client) }
71
- let(:room) { ('a'..'z').to_a.shuffle.join }
72
-
73
- before do
74
- tmp = double
75
- expect(hip_chat).to receive(:[]).with(room).and_return(tmp)
76
- expect(tmp).to receive(:send)
77
- .with('Stoplight', kind_of(String), kind_of(Hash)).and_return(true)
78
- end
79
-
80
- it 'returns the message' do
81
- error = nil
82
- expect(notifier.notify(light, from_color, to_color, error))
83
- .to eql(notifier.formatter.call(light, from_color, to_color, error))
84
- end
85
-
86
- it 'returns the message with an error' do
87
- error = ZeroDivisionError.new('divided by 0')
88
- expect(notifier.notify(light, from_color, to_color, error))
89
- .to eql(notifier.formatter.call(light, from_color, to_color, error))
90
- end
91
- end
92
- end