lolcommits 0.5.2 → 0.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -21,7 +21,7 @@ Feature: Basic UI functionality
21
21
  Given a git repository named "loltest" with no "post-commit" hook
22
22
  When I cd to "loltest"
23
23
  And I successfully run `lolcommits --enable`
24
- Then the output should contain "installed lolcommmit hook to:"
24
+ Then the output should contain "installed lolcommit hook to:"
25
25
  And the output should contain "(to remove later, you can use: lolcommits --disable)"
26
26
  And a file named ".git/hooks/post-commit" should exist
27
27
  And the file ".git/hooks/post-commit" should contain "lolcommits --capture"
@@ -32,7 +32,7 @@ Feature: Basic UI functionality
32
32
  And the "loltest" repository "post-commit" hook has content "#!/bin/sh\n\n/my/own/script"
33
33
  When I cd to "loltest"
34
34
  And I successfully run `lolcommits --enable`
35
- Then the output should contain "installed lolcommmit hook to:"
35
+ Then the output should contain "installed lolcommit hook to:"
36
36
  And the output should contain "(to remove later, you can use: lolcommits --disable)"
37
37
  And a file named ".git/hooks/post-commit" should exist
38
38
  And the file ".git/hooks/post-commit" should contain "#!/bin/sh"
@@ -53,7 +53,7 @@ Feature: Basic UI functionality
53
53
  Given a git repository named "loltest" with no "post-commit" hook
54
54
  When I cd to "loltest"
55
55
  And I successfully run `lolcommits --enable -w 5 --fork`
56
- Then the output should contain "installed lolcommmit hook to:"
56
+ Then the output should contain "installed lolcommit hook to:"
57
57
  And the output should contain "(to remove later, you can use: lolcommits --disable)"
58
58
  And a file named ".git/hooks/post-commit" should exist
59
59
  And the file ".git/hooks/post-commit" should contain "lolcommits --capture -w 5 --fork"
@@ -184,6 +184,16 @@ Feature: Basic UI functionality
184
184
  When I run `lolcommits --last`
185
185
  Then the exit status should be 0
186
186
 
187
+ Scenario: last command should work properly when in a lolrepo subdirectory
188
+ Given I am in a git repository named "randomgitrepo"
189
+ And a loldir named "randomgitrepo" with 2 lolimages
190
+ And a directory named "randomdir"
191
+ And I cd to "randomdir"
192
+ When I run `lolcommits --last`
193
+ Then the output should not contain "Can't do that since we're not in a valid git repository!"
194
+ And the exit status should be 0
195
+
196
+ @in-tempdir
187
197
  Scenario: last command should fail gracefully if not in a lolrepo
188
198
  Given I am in a directory named "gitsuxcvs4eva"
189
199
  When I run `lolcommits --last`
@@ -205,6 +215,16 @@ Feature: Basic UI functionality
205
215
  When I run `lolcommits --browse`
206
216
  Then the exit status should be 0
207
217
 
218
+ Scenario: browse command should work properly when in a lolrepo subdirectory
219
+ Given I am in a git repository named "randomgitrepo"
220
+ And a loldir named "randomgitrepo" with 2 lolimages
221
+ And a directory named "randomdir"
222
+ And I cd to "randomdir"
223
+ When I run `lolcommits --browse`
224
+ Then the output should not contain "Can't do that since we're not in a valid git repository!"
225
+ And the exit status should be 0
226
+
227
+ @in-tempdir
208
228
  Scenario: browse command should fail gracefully when not in a lolrepo
209
229
  Given I am in a directory named "gitsuxcvs4eva"
210
230
  When I run `lolcommits --browse`
@@ -1,3 +1,4 @@
1
+ # -*- encoding : utf-8 -*-
1
2
  include FileUtils
2
3
 
3
4
  Given /^I am in a directory named "(.*?)"$/ do |dir_name|
@@ -11,25 +12,25 @@ Given /^a git repository named "(.*?)"$/ do |repo_name|
11
12
  repo_dir = File.join current_dir, repo_name
12
13
  mkdir_p repo_dir
13
14
  Dir.chdir repo_dir do
14
- system "git init --quiet ."
15
+ system 'git init --quiet .'
15
16
  system "git config user.name 'Testy McTesterson'"
16
17
  system "git config user.email 'testy@tester.com'"
17
18
  end
18
19
  end
19
20
 
20
21
  Given /^the git repository named "(.*?)" has no "(.*?)" hook$/ do |repo_name, hook_name|
