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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ab23da77ec5a4a1d6c0f674d2235c37d56c15d1d
4
- data.tar.gz: d6e1657933ce1733fcaaabc7a199b4f9d8149867
3
+ metadata.gz: 69cf839fbc8a5dafc63fce8f4e0524686dadc738
4
+ data.tar.gz: 0a22d1aaaf8f11ca69ba3e0158b5dd969c6c17be
5
5
  SHA512:
6
- metadata.gz: e61b08fce71782a9c9cc514e3803d92200c82cb9ad93f1cec8383f330e76a3c7acbb3c2cb575d99bccfe042028111a0146dc413af63836af104863f9f72461ab
7
- data.tar.gz: 07b84510bb0130811ecbd3794a5cfab5cd8d154f5506249847c223fc5b9917926573215f822320d6b1885603c3db607f5eb46f095f42777f4bb03b1e809c0d2a
6
+ metadata.gz: 12c40435bebaf1d4db06283499ec8bee3855aaccb36d7dd9b00b4e3df675673676061a1384ffbf3468f31009f4d91349b77003e4b15cf1e00dc8df930ad1e55d
7
+ data.tar.gz: 7d182654f84dee2afcadfe2855cbe68d34009529df1ee499c5968c7aa51b85944b7bf15c7011f38d177138c6f388e30592c29f77cdf6706f9de9e07ecd8a5cbc
data/bin/timelapsify CHANGED
@@ -4,3 +4,6 @@ lib_directory = File.expand_path(File.join(File.dirname(__FILE__), %w_.. lib_))
4
4
  $LOAD_PATH.unshift(lib_directory) unless $LOAD_PATH.include?(lib_directory)
5
5
 
6
6
  require "timelapsify"
7
+ require "pry"
8
+
9
+ Timelapsify.pry
data/lib/timelapsify.rb CHANGED
@@ -1,2 +1,4 @@
1
1
  require "timelapsify/version"
2
+ require "timelapsify/rmagick_screenshot_capturer"
2
3
  require "timelapsify/screenshot_capturer"
4
+ require "timelapsify/paparazzi"
@@ -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
- def initialize(utility = :scrot)
4
- @utility = utility
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
@@ -1,3 +1,3 @@
1
1
  module Timelapsify
2
- VERSION = "0.0.0"
2
+ VERSION = "0.1.0"
3
3
  end
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.0.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-29 00:00:00.000000000 Z
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