timelapsify 0.0.0 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/timelapsify +3 -0
- data/lib/timelapsify.rb +2 -0
- data/lib/timelapsify/paparazzi.rb +51 -0
- data/lib/timelapsify/rmagick_screenshot_capturer.rb +22 -0
- data/lib/timelapsify/screenshot_capturer.rb +11 -2
- data/lib/timelapsify/version.rb +1 -1
- metadata +19 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 69cf839fbc8a5dafc63fce8f4e0524686dadc738
|
4
|
+
data.tar.gz: 0a22d1aaaf8f11ca69ba3e0158b5dd969c6c17be
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 12c40435bebaf1d4db06283499ec8bee3855aaccb36d7dd9b00b4e3df675673676061a1384ffbf3468f31009f4d91349b77003e4b15cf1e00dc8df930ad1e55d
|
7
|
+
data.tar.gz: 7d182654f84dee2afcadfe2855cbe68d34009529df1ee499c5968c7aa51b85944b7bf15c7011f38d177138c6f388e30592c29f77cdf6706f9de9e07ecd8a5cbc
|
data/bin/timelapsify
CHANGED
data/lib/timelapsify.rb
CHANGED
@@ -0,0 +1,51 @@
|
|
1
|
+
require "timelapsify/screenshot_capturer"
|
2
|
+
|
3
|
+
module Timelapsify
|
4
|
+
class Paparazzi
|
5
|
+
def self.capture(number, interval = 1.0)
|
6
|
+
capturing_agent = Timelapsify::ScreenshotCapturer.new
|
7
|
+
|
8
|
+
# Default bounds for new filename iteration.
|
9
|
+
start_number = 1
|
10
|
+
end_number = (start_number + number) - 1 # meth
|
11
|
+
|
12
|
+
# ScreenshotCapturers are a bit stupid and don't know
|
13
|
+
# what's going on, so we've gotta examine the range for
|
14
|
+
# them to make sure that nobody gets clobbered.
|
15
|
+
png_list = Dir.glob("*.png")
|
16
|
+
|
17
|
+
# If we've already got more than 0 PNG's in the directory.
|
18
|
+
if png_list.count > 0
|
19
|
+
# First generate an array of hashes, with :filename
|
20
|
+
# hashed to the filename and :number to the number
|
21
|
+
# that got parsed out of the filename.
|
22
|
+
png_hash_list = png_list.map do
|
23
|
+
|png_filename|
|
24
|
+
|
25
|
+
{filename: png_filename, number: png_filename.match(/(\d+)\.png/i)[0].to_i}
|
26
|
+
end
|
27
|
+
|
28
|
+
# Sort them by number.
|
29
|
+
sorted = png_hash_list.sort do
|
30
|
+
|a, b|
|
31
|
+
|
32
|
+
a[:number] <=> b[:number]
|
33
|
+
end
|
34
|
+
|
35
|
+
# Change the bounds for new filename iteration to be
|
36
|
+
# directly after the last PNG filename.
|
37
|
+
start_number = sorted.last[:number] + 1
|
38
|
+
end_number = (start_number + number) - 1
|
39
|
+
end
|
40
|
+
|
41
|
+
# Grab the predetermined number of screenshots.
|
42
|
+
(start_number..end_number).each do |n|
|
43
|
+
# Capture screenshots using the capturing_agent
|
44
|
+
capturing_agent.utility.capture_to_file("#{n}.png")
|
45
|
+
|
46
|
+
# Sleep a bit.
|
47
|
+
sleep interval
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require "date"
|
2
|
+
require "RMagick"
|
3
|
+
|
4
|
+
module Timelapsify
|
5
|
+
class RMagickScreenshotCapturer
|
6
|
+
def self.capture(options = {})
|
7
|
+
options[:silent] = !options[:silent].nil? ? options[:silent] : true
|
8
|
+
options[:frame] = !options[:frame].nil? ? options[:frame] : false
|
9
|
+
options[:descend] = !options[:descend].nil? ? options[:descend] : false
|
10
|
+
options[:screen] = !options[:screen].nil? ? options[:screen] : true
|
11
|
+
options[:borders] = !options[:borders].nil? ? options[:borders] : true
|
12
|
+
|
13
|
+
options[:optional_arguments] = !options[:optional_arguments].nil? ? options[:optional_arguments] : ->(test){ self.filename = "root" }
|
14
|
+
|
15
|
+
Magick::Image.capture(options[:silent], options[:frame], options[:descend], options[:screen], options[:borders], &options[:optional_arguments])
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.capture_to_file(filename = "unknown.png", options = {})
|
19
|
+
self.capture(options).write(filename)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -1,7 +1,16 @@
|
|
1
|
+
require "timelapsify/rmagick_screenshot_capturer"
|
2
|
+
|
1
3
|
module Timelapsify
|
2
4
|
class ScreenshotCapturer
|
3
|
-
|
4
|
-
|
5
|
+
attr_reader :utility
|
6
|
+
|
7
|
+
def initialize(utility = :rmagick)
|
8
|
+
case utility
|
9
|
+
when :rmagick
|
10
|
+
@utility = Timelapsify::RMagickScreenshotCapturer
|
11
|
+
else
|
12
|
+
raise NotImplementedError, "Cannot find an appropriate class for utility argument #{utility}"
|
13
|
+
end
|
5
14
|
end
|
6
15
|
end
|
7
16
|
end
|
data/lib/timelapsify/version.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: timelapsify
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kristofer Rye
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-09-
|
12
|
-
dependencies:
|
11
|
+
date: 2014-09-30 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rmagick
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.13'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.13'
|
13
27
|
description: A tool for creating timelapses by generating screenshots using common
|
14
28
|
utilities like scrot.
|
15
29
|
email: kristofer.rye@gmail.com
|
@@ -20,6 +34,8 @@ extra_rdoc_files: []
|
|
20
34
|
files:
|
21
35
|
- bin/timelapsify
|
22
36
|
- lib/timelapsify.rb
|
37
|
+
- lib/timelapsify/paparazzi.rb
|
38
|
+
- lib/timelapsify/rmagick_screenshot_capturer.rb
|
23
39
|
- lib/timelapsify/screenshot_capturer.rb
|
24
40
|
- lib/timelapsify/version.rb
|
25
41
|
homepage: https://github.com/krye/timelapsify
|