arduino_ir_remote 0.0.1 → 0.0.2

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: 474128049fe277af132adf82a3a78e5ee0f9b5f9
4
- data.tar.gz: eb628f354d318da0c68a3b79baa221029f17479e
3
+ metadata.gz: ca3617b6ff8956adaff02f74247d92e5b9a869af
4
+ data.tar.gz: 2c6d4b9489c09047782816d81a277ec852b0f96c
5
5
  SHA512:
6
- metadata.gz: 2992062198ce3437f3a902f43be70eeff15165bc3b76e86798f85d99f57ea7837f156a507746bba120c332acebcc5f65497a954fce1431a12e57c737007ae264
7
- data.tar.gz: 2db1350cc9e9a844d395c6d05c03a7cf2b14e172c99235bd9fa432a42a4e9b83f30c3ac83065a522d1a42fa1cbe8bcc981340aa2dd67658e75b6ed9efebe7fe4
6
+ metadata.gz: 5d188ae4d99dd2dd8ab0b306030328b52835780af3c81437203426ee35f4089f41f3e4bdf0b93688d9b3f1795f75b01062ac7dfa90224152934e4ef3cbab5267
7
+ data.tar.gz: 1be1417a3ce41959017e0662143b3f8c61817f2fccc1a35223a2c51378998f7a28d388ab6efb682a2281a69be741bb9237409a0d3e83600bd0515f93408c8509
data/History.txt CHANGED
@@ -1,3 +1,8 @@
1
+ === 0.0.2 2013-08-11
2
+
3
+ * add tests
4
+ * fix gem description
5
+
1
6
  === 0.0.1 2013-08-11
2
7
 
3
8
  * read write IR Data