21
- hook_file = File.join current_dir, repo_name, ".git", "hooks", hook_name
22
+ hook_file = File.join current_dir, repo_name, '.git', 'hooks', hook_name
22
23
  delete(hook_file) if File.exists? hook_file
23
24
  end
24
25
 
25
26
  Given /^the git repository named "(.*?)" has a "(.*?)" hook$/ do |repo_name, hook_name|
26
- hook_file = File.join current_dir, repo_name, ".git", "hooks", hook_name
27
+ hook_file = File.join current_dir, repo_name, '.git', 'hooks', hook_name
27
28
  touch(hook_file) if not File.exists? hook_file
28
29
  end
29
30
 
30
31
  Given /^the "(.*?)" repository "(.*?)" hook has content "(.*?)"$/ do |repo_name, hook_name, hook_content|
31
32
  step %{the git repository named "#{repo_name}" has a "#{hook_name}" hook}
32
- hook_file = File.join current_dir, repo_name, ".git", "hooks", hook_name
33
+ hook_file = File.join current_dir, repo_name, '.git', 'hooks', hook_name
33
34
  File.open(hook_file, 'w') { |f| f.write(hook_content) }
34
35
  end
35
36
 
@@ -66,8 +67,8 @@ Given /^a loldir named "(.*?)" with (\d+) lolimages$/ do |repo_name, num_images|
66
67
  loldir = "tmp/aruba/.lolcommits/#{repo_name}"
67
68
  mkdir_p loldir
68
69
  num_images.to_i.times do
69
- random_hex = "%011x" % (rand * 0xfffffffffff)
70
- cp "test/images/test_image.jpg", File.join( loldir, "#{random_hex}.jpg")
70
+ random_hex = '%011x' % (rand * 0xfffffffffff)
71
+ cp 'test/images/test_image.jpg', File.join(loldir, "#{random_hex}.jpg")
71
72
  end
72
73
  end
73
74
 
@@ -108,7 +109,7 @@ When /^I do (\d+) git commits$/ do |n|
108
109
  end
109
110
 
110
111
  Then /^there should be (\d+) commit entries in the git log$/ do |n|
111
- sleep 1 #let the file writing catch up
112
+ sleep 1 # let the file writing catch up
112
113
  assert_equal n.to_i, `git shortlog | grep -E '^[ ]+\w+' | wc -l`.chomp.to_i
113
114
  end
114
115
 
@@ -117,7 +118,5 @@ Given /^I am using a "(.*?)" platform$/ do |platform_name|
117
118
  end
118
119
 
119
120
  When /^I wait for the child process to exit in "(.*?)"$/ do |repo_name|
120
- while File.exist?("tmp/aruba/.lolcommits/#{repo_name}/lolcommits.pid")
121
- sleep 0.1
122
- end
121
+ sleep 0.1 while File.exist?("tmp/aruba/.lolcommits/#{repo_name}/lolcommits.pid")
123
122
  end
@@ -1,3 +1,4 @@
1
+ # -*- encoding : utf-8 -*-
1
2
  require 'aruba/cucumber'
2
3
  require 'methadone/cucumber'
3
4
  require 'open3'
@@ -9,7 +10,7 @@ require File.join(File.expand_path(File.dirname(__FILE__)), 'path_helpers')
9
10
  include Lolcommits
10
11
 
11
12
  ENV['PATH'] = "#{File.expand_path(File.dirname(__FILE__) + '/../../bin')}#{File::PATH_SEPARATOR}#{ENV['PATH']}"
12
- LIB_DIR = File.join(File.expand_path(File.dirname(__FILE__)),'..','..','lib')
13
+ LIB_DIR = File.join(File.expand_path(File.dirname(__FILE__)), '..', '..', 'lib')
13
14
 
14
15
  World(PathHelpers)
15
16
 
@@ -22,13 +23,13 @@ Before do
22
23
  ENV['RUBYLIB'] = LIB_DIR + File::PATH_SEPARATOR + ENV['RUBYLIB'].to_s
23
24
 
24
25
  @original_fakecapture = ENV['LOLCOMMITS_FAKECAPTURE']
25
- ENV['LOLCOMMITS_FAKECAPTURE'] = "1"
26
+ ENV['LOLCOMMITS_FAKECAPTURE'] = '1'
26
27
 
27
28
  # @original_loldir = ENV['LOLCOMMITS_DIR']
28
29
  # ENV['LOLCOMMITS_DIR'] = File.expand_path( File.join(current_dir, ".lolcommits") )
29
30
 
30
31
  @original_home = ENV['HOME']
