lolcommits 0.5.7 → 0.5.8
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.
- checksums.yaml +8 -8
- data/.rubocop.yml +1 -0
- data/.rubocop_todo.yml +16 -161
- data/.travis.yml +11 -4
- data/CHANGELOG +11 -0
- data/Gemfile +2 -2
- data/Rakefile +24 -32
- data/bin/lolcommits +62 -125
- data/features/bugs.feature +24 -9
- data/features/lolcommits.feature +136 -145
- data/features/plugins.feature +16 -33
- data/features/step_definitions/lolcommits_steps.rb +91 -71
- data/features/support/env.rb +18 -48
- data/features/support/path_helpers.rb +9 -8
- data/lib/core_ext/mini_magick/utilities.rb +15 -0
- data/lib/lolcommits/capturer/capture_linux.rb +1 -1
- data/lib/lolcommits/capturer/capture_linux_animated.rb +12 -13
- data/lib/lolcommits/capturer/capture_mac_animated.rb +12 -13
- data/lib/lolcommits/capturer.rb +10 -2
- data/lib/lolcommits/cli/fatals.rb +77 -0
- data/lib/lolcommits/cli/launcher.rb +29 -0
- data/lib/lolcommits/cli/process_runner.rb +48 -0
- data/lib/lolcommits/cli/timelapse_gif.rb +45 -0
- data/lib/lolcommits/configuration.rb +30 -133
- data/lib/lolcommits/git_info.rb +58 -28
- data/lib/lolcommits/installation.rb +11 -21
- data/lib/lolcommits/platform.rb +134 -0
- data/lib/lolcommits/plugin.rb +2 -2
- data/lib/lolcommits/plugins/dot_com.rb +15 -15
- data/lib/lolcommits/plugins/lol_protonet.rb +68 -0
- data/lib/lolcommits/plugins/lol_twitter.rb +12 -15
- data/lib/lolcommits/plugins/lol_yammer.rb +4 -6
- data/lib/lolcommits/plugins/lolsrv.rb +8 -11
- data/lib/lolcommits/plugins/loltext.rb +7 -7
- data/lib/lolcommits/plugins/tranzlate.rb +70 -70
- data/lib/lolcommits/plugins/uploldz.rb +8 -8
- data/lib/lolcommits/runner.rb +36 -35
- data/lib/lolcommits/version.rb +1 -1
- data/lib/lolcommits.rb +4 -10
- data/lolcommits.gemspec +11 -10
- data/test/lolcommits_test.rb +35 -0
- data/test/plugins_test.rb +52 -0
- metadata +40 -18
- data/test/test_lolcommits.rb +0 -78
data/bin/lolcommits
CHANGED
|
@@ -8,71 +8,32 @@ rescue LoadError
|
|
|
8
8
|
require 'lolcommits'
|
|
9
9
|
end
|
|
10
10
|
|
|
11
|
+
require 'lolcommits/cli/fatals'
|
|
12
|
+
require 'lolcommits/cli/launcher'
|
|
13
|
+
require 'lolcommits/cli/process_runner'
|
|
14
|
+
require 'lolcommits/cli/timelapse_gif'
|
|
15
|
+
|
|
11
16
|
include Lolcommits
|
|
12
|
-
|
|
13
|
-
require 'choice'
|
|
17
|
+
include Lolcommits::CLI
|
|
14
18
|
|
|
19
|
+
require 'choice'
|
|
15
20
|
require 'methadone'
|
|
16
21
|
include Methadone::CLILogging
|
|
17
22
|
|
|
18
|
-
#
|
|
19
|
-
# CHECK FOR FURTHER DEPENDENCIES
|
|
20
|
-
#
|
|
21
|
-
|
|
22
|
-
def die_on_fatal_conditions!
|
|
23
|
-
if Configuration.platform_mac?
|
|
24
|
-
%w(imagesnap videosnap).each do |executable|
|
|
25
|
-
unless File.executable? File.join(Configuration::LOLCOMMITS_ROOT, 'vendor', 'ext', executable, executable)
|
|
26
|
-
fatal "Couldn't properly execute #{executable} for some reason, please file a bug?!"
|
|
27
|
-
exit 1
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
elsif Configuration.platform_linux?
|
|
31
|
-
if not Configuration.command_which('mplayer')
|
|
32
|
-
fatal "Couldn't find mplayer in your PATH!"
|
|
33
|
-
exit 1
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
unless File.readable? File.join(Configuration::LOLCOMMITS_ROOT, 'vendor', 'fonts', 'Impact.ttf')
|
|
37
|
-
fatal "Couldn't properly read Impact font from gem package, please file a bug?!"
|
|
38
|
-
exit 1
|
|
39
|
-
end
|
|
40
|
-
if !Configuration.valid_ffmpeg_installed? && capture_animate
|
|
41
|
-
fatal 'FATAL: ffmpeg does not appear to be properly installed!'
|
|
42
|
-
exit 1
|
|
43
|
-
end
|
|
44
|
-
unless Configuration.valid_imagemagick_installed?
|
|
45
|
-
fatal 'FATAL: ImageMagick does not appear to be properly installed!'
|
|
46
|
-
exit 1
|
|
47
|
-
end
|
|
48
|
-
if Configuration.git_config_color_always?
|
|
49
|
-
fatal "Due to a bug in the ruby-git library, git config for color.ui cannot be set to 'always'."
|
|
50
|
-
fatal "Try setting it to 'auto' instead!"
|
|
51
|
-
exit 1
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
def die_if_not_git_repo!
|
|
56
|
-
begin
|
|
57
|
-
debug 'Checking for valid git repo'
|
|
58
|
-
g = Git.open('.')
|
|
59
|
-
rescue ArgumentError
|
|
60
|
-
# ruby-git throws an argument error if path isnt for a valid git repo...
|
|
61
|
-
fatal "Erm? Can't do that since we're not in a valid git repository!"
|
|
62
|
-
exit 1
|
|
63
|
-
end
|
|
64
|
-
end
|
|
65
|
-
|
|
66
23
|
#
|
|
67
24
|
# NO ARGUMENTS SPECIFIED, HELP THE USER OUT
|
|
68
25
|
#
|
|
69
26
|
def do_noargs
|
|
70
|
-
# TODO: make this a contextual helper to know
|
|
27
|
+
# TODO: make this a contextual helper to know whether lolcommits is enabled
|
|
71
28
|
puts 'Do what exactly?'
|
|
72
29
|
puts 'Try: lolcommits --enable (when in a git repository)'
|
|
73
30
|
puts 'Or: lolcommits --help'
|
|
74
31
|
end
|
|
75
32
|
|
|
33
|
+
# Gets a configuration object. If running in test mode will override the
|
|
34
|
+
# LOLDIR for the configuration.
|
|
35
|
+
#
|
|
36
|
+
# @return [Lolcommits::Configuration]
|
|
76
37
|
def configuration
|
|
77
38
|
if Choice.choices[:test]
|
|
78
39
|
Configuration.new(:loldir => Configuration.loldir_for('test'))
|
|
@@ -81,18 +42,26 @@ def configuration
|
|
|
81
42
|
end
|
|
82
43
|
end
|
|
83
44
|
|
|
45
|
+
# Duration for animated capture.
|
|
46
|
+
#
|
|
47
|
+
# If animation is enabled, returns an integer representing seconds OR a string
|
|
48
|
+
# containing the char representation of an integer.
|
|
49
|
+
# If animation is disabled, or if the platform doesn't support animated capture,
|
|
50
|
+
# returns nil instead.
|
|
51
|
+
#
|
|
52
|
+
# FIXME: we really should standardize this to always return integer, and remove
|
|
53
|
+
# all the to_i calls elsewhere.
|
|
54
|
+
#
|
|
55
|
+
# @return [Integer, String, nil]
|
|
84
56
|
def capture_animate
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
end
|
|
57
|
+
return unless Platform.can_animate?
|
|
58
|
+
Choice.choices[:animate] || ENV['LOLCOMMITS_ANIMATE'] || nil
|
|
88
59
|
end
|
|
89
60
|
|
|
90
61
|
def default_device
|
|
91
62
|
result = Choice.choices[:device] || ENV['LOLCOMMITS_DEVICE']
|
|
92
63
|
|
|
93
|
-
if
|
|
94
|
-
result ||= Dir.glob('/dev/video*').first
|
|
95
|
-
end
|
|
64
|
+
result ||= Dir.glob('/dev/video*').first if Platform.platform_linux?
|
|
96
65
|
|
|
97
66
|
result
|
|
98
67
|
end
|
|
@@ -101,10 +70,10 @@ end
|
|
|
101
70
|
# IF --CAPTURE, DO CAPTURE
|
|
102
71
|
#
|
|
103
72
|
def do_capture
|
|
104
|
-
capture_delay = Choice.choices[:delay]
|
|
105
|
-
capture_stealth = Choice.choices[:stealth]
|
|
73
|
+
capture_delay = Choice.choices[:delay] || ENV['LOLCOMMITS_DELAY'] || 0
|
|
74
|
+
capture_stealth = Choice.choices[:stealth] || ENV['LOLCOMMITS_STEALTH'] || nil
|
|
75
|
+
capture_font = Choice.choices[:font] || ENV['LOLCOMMITS_FONT'] || nil
|
|
106
76
|
capture_device = default_device
|
|
107
|
-
capture_font = Choice.choices[:font] || ENV['LOLCOMMITS_FONT'] || nil
|
|
108
77
|
|
|
109
78
|
capture_options = {
|
|
110
79
|
:capture_delay => capture_delay,
|
|
@@ -115,7 +84,9 @@ def do_capture
|
|
|
115
84
|
:config => configuration
|
|
116
85
|
}
|
|
117
86
|
|
|
118
|
-
|
|
87
|
+
process_runner = ProcessRunner.new(configuration)
|
|
88
|
+
should_we_fork = Choice.choices[:fork] || ENV['LOLCOMMITS_FORK']
|
|
89
|
+
process_runner.fork_me?(should_we_fork) do
|
|
119
90
|
if Choice.choices[:test]
|
|
120
91
|
info '*** Capturing in test mode.'
|
|
121
92
|
|
|
@@ -125,11 +96,12 @@ def do_capture
|
|
|
125
96
|
:sha => Choice.choices[:sha]
|
|
126
97
|
}
|
|
127
98
|
|
|
99
|
+
# fire off runner with the overriden fake commit metadata
|
|
128
100
|
runner = Lolcommits::Runner.new(capture_options.merge override_text)
|
|
129
101
|
runner.run
|
|
130
102
|
|
|
131
|
-
# automatically open so
|
|
132
|
-
|
|
103
|
+
# automatically open so user can see the test image results immediately
|
|
104
|
+
Launcher.open_image(runner.main_image)
|
|
133
105
|
else
|
|
134
106
|
runner = Lolcommits::Runner.new(capture_options)
|
|
135
107
|
runner.run
|
|
@@ -137,69 +109,19 @@ def do_capture
|
|
|
137
109
|
end
|
|
138
110
|
end
|
|
139
111
|
|
|
140
|
-
def fork_me?(&block)
|
|
141
|
-
if Choice.choices[:fork] || ENV['LOLCOMMITS_FORK']
|
|
142
|
-
$stdout.sync = true
|
|
143
|
-
write_pid fork {
|
|
144
|
-
yield block
|
|
145
|
-
delete_pid
|
|
146
|
-
}
|
|
147
|
-
else
|
|
148
|
-
yield block
|
|
149
|
-
end
|
|
150
|
-
end
|
|
151
|
-
|
|
152
|
-
def write_pid(pid)
|
|
153
|
-
File.open(pid_file, 'w') { |f| f.write(pid) }
|
|
154
|
-
end
|
|
155
|
-
|
|
156
|
-
def delete_pid
|
|
157
|
-
File.delete(pid_file) if File.exist?(pid_file)
|
|
158
|
-
end
|
|
159
|
-
|
|
160
|
-
def pid_file
|
|
161
|
-
File.join(configuration.loldir, 'lolcommits.pid')
|
|
162
|
-
end
|
|
163
|
-
|
|
164
112
|
def do_configure
|
|
113
|
+
$stdout.sync = true
|
|
165
114
|
configuration.do_configure! Choice.choices[:plugin]
|
|
166
115
|
end
|
|
167
116
|
|
|
168
117
|
def do_last
|
|
169
|
-
die_if_not_git_repo!
|
|
118
|
+
Fatals.die_if_not_git_repo!
|
|
170
119
|
lolimage = configuration.most_recent
|
|
171
120
|
if lolimage.nil?
|
|
172
121
|
warn 'No lolcommits have been captured for this repository yet.'
|
|
173
122
|
exit 1
|
|
174
123
|
end
|
|
175
|
-
|
|
176
|
-
end
|
|
177
|
-
|
|
178
|
-
def do_gif
|
|
179
|
-
die_if_not_git_repo!
|
|
180
|
-
|
|
181
|
-
case Choice.choices[:gif]
|
|
182
|
-
when 'today'
|
|
183
|
-
lolimages = configuration.jpg_images_today
|
|
184
|
-
filename = "#{Date.today.to_s}.gif"
|
|
185
|
-
else
|
|
186
|
-
lolimages = configuration.jpg_images
|
|
187
|
-
filename = 'archive.gif'
|
|
188
|
-
end
|
|
189
|
-
|
|
190
|
-
if lolimages.empty?
|
|
191
|
-
warn 'No lolcommits have been captured for this time yet.'
|
|
192
|
-
exit 1
|
|
193
|
-
end
|
|
194
|
-
|
|
195
|
-
puts '*** Generating animated gif.'
|
|
196
|
-
|
|
197
|
-
gif = MiniMagick::Image.new File.join configuration.archivedir, filename
|
|
198
|
-
|
|
199
|
-
# This is for ruby 1.8.7, *lolimages just doesn't work with ruby 187
|
|
200
|
-
gif.run_command('convert', *['-delay', '50', '-loop', '0', lolimages, "#{gif.path}"].flatten)
|
|
201
|
-
|
|
202
|
-
puts "*** #{gif.path} generated."
|
|
124
|
+
Launcher.open_image(lolimage)
|
|
203
125
|
end
|
|
204
126
|
|
|
205
127
|
def print_version_and_exit
|
|
@@ -219,11 +141,18 @@ def change_dir_to_root_or_repo!
|
|
|
219
141
|
end
|
|
220
142
|
end
|
|
221
143
|
|
|
144
|
+
# FIXME: this should be moved out of the CLI, but to where?
|
|
145
|
+
def load_local_plugins!
|
|
146
|
+
plugins_dir = Configuration.loldir_for('.plugins')
|
|
147
|
+
Dir.glob("#{plugins_dir}/*.rb").each do |plugin|
|
|
148
|
+
load plugin
|
|
149
|
+
end
|
|
150
|
+
end
|
|
151
|
+
|
|
222
152
|
#
|
|
223
153
|
# Command line parsing fun
|
|
224
154
|
#
|
|
225
155
|
Choice.options do
|
|
226
|
-
|
|
227
156
|
option :version do
|
|
228
157
|
long '--version'
|
|
229
158
|
short '-v'
|
|
@@ -270,7 +199,7 @@ Choice.options do
|
|
|
270
199
|
|
|
271
200
|
option :show_config do
|
|
272
201
|
short '-sc'
|
|
273
|
-
long
|
|
202
|
+
long '--show-config'
|
|
274
203
|
desc 'display configuration file'
|
|
275
204
|
end
|
|
276
205
|
|
|
@@ -344,7 +273,7 @@ Choice.options do
|
|
|
344
273
|
desc 'generate animated timeline gif from captured images'
|
|
345
274
|
end
|
|
346
275
|
|
|
347
|
-
if
|
|
276
|
+
if Platform.can_animate?
|
|
348
277
|
option :animate do
|
|
349
278
|
long '--animate=SECONDS'
|
|
350
279
|
short '-a'
|
|
@@ -369,17 +298,23 @@ end
|
|
|
369
298
|
#
|
|
370
299
|
# check for fatal conditions before execution
|
|
371
300
|
#
|
|
372
|
-
|
|
301
|
+
Fatals.die_if_no_valid_ffmpeg_installed! if capture_animate
|
|
302
|
+
Fatals.die_on_fatal_platform_conditions!
|
|
373
303
|
|
|
374
304
|
#
|
|
375
305
|
# change working dir to either a repo or the fs root
|
|
376
306
|
#
|
|
377
307
|
change_dir_to_root_or_repo!
|
|
378
308
|
|
|
309
|
+
#
|
|
310
|
+
# load system local plugins
|
|
311
|
+
#
|
|
312
|
+
load_local_plugins!
|
|
313
|
+
|
|
379
314
|
#
|
|
380
315
|
# Handle actions manually since choice seems weird
|
|
381
316
|
#
|
|
382
|
-
if
|
|
317
|
+
if !Choice.choices[:enable] || !Choice.choices[:disable]
|
|
383
318
|
if Choice.choices[:capture]
|
|
384
319
|
do_capture
|
|
385
320
|
elsif Choice.choices[:configure]
|
|
@@ -389,14 +324,16 @@ if not (Choice.choices[:enable] || Choice.choices[:disable])
|
|
|
389
324
|
elsif Choice.choices[:plugins]
|
|
390
325
|
configuration.puts_plugins
|
|
391
326
|
elsif Choice.choices[:devices]
|
|
392
|
-
|
|
327
|
+
puts Platform.device_list
|
|
328
|
+
puts "Specify a device with --device=\"{device name}\" "\
|
|
329
|
+
'or set the LOLCOMMITS_DEVICE env variable'
|
|
393
330
|
elsif Choice.choices[:last]
|
|
394
331
|
do_last
|
|
395
332
|
elsif Choice.choices[:browse]
|
|
396
|
-
die_if_not_git_repo!
|
|
397
|
-
|
|
333
|
+
Fatals.die_if_not_git_repo!
|
|
334
|
+
Launcher.open_folder(configuration.loldir)
|
|
398
335
|
elsif Choice.choices[:gif]
|
|
399
|
-
|
|
336
|
+
TimelapseGif.new(configuration).run(Choice.choices[:gif])
|
|
400
337
|
else
|
|
401
338
|
do_noargs
|
|
402
339
|
end
|
data/features/bugs.feature
CHANGED
|
@@ -3,11 +3,14 @@ Feature: Bug regression testing
|
|
|
3
3
|
I want to ensure fixed bugs stay fixed
|
|
4
4
|
So that I don't have to fix them again!
|
|
5
5
|
|
|
6
|
+
Background:
|
|
7
|
+
Given a mocked home directory
|
|
8
|
+
|
|
6
9
|
#
|
|
7
10
|
# issue #58, https://github.com/mroth/lolcommits/issues/58
|
|
8
11
|
#
|
|
9
12
|
Scenario: handle git repos with spaces in directory name
|
|
10
|
-
Given I am in a git
|
|
13
|
+
Given I am in a git repo named "test lolol" with lolcommits enabled
|
|
11
14
|
And I successfully run `git commit --allow-empty -m 'can haz commit'`
|
|
12
15
|
Then the output should contain "*** Preserving this moment in history."
|
|
13
16
|
And a directory named "../.lolcommits/test-lolol" should exist
|
|
@@ -17,7 +20,7 @@ Feature: Bug regression testing
|
|
|
17
20
|
#
|
|
18
21
|
@fake-interactive-rebase @slow_process @unstable
|
|
19
22
|
Scenario: Don't trigger capture during a git rebase
|
|
20
|
-
Given I am in a git
|
|
23
|
+
Given I am in a git repo named "yuh8history" with lolcommits enabled
|
|
21
24
|
And I do 6 git commits
|
|
22
25
|
When I successfully run `git rebase -i HEAD~5`
|
|
23
26
|
# Then there should be 4 commit entries in the git log
|
|
@@ -28,31 +31,43 @@ Feature: Bug regression testing
|
|
|
28
31
|
#
|
|
29
32
|
Scenario: don't warn about system_timer (on MRI 1.8.7)
|
|
30
33
|
When I successfully run `lolcommits`
|
|
31
|
-
Then the output should not contain
|
|
34
|
+
Then the output should not contain:
|
|
35
|
+
"""
|
|
36
|
+
Faraday: you may want to install system_timer for reliable timeouts
|
|
37
|
+
"""
|
|
32
38
|
|
|
33
39
|
#
|
|
34
40
|
# issue #81, https://github.com/mroth/lolcommits/issues/81
|
|
35
41
|
#
|
|
36
|
-
Scenario: don't want
|
|
42
|
+
Scenario: don't want initialized constant warning from Faraday (MRI 1.8.7)
|
|
37
43
|
When I successfully run `lolcommits`
|
|
38
|
-
Then the output should not contain
|
|
39
|
-
|
|
44
|
+
Then the output should not contain:
|
|
45
|
+
"""
|
|
46
|
+
warning: already initialized constant DEFAULT_BOUNDARY
|
|
47
|
+
"""
|
|
48
|
+
|
|
40
49
|
#
|
|
41
50
|
# issue #87, https://github.com/mroth/lolcommits/issues/87
|
|
42
51
|
#
|
|
43
52
|
@fake-no-imagemagick
|
|
44
53
|
Scenario: gracefully fail when imagemagick is not installed
|
|
45
54
|
When I run `lolcommits`
|
|
46
|
-
Then the output should contain
|
|
55
|
+
Then the output should contain:
|
|
56
|
+
"""
|
|
57
|
+
ImageMagick does not appear to be properly installed
|
|
58
|
+
"""
|
|
47
59
|
And the exit status should be 1
|
|
48
60
|
|
|
49
61
|
#
|
|
50
62
|
# issue #50, https://github.com/mroth/lolcommits/issues/50
|
|
51
63
|
#
|
|
52
64
|
Scenario: catch upstream bug with ruby-git and color=always
|
|
53
|
-
Given I am in a git
|
|
65
|
+
Given I am in a git repo named "whatev" with lolcommits enabled
|
|
54
66
|
And I successfully run `git config color.ui always`
|
|
55
67
|
When I run `lolcommits`
|
|
56
|
-
Then the output should contain
|
|
68
|
+
Then the output should contain:
|
|
69
|
+
"""
|
|
70
|
+
Due to a bug in the ruby-git library, git config for color.ui cannot be set to 'always'.
|
|
71
|
+
"""
|
|
57
72
|
And the output should contain "Try setting it to 'auto' instead!"
|
|
58
73
|
And the exit status should be 1
|