lolcommits 0.4.6 → 0.5.0.pre1

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: 2140d1910aeb858e8bfb1044634ff47afff9f251
4
- data.tar.gz: 0c211a4137db9faac7b16354dd6c3899c71665fc
3
+ metadata.gz: b252177e770c39d76fa39deaa4b0e12d9cfc4238
4
+ data.tar.gz: 49be41fcd3d15994f4c580bc68aef6c2fdbe2ea2
5
5
  SHA512:
6
- metadata.gz: 4c3830b33c6b5950ec3439ad2ea8c2cfb099b2aec12ab891b6e9467584e3341a4cc0c27bc78b41777ab1af7b73a78e86c1baeb046978ef70960565c2da22d61c
7
- data.tar.gz: f2adbabef5b40d00391ea9f30932e6a1e113873f5b75cc4734c97a729b65662e4f03fe1bb6577cf81a8a437b8a21166efe32476db7051b844b0608e4fe51f402
6
+ metadata.gz: 61094800f6b1a48aca403f6dc7270edfc8a2d22ac33534d85320bf9ff234f87873afa193ba1723234d5b66222746848f69b95acd548cb86ae1db0084a324c52d
7
+ data.tar.gz: b8cbf2834655da92461b7c7b7b2ac70a14a4a701b3b3d7fee740375baff711aee6497ac8a23ad4e59f4da4ba8a1a247ecd8118b72d90d6b596cd30d622d9a5ce
@@ -8,7 +8,8 @@ rvm:
8
8
  before_install:
9
9
  # imagemagick is installed by default on normal travis image now
10
10
  - sudo apt-get update -qq
11
- - sudo apt-get install -qq -y mplayer
11
+ - sudo apt-get install -qq -y mplayer
12
+ - sudo apt-get install ffmpeg
12
13
  # - sudo apt-get install -qq -y imagemagick libmagickwand-dev
13
14
 
14
15
  # matrix:
data/CHANGELOG CHANGED
@@ -1,6 +1,16 @@
1
- 0.5.0 (in development)
1
+ 0.x.x (in development)
2
2
  * TODO: figure out problems with GUI clients
3
3
 
