all_seeing_pi 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +47 -0
- data/LICENSE.txt +22 -0
- data/README.md +36 -0
- data/Rakefile +20 -0
- data/all_seeing_pi.gemspec +28 -0
- data/capture.sh +6 -0
- data/lib/all_seeing_pi.rb +14 -0
- data/lib/all_seeing_pi/camera.rb +7 -0
- data/lib/all_seeing_pi/palantir.rb +31 -0
- data/lib/all_seeing_pi/uploader.rb +21 -0
- data/lib/all_seeing_pi/version.rb +3 -0
- data/test/fixtures/eye_of_sauron.jpg +0 -0
- data/test/test_camera.rb +13 -0
- data/test/test_helper.rb +15 -0
- data/test/test_palantir.rb +32 -0
- data/test/test_uploader.rb +14 -0
- metadata +183 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
all_seeing_pi (0.0.1)
|
5
|
+
aws-sdk
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
addressable (2.3.6)
|
11
|
+
aws-sdk (1.11.3)
|
12
|
+
json (~> 1.4)
|
13
|
+
nokogiri (< 1.6.0)
|
14
|
+
uuidtools (~> 2.1)
|
15
|
+
coderay (1.1.0)
|
16
|
+
crack (0.4.2)
|
17
|
+
safe_yaml (~> 1.0.0)
|
18
|
+
json (1.8.1)
|
19
|
+
metaclass (0.0.4)
|
20
|
+
method_source (0.8.2)
|
21
|
+
mocha (0.12.10)
|
22
|
+
metaclass (~> 0.0.1)
|
23
|
+
nokogiri (1.5.11)
|
24
|
+
pry (0.9.12.6)
|
25
|
+
coderay (~> 1.0)
|
26
|
+
method_source (~> 0.8)
|
27
|
+
slop (~> 3.4)
|
28
|
+
rake (10.3.2)
|
29
|
+
safe_yaml (1.0.4)
|
30
|
+
slop (3.5.0)
|
31
|
+
uuidtools (2.1.4)
|
32
|
+
vcr (2.4.0)
|
33
|
+
webmock (1.20.0)
|
34
|
+
addressable (>= 2.3.6)
|
35
|
+
crack (>= 0.3.2)
|
36
|
+
|
37
|
+
PLATFORMS
|
38
|
+
ruby
|
39
|
+
|
40
|
+
DEPENDENCIES
|
41
|
+
all_seeing_pi!
|
42
|
+
bundler (~> 1.5)
|
43
|
+
mocha
|
44
|
+
pry
|
45
|
+
rake
|
46
|
+
vcr
|
47
|
+
webmock
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Jonan Scheffler
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# All Seeing Pi
|
2
|
+
|
3
|
+
The one gem to rule homemade Raspberry Pi surveillance systems. This gem will
|
4
|
+
capture images one after another and upload them to an S3 bucket.
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'all_seeing_pi'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install all_seeing_pi
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
1. Setup a Raspberry Pi running NOOBS with a Raspberry Pi camera.
|
22
|
+
2. Set your AWS credentials by creating this file ~/.aws/credentials:
|
23
|
+
```
|
24
|
+
[default]
|
25
|
+
aws_access_key_id = your_access_key_id
|
26
|
+
aws_secret_access_key = your_secret_access_key
|
27
|
+
```
|
28
|
+
3. Install the gem and start capturing images with `rake watch`
|
29
|
+
|
30
|
+
## Contributing
|
31
|
+
|
32
|
+
1. Fork it ( http://github.com/1337807/all_seeing_pi/fork )
|
33
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
34
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
35
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
36
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'bundler'
|
2
|
+
require "bundler/gem_tasks"
|
3
|
+
require 'rake/testtask'
|
4
|
+
require 'fileutils'
|
5
|
+
|
6
|
+
Bundler.require
|
7
|
+
|
8
|
+
Rake::TestTask.new do |t|
|
9
|
+
t.libs << "test"
|
10
|
+
t.test_files = FileList['test/test*.rb']
|
11
|
+
t.verbose = true
|
12
|
+
end
|
13
|
+
|
14
|
+
task :vcr do
|
15
|
+
FileUtils.rm_rf('test/fixtures/vcr_cassettes')
|
16
|
+
end
|
17
|
+
|
18
|
+
task :watch do
|
19
|
+
AllSeeingPi.watch
|
20
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'all_seeing_pi/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "all_seeing_pi"
|
8
|
+
spec.version = AllSeeingPi::VERSION
|
9
|
+
spec.authors = ["Jonan Scheffler"]
|
10
|
+
spec.email = ["jonanscheffler@gmail.com"]
|
11
|
+
spec.summary = %q{A gem to capture images with a Raspberry Pi camera.}
|
12
|
+
spec.description = %q{The one gem to rule homemade Raspberry Pi surveillance systems. This gem will capture images one after another and upload them to an S3 bucket.}
|
13
|
+
spec.homepage = "http://github.com/1337807/all_seeing_pi"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.5"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
spec.add_development_dependency "mocha"
|
24
|
+
spec.add_development_dependency "pry"
|
25
|
+
spec.add_development_dependency "vcr"
|
26
|
+
spec.add_development_dependency "webmock"
|
27
|
+
spec.add_runtime_dependency "aws-sdk"
|
28
|
+
end
|
data/capture.sh
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require "all_seeing_pi/version"
|
2
|
+
require "all_seeing_pi/palantir"
|
3
|
+
require "all_seeing_pi/camera"
|
4
|
+
require "all_seeing_pi/uploader"
|
5
|
+
|
6
|
+
module AllSeeingPi
|
7
|
+
def self.watch
|
8
|
+
palantir = AllSeeingPi::Palantir.new
|
9
|
+
|
10
|
+
loop do
|
11
|
+
palantir.spy
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'all_seeing_pi/camera'
|
2
|
+
require 'all_seeing_pi/uploader'
|
3
|
+
|
4
|
+
module AllSeeingPi
|
5
|
+
class Palantir
|
6
|
+
attr_reader :camera, :uploader
|
7
|
+
|
8
|
+
def initialize
|
9
|
+
@camera = AllSeeingPi::Camera.new
|
10
|
+
@uploader = AllSeeingPi::Uploader.new
|
11
|
+
end
|
12
|
+
|
13
|
+
def spy
|
14
|
+
image_path = @camera.capture
|
15
|
+
return unless File.exists?(image_path)
|
16
|
+
|
17
|
+
report "Captured #{image_path}"
|
18
|
+
|
19
|
+
store_image(image_path)
|
20
|
+
FileUtils.rm(image_path)
|
21
|
+
end
|
22
|
+
|
23
|
+
def report(msg)
|
24
|
+
puts msg unless ENV['ALL_SEEING_PI_ENV'] == 'test'
|
25
|
+
end
|
26
|
+
|
27
|
+
def store_image(image_path)
|
28
|
+
@uploader.upload(image_path)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'aws-sdk'
|
2
|
+
|
3
|
+
module AllSeeingPi
|
4
|
+
class Uploader
|
5
|
+
BUCKET = 'all_seeing_pi'
|
6
|
+
|
7
|
+
attr_reader :s3
|
8
|
+
|
9
|
+
def initialize
|
10
|
+
@s3 = AWS::S3.new
|
11
|
+
end
|
12
|
+
|
13
|
+
def upload(image_path)
|
14
|
+
buckets = s3.buckets
|
15
|
+
buckets.create(BUCKET) unless buckets[BUCKET].exists?
|
16
|
+
|
17
|
+
filename = File.basename(image_path)
|
18
|
+
buckets[BUCKET].objects[filename].write(:file => image_path)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
Binary file
|
data/test/test_camera.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class CameraTest < MiniTest::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
@camera = AllSeeingPi::Camera.new
|
6
|
+
end
|
7
|
+
|
8
|
+
def test_capture
|
9
|
+
# date returns 'N' for %N on OSX
|
10
|
+
regex = /\d{4}-\d{2}-\d{2}_\d{2}-\d{2}-\d{2}-\d{9}|N\.jpg/
|
11
|
+
assert_match regex, @camera.capture
|
12
|
+
end
|
13
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'minitest/autorun'
|
2
|
+
|
3
|
+
Bundler.require
|
4
|
+
|
5
|
+
require 'vcr'
|
6
|
+
require 'mocha'
|
7
|
+
|
8
|
+
VCR.configure do |c|
|
9
|
+
c.cassette_library_dir = 'test/fixtures/vcr_cassettes'
|
10
|
+
c.hook_into :webmock
|
11
|
+
end
|
12
|
+
|
13
|
+
AWS.config(YAML.load_file('test/aws.yml'))
|
14
|
+
|
15
|
+
ENV['ALL_SEEING_PI_ENV'] = 'test'
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class PalantirTest < MiniTest::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
@fixture = 'test/fixtures/eye_of_sauron.jpg'
|
6
|
+
@palantir = AllSeeingPi::Palantir.new
|
7
|
+
end
|
8
|
+
|
9
|
+
def test_spy_sends_capture_to_the_camera
|
10
|
+
@palantir.stubs(:store_image)
|
11
|
+
FileUtils.stubs(:rm)
|
12
|
+
|
13
|
+
@palantir.camera.expects(:capture).returns(@fixture)
|
14
|
+
@palantir.spy
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_store_image
|
18
|
+
@palantir.camera.stubs(:capture).returns(@fixture)
|
19
|
+
FileUtils.stubs(:rm)
|
20
|
+
|
21
|
+
@palantir.uploader.expects(:upload).with(@fixture)
|
22
|
+
@palantir.spy
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_spy_deletes_the_image
|
26
|
+
@palantir.camera.stubs(:capture).returns(@fixture)
|
27
|
+
@palantir.stubs(:store_image)
|
28
|
+
|
29
|
+
FileUtils.expects(:rm).with(@fixture)
|
30
|
+
@palantir.spy
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class UploaderTest < MiniTest::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
@fixture = 'test/fixtures/eye_of_sauron.jpg'
|
6
|
+
@uploader = AllSeeingPi::Uploader.new
|
7
|
+
end
|
8
|
+
|
9
|
+
def test_upload
|
10
|
+
VCR.use_cassette('uploader') do
|
11
|
+
@uploader.upload(@fixture)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
metadata
ADDED
@@ -0,0 +1,183 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: all_seeing_pi
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Jonan Scheffler
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2014-11-02 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: bundler
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '1.5'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '1.5'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rake
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: mocha
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: pry
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: vcr
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: webmock
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ! '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
- !ruby/object:Gem::Dependency
|
111
|
+
name: aws-sdk
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
113
|
+
none: false
|
114
|
+
requirements:
|
115
|
+
- - ! '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ! '>='
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
126
|
+
description: The one gem to rule homemade Raspberry Pi surveillance systems. This
|
127
|
+
gem will capture images one after another and upload them to an S3 bucket.
|
128
|
+
email:
|
129
|
+
- jonanscheffler@gmail.com
|
130
|
+
executables: []
|
131
|
+
extensions: []
|
132
|
+
extra_rdoc_files: []
|
133
|
+
files:
|
134
|
+
- .gitignore
|
135
|
+
- Gemfile
|
136
|
+
- Gemfile.lock
|
137
|
+
- LICENSE.txt
|
138
|
+
- README.md
|
139
|
+
- Rakefile
|
140
|
+
- all_seeing_pi.gemspec
|
141
|
+
- capture.sh
|
142
|
+
- lib/all_seeing_pi.rb
|
143
|
+
- lib/all_seeing_pi/camera.rb
|
144
|
+
- lib/all_seeing_pi/palantir.rb
|
145
|
+
- lib/all_seeing_pi/uploader.rb
|
146
|
+
- lib/all_seeing_pi/version.rb
|
147
|
+
- test/fixtures/eye_of_sauron.jpg
|
148
|
+
- test/test_camera.rb
|
149
|
+
- test/test_helper.rb
|
150
|
+
- test/test_palantir.rb
|
151
|
+
- test/test_uploader.rb
|
152
|
+
homepage: http://github.com/1337807/all_seeing_pi
|
153
|
+
licenses:
|
154
|
+
- MIT
|
155
|
+
post_install_message:
|
156
|
+
rdoc_options: []
|
157
|
+
require_paths:
|
158
|
+
- lib
|
159
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
160
|
+
none: false
|
161
|
+
requirements:
|
162
|
+
- - ! '>='
|
163
|
+
- !ruby/object:Gem::Version
|
164
|
+
version: '0'
|
165
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
166
|
+
none: false
|
167
|
+
requirements:
|
168
|
+
- - ! '>='
|
169
|
+
- !ruby/object:Gem::Version
|
170
|
+
version: '0'
|
171
|
+
requirements: []
|
172
|
+
rubyforge_project:
|
173
|
+
rubygems_version: 1.8.23.2
|
174
|
+
signing_key:
|
175
|
+
specification_version: 3
|
176
|
+
summary: A gem to capture images with a Raspberry Pi camera.
|
177
|
+
test_files:
|
178
|
+
- test/fixtures/eye_of_sauron.jpg
|
179
|
+
- test/test_camera.rb
|
180
|
+
- test/test_helper.rb
|
181
|
+
- test/test_palantir.rb
|
182
|
+
- test/test_uploader.rb
|
183
|
+
has_rdoc:
|