artoo-raspi 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0
4
+ - 1.9.3
5
+ - jruby-19mode
6
+ - rbx-19mode
7
+
@@ -1,14 +1,14 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- artoo-raspi (0.1.0)
5
- artoo (~> 1.0.0.rc4)
4
+ artoo-raspi (0.2.0)
5
+ artoo (~> 1.0.0)
6
6
  pi_piper
7
7
 
8
8
  GEM
9
9
  remote: http://rubygems.org/
10
10
  specs:
11
- artoo (1.0.0.rc4)
11
+ artoo (1.0.0)
12
12
  celluloid (~> 0.14.1)
13
13
  celluloid-io (~> 0.14.1)
14
14
  multi_json (~> 1.6)
@@ -28,7 +28,12 @@ GEM
28
28
  certified
29
29
  http_parser.rb
30
30
  http_parser.rb (0.5.3)
31
+ metaclass (0.0.1)
31
32
  method_source (0.8.2)
33
+ minitest (5.0.6)
34
+ minitest-happy (1.0.0)
35
+ mocha (0.14.0)
36
+ metaclass (~> 0.0.1)
32
37
  multi_json (1.7.9)
33
38
  nio4r (0.5.0)
34
39
  pi_piper (1.3.1)
@@ -56,3 +61,6 @@ PLATFORMS
56
61
 
57
62
  DEPENDENCIES
58
63
  artoo-raspi!
64
+ minitest (~> 5.0)
65
+ minitest-happy
66
+ mocha (~> 0.14.0)
data/README.md CHANGED
@@ -8,6 +8,8 @@ For more information about Artoo, check out our repo at https://github.com/hybri
8
8
 
