whipped-cream 0.0.1pre4 → 0.0.1pre5

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,13 +2,15 @@
2
2
  module PiPiper
3
3
  # Just enough to imitate a pin
4
4
  class Pin
5
- attr_reader :pin, :direction, :value
5
+ attr_reader :pin, :direction
6
6
 
7
7
  def initialize(options)
8
8
  @pin = options[:pin]
9
9
  @direction = options[:direction]
10
+ end
10
11
 
11
- @value = 0
12
+ def read
13
+ @value ||= 0
12
14
  end
13
15
 
14
16
  def on
@@ -23,6 +25,8 @@ module PiPiper
23
25
  log "Pin #{pin} off"
24
26
  end
25
27
 
28
+ private
29
+
26
30
  def log(message)
27
31
  puts message unless ENV['RUBY_ENV'] == 'test'
28
32
  end
@@ -69,7 +69,7 @@ module WhippedCream
69
69
  define_singleton_method sensor.id do
70
70
  pin = pins[sensor.id]
71
71
 
72
- pin.value == 1 ? sensor.high : sensor.low
72
+ pin.read == 1 ? sensor.high : sensor.low
73
73
  end
74
74
  end
75
75
 
@@ -86,7 +86,7 @@ module WhippedCream
86
86
  define_singleton_method switch.id do
87
87
  pin = pins[switch.id]
88
88
 
89
- pin.value == 1 ? pin.off : pin.on
89
+ pin.read == 1 ? pin.off : pin.on
90
90
  end
91
91
  end
92
92
  end
@@ -1,3 +1,3 @@
1
1
  module WhippedCream
2
- VERSION = "0.0.1pre4"
2
+ VERSION = "0.0.1pre5"
3
3
  end
@@ -1,7 +1,7 @@
1
1
  <div class="item">
2
2
  <h2><%= control.name %></h2>
3
- <p><%= runner.pins[control.id].value.nonzero? ? "On" : "Off" %></p>
3
+ <p><%= runner.pins[control.id].read.nonzero? ? "On" : "Off" %></p>
4
4
  <form action="/<%= control.id %>" method="get">
5
- <input type="submit" value="<%= runner.pins[control.id].value.nonzero? ? "Off" : "On" %>">
5
+ <input type="submit" value="<%= runner.pins[control.id].read.nonzero? ? "Off" : "On" %>">
6
6
  </form>
7
7
  </div>
@@ -54,7 +54,7 @@ describe WhippedCream::Runner do
54
54
 
55
55
  it "defines a method that reads and converts the pin's value" do
56
56
  pin = runner.pins[:door]
57
- pin.stub value: 1
57
+ pin.stub read: 1
58
58
 
59
59
  expect(runner.door).to eq("Closed")
60
60
  end
@@ -96,13 +96,13 @@ describe WhippedCream::Runner do
96
96
  it "defines a light method that switches the pin on and off" do
97
97
  pin = runner.pins[:light]
98
98
 
99
- expect(pin.value).to eq(0)
99
+ expect(pin.read).to eq(0)
100
100
  runner.light
101
- expect(pin.value).to eq(1)
101
+ expect(pin.read).to eq(1)
102
102
  runner.light
103
- expect(pin.value).to eq(0)
103
+ expect(pin.read).to eq(0)
104
104
  runner.light
105
- expect(pin.value).to eq(1)
105
+ expect(pin.read).to eq(1)
106
106
  end
107
107
  end
108
108
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: whipped-cream
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1pre4
4
+ version: 0.0.1pre5
5
5
  prerelease: 5
6
6
  platform: ruby
7
7
  authors: