arduino_build_notifier 0.0.1 → 0.0.2

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.
data/README.md CHANGED
@@ -2,6 +2,9 @@
2
2
 
3
3
  A Continuous Integration Server Monitor made it over an Arduino board
4
4
 
5
+ # Warning
6
+ At this moment this only works with Cruise Control servers
7
+
5
8
  # Installation
6
9
 
7
10
  1. Install the ruby gem
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'arduino_build_notifier'
3
- s.version = '0.0.1'
3
+ s.version = '0.0.2'
4
4
  s.date = '2012-11-08'
5
5
  s.summary = "An Integration server notifier"
6
6
  s.description = "like ccmenu but with Arduino"
data/bin/ard-notifier CHANGED
@@ -52,8 +52,13 @@ rescue OptionParser::InvalidOption, OptionParser::MissingArgument
52
52
  exit
53
53
  end
54
54
 
55
+ board = Dino::Board.new Dino::TxRx.new
55
56
  build = ArduinoBuildNotifier::CruiseControlBuild.new options[:server], options[:project], { username: options[:user], password: options[:pass] }
56
- arduino = ArduinoBuildNotifier::ArduinoBoard.new
57
+ success = ArduinoBuildNotifier::Arduino::Indicators::Success.new board, 13
58
+ failure = ArduinoBuildNotifier::Arduino::Indicators::Failure.new board, 12
59
+ building = ArduinoBuildNotifier::Arduino::Indicators::Building.new board, 11
60
+ error = ArduinoBuildNotifier::Arduino::Indicators::Error.new board, 10
61
+ arduino = ArduinoBuildNotifier::Arduino::Board.new success, failure, building, error
57
62
  notifier = ArduinoBuildNotifier::Notifier.new build, arduino, options[:time]
58
63
  notifier.start_notifications
59
64
  sleep
@@ -0,0 +1,40 @@
1
+ module ArduinoBuildNotifier
2
+ module Arduino
3
+ class Board
4
+ def initialize(success, failure, building, error)
5
+ @indicators = {}
6
+ @indicators[:success] = success
7
+ @indicators[:failure] = failure
8
+ @indicators[:building] = building
9
+ @indicators[:error] = error
10
+ end
11
+
12
+ def success
13
+ turn_off_indicators
14
+ @indicators[:success].on
15
+ end
16
+
17
+ def failure
18
+ turn_off_indicators
19
+ @indicators[:failure].on
20
+ end
21
+
22
+ def building
23
+ turn_off_indicators
24
+ @indicators[:building].on
25
+ end
26
+
27
+ def error
28
+ turn_off_indicators
29
+ @indicators[:error].on
30
+ end
31
+
32
+ private
33
+
34
+ def turn_off_indicators
35
+ @indicators.each { |key, indicator| indicator.off }
36
+ end
37
+
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,23 @@
1
+ require 'dino'
2
+
3
+ module ArduinoBuildNotifier
4
+ module Arduino
5
+ module Indicators
6
+ class Base
7
+ def initialize(board, pin)
8
+ @board = board
9
+ @pin = pin
10
+ @led = Dino::Components::Led.new pin: pin, board: board
11
+ end
12
+
13
+ def on
14
+ @led.on
15
+ end
16
+
17
+ def off
18
+ @led.off
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,9 @@
1
+ module ArduinoBuildNotifier
2
+ module Arduino
3
+ module Indicators
4
+ class Building < Base
5
+
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ module ArduinoBuildNotifier
2
+ module Arduino
3
+ module Indicators
4
+ class Error < Base
5
+
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ module ArduinoBuildNotifier
2
+ module Arduino
3
+ module Indicators
4
+ class Failure < Base
5
+
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ module ArduinoBuildNotifier
2
+ module Arduino
3
+ module Indicators
4
+ class Success < Base
5
+
6
+ end
7
+ end
8
+ end
9
+ end
@@ -1,3 +1,3 @@
1
1
  module ArduinoBuildNotifier
2
- VERSION = '0.0.1'
2
+ VERSION = '0.0.2'
3
3
  end
@@ -1,4 +1,9 @@
1
- require 'arduino_build_notifier/arduino_board'
1
+ require 'arduino_build_notifier/arduino/board'
2
+ require 'arduino_build_notifier/arduino/indicators/base'
3
+ require 'arduino_build_notifier/arduino/indicators/success'
4
+ require 'arduino_build_notifier/arduino/indicators/failure'
5
+ require 'arduino_build_notifier/arduino/indicators/error'
6
+ require 'arduino_build_notifier/arduino/indicators/building'
2
7
  require 'arduino_build_notifier/notifier'
3
8
  require 'arduino_build_notifier/cruise_control_build'
4
9
  require 'arduino_build_notifier/version'
@@ -1,25 +1,18 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe ArduinoBuildNotifier::ArduinoBoard do
4
- let(:txrx) { stub }
5
- let(:board) { stub }
3
+ describe ArduinoBuildNotifier::Arduino::Board do
6
4
  let(:success) { stub }
7
5
  let(:failure) { stub }
8
6
  let(:building) { stub }
9
7
  let(:error) { stub }
10
8
 
11
- before do
12
- Dino::TxRx.should_receive(:new).and_return txrx
13
- Dino::Board.should_receive(:new).with(txrx).and_return board
14
- Dino::Components::Led.should_receive(:new).with(pin: 13, board: board).and_return success
15
- Dino::Components::Led.should_receive(:new).with(pin: 12, board: board).and_return failure
16
- Dino::Components::Led.should_receive(:new).with(pin: 11, board: board).and_return building
17
- Dino::Components::Led.should_receive(:new).with(pin: 10, board: board).and_return error
9
+ subject do
10
+ ArduinoBuildNotifier::Arduino::Board.new success, failure, building, error
18
11
  end