31
- ENV['HOME'] = File.expand_path( current_dir )
32
+ ENV['HOME'] = File.expand_path(current_dir)
32
33
 
33
34
  ENV['LAUNCHY_DRY_RUN'] = 'true'
34
35
  end
@@ -47,7 +48,7 @@ Before('@fake-interactive-rebase') do
47
48
  # we replace the editor with a script that simply squashes a few random commits
48
49
  @original_git_editor = ENV['GIT_EDITOR']
49
50
  # ENV['GIT_EDITOR'] = "sed -i -e 'n;s/pick/squash/g'" #every other commit
50
- ENV['GIT_EDITOR'] = "sed -i -e '3,5 s/pick/squash/g'" #lines 3-5
51
+ ENV['GIT_EDITOR'] = "sed -i -e '3,5 s/pick/squash/g'" # lines 3-5
51
52
  end
52
53
 
53
54
  After('@fake-interactive-rebase') do
@@ -76,3 +77,12 @@ end
76
77
  After('@fake-no-ffmpeg') do
77
78
  reset_path
78
79
  end
80
+
81
+ # do test in temporary directory so our own git repo-ness doesn't affect it
82
+ Before('@in-tempdir') do
83
+ @dirs = [Dir.mktmpdir]
84
+ end
85
+
86
+ After('@in-tempdir') do
87
+ FileUtils.rm_rf(@dirs.first)
88
+ end
@@ -1,9 +1,9 @@
1
+ # -*- encoding : utf-8 -*-
1
2
  module PathHelpers
2
-
3
3
  def reject_paths_with_cmd(cmd)
4
4
  @original_path = ENV['PATH']
5
5
  # make a new subdir that still contains cmds
6
- tmpbindir = File.expand_path(File.join @dirs, "bin")
6
+ tmpbindir = File.expand_path(File.join @dirs, 'bin')
7
7
  FileUtils.mkdir_p tmpbindir
8
8
 
9
9
  preseve_cmds_in_path(['git', 'mplayer'], tmpbindir)
@@ -11,10 +11,10 @@ module PathHelpers
11
11
  exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
12
12
  newpaths = ENV['PATH'].split(File::PATH_SEPARATOR).reject do |path|
13
13
  found_cmd = false
14
- exts.each { |ext|
14
+ exts.each do |ext|
15
15
  exe = "#{path}/#{cmd}#{ext}"
16
16
  found_cmd = true if File.executable? exe
17
- }
17
+ end
18
18
  found_cmd
19
19
  end
20
20
 
@@ -35,5 +35,4 @@ module PathHelpers
35
35
  def reset_path
36
36
  ENV['PATH'] = @original_path
37
37
  end
38
-
39
38
  end
@@ -1,3 +1,4 @@
1
+ # -*- encoding : utf-8 -*-
1
2
  class Class
2
3
  def subclasses
3
4
  result = []
data/lib/lolcommits.rb CHANGED
@@ -1,4 +1,5 @@
1
- $:.unshift File.expand_path('.')
1
+ # -*- encoding : utf-8 -*-
2
+ $LOAD_PATH.unshift File.expand_path('.')
2
3
 
3
4
  require 'core_ext/class'
4
5
  require 'mini_magick'
@@ -21,6 +22,7 @@ require 'lolcommits/capture_windows'
21
22
  require 'lolcommits/capture_cygwin'
22
23
  require 'lolcommits/capture_fake'
23
24
  require 'lolcommits/git_info'
25
+ require 'lolcommits/installation'
24
26
  require 'lolcommits/plugin'
25
27
  require 'lolcommits/plugins/loltext'
26
28
  require 'lolcommits/plugins/dot_com'
@@ -1,20 +1,22 @@
1
+ # -*- encoding : utf-8 -*-
1
2
  module Lolcommits
2
3
  class CaptureCygwin < Capturer
3
4
  def capture
4
- commandcam_exe = File.join Configuration::LOLCOMMITS_ROOT, "vendor", "ext", "CommandCam", "CommandCam.exe"
5
5
  # DirectShow takes a while to show... at least for me anyway
6
- delaycmd = " /delay 3000"
6
+ delaycmd = ' /delay 3000'
7
7
  if capture_delay > 0
8
8
  # CommandCam delay is in milliseconds
9
9
  delaycmd = " /delay #{capture_delay * 1000}"
10
10
  end
11
11
 
12
- _, r, _ = Open3.popen3("#{commandcam_exe} /filename `cygpath -w #{snapshot_location}`#{delaycmd}")
12
+ _, r, _ = Open3.popen3("#{executable_path} /filename `cygpath -w #{snapshot_location}`#{delaycmd}")
13
13
 
