lolcommits 0.9.0 → 0.9.1.pre1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop_todo.yml +1 -1
- data/CHANGELOG.md +5 -1
- data/README.md +53 -43
- data/bin/lolcommits +180 -288
- data/features/lolcommits.feature +7 -7
- data/features/support/env.rb +1 -1
- data/lib/lolcommits/backends/git_info.rb +0 -1
- data/lib/lolcommits/backends/installation_git.rb +5 -11
- data/lib/lolcommits/backends/installation_mercurial.rb +3 -9
- data/lib/lolcommits/backends/mercurial_info.rb +0 -1
- data/lib/lolcommits/capturer.rb +0 -2
- data/lib/lolcommits/cli.rb +4 -0
- data/lib/lolcommits/cli/fatals.rb +0 -1
- data/lib/lolcommits/cli/timelapse_gif.rb +0 -2
- data/lib/lolcommits/configuration.rb +5 -4
- data/lib/lolcommits/installation.rb +18 -2
- data/lib/lolcommits/plugin.rb +0 -2
- data/lib/lolcommits/plugins/loltext.rb +2 -2
- data/lib/lolcommits/runner.rb +25 -34
- data/lib/lolcommits/vcs_info.rb +0 -1
- data/lib/lolcommits/version.rb +1 -1
- data/lolcommits.gemspec +0 -1
- data/test/lolcommits_test.rb +1 -0
- metadata +5 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1c4ac1d2dbe5a6453b6fc5f08ea083644a8867ef
|
4
|
+
data.tar.gz: 4ab1a2a37a903bc050ec338bb5fac0e02475dfda
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3502f3b8d8cf42a8a6b89bbb5962dbc6fe2f1ecca2d36594b39f292ec1c4bcdb2e60d36a7207a645058ae6cd9e40b980d0762df112be5f74009f90c8aa351569
|
7
|
+
data.tar.gz: 02a4452c6281d97938c58a0e3360f0a9a97b128c845cf4c12a73b17a3ea22dea8b3bcca116d7502733b54ed26c7abdc27e5e767b8bc7664aa38c4864588badf3
|
data/.rubocop_todo.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -8,6 +8,9 @@ project adheres to [Semantic Versioning][Semver].
|
|
8
8
|
* WIP - extract plugins to separate gems ...
|
9
9
|
* Your contribution here!
|
10
10
|
|
11
|
+
## [0.9.1][] (20 December 2016)
|
12
|
+
* Remove Choice gem, use Methadone (@matthutchinson #326)
|
13
|
+
|
11
14
|
## [0.9.0][] (14 December 2016)
|
12
15
|
* ditch ruby 1.9 support and upgrade some gems (@matthutchinson #325)
|
13
16
|
* term_output plugin added (iTerm2 only) (@ruxton #323)
|
@@ -259,7 +262,8 @@ project adheres to [Semantic Versioning][Semver].
|
|
259
262
|
instead of compositing multiply image Caption objects (this seems to be more
|
260
263
|
reliable to not glitch.)
|
261
264
|
|
262
|
-
[Unreleased]: https://github.com/mroth/lolcommits/compare/v0.9.
|
265
|
+
[Unreleased]: https://github.com/mroth/lolcommits/compare/v0.9.1...HEAD
|
266
|
+
[0.9.1]: https://github.com/mroth/lolcommits/compare/v0.9.0...v0.9.1
|
263
267
|
[0.9.0]: https://github.com/mroth/lolcommits/compare/v0.8.1...v0.9.0
|
264
268
|
[0.8.1]: https://github.com/mroth/lolcommits/compare/v0.8.0...v0.8.1
|
265
269
|
[0.8.0]: https://github.com/mroth/lolcommits/compare/v0.7.0...v0.8.0
|
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# lolcommits (git + webcam = lol)
|
2
2
|
|
3
3
|
lolcommits takes a snapshot with your webcam every time you git commit code, and
|
4
|
-
archives a lolcat style image with it.
|
4
|
+
archives a lolcat style image with it. Git blame has never been so much fun.
|
5
5
|
|
6
6
|
By default, the lol images are stored by a Github style short SHA in a
|
7
7
|
`~/.lolcommits` directory created for you.
|
@@ -12,6 +12,7 @@ By default, the lol images are stored by a Github style short SHA in a
|
|
12
12
|
[![CodeClimate Status](https://d3s6mut3hikguw.cloudfront.net/github/mroth/lolcommits/badges/gpa.svg)](https://codeclimate.com/github/mroth/lolcommits)
|
13
13
|
[![Coverage Status](https://coveralls.io/repos/mroth/lolcommits/badge.svg?branch=master&service=github)](https://coveralls.io/r/mroth/lolcommits)
|
14
14
|
|
15
|
+
|
15
16
|
## Sample images
|
16
17
|
|
17
18
|
<img src="https://lolcommits.github.io/assets/img/gallery.jpeg" />
|
@@ -20,19 +21,22 @@ Please add your own lolcommit! Add to the [People Using
|
|
20
21
|
Lolcommits](https://github.com/mroth/lolcommits/wiki/Lolcommits-from-around-the-world%21)
|
21
22
|
page on our wiki.
|
22
23
|
|
24
|
+
|
23
25
|
## Requirements
|
24
26
|
|
25
|
-
* Ruby >=
|
27
|
+
* Ruby >= 2.0.0
|
26
28
|
* A webcam
|
27
29
|
* [ImageMagick](http://www.imagemagick.org)
|
28
30
|
* [ffmpeg](https://www.ffmpeg.org) (optional) for animated gif capturing
|
29
31
|
|
32
|
+
|
30
33
|
## Installation
|
31
34
|
|
35
|
+
|
32
36
|
### Mac OS X
|
33
37
|
|
34
38
|
You'll need ImageMagick installed. [Homebrew](http://mxcl.github.com/homebrew/)
|
35
|
-
makes this easy.
|
39
|
+
makes this easy.
|
36
40
|
|
37
41
|
brew install imagemagick
|
38
42
|
|
@@ -47,11 +51,12 @@ If [Boxen](https://boxen.github.com) is your thing, [try
|
|
47
51
|
this](https://github.com/AssuredLabor/puppet-lolcommits).
|
48
52
|
|
49
53
|
Lolcommits v0.8.1 was the last release to support Ruby < 2.0. If you'd like to
|
50
|
-
use this gem on older rubies
|
54
|
+
use this gem on older rubies try:
|
51
55
|
|
52
56
|
[sudo] gem install lolcommits --version 0.8.1 # for Ruby 1.9
|
53
57
|
[sudo] gem install lolcommits --version 0.7.0 # for Ruby 1.8
|
54
58
|
|
59
|
+
|
55
60
|
### Linux
|
56
61
|
|
57
62
|
Install dependencies using your package manager of choice, for example in
|
@@ -70,14 +75,17 @@ Then install the gem with:
|
|
70
75
|
For more details, see [Installing on
|
71
76
|
Linux](https://github.com/mroth/lolcommits/wiki/Installing-on-Linux).
|
72
77
|
|
78
|
+
|
73
79
|
### Windows - here be dragons!
|
74
80
|
|
75
|
-
It
|
76
|
-
dependencies installed.
|
81
|
+
It works, but you'll need some more detailed instructions to get the
|
82
|
+
dependencies installed. See the wiki page for [Installing on
|
77
83
|
Windows](https://github.com/mroth/lolcommits/wiki/Installing-on-Windows).
|
78
84
|
|
85
|
+
|
79
86
|
## Usage
|
80
87
|
|
88
|
+
|
81
89
|
### Enabling and basic usage
|
82
90
|
|
83
91
|
From within any git repository, simply do a `lolcommits --enable`. From that
|
@@ -92,23 +100,27 @@ to achieve this using `git init` and the `init.templatedir` setting.
|
|
92
100
|
Don't worry about it too much, half the fun of lolcommits is forgetting it's
|
93
101
|
installed!
|
94
102
|
|
103
|
+
|
95
104
|
### Other commands
|
96
105
|
|
97
106
|
Ok, if you insist... Since you know about `--enable`, common sense suggests
|
98
107
|
there is also a repository specific `--disable`, hopefully you can guess what
|
99
|
-
that does.
|
100
|
-
display your most recent lolcommit image, or `--browse`, which pops open the
|
101
|
-
directory containing all the lolcommit images for your current repository. You
|
102
|
-
can always do `--help` for a full list of available commands.
|
108
|
+
that does.
|
103
109
|
|
104
|
-
|
105
|
-
|
110
|
+
Other handy common commands include `--last`, which will open for display your
|
111
|
+
most recent lolcommit, or `--browse`, which pops open the directory containing
|
112
|
+
all the lolcommit images for your current repository. You can always do `--help`
|
113
|
+
for a full list of available commands.
|
106
114
|
|
107
|
-
|
115
|
+
**NOTE**: Any extra arguments you pass with `--enable` are appended to the
|
116
|
+
git post-hook capture command. For example;
|
117
|
+
|
118
|
+
lolcommits --enable --delay 5 --animate 4 --fork
|
108
119
|
|
109
120
|
Will configure capturing of an animated gif (4 secs) after a 5 sec delay in a
|
110
121
|
forked process. See the section below for more capture configuration variables.
|
111
122
|
|
123
|
+
|
112
124
|
### Capture configuration variables
|
113
125
|
|
114
126
|
lolcommits has some capture options for additional lulz. You can enable these
|
@@ -124,27 +136,26 @@ via environment variables like so;
|
|
124
136
|
* `LOLCOMMITS_STEALTH` disable notification messages at commit time
|
125
137
|
* `LOLCOMMITS_DIR` set the output directory used for all repositories (defaults to ~/.lolcommits)
|
126
138
|
|
127
|
-
Or they can be set
|
128
|
-
|
139
|
+
Or they can be set with these arguments to the capture command (located in your
|
140
|
+
repository's `.git/hooks/post-commit` file).
|
129
141
|
|
130
|
-
* `--device
|
131
|
-
* `--animate
|
132
|
-
* `--delay
|
142
|
+
* `--device {name}` or `-d {name}`
|
143
|
+
* `--animate {seconds}` or `-a {seconds}`
|
144
|
+
* `--delay {seconds}` or `-w {seconds}`
|
133
145
|
* `--fork`
|
134
146
|
* `--stealth`
|
135
147
|
|
136
|
-
|
137
|
-
|
138
|
-
|
148
|
+
Use `lolcommits --devices` to list all attached video devices available for
|
149
|
+
capturing.
|
150
|
+
|
151
|
+
You can configure lolcommit text positions, font styles (type, size, color etc.)
|
152
|
+
or add a transparent overlay to your images. Simply configure the default
|
153
|
+
loltext plugin with this command:
|
139
154
|
|
140
155
|
lolcommits --config -p loltext
|
141
156
|
|
142
|
-
To find out more, read about
|
157
|
+
To find out more, read about [loltext options](https://github.com/mroth/lolcommits/wiki/Configure-Commit-Capturing#loltext-options).
|
143
158
|
|
144
|
-
You can use `lolcommits --devices` to list all attached video devices available
|
145
|
-
for capturing. Read how to [configure commit
|
146
|
-
capturing](https://github.com/mroth/lolcommits/wiki/Configure-Commit-Capturing)
|
147
|
-
for more details.
|
148
159
|
|
149
160
|
### Animated Gif Capturing
|
150
161
|
|
@@ -156,46 +167,45 @@ you capture and the capabilities of your machine).
|
|
156
167
|
* OSX - `brew install ffmpeg`
|
157
168
|
|
158
169
|
To enable, just set the `LOLCOMMITS_ANIMATE` environment variable with the
|
159
|
-
number of seconds to capture.
|
160
|
-
|
161
|
-
device or delay time (seconds) before capturing.
|
162
|
-
|
163
|
-
If you find capturing an animated gif takes too long, try setting the
|
164
|
-
`LOLCOMMITS_FORK=true` env variable. Animated gif captures are currently NOT
|
170
|
+
number of seconds to capture. If you find animated capturing takes too long, try
|
171
|
+
setting `LOLCOMMITS_FORK=true`. Animated gif captures are currently NOT
|
165
172
|
supported on Windows.
|
166
173
|
|
167
174
|
![Example animated lolcommit
|
168
175
|
gif](http://cdn2.usa.bugleblogs.com/blogs/000/000/003/de0eb9aa695.gif "Example
|
169
176
|
animated lolcommit gif")
|
170
177
|
|
178
|
+
|
171
179
|
### Plugins
|
172
180
|
|
173
|
-
A growing number of plugins are
|
181
|
+
A growing number of plugins are available, allowing you to transform or share
|
174
182
|
your lolcommits with others. The default plugin simply appends your commit
|
175
183
|
message and sha to the captured image. Others can auto post to Twitter, Tumblr
|
176
184
|
(and other services), or even translate your commit messages to
|
177
185
|
[lolspeak](http://www.urbandictionary.com/define.php?term=lolspeak). They can be
|
178
|
-
easily enabled, configured or disabled with
|
186
|
+
easily enabled, configured or disabled with the `--config` option:
|
179
187
|
|
180
188
|
lolcommits --config
|
181
189
|
|
182
190
|
Check them out on our [plugins
|
183
191
|
page](https://github.com/mroth/lolcommits/wiki/Configuring-Plugins).
|
184
192
|
|
193
|
+
|
194
|
+
## Timelapse
|
195
|
+
|
196
|
+
To watch your face as it decays while you program, you can create an animated
|
197
|
+
timelapse gif.
|
198
|
+
|
199
|
+
lolcommits --timelapse
|
200
|
+
# or for just today's lolcommits
|
201
|
+
lolcommits --timelapse --period today
|
202
|
+
|
185
203
|
## Troubles?
|
186
204
|
|
187
205
|
Try our trouble-shooting [FAQ](https://github.com/mroth/lolcommits/wiki/FAQ), or
|
188
206
|
take a read through our [wiki](https://github.com/mroth/lolcommits/wiki) for
|
189
|
-
more information. If you think something is broken or missing, raise a [
|
207
|
+
more information. If you think something is broken or missing, raise a [Github
|
190
208
|
issue](https://github.com/mroth/lolcommits/issues) (and please take a little
|
191
209
|
time to check if we haven't [already
|
192
210
|
addressed](https://github.com/mroth/lolcommits/issues?q=is%3Aissue+is%3Aclosed)
|
193
211
|
it).
|
194
|
-
|
195
|
-
## Timelapse?
|
196
|
-
|
197
|
-
To watch your face as it decays while you program, you can create a quick mpeg
|
198
|
-
of all your lolcommits snapshots (if you have `imagemagick` and `ffmpeg`
|
199
|
-
installed):
|
200
|
-
|
201
|
-
convert `find . -type f -name "*.jpg" -print0 | xargs -0 ls -tlr | awk '{print $9}'` timelapse.mpeg
|
data/bin/lolcommits
CHANGED
@@ -8,333 +8,225 @@ rescue LoadError
|
|
8
8
|
require 'lolcommits'
|
9
9
|
end
|
10
10
|
|
11
|
-
require '
|
12
|
-
require 'lolcommits/cli/launcher'
|
13
|
-
require 'lolcommits/cli/process_runner'
|
14
|
-
require 'lolcommits/cli/timelapse_gif'
|
15
|
-
|
16
|
-
include Lolcommits
|
17
|
-
include Lolcommits::CLI
|
18
|
-
|
19
|
-
require 'choice'
|
11
|
+
require 'optparse'
|
20
12
|
require 'methadone'
|
21
|
-
|
22
|
-
|
23
|
-
#
|
24
|
-
# NO ARGUMENTS SPECIFIED, HELP THE USER OUT
|
25
|
-
#
|
26
|
-
def do_noargs
|
27
|
-
# TODO: make this a contextual helper to know whether lolcommits is enabled
|
28
|
-
puts 'Do what exactly?'
|
29
|
-
puts 'Try: lolcommits --enable (when in a git repository)'
|
30
|
-
puts 'Or: lolcommits --help'
|
31
|
-
end
|
32
|
-
|
33
|
-
# Gets a configuration object. If running in test mode will override the
|
34
|
-
# LOLDIR for the configuration.
|
35
|
-
#
|
36
|
-
# @return [Lolcommits::Configuration]
|
37
|
-
def configuration
|
38
|
-
if Choice.choices[:test]
|
39
|
-
Configuration.new(loldir: Configuration.loldir_for('test'))
|
40
|
-
else
|
41
|
-
Configuration.new
|
42
|
-
end
|
43
|
-
end
|
13
|
+
require 'lolcommits/cli.rb'
|
44
14
|
|
45
|
-
#
|
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]
|
56
|
-
def capture_animate
|
57
|
-
return unless Platform.can_animate?
|
58
|
-
Choice.choices[:animate] || ENV['LOLCOMMITS_ANIMATE'] || nil
|
59
|
-
end
|
15
|
+
# allow logging from everywhere
|
16
|
+
include Methadone::CLILogging
|
60
17
|
|
61
|
-
|
62
|
-
|
18
|
+
class App
|
19
|
+
include Methadone::Main
|
63
20
|
|
64
|
-
|
21
|
+
include Lolcommits
|
22
|
+
include Lolcommits::CLI
|
65
23
|
|
66
|
-
|
67
|
-
|
24
|
+
description 'git-based selfies for software developers (https://lolcommits.github.io)'
|
25
|
+
version Lolcommits::VERSION
|
68
26
|
|
69
|
-
|
70
|
-
#
|
71
|
-
|
72
|
-
|
73
|
-
capture_delay = Choice.choices[:delay] || ENV['LOLCOMMITS_DELAY'] || 0
|
74
|
-
capture_stealth = Choice.choices[:stealth] || ENV['LOLCOMMITS_STEALTH'] || nil
|
75
|
-
capture_device = default_device
|
76
|
-
|
77
|
-
capture_options = {
|
78
|
-
capture_delay: capture_delay,
|
79
|
-
capture_stealth: capture_stealth,
|
80
|
-
capture_device: capture_device,
|
81
|
-
capture_animate: capture_animate,
|
82
|
-
config: configuration
|
83
|
-
}
|
84
|
-
|
85
|
-
process_runner = ProcessRunner.new(configuration)
|
86
|
-
should_we_fork = Choice.choices[:fork] || ENV['LOLCOMMITS_FORK']
|
87
|
-
process_runner.fork_me?(should_we_fork) do
|
88
|
-
if Choice.choices[:test]
|
89
|
-
info '*** Capturing in test mode.'
|
90
|
-
|
91
|
-
# get optional fake commit msg and sha from command line
|
92
|
-
override_text = {
|
93
|
-
message: Choice.choices[:msg],
|
94
|
-
sha: Choice.choices[:sha]
|
95
|
-
}
|
96
|
-
|
97
|
-
# fire off runner with the overriden fake commit metadata
|
98
|
-
runner = Lolcommits::Runner.new(capture_options.merge(override_text))
|
99
|
-
runner.run
|
27
|
+
main do
|
28
|
+
# check for fatal conditions before execution
|
29
|
+
Fatals.die_if_no_valid_ffmpeg_installed! if capture_animated?
|
30
|
+
Fatals.die_on_fatal_platform_conditions!
|
100
31
|
|
101
|
-
|
102
|
-
|
32
|
+
if options.empty?
|
33
|
+
puts no_options_help
|
103
34
|
else
|
104
|
-
|
105
|
-
|
35
|
+
if debug_enabled?
|
36
|
+
logger.level = Logger::DEBUG
|
37
|
+
debug 'Outputting at DEBUG verbosity'
|
38
|
+
end
|
39
|
+
|
40
|
+
if options[:'show-config']
|
41
|
+
puts configuration
|
42
|
+
elsif options[:plugins]
|
43
|
+
puts configuration.plugins_list
|
44
|
+
elsif options[:devices]
|
45
|
+
puts Platform.device_list
|
46
|
+
puts device_list_help
|
47
|
+
elsif options[:enable]
|
48
|
+
Installation.do_enable(options)
|
49
|
+
elsif options[:disable]
|
50
|
+
Installation.do_disable
|
51
|
+
else
|
52
|
+
# all other commands require a vcs repo, check its present and walk up
|
53
|
+
# to the root dir
|
54
|
+
unless options[:test]
|
55
|
+
Fatals.die_if_not_vcs_repo!
|
56
|
+
change_dir_to_root_or_repo!
|
57
|
+
end
|
58
|
+
|
59
|
+
if options[:last]
|
60
|
+
show_last_lolimage
|
61
|
+
elsif options[:browse]
|
62
|
+
Launcher.open_folder(configuration.loldir)
|
63
|
+
elsif options[:timelapse]
|
64
|
+
TimelapseGif.new(configuration).run(options[:period])
|
65
|
+
elsif options[:config]
|
66
|
+
configuration.do_configure!(options[:plugin])
|
67
|
+
elsif options[:capture]
|
68
|
+
capture_lolcommit
|
69
|
+
end
|
70
|
+
end
|
106
71
|
end
|
107
72
|
end
|
108
|
-
end
|
109
|
-
|
110
|
-
def do_configure
|
111
|
-
Fatals.die_if_not_vcs_repo!
|
112
|
-
$stdout.sync = true
|
113
|
-
configuration.do_configure! Choice.choices[:plugin]
|
114
|
-
end
|
115
73
|
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
74
|
+
on('--test', 'run in test mode')
|
75
|
+
on('--debug', 'show debugging info')
|
76
|
+
on('--show-config', 'show configuration file')
|
77
|
+
on('--devices', 'list available capture devices (mac only)')
|
78
|
+
on('--plugins', 'list all available plugins')
|
79
|
+
on('--config', 'configure a plugin')
|
80
|
+
on('-p', '--plugin {name}', 'plugin name to use with --config')
|
81
|
+
|
82
|
+
on('-c', '--capture', 'capture lolcommit based on last git commit')
|
83
|
+
on('-e', '--enable', 'install lolcommits for this repo')
|
84
|
+
on('-d', '--disable', 'uninstall lolcommits for this repo')
|
85
|
+
on('-l', '--last', 'view the most recent lolcommit')
|
86
|
+
on('-b', '--browse', 'browse this repo\'s lolcommits')
|
87
|
+
|
88
|
+
on('--timelapse', 'generate animated timelapse gif from captured images')
|
89
|
+
on('--period {today}', 'period to use for the timelapse gif (today or all)')
|
90
|
+
|
91
|
+
# optional capturing options
|
92
|
+
on('--device {name}', 'device name to capture from (mac/linux only)')
|
93
|
+
on('-a', '--animate {seconds}', 'enable animated gif captures with duration')
|
94
|
+
on('-w', '--delay {seconds}', 'delay before taking a snapshot')
|
95
|
+
on('--stealth', 'capture image in stealth mode (no output)')
|
96
|
+
on('--fork', 'fork capturing process to the background')
|
97
|
+
on('-s', '--sha {string}', 'pass commit sha manually (--test mode only)')
|
98
|
+
on('-m', '--msg {string}', 'pass commit message manually (--test mode only)')
|
99
|
+
|
100
|
+
#
|
101
|
+
# No options specified, help the user out
|
102
|
+
#
|
103
|
+
def self.no_options_help
|
104
|
+
# TODO: make this a contextual helper to know whether lolcommits is enabled
|
105
|
+
"Do what exactly?\n" \
|
106
|
+
"Try: lolcommits --enable (when in a git repository)\n" \
|
107
|
+
'Or: lolcommits --help'
|
108
|
+
end
|
109
|
+
|
110
|
+
# Gets a configuration object. If running in test mode will override the
|
111
|
+
# LOLDIR for the configuration.
|
112
|
+
#
|
113
|
+
# @return [Lolcommits::Configuration]
|
114
|
+
def self.configuration
|
115
|
+
if options[:test]
|
116
|
+
Configuration.new(loldir: Configuration.loldir_for('test'))
|
117
|
+
else
|
118
|
+
Configuration.new
|
139
119
|
end
|
140
|
-
return if VCSInfo.repo_root?
|
141
|
-
Dir.chdir(nxt)
|
142
|
-
end
|
143
|
-
end
|
144
|
-
|
145
|
-
# FIXME: this should be moved out of the CLI, but to where?
|
146
|
-
def load_local_plugins!
|
147
|
-
plugins_dir = Configuration.loldir_for('.plugins')
|
148
|
-
Dir.glob("#{plugins_dir}/*.rb").each do |plugin|
|
149
|
-
load plugin
|
150
120
|
end
|
151
|
-
end
|
152
121
|
|
153
|
-
|
154
|
-
|
155
|
-
#
|
156
|
-
Choice.options do
|
157
|
-
option :version do
|
158
|
-
long '--version'
|
159
|
-
short '-v'
|
160
|
-
desc 'print version and exit'
|
161
|
-
action { print_version_and_exit }
|
122
|
+
def self.debug_enabled?
|
123
|
+
options[:debug] || ENV['LOLCOMMITS_DEBUG'] || false
|
162
124
|
end
|
163
125
|
|
164
|
-
|
165
|
-
|
166
|
-
short '-e'
|
167
|
-
desc 'install lolcommits for this repo'
|
168
|
-
action do
|
169
|
-
Installation.do_enable
|
170
|
-
exit 0
|
171
|
-
end
|
126
|
+
def self.device_list_help
|
127
|
+
'Specify a device with --device "{device name}" or set the LOLCOMMITS_DEVICE env variable'
|
172
128
|
end
|
173
129
|
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
Installation.do_disable
|
180
|
-
exit 0
|
130
|
+
def self.show_last_lolimage
|
131
|
+
lolimage = configuration.most_recent
|
132
|
+
if lolimage.nil?
|
133
|
+
warn 'No lolcommits have been captured for this repository yet.'
|
134
|
+
exit 1
|
181
135
|
end
|
136
|
+
Launcher.open_image(lolimage)
|
182
137
|
end
|
183
138
|
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
end
|
189
|
-
|
190
|
-
option :last do
|
191
|
-
long '--last'
|
192
|
-
short '-l'
|
193
|
-
desc 'view the most recent lolcommit'
|
194
|
-
end
|
195
|
-
|
196
|
-
option :browse do
|
197
|
-
long '--browse'
|
198
|
-
short '-b'
|
199
|
-
desc "browse this repo's lolcommits"
|
200
|
-
end
|
201
|
-
|
202
|
-
option :configure do
|
203
|
-
long '--config'
|
204
|
-
desc 'configure a plugin'
|
139
|
+
def self.capture_device
|
140
|
+
result = options[:device] || ENV['LOLCOMMITS_DEVICE'] || nil
|
141
|
+
result ||= Dir.glob('/dev/video*').first if Platform.platform_linux?
|
142
|
+
result
|
205
143
|
end
|
206
144
|
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
end
|
212
|
-
|
213
|
-
option :plugin do
|
214
|
-
desc 'pass plugin name for --config'
|
215
|
-
long '--plugin'
|
216
|
-
short '-p'
|
217
|
-
default nil
|
218
|
-
end
|
145
|
+
def self.capture_lolcommit
|
146
|
+
should_we_fork = options[:fork] || ENV['LOLCOMMITS_FORK'] || false
|
147
|
+
capture_stealth = options[:stealth] || ENV['LOLCOMMITS_STEALTH'] || false
|
148
|
+
capture_delay = (options[:delay] || ENV['LOLCOMMITS_DELAY']).to_i
|
219
149
|
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
150
|
+
capture_options = {
|
151
|
+
capture_delay: capture_delay,
|
152
|
+
capture_stealth: capture_stealth,
|
153
|
+
capture_device: capture_device,
|
154
|
+
capture_animate: capture_animate,
|
155
|
+
config: configuration
|
156
|
+
}
|
224
157
|
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
desc 'pass SHA manually [TEST-MODE]'
|
232
|
-
long '--sha'
|
233
|
-
short '-s'
|
234
|
-
default "test-#{rand(10**10)}"
|
235
|
-
end
|
158
|
+
process_runner = ProcessRunner.new(configuration)
|
159
|
+
process_runner.fork_me?(should_we_fork) do
|
160
|
+
if options[:test]
|
161
|
+
info '*** Capturing in test mode.'
|
162
|
+
capture_options.merge!(test_capture_options)
|
163
|
+
end
|
236
164
|
|
237
|
-
|
238
|
-
|
239
|
-
long '--msg'
|
240
|
-
short '-m'
|
241
|
-
default 'this is a test message i didnt really commit something'
|
242
|
-
end
|
243
|
-
|
244
|
-
option :delay do
|
245
|
-
long '--delay=SECONDS'
|
246
|
-
desc 'delay taking of the snapshot by n seconds'
|
247
|
-
cast Integer
|
248
|
-
short '-w'
|
249
|
-
end
|
250
|
-
|
251
|
-
option :stealth do
|
252
|
-
long '--stealth'
|
253
|
-
desc 'capture image in stealth mode'
|
254
|
-
end
|
165
|
+
runner = Lolcommits::Runner.new(capture_options)
|
166
|
+
runner.run
|
255
167
|
|
256
|
-
|
257
|
-
|
258
|
-
|
168
|
+
# automatically open the image in test mode
|
169
|
+
Launcher.open_image(runner.main_image) if options[:test]
|
170
|
+
end
|
259
171
|
end
|
260
172
|
|
261
|
-
|
262
|
-
|
263
|
-
|
173
|
+
def self.test_capture_options
|
174
|
+
{
|
175
|
+
message: options[:msg] || 'this is a test message i didnt really commit something',
|
176
|
+
sha: options[:sha] || "test-#{rand(10**10)}"
|
177
|
+
}
|
264
178
|
end
|
265
179
|
|
266
|
-
|
267
|
-
|
268
|
-
|
180
|
+
# Duration for animated capturing
|
181
|
+
#
|
182
|
+
# If animation is enabled, returns an integer > 0 representing seconds.
|
183
|
+
# Seconds will be 0 if no option set, or if the platform doesn't support
|
184
|
+
# animated captures (in which case animated capturing will be disabled).
|
185
|
+
#
|
186
|
+
# @return [Integer]
|
187
|
+
def self.capture_animate
|
188
|
+
if Platform.can_animate?
|
189
|
+
(options[:animate] || ENV['LOLCOMMITS_ANIMATE']).to_i
|
190
|
+
else
|
191
|
+
0
|
192
|
+
end
|
269
193
|
end
|
270
194
|
|
271
|
-
|
272
|
-
|
273
|
-
short '-g'
|
274
|
-
desc 'generate animated timeline gif from captured images'
|
195
|
+
def self.capture_animated?
|
196
|
+
capture_animate > 0
|
275
197
|
end
|
276
198
|
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
199
|
+
# TODO: remove this after implementing gem based plugins
|
200
|
+
# https://github.com/mroth/lolcommits/issues/99
|
201
|
+
# Until then for local plugin dev, use $LOLCOMMITS_DIR/.plugins directory
|
202
|
+
def self.load_local_plugins!
|
203
|
+
plugins_dir = Configuration.loldir_for('.plugins')
|
204
|
+
Dir.glob("#{plugins_dir}/*.rb").each do |plugin|
|
205
|
+
load plugin
|
283
206
|
end
|
284
207
|
end
|
285
208
|
|
286
|
-
|
287
|
-
|
288
|
-
|
209
|
+
#
|
210
|
+
# change working dir to either a repo or the fs root
|
211
|
+
#
|
212
|
+
def self.change_dir_to_root_or_repo!
|
213
|
+
debug 'Walking up dir tree'
|
214
|
+
loop do
|
215
|
+
cur = File.expand_path('.')
|
216
|
+
nxt = File.expand_path('..', cur)
|
217
|
+
if nxt == cur
|
218
|
+
warn 'Repository root not found'
|
219
|
+
return
|
220
|
+
end
|
221
|
+
return if VCSInfo.repo_root?
|
222
|
+
Dir.chdir(nxt)
|
223
|
+
end
|
289
224
|
end
|
290
|
-
end
|
291
225
|
|
292
|
-
#
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
debug 'Outputting at DEBUG verbosity'
|
297
|
-
end
|
226
|
+
#
|
227
|
+
# load plugins
|
228
|
+
#
|
229
|
+
load_local_plugins!
|
298
230
|
|
299
|
-
|
300
|
-
# check for fatal conditions before execution
|
301
|
-
#
|
302
|
-
Fatals.die_if_no_valid_ffmpeg_installed! if capture_animate
|
303
|
-
Fatals.die_on_fatal_platform_conditions!
|
304
|
-
|
305
|
-
#
|
306
|
-
# change working dir to either a repo or the fs root
|
307
|
-
#
|
308
|
-
change_dir_to_root_or_repo!
|
309
|
-
|
310
|
-
# TODO: Allow local backend definitions?
|
311
|
-
|
312
|
-
#
|
313
|
-
# load system local plugins
|
314
|
-
#
|
315
|
-
load_local_plugins!
|
316
|
-
|
317
|
-
#
|
318
|
-
# Handle actions manually since choice seems weird
|
319
|
-
#
|
320
|
-
if Choice.choices[:capture]
|
321
|
-
do_capture
|
322
|
-
elsif Choice.choices[:configure]
|
323
|
-
do_configure
|
324
|
-
elsif Choice.choices[:show_config]
|
325
|
-
puts configuration
|
326
|
-
elsif Choice.choices[:plugins]
|
327
|
-
configuration.puts_plugins
|
328
|
-
elsif Choice.choices[:devices]
|
329
|
-
puts Platform.device_list
|
330
|
-
puts 'Specify a device with --device="{device name}" or set the LOLCOMMITS_DEVICE env variable'
|
331
|
-
elsif Choice.choices[:last]
|
332
|
-
do_last
|
333
|
-
elsif Choice.choices[:browse]
|
334
|
-
Fatals.die_if_not_vcs_repo!
|
335
|
-
Launcher.open_folder(configuration.loldir)
|
336
|
-
elsif Choice.choices[:gif]
|
337
|
-
TimelapseGif.new(configuration).run(Choice.choices[:gif])
|
338
|
-
else
|
339
|
-
do_noargs
|
231
|
+
go!
|
340
232
|
end
|
data/features/lolcommits.feature
CHANGED
@@ -47,8 +47,8 @@ Feature: Basic UI functionality
|
|
47
47
|
|
48
48
|
Scenario: Enable in a git repo passing capture arguments
|
49
49
|
Given I am in a git repo
|
50
|
-
When I successfully run `lolcommits --enable -w 5 --fork`
|
51
|
-
Then the git post-commit hook should contain "lolcommits --capture
|
50
|
+
When I successfully run `lolcommits --enable -w 5 --fork --stealth --device 'My Devce'`
|
51
|
+
Then the git post-commit hook should contain "lolcommits --capture --delay 5 --fork --stealth --device 'My Devce'"
|
52
52
|
And the exit status should be 0
|
53
53
|
|
54
54
|
Scenario: Disable in a enabled git repo
|
@@ -70,7 +70,7 @@ Feature: Basic UI functionality
|
|
70
70
|
Scenario: Capture doesnt break in forked mode
|
71
71
|
Given I am in a git repo named "forked"
|
72
72
|
And I do a git commit
|
73
|
-
When I
|
73
|
+
When I run `lolcommits --capture --fork`
|
74
74
|
Then there should be exactly 1 pid in "~/.lolcommits/forked"
|
75
75
|
When I wait for the child process to exit in "forked"
|
76
76
|
Then a directory named "~/.lolcommits/forked" should exist
|
@@ -270,7 +270,7 @@ Feature: Basic UI functionality
|
|
270
270
|
Scenario: generate gif should store in its own archive directory
|
271
271
|
Given I am in a git repo named "giffy" with lolcommits enabled
|
272
272
|
And a loldir named "giffy" with 2 lolimages
|
273
|
-
When I successfully run `lolcommits
|
273
|
+
When I successfully run `lolcommits --timelapse`
|
274
274
|
Then the output should contain "Generating animated gif."
|
275
275
|
And a directory named "~/.lolcommits/giffy/archive" should exist
|
276
276
|
And a file named "~/.lolcommits/giffy/archive/archive.gif" should exist
|
@@ -278,7 +278,7 @@ Feature: Basic UI functionality
|
|
278
278
|
Scenario: generate gif with argument 'today'
|
279
279
|
Given I am in a git repo named "sunday" with lolcommits enabled
|
280
280
|
And a loldir named "sunday" with 2 lolimages
|
281
|
-
When I successfully run `lolcommits
|
281
|
+
When I successfully run `lolcommits --timelapse --period today`
|
282
282
|
Then there should be exactly 1 gif in "~/.lolcommits/sunday/archive"
|
283
283
|
|
284
284
|
@mac-only
|
@@ -295,7 +295,7 @@ Feature: Basic UI functionality
|
|
295
295
|
@fake-no-ffmpeg
|
296
296
|
Scenario: gracefully fail when ffmpeg not installed and --animate is used
|
297
297
|
Given I am using a "darwin" platform
|
298
|
-
When I run `lolcommits --animate
|
298
|
+
When I run `lolcommits -c --animate 3`
|
299
299
|
Then the output should contain:
|
300
300
|
"""
|
301
301
|
ffmpeg does not appear to be properly installed
|
@@ -328,7 +328,7 @@ Feature: Basic UI functionality
|
|
328
328
|
Scenario: Enable in a mercurial repo passing capture arguments
|
329
329
|
Given I am in a mercurial repo
|
330
330
|
When I successfully run `lolcommits --enable -w 5 --fork`
|
331
|
-
Then the mercurial post-commit hook should contain "lolcommits --capture
|
331
|
+
Then the mercurial post-commit hook should contain "lolcommits --capture --delay 5 --fork"
|
332
332
|
And the exit status should be 0
|
333
333
|
|
334
334
|
Scenario: Disable in a enabled mercurial repo
|
data/features/support/env.rb
CHANGED
@@ -15,7 +15,7 @@ Before do
|
|
15
15
|
|
16
16
|
# prevent launchy from opening gifs in tests
|
17
17
|
set_env 'LAUNCHY_DRY_RUN', 'true'
|
18
|
-
set_env 'LOLCOMMITS_CAPTURER', 'CaptureFake'
|
18
|
+
set_env 'LOLCOMMITS_CAPTURER', 'Lolcommits::CaptureFake'
|
19
19
|
|
20
20
|
author_name = 'Testy McTesterson'
|
21
21
|
author_email = 'testy@tester.com'
|
@@ -10,12 +10,7 @@ module Lolcommits
|
|
10
10
|
#
|
11
11
|
# IF --ENABLE, DO ENABLE
|
12
12
|
#
|
13
|
-
def self.do_enable
|
14
|
-
unless File.directory?('.git')
|
15
|
-
fatal "You don't appear to be in the base directory of a git project."
|
16
|
-
exit 1
|
17
|
-
end
|
18
|
-
|
13
|
+
def self.do_enable(capture_args = '')
|
19
14
|
# its possible a hooks dir doesnt exist, so create it if so
|
20
15
|
Dir.mkdir(HOOK_DIR) unless File.directory?(HOOK_DIR)
|
21
16
|
|
@@ -39,7 +34,7 @@ module Lolcommits
|
|
39
34
|
|
40
35
|
File.open(HOOK_PATH, add_shebang ? 'w' : 'a') do |f|
|
41
36
|
f.write("#!/bin/sh\n") if add_shebang
|
42
|
-
f.write(hook_script)
|
37
|
+
f.write(hook_script(capture_args))
|
43
38
|
end
|
44
39
|
|
45
40
|
FileUtils.chmod 0o755, HOOK_PATH
|
@@ -63,7 +58,7 @@ module Lolcommits
|
|
63
58
|
end
|
64
59
|
end
|
65
60
|
|
66
|
-
def self.hook_script
|
61
|
+
def self.hook_script(capture_args = '')
|
67
62
|
ruby_path = Lolcommits::Platform.command_which('ruby', true)
|
68
63
|
imagick_path = Lolcommits::Platform.command_which('identify', true)
|
69
64
|
|
@@ -74,13 +69,12 @@ module Lolcommits
|
|
74
69
|
hook_export = "export PATH=\"#{ruby_path}:#{imagick_path}:$PATH\"\n"
|
75
70
|
end
|
76
71
|
|
77
|
-
capture_cmd
|
78
|
-
capture_args = " #{ARGV[1..-1].join(' ')}" if ARGV.length > 1
|
72
|
+
capture_cmd = 'lolcommits --capture'
|
79
73
|
|
80
74
|
<<-EOS
|
81
75
|
### lolcommits hook (begin) ###
|
82
76
|
if [ ! -d "$GIT_DIR/rebase-merge" ]; then
|
83
|
-
#{locale_export}#{hook_export}#{capture_cmd}#{capture_args}
|
77
|
+
#{locale_export}#{hook_export}#{capture_cmd} #{capture_args}
|
84
78
|
fi
|
85
79
|
### lolcommits hook (end) ###
|
86
80
|
EOS
|
@@ -10,12 +10,7 @@ module Lolcommits
|
|
10
10
|
#
|
11
11
|
# IF --ENABLE, DO ENABLE
|
12
12
|
#
|
13
|
-
def self.do_enable
|
14
|
-
unless File.directory?('.hg')
|
15
|
-
fatal "You don't appear to be in the base directory of a mercurial project."
|
16
|
-
exit 1
|
17
|
-
end
|
18
|
-
|
13
|
+
def self.do_enable(capture_args = '')
|
19
14
|
if lolcommits_hook_exists?
|
20
15
|
# clear away any existing lolcommits hook
|
21
16
|
remove_existing_hook!
|
@@ -23,7 +18,7 @@ module Lolcommits
|
|
23
18
|
|
24
19
|
config = repository.config
|
25
20
|
HOOK_OPERATIONS.each do |op|
|
26
|
-
config.add_setting(HOOK_SECTION, "post-#{op}.lolcommits", hook_script)
|
21
|
+
config.add_setting(HOOK_SECTION, "post-#{op}.lolcommits", hook_script(capture_args))
|
27
22
|
end
|
28
23
|
config.path
|
29
24
|
end
|
@@ -43,7 +38,7 @@ module Lolcommits
|
|
43
38
|
end
|
44
39
|
end
|
45
40
|
|
46
|
-
def self.hook_script
|
41
|
+
def self.hook_script(capture_args = '')
|
47
42
|
ruby_path = Lolcommits::Platform.command_which('ruby', true)
|
48
43
|
imagick_path = Lolcommits::Platform.command_which('identify', true)
|
49
44
|
capture_cmd = 'lolcommits --capture'
|
@@ -56,7 +51,6 @@ module Lolcommits
|
|
56
51
|
capture_cmd = "#{locale_export} #{hook_export} #{capture_cmd}"
|
57
52
|
end
|
58
53
|
|
59
|
-
capture_args = ARGV[1..-1].join(' ') if ARGV.length > 1
|
60
54
|
"#{capture_cmd} #{capture_args}"
|
61
55
|
end
|
62
56
|
|
data/lib/lolcommits/capturer.rb
CHANGED
@@ -15,8 +15,6 @@ module Lolcommits
|
|
15
15
|
# Runs the history timeline animator task thingy
|
16
16
|
# param args [String] the arg passed to the gif command on CLI (optional)
|
17
17
|
def run(args = nil)
|
18
|
-
Fatals.die_if_not_vcs_repo!
|
19
|
-
|
20
18
|
case args
|
21
19
|
when 'today'
|
22
20
|
lolimages = @configuration.jpg_images_today
|
@@ -67,12 +67,12 @@ module Lolcommits
|
|
67
67
|
File.join(loldir, 'tmp_frames')
|
68
68
|
end
|
69
69
|
|
70
|
-
def
|
71
|
-
|
70
|
+
def plugins_list
|
71
|
+
"Available plugins: \n * #{Lolcommits::Runner.plugins.map(&:name).join("\n * ")}"
|
72
72
|
end
|
73
73
|
|
74
74
|
def ask_for_plugin_name
|
75
|
-
|
75
|
+
puts plugins_list
|
76
76
|
print 'Name of plugin to configure: '
|
77
77
|
STDIN.gets.strip
|
78
78
|
end
|
@@ -83,10 +83,11 @@ module Lolcommits
|
|
83
83
|
end
|
84
84
|
|
85
85
|
puts "Unable to find plugin: '#{plugin_name}'"
|
86
|
-
|
86
|
+
puts plugins_list
|
87
87
|
end
|
88
88
|
|
89
89
|
def do_configure!(plugin_name)
|
90
|
+
$stdout.sync = true
|
90
91
|
plugin_name = ask_for_plugin_name if plugin_name.to_s.strip.empty?
|
91
92
|
|
92
93
|
plugin = find_plugin(plugin_name)
|
@@ -18,8 +18,9 @@ module Lolcommits
|
|
18
18
|
#
|
19
19
|
# IF --ENABLE, DO ENABLE
|
20
20
|
#
|
21
|
-
def self.do_enable
|
22
|
-
|
21
|
+
def self.do_enable(options = {})
|
22
|
+
capture_args = extract_capture_args(options)
|
23
|
+
path = backend.do_enable(capture_args)
|
23
24
|
|
24
25
|
info 'installed lolcommit hook to:'
|
25
26
|
info " -> #{File.expand_path(path)}"
|
@@ -34,5 +35,20 @@ module Lolcommits
|
|
34
35
|
def self.do_disable
|
35
36
|
backend.do_disable
|
36
37
|
end
|
38
|
+
|
39
|
+
# Extract any command line capture args from the parsed options hash, will
|
40
|
+
# be appended to the capture command within the commit hook script
|
41
|
+
#
|
42
|
+
# @return [String]
|
43
|
+
def self.extract_capture_args(options)
|
44
|
+
options.map do |k, v|
|
45
|
+
next unless %w(device animate delay stealth fork).include?(k)
|
46
|
+
if k == 'device'
|
47
|
+
"--device '#{v}'"
|
48
|
+
else
|
49
|
+
"--#{k}#{v == true ? '' : " #{v}"}"
|
50
|
+
end
|
51
|
+
end.compact.join(' ')
|
52
|
+
end
|
37
53
|
end
|
38
54
|
end
|
data/lib/lolcommits/plugin.rb
CHANGED
@@ -40,12 +40,12 @@ module Lolcommits
|
|
40
40
|
string.upcase! if config_option(type, :uppercase)
|
41
41
|
|
42
42
|
image.combine_options do |c|
|
43
|
-
c.strokewidth runner.
|
43
|
+
c.strokewidth runner.capture_animated? ? '1' : '2'
|
44
44
|
c.interline_spacing(-(config_option(type, :size) / 5))
|
45
45
|
c.stroke config_option(type, :stroke_color)
|
46
46
|
c.fill config_option(type, :color)
|
47
47
|
c.gravity transformed_position
|
48
|
-
c.pointsize runner.
|
48
|
+
c.pointsize runner.capture_animated? ? (config_option(type, :size) / 2) : config_option(type, :size)
|
49
49
|
c.font config_option(type, :font)
|
50
50
|
c.annotate annotate_location, string
|
51
51
|
end
|
data/lib/lolcommits/runner.rb
CHANGED
@@ -7,8 +7,6 @@ module Lolcommits
|
|
7
7
|
:sha, :snapshot_loc, :main_image, :config, :vcs_info,
|
8
8
|
:capture_animate
|
9
9
|
|
10
|
-
include Methadone::CLILogging
|
11
|
-
|
12
10
|
def initialize(attributes = {})
|
13
11
|
attributes.each do |attr, val|
|
14
12
|
send("#{attr}=", val)
|
@@ -85,7 +83,7 @@ module Lolcommits
|
|
85
83
|
self.snapshot_loc = config.raw_image(image_file_type)
|
86
84
|
self.main_image = config.main_image(sha, image_file_type)
|
87
85
|
|
88
|
-
capturer = Platform.capturer_class(
|
86
|
+
capturer = Platform.capturer_class(capture_animated?).new(
|
89
87
|
capture_device: capture_device,
|
90
88
|
capture_delay: capture_delay,
|
91
89
|
snapshot_location: snapshot_loc,
|
@@ -96,46 +94,39 @@ module Lolcommits
|
|
96
94
|
capturer.capture
|
97
95
|
end
|
98
96
|
|
99
|
-
def
|
100
|
-
capture_animate
|
97
|
+
def capture_animated?
|
98
|
+
capture_animate > 0
|
101
99
|
end
|
102
100
|
|
103
101
|
private
|
104
102
|
|
105
|
-
# def capturer_class
|
106
|
-
# capturer_module = 'Lolcommits'
|
107
|
-
# Object.const_get(capturer_module).const_get(Platform.capturer_class(animate?))
|
108
|
-
# end
|
109
|
-
|
110
103
|
def image_file_type
|
111
|
-
|
104
|
+
capture_animated? ? 'gif' : 'jpg'
|
112
105
|
end
|
113
|
-
end
|
114
106
|
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
107
|
+
def resize_snapshot!
|
108
|
+
debug 'Runner: resizing snapshot'
|
109
|
+
image = MiniMagick::Image.open(snapshot_loc)
|
110
|
+
if image[:width] > 640 || image[:height] > 480
|
111
|
+
# this is ghetto resize-to-fill
|
112
|
+
image.combine_options do |c|
|
113
|
+
c.resize '640x480^'
|
114
|
+
c.gravity 'center'
|
115
|
+
c.extent '640x480'
|
116
|
+
end
|
117
|
+
debug "Runner: writing resized image to #{snapshot_loc}"
|
118
|
+
image.write snapshot_loc
|
126
119
|
end
|
127
|
-
debug "Runner:
|
128
|
-
|
120
|
+
debug "Runner: copying resized image to #{main_image}"
|
121
|
+
FileUtils.cp(snapshot_loc, main_image)
|
129
122
|
end
|
130
|
-
debug "Runner: copying resized image to #{main_image}"
|
131
|
-
FileUtils.cp(snapshot_loc, main_image)
|
132
|
-
end
|
133
123
|
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
124
|
+
def cleanup!
|
125
|
+
debug 'Runner: running cleanup'
|
126
|
+
# clean up the captured image and any other raw assets
|
127
|
+
FileUtils.rm(snapshot_loc)
|
128
|
+
FileUtils.rm_f(config.video_loc)
|
129
|
+
FileUtils.rm_rf(config.frames_loc)
|
130
|
+
end
|
140
131
|
end
|
141
132
|
end
|
data/lib/lolcommits/vcs_info.rb
CHANGED
data/lib/lolcommits/version.rb
CHANGED
data/lolcommits.gemspec
CHANGED
@@ -36,7 +36,6 @@ Gem::Specification.new do |s|
|
|
36
36
|
|
37
37
|
# core
|
38
38
|
s.add_runtime_dependency('methadone', '~> 1.9.3')
|
39
|
-
s.add_runtime_dependency('choice', '~> 0.2.0')
|
40
39
|
s.add_runtime_dependency('mercurial-ruby', '~> 0.7.12')
|
41
40
|
s.add_runtime_dependency('mini_magick', '~> 4.6.0')
|
42
41
|
s.add_runtime_dependency('launchy', '~> 2.4.3')
|
data/test/lolcommits_test.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lolcommits
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.1.pre1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matthew Rothenberg
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-12-
|
12
|
+
date: 2016-12-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: aruba
|
@@ -81,20 +81,6 @@ dependencies:
|
|
81
81
|
- - "~>"
|
82
82
|
- !ruby/object:Gem::Version
|
83
83
|
version: 1.9.3
|
84
|
-
- !ruby/object:Gem::Dependency
|
85
|
-
name: choice
|
86
|
-
requirement: !ruby/object:Gem::Requirement
|
87
|
-
requirements:
|
88
|
-
- - "~>"
|
89
|
-
- !ruby/object:Gem::Version
|
90
|
-
version: 0.2.0
|
91
|
-
type: :runtime
|
92
|
-
prerelease: false
|
93
|
-
version_requirements: !ruby/object:Gem::Requirement
|
94
|
-
requirements:
|
95
|
-
- - "~>"
|
96
|
-
- !ruby/object:Gem::Version
|
97
|
-
version: 0.2.0
|
98
84
|
- !ruby/object:Gem::Dependency
|
99
85
|
name: mercurial-ruby
|
100
86
|
requirement: !ruby/object:Gem::Requirement
|
@@ -358,6 +344,7 @@ files:
|
|
358
344
|
- lib/lolcommits/capturer/capture_mac.rb
|
359
345
|
- lib/lolcommits/capturer/capture_mac_animated.rb
|
360
346
|
- lib/lolcommits/capturer/capture_windows.rb
|
347
|
+
- lib/lolcommits/cli.rb
|
361
348
|
- lib/lolcommits/cli/fatals.rb
|
362
349
|
- lib/lolcommits/cli/launcher.rb
|
363
350
|
- lib/lolcommits/cli/process_runner.rb
|
@@ -408,9 +395,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
408
395
|
version: '2.0'
|
409
396
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
410
397
|
requirements:
|
411
|
-
- - "
|
398
|
+
- - ">"
|
412
399
|
- !ruby/object:Gem::Version
|
413
|
-
version:
|
400
|
+
version: 1.3.1
|
414
401
|
requirements:
|
415
402
|
- imagemagick
|
416
403
|
- a webcam
|