19
12
 
20
13
  describe '#success' do
21
14
  before do
22
- subject.should_receive(:turn_off_leds)
15
+ subject.should_receive(:turn_off_indicators)
23
16
  success.should_receive :on
24
17
  end
25
18
 
@@ -30,7 +23,7 @@ describe ArduinoBuildNotifier::ArduinoBoard do
30
23
 
31
24
  describe '#failure' do
32
25
  before do
33
- subject.should_receive(:turn_off_leds)
26
+ subject.should_receive(:turn_off_indicators)
34
27
  failure.should_receive :on
35
28
  end
36
29
 
@@ -41,7 +34,7 @@ describe ArduinoBuildNotifier::ArduinoBoard do
41
34
 
42
35
  describe '#building' do
43
36
  before do
44
- subject.should_receive(:turn_off_leds)
37
+ subject.should_receive(:turn_off_indicators)
45
38
  building.should_receive :on
46
39
  end
47
40
 
@@ -53,7 +46,7 @@ describe ArduinoBuildNotifier::ArduinoBoard do
53
46
 
54
47
  describe '#error' do
55
48
  before do
56
- subject.should_receive(:turn_off_leds)
49
+ subject.should_receive(:turn_off_indicators)
57
50
  error.should_receive :on
58
51
  end
59
52
 
@@ -62,13 +55,13 @@ describe ArduinoBuildNotifier::ArduinoBoard do
62
55
  end
63
56
  end
64
57
 
65
- describe '#turn_off_leds' do
66
- it 'turns off all the leds' do
58
+ describe '#turn_off_indicators' do
59
+ it 'turns off all indicators' do
67
60
  success.should_receive :off
68
61
  failure.should_receive :off
69
62
  building.should_receive :off
70
63
  error.should_receive :off
71
- subject.send :turn_off_leds
64
+ subject.send :turn_off_indicators
72
65
  end
73
66
  end
74
67
 
@@ -0,0 +1,26 @@
1
+ require 'spec_helper'
2
+
3
+ describe ArduinoBuildNotifier::Arduino::Indicators::Base do
4
+ let(:board) { stub }
5
+ let(:led) { stub }
6
+
7
+ before do
8
+ Dino::Components::Led.should_receive(:new).with(pin: 1, board: board).and_return led
9
+ end
10
+
11
+ subject { ArduinoBuildNotifier::Arduino::Indicators::Base.new board, 1 }
12
+
13
+ describe '#on' do
14
+ it 'Turns on the led' do
15
+ led.should_receive :on
16
+ subject.on
17
+ end
18
+ end
19
+
20
+ describe '#off' do
21
+ it 'Turns off the led' do
22
+ led.should_receive :off
23
+ subject.off
24
+ end
25
+ end
26
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: arduino_build_notifier
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -122,11 +122,17 @@ files:
122
122
  - arduino_build_notifier.gemspec
123
123
  - bin/ard-notifier
124
124
  - lib/arduino_build_notifier.rb
125
- - lib/arduino_build_notifier/arduino_board.rb
125
+ - lib/arduino_build_notifier/arduino/board.rb
126
+ - lib/arduino_build_notifier/arduino/indicators/base.rb
127
+ - lib/arduino_build_notifier/arduino/indicators/building.rb
128
+ - lib/arduino_build_notifier/arduino/indicators/error.rb
129
+ - lib/arduino_build_notifier/arduino/indicators/failure.rb
130
+ - lib/arduino_build_notifier/arduino/indicators/success.rb
126
131
  - lib/arduino_build_notifier/cruise_control_build.rb
127
132
  - lib/arduino_build_notifier/notifier.rb
128
133
  - lib/arduino_build_notifier/version.rb
129
- - spec/lib/arduino_board_spec.rb
134
+ - spec/lib/arduino/board_spec.rb
135
+ - spec/lib/arduino/indicators/base_spec.rb
130
136
  - spec/lib/cruise_control_build_spec.rb
131
137
  - spec/lib/notifier_spec.rb
132
138
  - spec/spec_helper.rb
@@ -1,41 +0,0 @@
1
- require 'dino'
2
-
3
- module ArduinoBuildNotifier
4
- class ArduinoBoard
5
- def initialize
6
- @board = Dino::Board.new(Dino::TxRx.new)
7
- @success_led = Dino::Components::Led.new(pin: 13, board: @board)
8
- @failure_led = Dino::Components::Led.new(pin: 12, board: @board)
9
- @building_led = Dino::Components::Led.new(pin: 11, board: @board)
10
- @error_led = Dino::Components::Led.new(pin: 10, board: @board)
11
- @leds = [@success_led, @failure_led, @building_led, @error_led]
12
- end
13
-
14
- def success
15
- turn_off_leds
16
- @success_led.on
17
- end
18
-
19
- def failure
20
- turn_off_leds
21
- @failure_led.on
22
- end
23
-
24
- def building
25
- turn_off_leds
26
- @building_led.on
27
- end
28
-
29
- def error
30
- turn_off_leds
31
- @error_led.on
32
- end
33
-
34
- private
35
-
36
- def turn_off_leds
37
- @leds.each { |led| led.off }
38
- end
39
-
40
- end
41
- end