foscam-ruby 0.0.3 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +6 -14
- data/.travis.yml +1 -1
- data/foscam-ruby.gemspec +1 -0
- data/lib/foscam-ruby.rb +20 -0
- data/lib/foscam/client.rb +69 -248
- data/lib/foscam/constants.rb +144 -0
- data/lib/foscam/model/alarm_config.rb +147 -0
- data/lib/foscam/model/base.rb +48 -0
- data/lib/foscam/model/device.rb +92 -0
- data/lib/foscam/model/ftp_server.rb +109 -0
- data/lib/foscam/model/mail_server.rb +124 -0
- data/lib/foscam/model/network.rb +79 -0
- data/lib/foscam/model/user.rb +174 -0
- data/lib/foscam/schedule/day.rb +63 -0
- data/lib/foscam/schedule/third_of_a_day.rb +42 -0
- data/lib/foscam/schedule/week.rb +89 -0
- data/lib/foscam/version.rb +1 -1
- data/spec/foscam/client_spec.rb +18 -60
- data/spec/foscam/model/alarm_config_spec.rb +164 -0
- data/spec/foscam/model/base_spec.rb +22 -0
- data/spec/foscam/model/device_spec.rb +136 -0
- data/spec/foscam/model/ftp_server_spec.rb +135 -0
- data/spec/foscam/model/mail_server_spec.rb +126 -0
- data/spec/foscam/model/network_spec.rb +128 -0
- data/spec/foscam/model/user_spec.rb +322 -0
- data/spec/foscam/schedule/day_spec.rb +37 -0
- data/spec/foscam/schedule/third_of_a_day_spec.rb +42 -0
- data/spec/foscam/schedule/week_spec.rb +109 -0
- metadata +64 -19
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Foscam::Schedule::Day do
|
4
|
+
|
5
|
+
before(:each) do
|
6
|
+
@day = Foscam::Schedule::Day.new(0,0,0)
|
7
|
+
end
|
8
|
+
describe "#to_hash" do
|
9
|
+
it "returns a hash with 96 keys" do
|
10
|
+
h = @day.to_hash
|
11
|
+
h.should be_a_kind_of(Hash)
|
12
|
+
h.keys.length.should == 96
|
13
|
+
end
|
14
|
+
it "uses the times as the keys" do
|
15
|
+
h = @day.to_hash
|
16
|
+
23.times do |hour|
|
17
|
+
[0,15,30,45].each do |minute|
|
18
|
+
h.should have_key("#{"%02d" % hour}:#{"%02d" % minute}")
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe "#busy_at?" do
|
25
|
+
context "with even bits set" do
|
26
|
+
before(:each) do
|
27
|
+
@day = Foscam::Schedule::Day.new(1,1,1)
|
28
|
+
end
|
29
|
+
it "is busy in the first 15 minutes of each eight hour block" do
|
30
|
+
@day.should be_busy_at(Time.new(2013,5,2,0,5,0))
|
31
|
+
@day.should be_busy_at(Time.new(2013,5,2,8,5,0))
|
32
|
+
@day.should be_busy_at(Time.new(2013,5,2,16,5,0))
|
33
|
+
@day.should_not be_busy_at(Time.new(2013,5,2,17,5,0))
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Foscam::Schedule::ThirdOfADay do
|
4
|
+
|
5
|
+
before(:each) do
|
6
|
+
@toad = Foscam::Schedule::ThirdOfADay.new(1431655765)
|
7
|
+
end
|
8
|
+
describe "#to_hash" do
|
9
|
+
it "returns a hash with 32 values" do
|
10
|
+
h = @toad.to_hash
|
11
|
+
h.should be_a_kind_of(Hash)
|
12
|
+
h.keys.length.should == 32
|
13
|
+
end
|
14
|
+
it "sets the busy times to true and otherwise false" do
|
15
|
+
h = @toad.to_hash
|
16
|
+
32.times do |i|
|
17
|
+
if (i % 2 == 0)
|
18
|
+
h[i].should be_true
|
19
|
+
else
|
20
|
+
h[i].should be_false
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe "#active?" do
|
28
|
+
context "with even bits set" do
|
29
|
+
before(:each) do
|
30
|
+
@toad = Foscam::Schedule::ThirdOfADay.new(286331153)
|
31
|
+
end
|
32
|
+
it "is busy in the first 15 minutes of each hour" do
|
33
|
+
[0,4,8,12,16,20,24,28].each do |idx|
|
34
|
+
@toad.should be_active(idx)
|
35
|
+
end
|
36
|
+
[1,2,3,5,6,7,9,10,11,13,14,15,17,18,19,21,22,23,25,26,27,29,30,31].each do |idx|
|
37
|
+
@toad.should_not be_active(idx)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,109 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Foscam::Schedule::Week do
|
4
|
+
|
5
|
+
def valid_params
|
6
|
+
{
|
7
|
+
:sun_0 => 1, # 00:00 - 00:15
|
8
|
+
:sun_1 => 2, # 08:15 - 08:30
|
9
|
+
:sun_2 => 4, # 16:30 - 16:45
|
10
|
+
:mon_0 => 8, # 00:45 - 01:00
|
11
|
+
:mon_1 => 16, # 09:00 - 09:15
|
12
|
+
:mon_2 => 32, # 17:15 - 17:30
|
13
|
+
:tue_0 => 64, # 01:30 - 01:45
|
14
|
+
:tue_1 => 128, # 09:45 - 10:00
|
15
|
+
:tue_2 => 256, # 18:00 - 18:15
|
16
|
+
:wed_0 => 512, # 02:15 - 02:30
|
17
|
+
:wed_1 => 1024, # 10:30 - 10:45
|
18
|
+
:wed_2 => 2048, # 18:45 - 19:00
|
19
|
+
:thu_0 => 4096, # 03:00 - 03:15
|
20
|
+
:thu_1 => 8192, # 11:15 - 11:30
|
21
|
+
:thu_2 => 16384, # 19:30 - 19:45
|
22
|
+
:fri_0 => 32768, # 03:45 - 04:00
|
23
|
+
:fri_1 => 65536, # 12:00 - 12:15
|
24
|
+
:fri_2 => 131072, # 20:15 - 20:30
|
25
|
+
:sat_0 => 262144, # 04:30 - 04:45
|
26
|
+
:sat_1 => 524288, # 12:45 - 13:00
|
27
|
+
:sat_2 => 1048576, # 21:00 - 21:15
|
28
|
+
}
|
29
|
+
end
|
30
|
+
|
31
|
+
describe "#to_hash" do
|
32
|
+
before(:each) do
|
33
|
+
@week = Foscam::Schedule::Week.new(valid_params)
|
34
|
+
end
|
35
|
+
it "returns a hash with 7 keys" do
|
36
|
+
h = @week.to_hash
|
37
|
+
h.should be_a_kind_of(Hash)
|
38
|
+
h.keys.length.should == 7
|
39
|
+
end
|
40
|
+
it "uses the days of the week as the keys" do
|
41
|
+
h = @week.to_hash
|
42
|
+
[:sunday, :monday, :tuesday, :wednesday, :thursday, :friday, :saturday].each do |day|
|
43
|
+
h.should have_key(day)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
it "converts each of the days as a value to a hash" do
|
47
|
+
# @week.days.each do |day|
|
48
|
+
# day.should_receive(:to_hash).once
|
49
|
+
# end
|
50
|
+
h = @week.to_hash
|
51
|
+
[:sunday, :monday, :tuesday, :wednesday, :thursday, :friday, :saturday].each do |day|
|
52
|
+
h[day].should be_a_kind_of(Hash)
|
53
|
+
h[day].keys.length.should == 96
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
describe "#to_param" do
|
59
|
+
it "converts the object back to the input hash" do
|
60
|
+
week = Foscam::Schedule::Week.new(valid_params)
|
61
|
+
week.to_param.should == valid_params
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
describe "#busy_at?" do
|
66
|
+
context "with even bits set" do
|
67
|
+
before(:each) do
|
68
|
+
@week = Foscam::Schedule::Week.new(valid_params)
|
69
|
+
end
|
70
|
+
it "is busy in the first 15 minutes of each eight hour block" do
|
71
|
+
# sunday
|
72
|
+
@week.should be_busy_at(Time.new(2013,5,5,0,5,0)) # 00:00 - 00:15
|
73
|
+
@week.should be_busy_at(Time.new(2013,5,5,8,20,0)) # 08:15 - 08:30
|
74
|
+
@week.should be_busy_at(Time.new(2013,5,5,16,35,0)) # 16:30 - 16:45
|
75
|
+
|
76
|
+
# # monday
|
77
|
+
@week.should be_busy_at(Time.new(2013,5,6,0,50,0)) # 00:45 - 01:00
|
78
|
+
@week.should be_busy_at(Time.new(2013,5,6,9,5,0)) # 09:00 - 09:15
|
79
|
+
@week.should be_busy_at(Time.new(2013,5,6,17,20,0)) # 17:15 - 17:30
|
80
|
+
|
81
|
+
|
82
|
+
# tuesday
|
83
|
+
@week.should be_busy_at(Time.new(2013,5,7,1,35,0)) # 01:30 - 01:45
|
84
|
+
@week.should be_busy_at(Time.new(2013,5,7,9,50,0)) # 09:45 - 10:00
|
85
|
+
@week.should be_busy_at(Time.new(2013,5,7,18,5,0)) # 18:00 - 18:15
|
86
|
+
|
87
|
+
# wednesday
|
88
|
+
@week.should be_busy_at(Time.new(2013,5,8,2,20,0)) # 02:15 - 02:30
|
89
|
+
@week.should be_busy_at(Time.new(2013,5,8,10,35,0)) # 10:30 - 10:45
|
90
|
+
@week.should be_busy_at(Time.new(2013,5,8,18,50,0)) # 18:45 - 19:00
|
91
|
+
|
92
|
+
# thursday
|
93
|
+
@week.should be_busy_at(Time.new(2013,5,9,3,5,0)) # 03:00 - 03:15
|
94
|
+
@week.should be_busy_at(Time.new(2013,5,9,11,20,0)) # 11:15 - 11:30
|
95
|
+
@week.should be_busy_at(Time.new(2013,5,9,19,35,0)) # 19:30 - 19:45
|
96
|
+
|
97
|
+
# friday
|
98
|
+
@week.should be_busy_at(Time.new(2013,5,10,3,50,0)) # 03:45 - 04:00
|
99
|
+
@week.should be_busy_at(Time.new(2013,5,10,12,05,0))# 12:00 - 12:15
|
100
|
+
@week.should be_busy_at(Time.new(2013,5,10,20,20,0))# 20:15 - 20:30
|
101
|
+
|
102
|
+
# saturday
|
103
|
+
@week.should be_busy_at(Time.new(2013,5,11,4,35,0)) # 04:30 - 04:45
|
104
|
+
@week.should be_busy_at(Time.new(2013,5,11,12,50,0))# 12:45 - 13:00
|
105
|
+
@week.should be_busy_at(Time.new(2013,5,11,21,5,0)) # 21:00 - 21:15
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
metadata
CHANGED
@@ -1,55 +1,69 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foscam-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Waddington
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-03-
|
11
|
+
date: 2013-03-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - '>='
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - '>='
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: mini_magick
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - '>='
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - '>='
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: active_support
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - '>='
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: activemodel
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
53
67
|
- !ruby/object:Gem::Version
|
54
68
|
version: '0'
|
55
69
|
- !ruby/object:Gem::Dependency
|
@@ -70,56 +84,56 @@ dependencies:
|
|
70
84
|
name: rake
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
72
86
|
requirements:
|
73
|
-
- -
|
87
|
+
- - '>='
|
74
88
|
- !ruby/object:Gem::Version
|
75
89
|
version: '0'
|
76
90
|
type: :development
|
77
91
|
prerelease: false
|
78
92
|
version_requirements: !ruby/object:Gem::Requirement
|
79
93
|
requirements:
|
80
|
-
- -
|
94
|
+
- - '>='
|
81
95
|
- !ruby/object:Gem::Version
|
82
96
|
version: '0'
|
83
97
|
- !ruby/object:Gem::Dependency
|
84
98
|
name: rspec
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
86
100
|
requirements:
|
87
|
-
- -
|
101
|
+
- - '>='
|
88
102
|
- !ruby/object:Gem::Version
|
89
103
|
version: '0'
|
90
104
|
type: :development
|
91
105
|
prerelease: false
|
92
106
|
version_requirements: !ruby/object:Gem::Requirement
|
93
107
|
requirements:
|
94
|
-
- -
|
108
|
+
- - '>='
|
95
109
|
- !ruby/object:Gem::Version
|
96
110
|
version: '0'
|
97
111
|
- !ruby/object:Gem::Dependency
|
98
112
|
name: vcr
|
99
113
|
requirement: !ruby/object:Gem::Requirement
|
100
114
|
requirements:
|
101
|
-
- -
|
115
|
+
- - '>='
|
102
116
|
- !ruby/object:Gem::Version
|
103
117
|
version: '0'
|
104
118
|
type: :development
|
105
119
|
prerelease: false
|
106
120
|
version_requirements: !ruby/object:Gem::Requirement
|
107
121
|
requirements:
|
108
|
-
- -
|
122
|
+
- - '>='
|
109
123
|
- !ruby/object:Gem::Version
|
110
124
|
version: '0'
|
111
125
|
- !ruby/object:Gem::Dependency
|
112
126
|
name: webmock
|
113
127
|
requirement: !ruby/object:Gem::Requirement
|
114
128
|
requirements:
|
115
|
-
- -
|
129
|
+
- - '>='
|
116
130
|
- !ruby/object:Gem::Version
|
117
131
|
version: '0'
|
118
132
|
type: :development
|
119
133
|
prerelease: false
|
120
134
|
version_requirements: !ruby/object:Gem::Requirement
|
121
135
|
requirements:
|
122
|
-
- -
|
136
|
+
- - '>='
|
123
137
|
- !ruby/object:Gem::Version
|
124
138
|
version: '0'
|
125
139
|
description: A ruby client for the foscam SDK.
|
@@ -138,6 +152,17 @@ files:
|
|
138
152
|
- foscam-ruby.gemspec
|
139
153
|
- lib/foscam-ruby.rb
|
140
154
|
- lib/foscam/client.rb
|
155
|
+
- lib/foscam/constants.rb
|
156
|
+
- lib/foscam/model/alarm_config.rb
|
157
|
+
- lib/foscam/model/base.rb
|
158
|
+
- lib/foscam/model/device.rb
|
159
|
+
- lib/foscam/model/ftp_server.rb
|
160
|
+
- lib/foscam/model/mail_server.rb
|
161
|
+
- lib/foscam/model/network.rb
|
162
|
+
- lib/foscam/model/user.rb
|
163
|
+
- lib/foscam/schedule/day.rb
|
164
|
+
- lib/foscam/schedule/third_of_a_day.rb
|
165
|
+
- lib/foscam/schedule/week.rb
|
141
166
|
- lib/foscam/version.rb
|
142
167
|
- spec/fixtures/vcr/foscam_camera_control_brightness.yml
|
143
168
|
- spec/fixtures/vcr/foscam_camera_control_contrast.yml
|
@@ -177,6 +202,16 @@ files:
|
|
177
202
|
- spec/fixtures/vcr/foscam_upgrade_firmware.yml
|
178
203
|
- spec/fixtures/vcr/foscam_upgrade_htmls.yml
|
179
204
|
- spec/foscam/client_spec.rb
|
205
|
+
- spec/foscam/model/alarm_config_spec.rb
|
206
|
+
- spec/foscam/model/base_spec.rb
|
207
|
+
- spec/foscam/model/device_spec.rb
|
208
|
+
- spec/foscam/model/ftp_server_spec.rb
|
209
|
+
- spec/foscam/model/mail_server_spec.rb
|
210
|
+
- spec/foscam/model/network_spec.rb
|
211
|
+
- spec/foscam/model/user_spec.rb
|
212
|
+
- spec/foscam/schedule/day_spec.rb
|
213
|
+
- spec/foscam/schedule/third_of_a_day_spec.rb
|
214
|
+
- spec/foscam/schedule/week_spec.rb
|
180
215
|
- spec/spec_helper.rb
|
181
216
|
homepage: https://github.com/cwadding/foscam-ruby
|
182
217
|
licenses:
|
@@ -188,17 +223,17 @@ require_paths:
|
|
188
223
|
- lib
|
189
224
|
required_ruby_version: !ruby/object:Gem::Requirement
|
190
225
|
requirements:
|
191
|
-
- -
|
226
|
+
- - '>='
|
192
227
|
- !ruby/object:Gem::Version
|
193
228
|
version: '0'
|
194
229
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
195
230
|
requirements:
|
196
|
-
- -
|
231
|
+
- - '>='
|
197
232
|
- !ruby/object:Gem::Version
|
198
233
|
version: '0'
|
199
234
|
requirements: []
|
200
235
|
rubyforge_project:
|
201
|
-
rubygems_version: 2.0.
|
236
|
+
rubygems_version: 2.0.2
|
202
237
|
signing_key:
|
203
238
|
specification_version: 4
|
204
239
|
summary: A ruby client for the foscam SDK.
|
@@ -241,4 +276,14 @@ test_files:
|
|
241
276
|
- spec/fixtures/vcr/foscam_upgrade_firmware.yml
|
242
277
|
- spec/fixtures/vcr/foscam_upgrade_htmls.yml
|
243
278
|
- spec/foscam/client_spec.rb
|
279
|
+
- spec/foscam/model/alarm_config_spec.rb
|
280
|
+
- spec/foscam/model/base_spec.rb
|
281
|
+
- spec/foscam/model/device_spec.rb
|
282
|
+
- spec/foscam/model/ftp_server_spec.rb
|
283
|
+
- spec/foscam/model/mail_server_spec.rb
|
284
|
+
- spec/foscam/model/network_spec.rb
|
285
|
+
- spec/foscam/model/user_spec.rb
|
286
|
+
- spec/foscam/schedule/day_spec.rb
|
287
|
+
- spec/foscam/schedule/third_of_a_day_spec.rb
|
288
|
+
- spec/foscam/schedule/week_spec.rb
|
244
289
|
- spec/spec_helper.rb
|