14
14
  # looks like we still need to read the output for something to happen
15
15
  r.read
16
16
  end
17
17
 
18
+ def executable_path
19
+ File.join(Configuration::LOLCOMMITS_ROOT, 'vendor', 'ext', 'CommandCam', 'CommandCam.exe')
20
+ end
18
21
  end
19
-
20
22
  end
@@ -1,10 +1,9 @@
1
+ # -*- encoding : utf-8 -*-
1
2
  module Lolcommits
2
3
  class CaptureFake < Capturer
3
4
  def capture
4
- test_image = File.join Configuration::LOLCOMMITS_ROOT, "test", "images", "test_image.jpg"
5
+ test_image = File.join Configuration::LOLCOMMITS_ROOT, 'test', 'images', 'test_image.jpg'
5
6
  FileUtils.cp test_image, snapshot_location
6
7
  end
7
-
8
8
  end
9
9
  end
10
-
@@ -1,3 +1,4 @@
1
+ # -*- encoding : utf-8 -*-
1
2
  module Lolcommits
2
3
  class CaptureLinux < Capturer
3
4
  def capture_device_string
@@ -5,7 +6,7 @@ module Lolcommits
5
6
  end
6
7
 
7
8
  def capture
8
- debug "LinuxCapturer: making tmp directory"
9
+ debug 'LinuxCapturer: making tmp directory'
9
10
  tmpdir = Dir.mktmpdir
10
11
 
11
12
  # Default delay is 1s
@@ -16,21 +17,23 @@ module Lolcommits
16
17
  # multiply the set value (in seconds) by 25
17
18
  frames = delay.to_i * 25
18
19
 
19
- debug "LinuxCapturer: calling out to mplayer to capture image"
20
+ debug 'LinuxCapturer: calling out to mplayer to capture image'
20
21
  # mplayer's output is ugly and useless, let's throw it away
21
- _, r, _ = Open3.popen3("mplayer -vo jpeg:outdir=#{tmpdir} #{capture_device_string} -frames #{frames} tv://")
22
+ _, r, _ = Open3.popen3("#{executable_path} -vo jpeg:outdir=#{tmpdir} #{capture_device_string} -frames #{frames} tv://")
22
23
  # looks like we still need to read the output for something to happen
23
24
  r.read
24
25
 
25
26
  # the below SHOULD tell FileUtils actions to post their output if we are in debug mode
26
27
  include FileUtils::Verbose if logger.level == 0
27
28
 
28
- debug "LinuxCapturer: calling out to mplayer to capture image"
29
- FileUtils.mv(tmpdir + "/%08d.jpg" % frames, snapshot_location)
30
- debug "LinuxCapturer: cleaning up"
31
- FileUtils.rm_rf( tmpdir )
29
+ debug 'LinuxCapturer: calling out to mplayer to capture image'
30
+ FileUtils.mv(tmpdir + '/%08d.jpg' % frames, snapshot_location)
31
+ debug 'LinuxCapturer: cleaning up'
32
+ FileUtils.rm_rf(tmpdir)
32
33
  end
33
34
 
35
+ def executable_path
36
+ 'mplayer'
37
+ end
34
38
  end
35
-
36
39
  end
@@ -1,3 +1,4 @@
1
+ # -*- encoding : utf-8 -*-
1
2
  module Lolcommits
2
3
  class CaptureMac < Capturer
3
4
  def capture_device_string
@@ -5,15 +6,13 @@ module Lolcommits
5
6
  end
6
7
 
7
8
  def capture
8
- call_str = "#{imagesnap_bin} -q \"#{snapshot_location}\" -w #{capture_delay} #{capture_device_string}"
9
+ call_str = "#{executable_path} -q \"#{snapshot_location}\" -w #{capture_delay} #{capture_device_string}"
9
10
  debug "Capturer: making system call for #{call_str}"
10
11
  system(call_str)
11
12
  end
12
13
 
13
- private
14
-
15
- def imagesnap_bin
16
- File.join(Configuration::LOLCOMMITS_ROOT, "vendor", "ext", "imagesnap", "imagesnap")
14
+ def executable_path
15
+ File.join(Configuration::LOLCOMMITS_ROOT, 'vendor', 'ext', 'imagesnap', 'imagesnap')
17
16
  end
18
17
  end
19
18
  end
@@ -1,13 +1,13 @@
1
+ # -*- encoding : utf-8 -*-
1
2
  module Lolcommits
2
3
  class CaptureMacAnimated < Capturer