9
9
  This gem makes extensive us the the pi_piper gem (https://github.com/jwhitehorn/pi_piper) thanks to @jwhitehorn
10
10
 
11
+ [![Code Climate](https://codeclimate.com/github/hybridgroup/artoo-raspi.png)](https://codeclimate.com/github/hybridgroup/artoo-raspi) [![Build Status](https://travis-ci.org/hybridgroup/artoo-raspi.png?branch=master)](https://travis-ci.org/hybridgroup/artoo-raspi)
12
+
11
13
  ## Installing On Raspberry Pi
12
14
 
13
15
  If you do not already have Ruby installed, first you'll need to:
@@ -56,5 +58,10 @@ To add the button used in the example, add a momentary contact switch to the cir
56
58
 
57
59
  ![GPIO Switch Circuit Example](https://github.com/jwhitehorn/pi_piper/blob/master/examples/simple_switch/circuit.png)
58
60
 
61
+ ## Contributing
59
62
 
60
-
63
+ 1. Fork it
64
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
65
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
66
+ 4. Push to the branch (`git push origin my-new-feature`)
67
+ 5. Create new Pull Request
@@ -20,11 +20,9 @@ Gem::Specification.new do |s|
20
20
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
21
21
  s.require_paths = ["lib"]
22
22
 
23
- s.add_runtime_dependency 'artoo', '~> 1.0.0.rc4'
23
+ s.add_runtime_dependency 'artoo', '~> 1.0.0'
24
24
  s.add_runtime_dependency 'pi_piper'
25
- # TODO: add your development dependencies here
26
- # EXAMPLE:
27
- # s.add_development_dependency 'minitest', '~> 5.0'
28
- # s.add_development_dependency 'minitest-happy'
29
- # s.add_development_dependency 'mocha', '~> 0.14.0'
25
+ s.add_development_dependency 'minitest', '~> 5.0'
26
+ s.add_development_dependency 'minitest-happy'
27
+ s.add_development_dependency 'mocha', '~> 0.14.0'
30
28
  end
@@ -1,5 +1,5 @@
1
1
  module Artoo
2
2
  module Raspi
3
- VERSION = '0.1.0'
3
+ VERSION = '0.2.0'
4
4
  end
5
5
  end
@@ -4,15 +4,18 @@ module Artoo
4
4
  module Drivers
5
5
  # Raspberry Pi pin driver behaviors
6
6
  class RaspiPin < Driver
7
- COMMANDS = [:on?, :on, :off?, :off, :toggle].freeze
7
+ COMMANDS = [:is_on?, :on, :is_off?, :off, :toggle].freeze
8
8
 
9
9
  attr_reader :raspi_pin, :direction, :value
10
10
 
11
- def initialize(params)
11
+ def initialize(params={})
12
12
  super
13
13
 
14
- @direction = params[:additional_params][:direction]
14
+ params[:additional_params] ||= {}
15
+ @direction = params[:additional_params][:direction] || :out
15
16
  @value = false
17
+
18
+ @raspi_pin = ::PiPiper::Pin.new(:pin => pin, :direction => direction)
16
19
  end
17
20
 
18
21
  # Start driver and any required connections
@@ -22,8 +25,6 @@ module Artoo
22
25
  handle_message_events
23
26
  end
24
27
 
25
- @raspi_pin = PiPiper::Pin.new(:pin => pin, :direction => direction)
26
-
27
28
  super
28
29
  rescue Exception => e
29
30
  Logger.error "Error starting Raspberry Pi pin driver!"
@@ -42,7 +43,7 @@ module Artoo
42
43
  end
43
44
 
44
45
  def toggle
45
- off? ? on : off
46
+ is_off? ? on : off
46
47
  end
47
48
 
48
49
  def on
@@ -50,7 +51,7 @@ module Artoo
50
51
  raspi_pin.on
51
52
  end
52
53
 
53
- def on?
54
+ def is_on?
54
55
  value == true
55
56
  end
56
57
 
@@ -59,8 +60,8 @@ module Artoo
59
60
  raspi_pin.off
60
61
  end
61
62
 
62
- def off?
63
- !on?
63
+ def is_off?
64
+ !is_on?
64
65
  end
65
66
  end
66
67
  end
@@ -1,4 +1,45 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + "/../test_helper")
2
2
  require 'artoo/drivers/raspi_pin'
3
3
 
4
- # TODO: test for your driver goes here...
4
+ describe Artoo::Drivers::RaspiPin do
5
+ before do
6
+ @device = mock('device')
7
+ @pin = 17
8
+ @device.stubs(:pin).returns(@pin)
9
+ @connection = mock('connection')
10
+ @device.stubs(:connection).returns(@connection)
11
+ @pi_pin = mock('pin')
12
+ ::PiPiper::Pin.stubs(:new).returns(@pi_pin)
13
+ @led = Artoo::Drivers::RaspiPin.new(:parent => @device)
14
+ end
15
+
16
+ it 'RaspiPin#is_on?' do
17
+ @led.is_on?.must_equal false
18
+ end
19
+
20
+ it 'RaspiPin#is_off?' do
21
+ @led.is_off?.must_equal true
22
+ end
23
+
24
+ it 'RaspiPin#on' do
25
+ @pi_pin.expects(:on)
26
+ @led.on
27
+ @led.is_on?.must_equal true
28
+ end
29
+
30
+ it 'RaspiPin#off' do
31
+ @pi_pin.expects(:off)
32
+ @led.off
33
+ @led.is_off?.must_equal true
34
+ end
35
+
36
+ it 'RaspiPin#toggle' do
37
+ @pi_pin.expects(:on)
38
+ @pi_pin.expects(:off)
39
+ @led.is_off?.must_equal true
40
+ @led.toggle
41
+ @led.is_on?.must_equal true
42
+ @led.toggle
43
+ @led.is_off?.must_equal true
44
+ end
45
+ end
@@ -1,5 +1,14 @@
1
1
  require 'artoo/robot'
2
2
 
3
3
  require 'minitest/autorun'
4
+ require 'mocha/setup'
4
5
 
5
6
  Celluloid.logger = nil
7
+
8
+ # here to be mocked, so we can run tests without having a real Raspberry Pi
9
+ module PiPiper
10
+ class Pin
11
+ def initialize(params={})
12
+ end
13
+ end
14
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: artoo-raspi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-08-16 00:00:00.000000000 Z
12
+ date: 2013-08-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: artoo
@@ -18,7 +18,7 @@ dependencies:
18
18
  requirements:
19
19
  - - ~>
20
20
  - !ruby/object:Gem::Version
21
- version: 1.0.0.rc4
21
+ version: 1.0.0
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
@@ -26,7 +26,7 @@ dependencies:
26
26
  requirements:
27
27
  - - ~>
28
28
  - !ruby/object:Gem::Version
29
- version: 1.0.0.rc4
29
+ version: 1.0.0
30
30
  - !ruby/object:Gem::Dependency
31
31
  name: pi_piper
32
32
  requirement: !ruby/object:Gem::Requirement
@@ -43,6 +43,54 @@ dependencies:
43
43
  - - ! '>='
44
44
  - !ruby/object:Gem::Version
45
45
  version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: minitest
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: '5.0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '5.0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: minitest-happy
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: mocha
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ~>
84
+ - !ruby/object:Gem::Version
85
+ version: 0.14.0
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ~>
92
+ - !ruby/object:Gem::Version
93
+ version: 0.14.0
46
94
  description: Artoo adaptor and driver for Raspberry Pi GPIO
47
95
  email:
48
96
  - artoo@hybridgroup.com
@@ -50,6 +98,7 @@ executables: []
50
98
  extensions: []
51
99
  extra_rdoc_files: []
52
100
  files:
101
+ - .travis.yml
53
102
  - Gemfile
54
103
  - Gemfile.lock
55
104
  - LICENSE
@@ -80,7 +129,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
80
129
  version: '0'
81
130
  segments:
82
131
  - 0
83
- hash: 3220213707000459885
132
+ hash: -4183422452259887056
84
133
  required_rubygems_version: !ruby/object:Gem::Requirement
85
134
  none: false
86
135
  requirements:
@@ -89,7 +138,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
89
138
  version: '0'
90
139
  segments:
91
140
  - 0
92
- hash: 3220213707000459885
141
+ hash: -4183422452259887056
93
142
  requirements: []
94
143
  rubyforge_project: artoo-raspi
95
144
  rubygems_version: 1.8.24