tag-it 0.1.1 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +7 -3
- data/Gemfile.lock +2 -0
- data/README.rdoc +5 -1
- data/VERSION +1 -1
- data/lib/tag_it/tag_tracker.rb +10 -0
- data/pkg/tag-it-0.1.0.gem +0 -0
- data/tag-it.gemspec +61 -0
- data/test/helper.rb +1 -0
- data/test/test_tag_tracker.rb +18 -0
- metadata +6 -4
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
data/README.rdoc
CHANGED
@@ -32,6 +32,8 @@ Typical usage involves building an observer like this:
|
|
32
32
|
# do something because a tag has come into range
|
33
33
|
elsif event == :tag_departed
|
34
34
|
# do something because a tag has gone out of range
|
35
|
+
elsif even == :pulse
|
36
|
+
# let something know the client is still active
|
35
37
|
end
|
36
38
|
end
|
37
39
|
end
|
@@ -45,7 +47,9 @@ And then attaching it to a tag-it tag_tracker like this:
|
|
45
47
|
tracher.add_observer(watcher)
|
46
48
|
tracker.start!
|
47
49
|
|
48
|
-
the tracker will run indefinately, pulling in tag ids as they come into range and leave the area, and dispatch the necessary events. Right now there are
|
50
|
+
the tracker will run indefinately, pulling in tag ids as they come into range and leave the area, and dispatch the necessary events. It also will dispatch a "pulse" event every 3 minutes so you know that the client is still running. Right now there are 3 events -- :tag_arrived when the tag comes into range, :tag_departed when it leaves, and the :pulse event every three minutes. The other parameters to the update method are the tag id ("1nrw") and the Relative Signal Strength (an integer: 34, 86, etc) indicating how close to the source the tag is.
|
51
|
+
|
52
|
+
ATTENTION!: In the "pulse" event, the tag parameter will actually be an array of currently in-range tags
|
49
53
|
|
50
54
|
Happy Tagging!
|
51
55
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.1
|
data/lib/tag_it/tag_tracker.rb
CHANGED
@@ -9,6 +9,7 @@ module TagIt
|
|
9
9
|
def initialize(port)
|
10
10
|
@port = port
|
11
11
|
@tag_map ||= {}
|
12
|
+
@last_pulse = Time.now
|
12
13
|
end
|
13
14
|
|
14
15
|
def start!
|
@@ -38,6 +39,9 @@ module TagIt
|
|
38
39
|
rescue Timeout::Error
|
39
40
|
depart_all_tags!
|
40
41
|
end
|
42
|
+
if ((Time.now - 180) > @last_pulse)
|
43
|
+
pulse!
|
44
|
+
end
|
41
45
|
end
|
42
46
|
end
|
43
47
|
|
@@ -74,5 +78,11 @@ module TagIt
|
|
74
78
|
def split_tag_data(tag_name)
|
75
79
|
[tag_name[0,4],tag_name[4,tag_name.size - 4].to_i]
|
76
80
|
end
|
81
|
+
|
82
|
+
def pulse!
|
83
|
+
changed
|
84
|
+
notify_observers(@tag_map.keys.sort,0,:pulse)
|
85
|
+
@last_pulse = Time.now
|
86
|
+
end
|
77
87
|
end
|
78
88
|
end
|
Binary file
|
data/tag-it.gemspec
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{tag-it}
|
8
|
+
s.version = "0.2.1"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["evizitei"]
|
12
|
+
s.date = %q{2010-10-23}
|
13
|
+
s.description = %q{Interacting with RFID receivers through serial ports is not much fun. This makes it a little better. tag-it provides a class that will monitor a serial port for you, and will dispatch events through ruby's standard "observer" functionality when a tag comes into range and leaves.}
|
14
|
+
s.email = %q{ethan.vizitei@gmail.com}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE",
|
17
|
+
"README.rdoc"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".bundle/config",
|
21
|
+
".document",
|
22
|
+
".gitignore",
|
23
|
+
"Gemfile",
|
24
|
+
"Gemfile.lock",
|
25
|
+
"LICENSE",
|
26
|
+
"README.rdoc",
|
27
|
+
"Rakefile",
|
28
|
+
"VERSION",
|
29
|
+
"lib/tag_it.rb",
|
30
|
+
"lib/tag_it/tag_tracker.rb",
|
31
|
+
"pkg/tag-it-0.1.0.gem",
|
32
|
+
"tag-it.gemspec",
|
33
|
+
"test/helper.rb",
|
34
|
+
"test/mock_serial_port.rb",
|
35
|
+
"test/test_tag_tracker.rb"
|
36
|
+
]
|
37
|
+
s.homepage = %q{http://github.com/evizitei/tag-it}
|
38
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
39
|
+
s.require_paths = ["lib"]
|
40
|
+
s.rubygems_version = %q{1.3.7}
|
41
|
+
s.summary = %q{interaction with RFID receiver through a serial port.}
|
42
|
+
s.test_files = [
|
43
|
+
"test/helper.rb",
|
44
|
+
"test/mock_serial_port.rb",
|
45
|
+
"test/test_tag_tracker.rb"
|
46
|
+
]
|
47
|
+
|
48
|
+
if s.respond_to? :specification_version then
|
49
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
50
|
+
s.specification_version = 3
|
51
|
+
|
52
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
53
|
+
s.add_development_dependency(%q<thoughtbot-shoulda>, [">= 0"])
|
54
|
+
else
|
55
|
+
s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
|
56
|
+
end
|
57
|
+
else
|
58
|
+
s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
data/test/helper.rb
CHANGED
data/test/test_tag_tracker.rb
CHANGED
@@ -44,6 +44,24 @@ class TestTagTracker < Test::Unit::TestCase
|
|
44
44
|
watcher.expects(:update).with("1nri",0,:tag_departed).times(1)
|
45
45
|
check_data_extract(data,watcher,PacingSerialPort)
|
46
46
|
end
|
47
|
+
|
48
|
+
should "dispatch a heartbeat event every 180 seconds" do
|
49
|
+
start_time = Time.local(2008, 9, 1, 12, 0, 0)
|
50
|
+
end_time = start_time + 300
|
51
|
+
Timecop.freeze(start_time)
|
52
|
+
data = " 1nri85 1nwP79 "
|
53
|
+
watcher = TagObserver.new
|
54
|
+
watcher.expects(:update).with("1nri",85,:tag_arrived).times(1)
|
55
|
+
watcher.expects(:update).with("1nwP",79,:tag_arrived).times(1)
|
56
|
+
watcher.expects(:update).with(["1nri","1nwP"],0,:pulse).times(1)
|
57
|
+
port = MockSerialPort.new(data)
|
58
|
+
tracker = TagIt::TagTracker.new(port)
|
59
|
+
tracker.add_observer(watcher)
|
60
|
+
tracker.start!
|
61
|
+
Timecop.travel(end_time)
|
62
|
+
tracker.start!
|
63
|
+
Timecop.return
|
64
|
+
end
|
47
65
|
end
|
48
66
|
|
49
67
|
def check_data_extract(data,watcher,port_mocker = MockSerialPort)
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tag-it
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 21
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
+
- 2
|
8
9
|
- 1
|
9
|
-
|
10
|
-
version: 0.1.1
|
10
|
+
version: 0.2.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- evizitei
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-10-
|
18
|
+
date: 2010-10-23 00:00:00 -05:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -53,6 +53,8 @@ files:
|
|
53
53
|
- VERSION
|
54
54
|
- lib/tag_it.rb
|
55
55
|
- lib/tag_it/tag_tracker.rb
|
56
|
+
- pkg/tag-it-0.1.0.gem
|
57
|
+
- tag-it.gemspec
|
56
58
|
- test/helper.rb
|
57
59
|
- test/mock_serial_port.rb
|
58
60
|
- test/test_tag_tracker.rb
|