4
+ 0.5.0 (9 September 2013)
5
+ * better handling of LOLCOMMITS_DELAY (thx @leewillis77, #125)
6
+ * LOLCOMMITS_DEVICE support on Linux (thx @EbenezerEdelman, #139)
7
+ * better handling of repository names (thx @drocamor and @andromedado, #145 and #146)
8
+ * added new LOLCOMMITS_ANIMATE (or `--animate`) option (Mac/OSX only) (#114, #108)
9
+ - defaults to a 320x240 sized animated gif
10
+ - new vendored binary videosnap - https://github.com/matthutchinson/videosnap
11
+ - feature requires ffmpeg
12
+ - README updated with details and an example
13
+
4
14
  0.4.6 (12 August 2013)
5
15
  * Fix for incorrect permissioning in gem issue (see #112)
6
16
 
@@ -23,7 +33,7 @@
23
33
 
24
34
  0.4.1 (17 February 2013)
25
35
  * add lolsrv plugin (thx @sebastianmarr!, #82)
26
- * enable feature to change font (thx @fukayatsu!, #89)
36
+ * enable feature to change font (thx @fukayatsu!, #89)
27
37
  * correct activesupport gem name in bundle (thx @djbender!, #90)
28
38
  * graceful detection of imagemagick not being installed (#87)
29
39
  * restructure logging slightly to use Methadone::CLILogging in most places
data/README.md CHANGED
@@ -57,20 +57,30 @@ environment variables.
57
57
  * Set delay persistently (for slow to warmup webcams) - set
58
58
  `LOLCOMMITS_DELAY` var to time in seconds.
59
59
  * Set font file location - set `LOLCOMMITS_FONT` environment variable.
60
+ * Animated gifs - set `LOLCOMMITS_ANIMATE=3` (currently Mac/OSX only and requires `ffmpeg`).
60
61
  * Fork lolcommits runner - set `LOLCOMMITS_FORK` environment variable
61
62
  (causes capturing command to fork to a new process, speedily returning you to your terminal).
62
63
 
63
64
  For the full list, see the [configuration variables](https://github.com/mroth/lolcommits/wiki/Configuration-Variables).
64
65
 
65
- ### Plugins
66
+ ### Animated Gif Capturing
67
+ Animated gifs (Mac/OSX only) can take a while to generate (depending on the number of seconds you capture and the capabilities of your machine). `ffmpeg` is required and can be installed with brew like so;
68
+
69
+ brew install ffmpeg
70
+
71
+ To enable, just set the `LOLCOMMITS_ANIMATE` environment variable with the number of seconds to capture.
72
+ And like regular image captures you can use the env variables `LOLCOMMITS_DEVICE` and `LOLCOMMITS_DELAY` to change the capture device or delay time (seconds) before capturing.
73
+ If you find capturing an animated gif takes too long, try setting the `LOLCOMMITS_FORK=true` env variable.
66
74
 
75
+ ![Example animated lolcommit gif](http://cdn2.usa.bugleblogs.com/blogs/000/000/003/de0eb9aa695.gif "Example animated lolcommit gif")
76
+
77
+ ### Plugins
67
78
  There are a growing amount of plugins for lolcommits to enable things like Twitter upload, translating your commit messages to lolspeak, etc. Check them out on the [plugins wiki page](https://github.com/mroth/lolcommits/wiki/Plugins).
68
79
 
69
80
  ## Troubles?
70
81
  Started a [FAQ](https://github.com/mroth/lolcommits/wiki/FAQ).
71
82
 
72
83
  ## Timelapse?
73
-
74
84
  To watch your face as it decays while you program, you can create a quick mpeg of all your lolcommits snapshots (if you have `imagemagick` and `ffmpeg` installed):
75
85
 
76
86
  convert `find . -type f -name "*.jpg" -print0 | xargs -0 ls -tlr | awk '{print $9}'` timelapse.mpeg
data/Rakefile CHANGED
@@ -12,6 +12,14 @@ include Rake::DSL
12
12
 
13
13
  Bundler::GemHelper.install_tasks
14
14
 
15
+ task :fix_permissions do
16
+ # Reset all permissions.
17
+ system 'bash -c "find . -type f -exec chmod 644 {} \; && find . -type d -exec chmod 755 {} \;"'
18
+ # Executable files.
19
+ system 'bash -c "chmod +x ./bin/* vendor/ext/imagesnap/imagesnap vendor/ext/videosnap/videosnap"'
20
+ end
21
+
22
+ Rake::Task[:build].prerequisites.unshift :fix_permissions
15
23
 
16
24
  Rake::TestTask.new do |t|
17
25
  t.pattern = 'test/test_*.rb'
@@ -26,9 +26,11 @@ end
26
26
 
27
27
  def die_on_fatal_conditions!
28
28
  if Configuration.is_mac?
29
- unless File.executable? File.join(Configuration::LOLCOMMITS_ROOT, "vendor", "ext", "imagesnap", "imagesnap")
30
- fatal "Couldn't properly execute imagesnap for some reason, please file a bug?!"
31
- exit 1
29
+ %w(imagesnap videosnap).each do |executable|
30
+ unless File.executable? File.join(Configuration::LOLCOMMITS_ROOT, "vendor", "ext", executable, executable)
31
+ fatal "Couldn't properly execute #{executable} for some reason, please file a bug?!"
32
+ exit 1
33
+ end
32
34
  end
33
35
  elsif Configuration.is_linux?
34
36
  if not command?('mplayer')
@@ -40,6 +42,10 @@ def die_on_fatal_conditions!
40
42
  fatal "Couldn't properly read Impact font from gem package, please file a bug?!"
41
43
  exit 1
42
44
  end
45
+ if !Configuration.valid_ffmpeg_installed? && capture_animate
46
+ fatal "FATAL: ffmpeg does not appear to be properly installed!"
47
+ exit 1
48
+ end
43
49
  unless Configuration.valid_imagemagick_installed?
44
50
  fatal "FATAL: ImageMagick does not appear to be properly installed!"
45
51
  exit 1
@@ -126,32 +132,42 @@ def configuration
126
132
  end
127
133
  end
128
134
 
135
+ def capture_animate
136
+ if Configuration.can_animate?
137
+ Choice.choices[:animate] || ENV['LOLCOMMITS_ANIMATE'] || nil
138
+ end
139
+ end
140
+
129
141
  #
130
142
  # IF --CAPTURE, DO CAPTURE
131
143
  #
132
144
  def do_capture
133
- capture_delay = Choice.choices[:delay] || ENV['LOLCOMMITS_DELAY'] || 0
145
+ capture_delay = Choice.choices[:delay] || ENV['LOLCOMMITS_DELAY'] || 0
134
146
  capture_device = Choice.choices[:device] || ENV['LOLCOMMITS_DEVICE'] || nil
135
- capture_font = Choice.choices[:font] || ENV['LOLCOMMITS_FONT'] || nil
147
+ capture_font = Choice.choices[:font] || ENV['LOLCOMMITS_FONT'] || nil
136
148
 
137
149
  fork_me? do
138
150
  if Choice.choices[:test]
139
151
  info "*** Capturing in test mode."
140
- runner = Lolcommits::Runner.new(:capture_delay => capture_delay,
141
- :capture_device => capture_device,
142
- :message => Choice.choices[:msg],
143
- :sha => Choice.choices[:sha],
144
- :config => configuration,
145
- :font => capture_font
146
- )
152
+ runner = Lolcommits::Runner.new(
153
+ :capture_delay => capture_delay,
154
+ :capture_device => capture_device,
155
+ :capture_animate => capture_animate,
156
+ :message => Choice.choices[:msg],
157
+ :sha => Choice.choices[:sha],
158
+ :config => configuration,
159
+ :font => capture_font
160
+ )
147
161
  runner.run
148
162
 
149
163
  Launchy.open(runner.main_image)
150
164
  else
151
- runner = Lolcommits::Runner.new(:capture_delay => capture_delay,
152
- :capture_device => capture_device,
153
- :config => configuration,
154
- :font => capture_font
165
+ runner = Lolcommits::Runner.new(
166
+ :capture_delay => capture_delay,
167
+ :capture_device => capture_device,
168
+ :capture_animate => capture_animate,
169
+ :config => configuration,
170
+ :font => capture_font
155
171
  )
156
172
  runner.run
157
173
  end
@@ -160,12 +176,28 @@ end
160
176
 
161
177
  def fork_me?(&block)
162
178
  if Choice.choices[:fork] || ENV['LOLCOMMITS_FORK']
163
- fork { yield block }
179
+ $stdout.sync = true
180
+ write_pid fork {
181
+ yield block
182
+ delete_pid
183
+ }
164
184
  else
165
185
  yield block
166
186
  end
167
187
  end
168
188
 
189
+ def write_pid(pid)
190
+ File.open(pid_file, 'w') { |f| f.write(pid) }
191
+ end
192
+
193
+ def delete_pid
194
+ File.delete(pid_file) if File.exist?(pid_file)
195
+ end
196
+
197
+ def pid_file
198
+ File.join(configuration.loldir, 'lolcommits.pid')
199
+ end
200
+
169
201
  def do_configure
170
202
  configuration.do_configure! Choice.choices[:plugin]
171
203
  end
@@ -295,7 +327,7 @@ Choice.options do
295
327
 
296
328
  option :device do
297
329
  long "--device=DEVICE"
298
- desc "the device name used to take the snapshot (only mac)"
330
+ desc "the device name used to take the snapshot (only mac/linux)"
299
331
  end
300
332
 
301
333
  option :debug do
@@ -315,6 +347,15 @@ Choice.options do
315
347
  desc "generate animated gif"
316
348
  end
317
349
 
350
+ if Configuration.can_animate?
351
+ option :animate do
352
+ long "--animate=SECONDS"
353
+ short "-a"
354
+ cast Integer
355
+ desc "duration for capturing an animated gif"
356
+ end
357
+ end
358
+
318
359
  option :fork do
319
360
  long "--fork"
320
361
  desc "fork the lolcommits runner to the background"
@@ -0,0 +1,2 @@
1
+ ---
2
+ default: <%= (RUBY_PLATFORM =~ /darwin/) ? 'features' : '--tags ~@mac-only' %>
@@ -5,6 +5,18 @@ Feature: Basic UI functionality
5
5
  Then the exit status should be 0
6
6
  And the banner should be present
7
7
 
8
+ Scenario: Help should show the animate option on a Mac platform
9
+ Given I am using a "Mac" platform
10
+ When I get help for "lolcommits"
11
+ Then the following options should be documented:
12
+ |--animate|which is optional|
13
+ |-a |which is optional|
14
+
15
+ Scenario: Help should not show the animate option on a Linux plaftorm
16
+ Given I am using a "Linux" platform
17
+ When I get help for "lolcommits"
18
+ Then the output should not match /\-a\, \-\-animate\=SECONDS/
19
+
8
20
  Scenario: Enable in a naked git repository
9
21
  Given a git repository named "loltest" with no "post-commit" hook
10
22
  When I cd to "loltest"
@@ -31,7 +43,8 @@ Feature: Basic UI functionality
31
43
  Given I am in a git repository named "testforkcapture"
32
44
  And I do a git commit
33
45
  When I successfully run `lolcommits --capture --fork`
34
- And I successfully run `sleep 3`
46
+ Then there should be exactly 1 pid in "../.lolcommits/testforkcapture"
47
+ When I wait for the child process to exit in "testforkcapture"
35
48
  Then the output should contain "*** Preserving this moment in history."
36
49
  And a directory named "../.lolcommits/testforkcapture" should exist
37
50
  And a file named "../.lolcommits/testforkcapture/tmp_snapshot.jpg" should not exist
@@ -90,7 +103,7 @@ Feature: Basic UI functionality
90
103
  When I successfully run `lolcommits --show-config`
91
104
  Then the output should contain "loltext:"
92
105
  And the output should contain "enabled: true"
93
-
106
+
94
107
  Scenario: Configuring Plugin In Test Mode
95
108
  Given a git repository named "testmode-config-test"
96
109
  When I cd to "testmode-config-test"
@@ -169,3 +182,22 @@ Feature: Basic UI functionality
169
182
  And a loldir named "randomgitrepo" with 2 lolimages
170
183
  When I successfully run `lolcommits -g today`
171
184
  And there should be exactly 1 gif in "../.lolcommits/randomgitrepo/archive"
185
+
186
+ @mac-only
187
+ Scenario: should generate an animated gif on the Mac platform
188
+ Given I am in a git repository named "testanimatedcapture"
189
+ And I do a git commit
190
+ And I am using a "Mac" platform
191
+ When I run `lolcommits --capture --animate=1`
192
+ Then the output should contain "*** Preserving this moment in history."
193
+ And a directory named "../.lolcommits/testanimatedcapture" should exist
194
+ And a file named "../.lolcommits/testanimatedcapture/tmp_video.mov" should not exist
195
+ And a directory named "../.lolcommits/testanimatedcapture/tmp_frames" should not exist
196
+ And there should be exactly 1 gif in "../.lolcommits/testanimatedcapture"
197
+
198
+ @fake-no-ffmpeg
199
+ Scenario: gracefully fail when ffmpeg is not installed and animate option is used
200
+ Given I am using a "Mac" platform
201
+ When I run `lolcommits --animate=3`
202
+ Then the output should contain "ffmpeg does not appear to be properly installed"
203
+ And the exit status should be 1
@@ -70,7 +70,7 @@ When /^I enter "(.*?)" for "(.*?)"$/ do |input, field|
70
70
  @stdin.puts input
71
71
  end
72
72
 
73
- Then /^there should be (?:exactly|only) (.*?) (jpg|gif)(?:s?) in "(.*?)"$/ do |n, type, folder|
73
+ Then /^there should be (?:exactly|only) (.*?) (jpg|gif|pid)(?:s?) in "(.*?)"$/ do |n, type, folder|
74
74
  assert_equal n.to_i, Dir["#{current_dir}/#{folder}/*.#{type}"].count
75
75
  end
76
76
 
@@ -102,3 +102,12 @@ Then /^there should be (\d+) commit entries in the git log$/ do |n|
102
102
  assert_equal n.to_i, `git shortlog | grep -E '^[ ]+\w+' | wc -l`.chomp.to_i
103
103
  end
104
104
 
105
+ Given /^I am using a "(.*?)" platform$/ do |platform_name|
106
+ ENV['LOLCOMMITS_FAKEPLATFORM'] = platform_name
107
+ end
108
+
109
+ When /^I wait for the child process to exit in "(.*?)"$/ do |repo_name|
110
+ while File.exist?("tmp/aruba/.lolcommits/#{repo_name}/lolcommits.pid")
111
+ sleep 0.1
112
+ end
113
+ end
@@ -5,11 +5,14 @@ require 'test/unit/assertions'
5
5
  include Test::Unit::Assertions
6
6
  require 'faker'
7
7
  require 'lolcommits/configuration'
8
+ require File.join(File.expand_path(File.dirname(__FILE__)), 'path_helpers')
8
9
  include Lolcommits
9
10
 
10
11
  ENV['PATH'] = "#{File.expand_path(File.dirname(__FILE__) + '/../../bin')}#{File::PATH_SEPARATOR}#{ENV['PATH']}"
11
12
  LIB_DIR = File.join(File.expand_path(File.dirname(__FILE__)),'..','..','lib')
12
13
 
14
+ World(PathHelpers)
15
+
13
16
  Before do
14
17
  # Using "announce" causes massive warnings on 1.9.2
15
18
  @puts = true
@@ -36,10 +39,11 @@ After do
36
39
  # ENV['LOLCOMMITS_DIR'] = @original_loldir
37
40
  ENV['HOME'] = @original_home
38
41
  ENV['LAUNCHY_DRY_RUN'] = nil
42
+ ENV['LOLCOMMITS_FAKEPLATFORM'] = nil
39
43
  end
40
44
 
41
45
  Before('@fake-interactive-rebase') do
42
- # in order to fake an interactive rebase,
46
+ # in order to fake an interactive rebase,
43
47
  # we replace the editor with a script that simply squashes a few random commits
44
48
  @original_git_editor = ENV['GIT_EDITOR']
45
49
  # ENV['GIT_EDITOR'] = "sed -i -e 'n;s/pick/squash/g'" #every other commit
@@ -57,38 +61,18 @@ end
57
61
 
58
62
  # adjust the path so tests dont see a global imagemagick install
59
63
  Before('@fake-no-imagemagick') do
60
-
61
- # make a new subdir that still contains git and mplayer
62
- tmpbindir = File.expand_path(File.join @dirs, "bin")
63
- FileUtils.mkdir_p tmpbindir
64
- ["git","mplayer"].each do |cmd|
65
- whichcmd = Lolcommits::Configuration.command_which(cmd)
66
- unless whichcmd.nil?
67
- FileUtils.ln_s whichcmd, File.join(tmpbindir, File.basename(whichcmd))
68
- end
69
- end
70
-
71
- # use a modified version of Configuration::command_which to detect where IM is installed
72
- # and remove that from the path
73
- cmd = 'mogrify'
74
- exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
75
- newpaths = ENV['PATH'].split(File::PATH_SEPARATOR).reject do |path|
76
- found_cmd = false
77
- exts.each { |ext|
78
- exe = "#{path}/#{cmd}#{ext}"
79
- found_cmd = true if File.executable? exe
80
- }
81
- found_cmd
82
- end
83
-
84
- # add the temporary directory with git in it back into the path
85
- newpaths << tmpbindir
86
-
87
- @original_path = ENV['PATH']
88
- ENV['PATH'] = newpaths.join(File::PATH_SEPARATOR)
89
- # puts ENV['PATH'] dont need to announce this for debug anymore!
64
+ reject_paths_with_cmd('mogrify')
90
65
  end
91
66
 
92
67
  After('@fake-no-imagemagick') do
93
- ENV['PATH'] = @original_path
94
- end
68
+ reset_path
69
+ end
70
+
71
+ # adjust the path so tests dont see a global ffmpeg install
72
+ Before('@fake-no-ffmpeg') do
73
+ reject_paths_with_cmd('ffmpeg')
74
+ end
75
+
76
+ After('@fake-no-ffmpeg') do
77
+ reset_path
78
+ end
@@ -0,0 +1,39 @@
1
+ module PathHelpers
2
+
3
+ def reject_paths_with_cmd(cmd)
4
+ @original_path = ENV['PATH']
5
+ # make a new subdir that still contains cmds
6
+ tmpbindir = File.expand_path(File.join @dirs, "bin")
7
+ FileUtils.mkdir_p tmpbindir
8
+
9
+ preseve_cmds_in_path(['git', 'mplayer'], tmpbindir)
10
+
11
+ exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
12
+ newpaths = ENV['PATH'].split(File::PATH_SEPARATOR).reject do |path|
13
+ found_cmd = false
14
+ exts.each { |ext|
15
+ exe = "#{path}/#{cmd}#{ext}"
16
+ found_cmd = true if File.executable? exe
17
+ }
18
+ found_cmd
19
+ end
20
+
21
+ # add the temporary directory with git in it back into the path
22
+ newpaths << tmpbindir
23
+ ENV['PATH'] = newpaths.join(File::PATH_SEPARATOR)
24
+ end
25
+
26
+ def preseve_cmds_in_path(cmds, tmpbindir)
27
+ cmds.each do |cmd|
28
+ whichcmd = Lolcommits::Configuration.command_which(cmd)
29
+ unless whichcmd.nil?
30
+ FileUtils.ln_s whichcmd, File.join(tmpbindir, File.basename(whichcmd))
31
+ end
32
+ end
33
+ end
34
+
35
+ def reset_path
36
+ ENV['PATH'] = @original_path
37
+ end
38
+
39
+ end
@@ -15,6 +15,7 @@ require 'lolcommits/version'
15
15
  require 'lolcommits/configuration'
16
16
  require 'lolcommits/capturer'
17
17
  require 'lolcommits/capture_mac'
18
+ require 'lolcommits/capture_mac_animated'
18
19
  require 'lolcommits/capture_linux'
19
20
  require 'lolcommits/capture_windows'
20
21
  require 'lolcommits/capture_fake'
@@ -1,16 +1,24 @@
1
1
  module Lolcommits
2
2
  class CaptureLinux < Capturer
3
+ def capture_device_string
4
+ @capture_device.nil? ? nil : "-tv device=\"#{@capture_device}\""
5
+ end
6
+
3
7
  def capture
4
8
  debug "LinuxCapturer: making tmp directory"
5
9
  tmpdir = Dir.mktmpdir
6
10
 
11
+ # Default delay is 1s
12
+ delay = if capture_delay != 0 then capture_delay else 1 end
13
+
7
14
  # There's no way to give a capture delay in mplayer, but a number of frame
8
- # I've found that 6 is a good value for me.
9
- frames = if capture_delay != 0 then capture_delay else 6 end
15
+ # mplayer's "delay" is actually a number of frames at 25fps
16
+ # multiply the set value (in seconds) by 25
17
+ frames = delay.to_i * 25
10
18
 
11
19
  debug "LinuxCapturer: calling out to mplayer to capture image"
12
20
  # mplayer's output is ugly and useless, let's throw it away
13
- _, r, _ = Open3.popen3("mplayer -vo jpeg:outdir=#{tmpdir} -frames #{frames} tv://")
21
+ _, r, _ = Open3.popen3("mplayer -vo jpeg:outdir=#{tmpdir} #{capture_device_string} -frames #{frames} tv://")
14
22
  # looks like we still need to read the output for something to happen
15
23
  r.read
16
24
 
@@ -0,0 +1,40 @@
1
+ module Lolcommits
2
+ class CaptureMacAnimated < Capturer
3
+
4
+ def capture
5
+ # make a fresh frames directory
6
+ FileUtils.rm_rf(frames_location)
7
+ FileUtils.mkdir_p(frames_location)
8
+
9
+ # capture the raw video with videosnap
10
+ system_call "#{videosnap_bin} -s 240 #{capture_device_string}#{capture_delay_string}-t #{animated_duration} --no-audio #{video_location} > /dev/null"
11
+ if File.exists?(video_location)
12
+ # convert raw video to png frames with ffmpeg
13
+ system_call "ffmpeg -v quiet -i #{video_location} -t #{animated_duration} #{frames_location}/%09d.png"
14
+ # create the looping animated gif from frames (picks every 2nd frame with seq)
15
+ seq_command = "seq -f #{frames_location}/%09g.png 1 2 #{Dir["#{frames_location}/*"].length}"
16
+ # delay of 12 between every other frame, 24fps
17
+ system_call "convert -layers OptimizeTransparency -delay 12 -loop 0 `#{seq_command}` -coalesce #{snapshot_location}"
18
+ end
19
+ end
20
+
21
+ private
22
+ def system_call(call_str)
23
+ debug "Capturer: making system call for \n #{call_str}"
24
+ system(call_str)
25
+ end
26
+
27
+ def videosnap_bin
28
+ File.join(Configuration::LOLCOMMITS_ROOT, 'vendor', 'ext', 'videosnap', 'videosnap')
29
+ end
30
+
31
+ def capture_device_string
32
+ "-d '#{capture_device}' " if capture_device
33
+ end
34
+
35
+ def capture_delay_string
36
+ "-w '#{capture_delay}' " if capture_delay.to_i > 0
37
+ end
38
+
39
+ end
40
+ end
@@ -1,7 +1,8 @@
1
1
  module Lolcommits
2
2
  class Capturer
3
3
  include Methadone::CLILogging
4
- attr_accessor :capture_device, :capture_delay, :snapshot_location, :font
4
+ attr_accessor :capture_device, :capture_delay, :snapshot_location, :font,
5
+ :video_location, :frames_location, :animated_duration
5
6
 
6
7
  def initialize(attributes = Hash.new)
7
8
  attributes.each do |attr, val|
@@ -11,7 +11,9 @@ module Lolcommits
11
11
  end
12
12
 
13
13
  def self.platform
14
- if is_fakecapture?
14
+ if is_fakeplatform?
15
+ ENV['LOLCOMMITS_FAKEPLATFORM']
16
+ elsif is_fakecapture?
15
17
  'Fake'
16
18
  elsif is_mac?
17
19
  'Mac'
@@ -74,12 +76,20 @@ module Lolcommits
74
76
  images.select { |f| Date.parse(File.mtime(f).to_s) === Date.today }
75
77
  end
76
78
 
77
- def raw_image
78
- File.join self.loldir, "tmp_snapshot.jpg"
79
+ def raw_image(image_file_type = 'jpg')
80
+ File.join self.loldir, "tmp_snapshot.#{image_file_type}"
79
81
  end
80
82
 
81
- def main_image(commit_sha)
82
- File.join self.loldir, "#{commit_sha}.jpg"
83
+ def main_image(commit_sha, image_file_type = 'jpg')
84
+ File.join self.loldir, "#{commit_sha}.#{image_file_type}"
85
+ end
86
+
87
+ def video_loc
88
+ File.join(self.loldir, 'tmp_video.mov')
89
+ end
90
+
91
+ def frames_loc
92
+ File.join(self.loldir, 'tmp_frames')
83
93
  end
84
94
 
85
95
  def puts_plugins
@@ -145,6 +155,10 @@ module Lolcommits
145
155
  (ENV['LOLCOMMITS_FAKECAPTURE'] == '1' || false)
146
156
  end
147
157
 
158
+ def self.is_fakeplatform?
159
+ ENV['LOLCOMMITS_FAKEPLATFORM']
160
+ end
161
+
148
162
  def self.valid_imagemagick_installed?
149
163
  return false unless self.command_which('identify')
150
164
  return false unless self.command_which('mogrify')
@@ -153,10 +167,18 @@ module Lolcommits
153
167
  MiniMagick::valid_version_installed?
154
168
  end
155
169
 
170
+ def self.valid_ffmpeg_installed?
171
+ self.command_which('ffmpeg')
172
+ end
173
+
156
174
  def self.git_config_color_always?
157
175
  `git config color.ui`.chomp =~ /always/
158
176
  end
159
177
 
178
+ def self.can_animate?
179
+ platform == 'Mac'
180
+ end
181
+
160
182
  # Cross-platform way of finding an executable in the $PATH.
161
183
  # idea taken from http://bit.ly/qDaTbY
162
184
  #
@@ -13,10 +13,14 @@ module Lolcommits
13
13
  self.message = commit.message.split("\n").first
14
14
  self.sha = commit.sha[0..10]
15
15
  self.repo_internal_path = g.repo.path
16
- regex = /.*[:\/](\w*).git/
16
+ regex = /.*[:\/]([\w\-]*).git/
17
17
  match = g.remote.url.match regex if g.remote.url
18
- self.repo = match[1] if match
19
-
18
+ if match
19
+ self.repo = match[1]
20
+ elsif !g.repo.path.empty?
21
+ self.repo = g.repo.path.split(File::SEPARATOR)[-2]
22
+ end
23
+
20
24
  debug "GitInfo: parsed the following values from commit:"
21
25
  debug "GitInfo: \t#{self.message}"
22
26
  debug "GitInfo: \t#{self.sha}"
@@ -25,7 +25,7 @@ module Lolcommits
25
25
  c.fill 'white'
26
26
  c.stroke 'black'
27
27
  c.strokewidth '2'
28
- c.pointsize '48'
28
+ c.pointsize(self.runner.animate? ? '24' : '48')
29
29
  c.interline_spacing '-9'
30
30
  c.font font_location
31
31
  c.annotate '0', clean_msg(self.runner.message)
@@ -36,7 +36,7 @@ module Lolcommits
36
36
  c.fill 'white'
37
37
  c.stroke 'black'
38
38
  c.strokewidth '2'
39
- c.pointsize '32'
39
+ c.pointsize(self.runner.animate? ? '21' : '32')
40
40
  c.font font_location
41
41
  c.annotate '0', self.runner.sha
42
42
  end
@@ -4,7 +4,7 @@ module Lolcommits
4
4
  class Runner
5
5
  attr_accessor :capture_delay, :capture_device, :message, :sha,
6
6
  :snapshot_loc, :main_image, :repo, :config, :repo_internal_path,
7
- :font
7
+ :font, :capture_animate
8
8
 
9
9
  include Methadone::CLILogging
10
10
  include ActiveSupport::Callbacks
@@ -39,18 +39,34 @@ module Lolcommits
39
39
 
40
40
  run_callbacks :run do
41
41
  puts "*** Preserving this moment in history."
42
- self.snapshot_loc = self.config.raw_image
43
- self.main_image = self.config.main_image(self.sha)
44
- capturer = "Lolcommits::Capture#{Configuration.platform}".constantize.new(
42
+ self.snapshot_loc = self.config.raw_image(image_file_type)
43
+ self.main_image = self.config.main_image(self.sha, image_file_type)
44
+ capturer = capturer_class.new(
45
45
  :capture_device => self.capture_device,
46
46
  :capture_delay => self.capture_delay,
47
47
  :snapshot_location => self.snapshot_loc,
48
- :font => self.font
48
+ :font => self.font,
49
+ :video_location => self.config.video_loc,
50
+ :frames_location => self.config.frames_loc,
51
+ :animated_duration => self.capture_animate
49
52
  )
50
53
  capturer.capture
51
54
  resize_snapshot!
52
55
  end
53
56
  end
57
+
58
+ def animate?
59
+ capture_animate && (capture_animate > 0)
60
+ end
61
+
62
+ private
63
+ def capturer_class
64
+ "Lolcommits::Capture#{Configuration.platform}#{animate? ? 'Animated' : nil}".constantize
65
+ end
66
+
67
+ def image_file_type
68
+ animate? ? 'gif' : 'jpg'
69
+ end
54
70
  end
55
71
 
56
72
  protected
@@ -84,8 +100,10 @@ module Lolcommits
84
100
 
85
101
  def cleanup!
86
102
  debug "Runner: running cleanup"
87
- #clean up the captured image
103
+ # clean up the captured image and any other raw assets
88
104
  FileUtils.rm(self.snapshot_loc)
105
+ FileUtils.rm_f(self.config.video_loc)
106
+ FileUtils.rm_rf(self.config.frames_loc)
89
107
  end
90
108
 
91
109
  # register a method called "execute_lolcommits_#{plugin_name}"
@@ -1,3 +1,3 @@
1
1
  module Lolcommits
2
- VERSION = "0.4.6"
2
+ VERSION = "0.5.0.pre1"
3
3
  end
File without changes
@@ -33,10 +33,13 @@ class LolTest < Test::Unit::TestCase
33
33
  def test_permissions
34
34
  impact_perms = File.lstat(File.join(Configuration::LOLCOMMITS_ROOT, "vendor", "fonts", "Impact.ttf")).mode & 0777
35
35
  imagesnap_perms = File.lstat(File.join(Configuration::LOLCOMMITS_ROOT, "vendor", "ext", "imagesnap", "imagesnap")).mode & 0777
36
+ videosnap_perms = File.lstat(File.join(Configuration::LOLCOMMITS_ROOT, "vendor", "ext", "videosnap", "videosnap")).mode & 0777
36
37
  assert impact_perms == 0644 || impact_perms == 0664,
37
38
  "expected perms of 644/664 but instead got #{sprintf '%o', impact_perms}"
38
39
  assert imagesnap_perms == 0755 || imagesnap_perms == 0775,
39
40
  "expected perms of 755/775 but instead got #{sprintf '%o', imagesnap_perms}"
41
+ assert videosnap_perms == 0755 || videosnap_perms == 0775,
42
+ "expected perms of 755/775 but instead got #{sprintf '%o', videosnap_perms}"
40
43
  end
41
44
 
42
45
  # Hmm.. webcam capture breaks travis-ci tests
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lolcommits
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.6
4
+ version: 0.5.0.pre1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthew Rothenberg
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-08-12 00:00:00.000000000 Z
11
+ date: 2013-09-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mini_magick
@@ -267,16 +267,19 @@ files:
267
267
  - README.md
268
268
  - Rakefile
269
269
  - bin/lolcommits
270
+ - config/cucumber.yml
270
271
  - features/bugs.feature
271
272
  - features/lolcommits.feature
272
273
  - features/plugins.feature
273
274
  - features/step_definitions/lolcommits_steps.rb
274
275
  - features/support/env.rb
276
+ - features/support/path_helpers.rb
275
277
  - lib/core_ext/class.rb
276
278
  - lib/lolcommits.rb
277
279
  - lib/lolcommits/capture_fake.rb
278
280
  - lib/lolcommits/capture_linux.rb
279
281
  - lib/lolcommits/capture_mac.rb
282
+ - lib/lolcommits/capture_mac_animated.rb
280
283
  - lib/lolcommits/capture_windows.rb
281
284
  - lib/lolcommits/capturer.rb
282
285
  - lib/lolcommits/configuration.rb
@@ -299,6 +302,7 @@ files:
299
302
  - vendor/ext/CommandCam/LICENSE
300
303
  - vendor/ext/imagesnap/ReadMeOrDont.rtf
301
304
  - vendor/ext/imagesnap/imagesnap
305
+ - vendor/ext/videosnap/videosnap
302
306
  - vendor/fonts/Impact.ttf
303
307
  homepage: http://mroth.github.com/lolcommits/
304
308
  licenses:
@@ -315,9 +319,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
315
319
  version: '0'
316
320
  required_rubygems_version: !ruby/object:Gem::Requirement
317
321
  requirements:
318
- - - '>='
322
+ - - '>'
319
323
  - !ruby/object:Gem::Version
320
- version: '0'
324
+ version: 1.3.1
321
325
  requirements: []
322
326
  rubyforge_project: lolcommits
323
327
  rubygems_version: 2.0.3
@@ -330,5 +334,6 @@ test_files:
330
334
  - features/plugins.feature
331
335
  - features/step_definitions/lolcommits_steps.rb
332
336
  - features/support/env.rb
337
+ - features/support/path_helpers.rb
333
338
  - test/images/test_image.jpg
334
339
  - test/test_lolcommits.rb