3
-
4
4
  def capture
5
5
  # make a fresh frames directory
6
6
  FileUtils.rm_rf(frames_location)
7
7
  FileUtils.mkdir_p(frames_location)
8
8
 
9
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"
10
+ system_call "#{executable_path} -s 240 #{capture_device_string}#{capture_delay_string}-t #{animated_duration} --no-audio #{video_location} > /dev/null"
11
11
  if File.exists?(video_location)
12
12
  # convert raw video to png frames with ffmpeg
13
13
  system_call "ffmpeg -v quiet -i #{video_location} -t #{animated_duration} #{frames_location}/%09d.png"
@@ -25,7 +25,12 @@ module Lolcommits
25
25
  end
26
26
  end
27
27
 
28
+ def executable_path
29
+ File.join(Configuration::LOLCOMMITS_ROOT, 'vendor', 'ext', 'videosnap', 'videosnap')
30
+ end
31
+
28
32
  private
33
+
29
34
  def system_call(call_str, capture_output = false)
30
35
  debug "Capturer: making system call for \n #{call_str}"
31
36
  capture_output ? `#{call_str}` : system(call_str)
@@ -33,7 +38,7 @@ module Lolcommits
33
38
 
34
39
  def frame_delay(fps, skip)
35
40
  # calculate frame delay
36
- delay = ((100.0 * skip)/fps.to_f).to_i
41
+ delay = ((100.0 * skip) / fps.to_f).to_i
37
42
  delay < 6 ? 6 : delay # hard limit for IE browsers
38
43
  end
39
44
 
@@ -45,7 +50,7 @@ module Lolcommits
45
50
 
46
51
  def frame_skip(fps)
47
52
  # of frames to skip depends on movie fps
48
- case(fps)
53
+ case (fps)
49
54
  when 0..15
50
55
  2
51
56
  when 16..28
@@ -55,10 +60,6 @@ module Lolcommits
55
60
  end
56
61
  end
57
62
 
58
- def videosnap_bin
59
- File.join(Configuration::LOLCOMMITS_ROOT, 'vendor', 'ext', 'videosnap', 'videosnap')
60
- end
61
-
62
63
  def capture_device_string
63
64
  "-d '#{capture_device}' " if capture_device
64
65
  end
@@ -66,6 +67,5 @@ module Lolcommits
66
67
  def capture_delay_string
67
68
  "-w '#{capture_delay}' " if capture_delay.to_i > 0
68
69
  end
69
-
70
70
  end
71
71
  end
@@ -1,20 +1,22 @@
1
+ # -*- encoding : utf-8 -*-
1
2
  module Lolcommits
2
3
  class CaptureWindows < Capturer
3
4
  def capture
4
- commandcam_exe = File.join Configuration::LOLCOMMITS_ROOT, "vendor", "ext", "CommandCam", "CommandCam.exe"
5
5
  # DirectShow takes a while to show... at least for me anyway
6
- delaycmd = " /delay 3000"
6
+ delaycmd = ' /delay 3000'
7
7
  if capture_delay > 0
8
8
  # CommandCam delay is in milliseconds
9
9
  delaycmd = " /delay #{capture_delay * 1000}"
10
10
  end
11
11
 
12
- _, r, _ = Open3.popen3("#{commandcam_exe} /filename #{snapshot_location}#{delaycmd}")
12
+ _, r, _ = Open3.popen3("#{executable_path} /filename #{snapshot_location}#{delaycmd}")
13
13
 
14
14
  # looks like we still need to read the output for something to happen
15
15
  r.read
16
16
  end
17
17
 
18
+ def executable_path
19
+ File.join(Configuration::LOLCOMMITS_ROOT, 'vendor', 'ext', 'CommandCam', 'CommandCam.exe')
20
+ end
18
21
  end
19
-
20
22
  end
@@ -1,14 +1,16 @@
1
+ # -*- encoding : utf-8 -*-
1
2
  module Lolcommits
2
3
  class Capturer
3
4
  include Methadone::CLILogging
5
+
4
6
  attr_accessor :capture_device, :capture_delay, :snapshot_location, :font,
5
7
  :video_location, :frames_location, :animated_duration
6
8
 
7
- def initialize(attributes = Hash.new)
9
+ def initialize(attributes = {})
8
10
  attributes.each do |attr, val|
9
11
  self.send("#{attr}=", val)
10
12
  end
11
- debug "Capturer: initializing new instance " + self.to_s
13
+ debug 'Capturer: initializing new instance ' + self.to_s
12
14
  end
13
15
  end
14
16
  end