gorthaur 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/bin/gorthaur +52 -0
- data/lib/gorthaur.rb +17 -0
- data/lib/gorthaur/client.rb +20 -0
- data/lib/gorthaur/server.rb +31 -0
- data/lib/gorthaur/version.rb +3 -0
- metadata +135 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 6f7eae1fa292604c422b65c4c098a5ef5bc9a543
|
4
|
+
data.tar.gz: 5c89d51c6f7be40a92feb22b664bfd3a9a3a9e21
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2b68cf797096c0eb59094d6b522e6179df6cb830b3c2fa8119d5e1790f77e1b73f1aee6113497d0d7c467fdc4921edc342aba0aa0514dfd45e790950b6674ff0
|
7
|
+
data.tar.gz: 53942893460458e5c58268cbc9602e5a621d85e74008d9392f85037bc97bd10e1b392a3a821eb9bbd9e7fdcf20c121465a5ea766fac5e11f890276110ba290c2
|
data/bin/gorthaur
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "dante"
|
4
|
+
require "gorthaur"
|
5
|
+
case
|
6
|
+
when ARGV.include?("server") then
|
7
|
+
Dante::Runner.new("gorthaur_server").tap do |runner|
|
8
|
+
runner.description = "Listen for any clients"
|
9
|
+
|
10
|
+
log_path = File.join((ENV["GORTHAUR_LOG_PATH"] || Gorthaur::DEFAULT_LOG_PATH), "server.log")
|
11
|
+
pid_path = File.join((ENV["GORTHAUR_PID_PATH"] || Gorthaur::DEFAULT_PID_PATH), "server.pid")
|
12
|
+
|
13
|
+
runner.execute(:log_path => log_path, :pid_path => pid_path) do
|
14
|
+
server = Gorthaur::Server.new
|
15
|
+
Thread.new { server.call }
|
16
|
+
DRb.start_service(Gorthaur::URI, server)
|
17
|
+
DRb.thread.join
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
when ARGV.include?("client")
|
22
|
+
Dante::Runner.new("gorthaur_client").tap do |runner|
|
23
|
+
runner.description = "Uses the camera and reports to the server"
|
24
|
+
|
25
|
+
runner.with_options do |opts|
|
26
|
+
opts.on("-r", "--rate SECONDS", Integer, "Wait this long between shots") do |rate|
|
27
|
+
options[:rate] = rate
|
28
|
+
end
|
29
|
+
|
30
|
+
opts.on("-f", "--frame INDEX", Integer, "Start at this frame index") do |frame|
|
31
|
+
options[:frame] = frame
|
32
|
+
end
|
33
|
+
|
34
|
+
opts.on("-p", "--path PATH", String, "Store shots in this path") do |path|
|
35
|
+
options[:path] = path
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
log_path = File.join((ENV["GORTHAUR_LOG_PATH"] || Gorthaur::DEFAULT_LOG_PATH), "client.log")
|
40
|
+
pid_path = File.join((ENV["GORTHAUR_PID_PATH"] || Gorthaur::DEFAULT_PID_PATH), "client.pid")
|
41
|
+
|
42
|
+
runner.execute(:log_path => log_path, :pid_path => pid_path) do |opts|
|
43
|
+
rate = opts[:rate] || ENV["GORTHAUR_RATE"] || Gorthaur::DEFAULT_RATE
|
44
|
+
frame = opts[:frame] || ENV["GORTHAUR_FRAME"] || Gorthaur::DEFAULT_FRAME
|
45
|
+
directory = opts[:path] || ENV["GORTHAUR_PATH"] || Gorthaur::DEFAULT_PATH
|
46
|
+
|
47
|
+
Gorthaur::Client.new(rate, frame, FileUtils.mkdir_p(directory).first).call
|
48
|
+
end
|
49
|
+
end
|
50
|
+
else
|
51
|
+
abort "You need to use gorthaur server or gorthaur client"
|
52
|
+
end
|
data/lib/gorthaur.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require "drb"
|
2
|
+
require "thread"
|
3
|
+
require "logger"
|
4
|
+
require "av_capture"
|
5
|
+
|
6
|
+
module Gorthaur
|
7
|
+
URI = "druby://localhost:8787"
|
8
|
+
DEFAULT_RATE = 5
|
9
|
+
DEFAULT_FRAME = 1
|
10
|
+
DEFAULT_PATH = File.join(Dir.home, "Pictures", "gorthaur", "frames")
|
11
|
+
DEFAULT_PID_PATH = File.join(Dir.home, ".gorthaur")
|
12
|
+
DEFAULT_LOG_PATH = File.join(Dir.home, ".gorthaur")
|
13
|
+
end
|
14
|
+
|
15
|
+
require_relative "gorthaur/version"
|
16
|
+
require_relative "gorthaur/server"
|
17
|
+
require_relative "gorthaur/client"
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Gorthaur
|
2
|
+
class Client
|
3
|
+
def initialize(rate, frame, directory)
|
4
|
+
@rate = rate
|
5
|
+
@frame = frame
|
6
|
+
@directory = directory
|
7
|
+
# @logger = Logger.new
|
8
|
+
@server = DRbObject.new_with_uri(Gorthaur::URI)
|
9
|
+
end
|
10
|
+
|
11
|
+
def call
|
12
|
+
loop do
|
13
|
+
# @logger.info "#{@frame} "
|
14
|
+
IO.write(File.join(@directory, "#{@frame}.jpg"), @server.capture)
|
15
|
+
sleep(@rate)
|
16
|
+
@frame += 1
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Gorthaur
|
2
|
+
class Server
|
3
|
+
def initialize
|
4
|
+
@request = Queue.new
|
5
|
+
@response = Queue.new
|
6
|
+
@mutex = Mutex.new
|
7
|
+
@session = AVCapture::Session.new
|
8
|
+
end
|
9
|
+
|
10
|
+
def capture
|
11
|
+
@mutex.synchronize do
|
12
|
+
@request << "x"
|
13
|
+
@response.pop
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def call
|
18
|
+
@session.run_with(recorders) do |connection|
|
19
|
+
while @request.pop
|
20
|
+
@response.push connection.capture
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def recorders
|
28
|
+
AVCapture.devices.find(&:video?)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
metadata
ADDED
@@ -0,0 +1,135 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: gorthaur
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Aaron Paterson
|
8
|
+
- Benjamin Eckel
|
9
|
+
- Kurtis Rainbolt-Greene
|
10
|
+
autorequire:
|
11
|
+
bindir: bin
|
12
|
+
cert_chain: []
|
13
|
+
date: 2014-04-16 00:00:00.000000000 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: av_capture
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
|
+
requirements:
|
19
|
+
- - "~>"
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '1.0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
requirements:
|
26
|
+
- - "~>"
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
version: '1.0'
|
29
|
+
- !ruby/object:Gem::Dependency
|
30
|
+
name: dante
|
31
|
+
requirement: !ruby/object:Gem::Requirement
|
32
|
+
requirements:
|
33
|
+
- - "~>"
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: '0.2'
|
36
|
+
type: :runtime
|
37
|
+
prerelease: false
|
38
|
+
version_requirements: !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - "~>"
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '0.2'
|
43
|
+
- !ruby/object:Gem::Dependency
|
44
|
+
name: bundler
|
45
|
+
requirement: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - "~>"
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '1.3'
|
50
|
+
type: :development
|
51
|
+
prerelease: false
|
52
|
+
version_requirements: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - "~>"
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: '1.3'
|
57
|
+
- !ruby/object:Gem::Dependency
|
58
|
+
name: rspec
|
59
|
+
requirement: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - "~>"
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '2.14'
|
64
|
+
type: :development
|
65
|
+
prerelease: false
|
66
|
+
version_requirements: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - "~>"
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '2.14'
|
71
|
+
- !ruby/object:Gem::Dependency
|
72
|
+
name: rake
|
73
|
+
requirement: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - "~>"
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '10.1'
|
78
|
+
type: :development
|
79
|
+
prerelease: false
|
80
|
+
version_requirements: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - "~>"
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '10.1'
|
85
|
+
- !ruby/object:Gem::Dependency
|
86
|
+
name: pry
|
87
|
+
requirement: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - "~>"
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '0.9'
|
92
|
+
type: :development
|
93
|
+
prerelease: false
|
94
|
+
version_requirements: !ruby/object:Gem::Requirement
|
95
|
+
requirements:
|
96
|
+
- - "~>"
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '0.9'
|
99
|
+
description: Watch yourself coding
|
100
|
+
email: []
|
101
|
+
executables:
|
102
|
+
- gorthaur
|
103
|
+
extensions: []
|
104
|
+
extra_rdoc_files: []
|
105
|
+
files:
|
106
|
+
- bin/gorthaur
|
107
|
+
- lib/gorthaur.rb
|
108
|
+
- lib/gorthaur/client.rb
|
109
|
+
- lib/gorthaur/server.rb
|
110
|
+
- lib/gorthaur/version.rb
|
111
|
+
homepage: http://bhelx.github.io/time_lapser
|
112
|
+
licenses:
|
113
|
+
- MIT
|
114
|
+
metadata: {}
|
115
|
+
post_install_message:
|
116
|
+
rdoc_options: []
|
117
|
+
require_paths:
|
118
|
+
- lib
|
119
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - ">="
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: '0'
|
124
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
125
|
+
requirements:
|
126
|
+
- - ">="
|
127
|
+
- !ruby/object:Gem::Version
|
128
|
+
version: '0'
|
129
|
+
requirements: []
|
130
|
+
rubyforge_project:
|
131
|
+
rubygems_version: 2.2.2
|
132
|
+
signing_key:
|
133
|
+
specification_version: 4
|
134
|
+
summary: Watch yourself coding
|
135
|
+
test_files: []
|