electric_eye 0.0.3 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.org +20 -8
- data/bin/electric_eye +6 -1
- data/features/electric_eye.feature +8 -7
- data/lib/electric_eye/config_eye.rb +17 -4
- data/lib/electric_eye/motion.rb +44 -0
- data/lib/electric_eye/record.rb +27 -4
- data/lib/electric_eye/version.rb +1 -1
- data/lib/electric_eye.rb +1 -0
- data/man/electric_eye.1 +2 -2
- data/man/electric_eye.1.html +2 -2
- data/man/electric_eye.1.ronn +2 -2
- data/spec/config_spec.rb +46 -7
- data/spec/fixtures/movement.log +1219 -0
- data/spec/fixtures/no_movement.log +1219 -0
- data/spec/motion_spec.rb +79 -0
- data/spec/{electric_eye_spec.rb → record_spec.rb} +21 -1
- metadata +11 -4
data/spec/motion_spec.rb
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
require ('spec_helper.rb')
|
2
|
+
|
3
|
+
describe "motion" do
|
4
|
+
before do
|
5
|
+
@motion = ElectricEye::Motion.new
|
6
|
+
end
|
7
|
+
|
8
|
+
describe "#read_log" do
|
9
|
+
context "with file passed" do
|
10
|
+
before do
|
11
|
+
@results = @motion.read_log('spec/fixtures/movement.log')
|
12
|
+
end
|
13
|
+
|
14
|
+
it "returns data" do
|
15
|
+
expect(@results.nil?).to equal(false)
|
16
|
+
end
|
17
|
+
|
18
|
+
it "returns motion detect lines" do
|
19
|
+
expect(@results[0]).to match(/motiondetect filter debug: Counted 0 moving shapes./)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
context "with a file which doesn't exist" do
|
24
|
+
before do
|
25
|
+
@results = @motion.read_log('spec/does/not/exist')
|
26
|
+
end
|
27
|
+
|
28
|
+
it "returns a blank array" do
|
29
|
+
expect(@results.length).to equal(0)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe "#get_movement" do
|
35
|
+
context "with single digit" do
|
36
|
+
it "returns 1" do
|
37
|
+
expect(@motion.movement("[0x1572e58] motiondetect filter debug: Counted 1 moving shapes.")).to equal(1)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
context "with double digit" do
|
42
|
+
it "returns 10" do
|
43
|
+
expect(@motion.movement("[0x1572e58] motiondetect filter debug: Counted 10 moving shapes.")).to equal(10)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe "#detect" do
|
49
|
+
context "when there is movement" do
|
50
|
+
before do
|
51
|
+
@file = 'spec/fixtures/movement.log'
|
52
|
+
end
|
53
|
+
|
54
|
+
context "with a threshold of 2" do
|
55
|
+
it "returns true" do
|
56
|
+
expect(@motion.detect(@file,2)).to equal(true)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
context "with no threshold" do
|
61
|
+
it "returns true" do
|
62
|
+
expect(@motion.detect(@file)).to equal(true)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
context "when there is no movement" do
|
68
|
+
before do
|
69
|
+
@file = 'spec/fixtures/no_movement.log'
|
70
|
+
end
|
71
|
+
|
72
|
+
it "returns false" do
|
73
|
+
expect(@motion.detect(@file,2)).to equal(false)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
|
79
|
+
end
|
@@ -38,7 +38,7 @@ describe "record" do
|
|
38
38
|
|
39
39
|
it "returns a full path with todays date" do
|
40
40
|
path = @record.path(@configEye.config.cameras.first)
|
41
|
-
expect(path).to include("~/recordings/Reception/20150630-1005-Reception
|
41
|
+
expect(path).to include("~/recordings/Reception/20150630-1005-Reception")
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
@@ -74,4 +74,24 @@ describe "record" do
|
|
74
74
|
expect(File.exists?("/tmp/electric_eye.pid")).to equal(false)
|
75
75
|
end
|
76
76
|
end
|
77
|
+
|
78
|
+
describe "#remove" do
|
79
|
+
before do
|
80
|
+
@path = "/tmp/electric_eye"
|
81
|
+
File.new("#{@path}.log", "w")
|
82
|
+
File.new("#{@path}.mjpeg", "w")
|
83
|
+
end
|
84
|
+
|
85
|
+
it "removes recording" do
|
86
|
+
expect(File.exist?("#{@path}.mjpeg")).to equal(true)
|
87
|
+
@record.remove(@path)
|
88
|
+
expect(File.exist?("#{@path}.mjpeg")).to equal(false)
|
89
|
+
end
|
90
|
+
|
91
|
+
it "removes log" do
|
92
|
+
expect(File.exist?("#{@path}.log")).to equal(true)
|
93
|
+
@record.remove(@path)
|
94
|
+
expect(File.exist?("#{@path}.log")).to equal(false)
|
95
|
+
end
|
96
|
+
end
|
77
97
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: electric_eye
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Pope
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-07-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: construct
|
@@ -218,6 +218,7 @@ files:
|
|
218
218
|
- features/support/env.rb
|
219
219
|
- lib/electric_eye.rb
|
220
220
|
- lib/electric_eye/config_eye.rb
|
221
|
+
- lib/electric_eye/motion.rb
|
221
222
|
- lib/electric_eye/record.rb
|
222
223
|
- lib/electric_eye/settings.rb
|
223
224
|
- lib/electric_eye/version.rb
|
@@ -225,7 +226,10 @@ files:
|
|
225
226
|
- man/electric_eye.1.html
|
226
227
|
- man/electric_eye.1.ronn
|
227
228
|
- spec/config_spec.rb
|
228
|
-
- spec/
|
229
|
+
- spec/fixtures/movement.log
|
230
|
+
- spec/fixtures/no_movement.log
|
231
|
+
- spec/motion_spec.rb
|
232
|
+
- spec/record_spec.rb
|
229
233
|
- spec/spec_helper.rb
|
230
234
|
homepage: https://github.com/map7/electric_eye
|
231
235
|
licenses:
|
@@ -259,5 +263,8 @@ test_files:
|
|
259
263
|
- features/step_definitions/electric_eye_steps.rb
|
260
264
|
- features/support/env.rb
|
261
265
|
- spec/config_spec.rb
|
262
|
-
- spec/
|
266
|
+
- spec/fixtures/movement.log
|
267
|
+
- spec/fixtures/no_movement.log
|
268
|
+
- spec/motion_spec.rb
|
269
|
+
- spec/record_spec.rb
|
263
270
|
- spec/spec_helper.rb
|