data/README.md CHANGED
@@ -98,6 +98,15 @@ end
98
98
  ```
99
99
 
100
100
 
101
+ Test
102
+ ----
103
+
104
+ % gem install bundler
105
+ % bundle install
106
+ % export ARDUINO=/dev/tty.usb-devicename
107
+ % bundle exec rake test
108
+
109
+
101
110
  Contributing
102
111
  ------------
103
112
  1. Fork it
data/Rakefile CHANGED
@@ -1 +1,8 @@
1
1
  require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new do |t|
5
+ t.pattern = "test/test_*.rb"
6
+ end
7
+
8
+ task :default => :test
@@ -8,8 +8,8 @@ Gem::Specification.new do |spec|
8
8
  spec.version = ArduinoIrRemote::VERSION
9
9
  spec.authors = ["Sho Hashimoto"]
10
10
  spec.email = ["hashimoto@shokai.org"]
11
- spec.description = %q{IR Learning Remote with Arduino and Ruby}
12
- spec.summary = %q{This Rubygem provides a wrapper for IR-Learning-Remote that has been built using the Arduino. https://github.com/shokai/arduino_ir_remote}
11
+ spec.description = %q{This Rubygem provides a wrapper for IR-Learning-Remote that has been built using the Arduino. https://github.com/shokai/arduino_ir_remote}
12
+ spec.summary = spec.description
13
13
  spec.homepage = "https://github.com/shokai/arduino_ir_remote"
14
14
  spec.license = "MIT"
15
15
 
@@ -25,4 +25,5 @@ Gem::Specification.new do |spec|
25
25
 
26
26
  spec.add_development_dependency "bundler", "~> 1.3"
27
27
  spec.add_development_dependency "rake"
28
+ spec.add_development_dependency "minitest"
28
29
  end
@@ -57,7 +57,7 @@ if args.has_param? :write
57
57
  puts %Q{there is no data "#{args[:write]}"}
58
58
  exit 1
59
59
  end
60
- puts %Q{Write "#{args[:write]}"}
60
+ puts %Q{write "#{args[:write]}"}
61
61
  ir.write ArduinoIrRemote::DATA[ args[:write] ]
62
62
  ir.wait
63
63
  end
@@ -1,4 +1,9 @@
1
1
  module ArduinoIrRemote
2
2
  DATA_FILE = File.expand_path '.ir_remote.yml', ENV['HOME']
3
3
  DATA = Hashie::Mash.new YAML::load File.open(DATA_FILE).read
4
+
5
+ class Status
6
+ CLOSE = 0
7
+ OPEN = 1
8
+ end
4
9
  end
@@ -2,13 +2,16 @@ module ArduinoIrRemote
2
2
  class Device
3
3
  include EventEmitter
4
4
  attr_accessor :temp_pin
5
+ attr_reader :status
5
6
 
6
7
  def initialize(port)
8
+ @status = Status::CLOSE
7
9
  @state = nil
8
- @sp = SerialPort.new(port, 57600, 8, 1, SerialPort::NONE) # 57600bps, 8bit, stopbit1, parity-none
10
+ @serial = SerialPort.new(port, 57600, 8, 1, SerialPort::NONE) # 57600bps, 8bit, stopbit1, parity-none
11
+ @status = Status::OPEN
9
12
  Thread.new do
10
- loop do
11
- process_input @sp.gets.strip
13
+ while status == Status::OPEN do
14
+ process_input @serial.gets.strip
12
15
  end
13
16
  end
14
17
  @temp_pin = 0
@@ -16,17 +19,23 @@ module ArduinoIrRemote
16
19
  sleep 3
17
20
  end
18
21
 
22
+ def close
23
+ return if status == Status::CLOSE
24
+ @status = Status::CLOSE
25
+ @serial.close
26
+ end
27
+
19
28
  public
20
29
  def write(data)
21
30
  "w#{data}W".split(//).each do |c|
22
- @sp.write c
31
+ @serial.write c
23
32
  sleep 0.001
24
33
  end
25
34
  end
26
35
 
27
36
  def read(&block)
28
37
  once :__ir_read, &block if block_given?
29
- @sp.write "r"
38
+ @serial.write "r"
30
39
  end
31
40
 
32
41
  def analog_read(pin)
@@ -1,3 +1,3 @@
1
1
  module ArduinoIrRemote
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -0,0 +1,5 @@
1
+ require 'rubygems'
2
+ require 'minitest/autorun'
3
+
4
+ $:.unshift File.expand_path '../lib', File.dirname(__FILE__)
5
+ require 'arduino_ir_remote'
@@ -0,0 +1,24 @@
1
+ require File.expand_path 'test_helper', File.dirname(__FILE__)
2
+
3
+ class TestIrRemote < MiniTest::Test
4
+
5
+ def setup
6
+ @ir = ArduinoIrRemote.connect ENV["ARDUINO"]
7
+ end
8
+
9
+ def teardown
10
+ @ir.close
11
+ end
12
+
13
+ def test_analog_read
14
+ 0.upto(5) do |pin|
15
+ ain = @ir.analog_read pin
16
+ assert 0 <= ain and ain < 1024
17
+ end
18
+ end
19
+
20
+ def test_temp_sensor
21
+ assert_instance_of Float, @ir.temp_sensor
22
+ end
23
+
24
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: arduino_ir_remote
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sho Hashimoto
@@ -94,7 +94,22 @@ dependencies:
94
94
  - - '>='
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
- description: IR Learning Remote with Arduino and Ruby
97
+ - !ruby/object:Gem::Dependency
98
+ name: minitest
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ description: This Rubygem provides a wrapper for IR-Learning-Remote that has been
112
+ built using the Arduino. https://github.com/shokai/arduino_ir_remote
98
113
  email:
99
114
  - hashimoto@shokai.org
100
115
  executables:
@@ -117,6 +132,8 @@ files:
117
132
  - lib/arduino_ir_remote/main.rb
118
133
  - lib/arduino_ir_remote/version.rb
119
134
  - samples/read_sensor.rb
135
+ - test/test_helper.rb
136
+ - test/test_ir_remote.rb
120
137
  homepage: https://github.com/shokai/arduino_ir_remote
121
138
  licenses:
122
139
  - MIT
@@ -142,4 +159,6 @@ signing_key:
142
159
  specification_version: 4
143
160
  summary: This Rubygem provides a wrapper for IR-Learning-Remote that has been built
144
161
  using the Arduino. https://github.com/shokai/arduino_ir_remote
145
- test_files: []
162
+ test_files:
163
+ - test/test_helper.rb
164
+ - test/test_ir_remote.rb