traffic_light 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -2,13 +2,14 @@ require 'rubygems'
2
2
  require 'rake'
3
3
  require 'echoe'
4
4
 
5
- Echoe.new('traffic_light', '0.1.0') do |p|
5
+ Echoe.new('traffic_light', '0.2.0') do |p|
6
6
  p.description = "Drive a traffic light with an Arduino."
7
7
  p.url = "http://github.com/nledez/traffic_light"
8
8
  p.author = "Nicolas Ledez"
9
9
  p.email = "rubygems@ledez.net"
10
10
  p.ignore_pattern = ["tmp/*", "script/*"]
11
11
  p.development_dependencies = []
12
+ p.runtime_dependencies = [ "serialport" ]
12
13
  end
13
14
 
14
- Dir["#{File.dirname(__FILE__)}/tasks/*.rake"].sort.each { |ext| load ext }
15
+ Dir["#{File.dirname(__FILE__)}/tasks/*.rake"].sort.each { |ext| load ext }
@@ -13,9 +13,20 @@ class TrafficLight
13
13
  @sp = SerialPort.new(@port_str, @baud_rate, @data_bits, @stop_bits, @parity)
14
14
  @sp.read_timeout = 1000
15
15
 
16
+ @opened = true
17
+
16
18
  clear
17
19
  end
18
20
 
21
+ def open?
22
+ @opened
23
+ end
24
+
25
+ def close!
26
+ @sp.close
27
+ @opened = false
28
+ end
29
+
19
30
  def read
20
31
  @message = @sp.read.chomp
21
32
  end
@@ -44,4 +44,10 @@ describe "Can change light colors" do
44
44
  @traffic.all
45
45
  @traffic.message.should == "7 -> GOR"
46
46
  end
47
+
48
+ it "Close socket" do
49
+ @traffic.open? == true
50
+ @traffic.close!
51
+ @traffic.open? == false
52
+ end
47
53
  end
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "traffic_light"
5
- s.version = "0.1.0"
5
+ s.version = "0.2.0"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Nicolas Ledez"]
9
- s.date = "2012-07-28"
9
+ s.date = "2012-07-29"
10
10
  s.description = "Drive a traffic light with an Arduino."
11
11
  s.email = "rubygems@ledez.net"
12
12
  s.extra_rdoc_files = ["README.rdoc", "lib/traffic_light.rb"]
@@ -22,8 +22,11 @@ Gem::Specification.new do |s|
22
22
  s.specification_version = 3
23
23
 
24
24
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
25
+ s.add_runtime_dependency(%q<serialport>, [">= 0"])
25
26
  else
27
+ s.add_dependency(%q<serialport>, [">= 0"])
26
28
  end
27
29
  else
30
+ s.add_dependency(%q<serialport>, [">= 0"])
28
31
  end
29
32
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: traffic_light
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,8 +9,24 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-28 00:00:00.000000000 Z
13
- dependencies: []
12
+ date: 2012-07-29 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: serialport
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
14
30
  description: Drive a traffic light with an Arduino.
15
31
  email: rubygems@ledez.net
16
32
  executables: []