lolcommits 0.9.3.pre1 → 0.9.3.pre2

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: 55a7484224a62eed8753cf32fad0f20d9a483085
4
- data.tar.gz: 2df1e2ec28806051f29c7b36be4a0e488ee7e421
3
+ metadata.gz: c7f9361b802d1360887f9abf9851379a40a006af
4
+ data.tar.gz: f6eaccaf5bcd60b3de0919d0e2d50cd0c9b42c60
5
5
  SHA512:
6
- metadata.gz: 95f619adfecfd08f49430f1745a73a1de8047b9342564d304149d61ba00ccb8bdff560760fa6bf33e440e25ab505f6c6239527ff328f88f098bf71bbb2dbfa08
7
- data.tar.gz: 5aac1f41ae637f4d479707e60d4140fcf240ddb8820fd82de8415ca93c7d43494be40f2dfc266e16e6bad737bc9015089ead311ed32e099cb0d15d3f8558e162
6
+ metadata.gz: 7760ce09dbb11464c376382c1d7aad4503affba32f36aaae686f0095ad0348e97f5dc6d20185bbe26709936cca5e68f60aa99f6e705252a21479a44868c366dc
7
+ data.tar.gz: a55a968ffcb164820a4b7ca18994ebd58a7da8ca95cf06033e4ab069a5560cb0f22459757a374a74be3382bba48399b635c31c2c66d8e9d9b58523768daf5d08
@@ -1,50 +1,83 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2016-12-11 21:07:49 +0000 using RuboCop version 0.46.0.
3
+ # on 2017-04-04 11:42:26 +0100 using RuboCop version 0.48.1.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
7
7
  # versions of RuboCop, may require this file to be generated again.
8
8
 
9
+ # Offense count: 1
10
+ Lint/AmbiguousBlockAssociation:
11
+ Exclude:
12
+ - 'lib/lolcommits/cli/process_runner.rb'
13
+
9
14
  # Offense count: 35
10
15
  Metrics/AbcSize:
11
- Max: 38
16
+ Max: 37
12
17
 
13
18
  # Offense count: 2
14
- # Configuration parameters: CountComments.
19
+ # Configuration parameters: CountComments, ExcludedMethods.
15
20
  Metrics/BlockLength:
16
- Max: 113
21
+ Max: 40
17
22
 
18
23
  # Offense count: 5
19
24
  # Configuration parameters: CountComments.
20
25
  Metrics/ClassLength:
21
- Max: 160
26
+ Max: 149
22
27
 
23
28
  # Offense count: 6
24
29
  Metrics/CyclomaticComplexity:
25
- Max: 9
30
+ Max: 8
26
31
 
27
- # Offense count: 137
32
+ # Offense count: 152
28
33
  # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
29
34
  # URISchemes: http, https
30
35
  Metrics/LineLength:
31
36
  Max: 161
32
37
 
33
- # Offense count: 44
38
+ # Offense count: 42
34
39
  # Configuration parameters: CountComments.
35
40
  Metrics/MethodLength:
36
41
  Max: 31
37
42
 
38
43
  # Offense count: 5
39
44
  Metrics/PerceivedComplexity:
40
- Max: 11
45
+ Max: 10
41
46
 
42
- # Offense count: 34
47
+ # Offense count: 1
48
+ # Cop supports --auto-correct.
49
+ Security/YAMLLoad:
50
+ Exclude:
51
+ - 'lib/lolcommits/configuration.rb'
52
+
53
+ # Offense count: 37
43
54
  Style/Documentation:
44
55
  Enabled: false
45
56
 
57
+ # Offense count: 2
58
+ # Cop supports --auto-correct.
59
+ Style/EmptyLinesAroundBeginBody:
60
+ Exclude:
61
+ - 'lib/lolcommits/plugin/lol_flowdock.rb'
62
+ - 'lib/lolcommits/plugin/lol_slack.rb'
63
+
46
64
  # Offense count: 1
47
65
  # Cop supports --auto-correct.
48
- Security/YAMLLoad:
66
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
67
+ # SupportedStyles: auto_detection, squiggly, active_support, powerpack, unindent
68
+ Style/IndentHeredoc:
49
69
  Exclude:
50
- - 'lib/lolcommits/configuration.rb'
70
+ - 'lib/lolcommits/backends/installation_git.rb'
71
+
72
+ # Offense count: 77
73
+ # Cop supports --auto-correct.
74
+ # Configuration parameters: PreferredDelimiters.
75
+ Style/PercentLiteralDelimiters:
76
+ Enabled: false
77
+
78
+ # Offense count: 1
79
+ # Cop supports --auto-correct.
80
+ # Configuration parameters: SupportedStyles.
81
+ # SupportedStyles: percent, brackets
82
+ Style/SymbolArray:
83
+ EnforcedStyle: brackets
@@ -8,8 +8,9 @@ project adheres to [Semantic Versioning][Semver].
8
8
  * WIP - extract more plugins to gems ...
9
9
  * Your contribution here!
10
10
 
11
- ## [0.9.3][] (6 March 2017)
12
- * Gem plugin support (@matthutchinson [#332][])
11
+ ## [0.9.3][] (5 April 2017)
12
+ * LOLCOMMITS_CAPTURE_DISABLED env var (@williamboman [#338][])
13
+ * Plugin Manager and Gem plugin support (@matthutchinson [#332][])
13
14
  * Add North gravity for ImageMagick (@domudall [#331][])
14
15
  * remove Ruby 1.9 magic comments (@matthutchinson [#330][])
15
16
  * add links to PRs in CHANGELOG (@bfontaine [#329][])
@@ -272,7 +273,8 @@ project adheres to [Semantic Versioning][Semver].
272
273
  instead of compositing multiply image Caption objects (this seems to be more
273
274
  reliable to not glitch.)
274
275
 
275
- [Unreleased]: https://github.com/mroth/lolcommits/compare/v0.9.2...HEAD
276
+ [Unreleased]: https://github.com/mroth/lolcommits/compare/v0.9.3...HEAD
277
+ [0.9.3]: https://github.com/mroth/lolcommits/compare/v0.9.2...v0.9.3
276
278
  [0.9.2]: https://github.com/mroth/lolcommits/compare/v0.9.1...v0.9.2
277
279
  [0.9.1]: https://github.com/mroth/lolcommits/compare/v0.9.0...v0.9.1
278
280
  [0.9.0]: https://github.com/mroth/lolcommits/compare/v0.8.1...v0.9.0
@@ -429,3 +431,4 @@ project adheres to [Semantic Versioning][Semver].
429
431
  [#330]: https://github.com/mroth/lolcommits/pull/330
430
432
  [#331]: https://github.com/mroth/lolcommits/pull/331
431
433
  [#332]: https://github.com/mroth/lolcommits/pull/332
434
+ [#338]: https://github.com/mroth/lolcommits/pull/338
data/README.md CHANGED
@@ -17,9 +17,9 @@ By default, the lol images are stored by a Github style short SHA in a
17
17
 
18
18
  <img src="https://lolcommits.github.io/assets/img/gallery.jpeg" />
19
19
 
20
- Please add your own lolcommit! Add to the [People Using
20
+ Please add your own lolcommit to the [People Using
21
21
  Lolcommits](https://github.com/mroth/lolcommits/wiki/Lolcommits-from-around-the-world%21)
22
- page on our wiki.
22
+ page on our wiki!
23
23
 
24
24
 
25
25
  ## Requirements
@@ -33,7 +33,7 @@ page on our wiki.
33
33
  ## Installation
34
34
 
35
35
 
36
- ### Mac OS X
36
+ ### macOS
37
37
 
38
38
  You'll need ImageMagick installed. [Homebrew](http://mxcl.github.com/homebrew/)
39
39
  makes this easy.
@@ -45,13 +45,10 @@ Then install with:
45
45
  [sudo] gem install lolcommits
46
46
 
47
47
  If you're using RVM (or rbenv), you can/should probably omit the sudo, but the
48
- default MacOSX Ruby install is dumb and requires it.
49
-
50
- If [Boxen](https://boxen.github.com) is your thing, [try
51
- this](https://github.com/AssuredLabor/puppet-lolcommits).
48
+ default macOS Ruby install is dumb and requires it.
52
49
 
53
50
  Lolcommits v0.8.1 was the last release to support Ruby < 2.0. If you'd like to
54
- use this program on older rubies try:
51
+ use older Rubies try:
55
52
 
56
53
  [sudo] gem install lolcommits --version 0.8.1 # for Ruby 1.9
57
54
  [sudo] gem install lolcommits --version 0.7.0 # for Ruby 1.8
@@ -59,14 +56,14 @@ use this program on older rubies try:
59
56
 
60
57
  ### Linux
61
58
 
62
- Install dependencies using your package manager of choice, for example in
59
+ Install these dependencies using your package manager of choice, for example in
63
60
  Ubuntu:
64
61
 
65
62
  sudo apt-get install mplayer imagemagick libmagickwand-dev
66
63
 
67
64
  For Ubuntu 14.04 or newer, you need to manually install ffmpeg since it no
68
- longer ships with the default Ubuntu sources. [Downloads for
69
- ffmpeg](http://ffmpeg.org/download.html)
65
+ longer ships with the default Ubuntu sources ([downloads
66
+ here](http://ffmpeg.org/download.html)).
70
67
 
71
68
  Then install with:
72
69
 
@@ -88,14 +85,15 @@ Windows](https://github.com/mroth/lolcommits/wiki/Installing-on-Windows).
88
85
 
89
86
  ### Enabling and basic usage
90
87
 
91
- From within any git repository, simply do a `lolcommits --enable`. From that
92
- point on, any git commit will automatically trigger a lolcommit capture! All
93
- lolcommits are stored in `~/.lolcommits` by default, placed in a subdirectory by
94
- project name, and with a filename matching the commit hash.
88
+ Within any git repository, simply run `lolcommits --enable`. From that point on,
89
+ any git commit will automatically trigger a lolcommit capture! By default, all
90
+ lolcommits are stored in `~/.lolcommits` and placed in a subdirectory by project
91
+ name, with a filename matching the commit hash.
95
92
 
96
- You can also enable lolcommits across all your local git repos. Follow [these
93
+ Follow [these
97
94
  steps](https://github.com/mroth/lolcommits/wiki/Enabling-Lolcommits-for-all-your-Git-Repositories)
98
- to achieve this using `git init` and the `init.templatedir` setting.
95
+ to enable lolcommits across all your repos; using `git init` and the
96
+ `init.templatedir` setting.
99
97
 
100
98
  Don't worry about it too much, half the fun of lolcommits is forgetting it's
101
99
  installed!
@@ -103,7 +101,7 @@ installed!
103
101
 
104
102
  ### Other commands
105
103
 
106
- Ok, if you insist... Since you know about `--enable`, common sense suggests
104
+ OK, if you insist... Since you know about `--enable`, common sense suggests
107
105
  there is also a repository specific `--disable`, hopefully you can guess what
108
106
  that does.
109
107
 
@@ -118,10 +116,10 @@ git post-hook capture command. For example;
118
116
  lolcommits --enable --delay 5 --animate 4 --fork
119
117
 
120
118
  Will configure capturing of an animated gif (4 secs) after a 5 sec delay in a
121
- forked process. See the section below for more capture configuration variables.
119
+ forked process. See the section below for more capture configuration options.
122
120
 
123
121
 
124
- ### Capture configuration variables
122
+ ### Capture configuration options
125
123
 
126
124
  lolcommits has some capture options for additional lulz. You can enable these
127
125
  via environment variables like so;
@@ -129,14 +127,18 @@ via environment variables like so;
129
127
  * `LOLCOMMITS_DEVICE` set a webcam device - **mac and linux only**
130
128
  * `LOLCOMMITS_ANIMATE` (in seconds) set time for capturing an animated gif -
131
129
  **requires ffmpeg**
132
- * `LOLCOMMITS_DELAY` (in seconds) set delay persistently (for slow webcams to
133
- warmup)
130
+ * `LOLCOMMITS_DELAY` (in seconds) set delay time before capturing (for slow
131
+ webcams to warmup)
134
132
  * `LOLCOMMITS_FORK` fork lolcommit runner (capture command forks to a new
135
133
  process, speedily returning you to your terminal)
136
- * `LOLCOMMITS_STEALTH` disable notification messages at commit time
137
- * `LOLCOMMITS_DIR` set the output directory used for all repositories (defaults to ~/.lolcommits)
134
+ * `LOLCOMMITS_STEALTH` disable all notification messages when capturing
135
+ * `LOLCOMMITS_DIR` set the output directory used for all repositories (defaults
136
+ to ~/.lolcommits)
137
+ * `LOLCOMMITS_CAPTURE_DISABLED` disables lolcommit capturing in the commit hook
138
+ (when set as 'true')
139
+
138
140
 
139
- Or they can be set with these arguments to the capture command (located in your
141
+ Or they can be set with arguments to the capture command (located in your
140
142
  repository's `.git/hooks/post-commit` file).
141
143
 
142
144
  * `--device {name}` or `-d {name}`
@@ -154,7 +156,8 @@ loltext plugin with this command:
154
156
 
155
157
  lolcommits --config -p loltext
156
158
 
157
- To find out more, read about [loltext options](https://github.com/mroth/lolcommits/wiki/Configure-Commit-Capturing#loltext-options).
159
+ To find out more about styling, read about the [loltext
160
+ options](https://github.com/mroth/lolcommits/wiki/Configure-Commit-Capturing#loltext-options).
158
161
 
159
162
 
160
163
  ### Animated Gif Capturing
@@ -164,7 +167,7 @@ you capture and the capabilities of your machine).
164
167
  [ffmpeg](https://www.ffmpeg.org) is required and can be installed like so;
165
168
 
166
169
  * Linux - [follow this guide](https://www.ffmpeg.org/download.html#build-linux)
167
- * OSX - `brew install ffmpeg`
170
+ * macOS - `brew install ffmpeg`
168
171
 
169
172
  To enable, just set the `LOLCOMMITS_ANIMATE` environment variable with the
170
173
  number of seconds to capture. If you find animated capturing takes too long, try
@@ -180,21 +183,38 @@ animated lolcommit gif")
180
183
 
181
184
  A growing number of plugins are available, allowing you to transform or share
182
185
  your lolcommits with others. The default plugin simply appends your commit
183
- message and sha to the captured image. Others can auto post to Twitter, Tumblr
184
- (and other services), or even translate your commit messages to
185
- [lolspeak](http://www.urbandictionary.com/define.php?term=lolspeak). They can be
186
- easily enabled, configured or disabled with the `--config` option:
186
+ message and sha to the captured image. Others can post to Twitter, Tumblr (and
187
+ other services), or even translate your commit messages to
188
+ [lolspeak](http://www.urbandictionary.com/define.php?term=lolspeak). Check them
189
+ out on our [plugins
190
+ page](https://github.com/mroth/lolcommits/wiki/Configuring-Plugins).
191
+
192
+ Until recently, all plugins lived inside the main lolcommits gem. We are in the
193
+ process of extracting them to individual gems. For [gem
194
+ plugins](https://github.com/lolcommits), you'll need
195
+ to install the gem first:
196
+
197
+ [sudo] gem install lolcommits-plugin-sample
198
+
199
+ To list available/installed plugins use:
200
+
201
+ lolcommits --plugins
202
+
203
+ Plugins can be easily enabled, configured or disabled with the `--config`
204
+ option:
187
205
 
188
206
  lolcommits --config
207
+ # or
208
+ lolcommits --config -p loltxt
189
209
 
190
- Check them out on our [plugins
191
- page](https://github.com/mroth/lolcommits/wiki/Configuring-Plugins).
210
+ Interested in developing your own plugin? Follow this [this simple
211
+ guide](https://github.com/lolcommits/lolcommits-plugin-sample) for the
212
+ Lolcommits Plugin Sample gem.
192
213
 
193
214
 
194
215
  ## Timelapse
195
216
 
196
- To watch your face as it decays while you program, you can create an animated
197
- timelapse gif.
217
+ Watch your face decay while you program, with an animated timelapse gif!
198
218
 
199
219
  lolcommits --timelapse
200
220
  # or for just today's lolcommits
@@ -203,10 +223,10 @@ timelapse gif.
203
223
  ## Troubles?
204
224
 
205
225
  Try our trouble-shooting [FAQ](https://github.com/mroth/lolcommits/wiki/FAQ), or
206
- take a read through our [wiki](https://github.com/mroth/lolcommits/wiki) for
207
- more information. If you think something is broken or missing, raise a [Github
208
- issue](https://github.com/mroth/lolcommits/issues) (and please take a little
209
- time to check if we haven't [already
226
+ take a read through our [wiki](https://github.com/mroth/lolcommits/wiki). If you
227
+ think something is broken or missing, please raise a [Github
228
+ issue](https://github.com/mroth/lolcommits/issues) (and please check if we
229
+ haven't [already
210
230
  addressed](https://github.com/mroth/lolcommits/issues?q=is%3Aissue+is%3Aclosed)
211
231
  it).
212
232
 
@@ -36,13 +36,13 @@ class App
36
36
  debug 'Outputting at DEBUG verbosity'
37
37
  end
38
38
 
39
- # TODO: move to a better place
40
- load_plugins
39
+ plugin_manager = PluginManager.init
40
+ config = Configuration.new(plugin_manager, test_mode: options[:test])
41
41
 
42
42
  if options[:'show-config']
43
- puts configuration
43
+ puts config
44
44
  elsif options[:plugins]
45
- puts configuration.plugins_list
45
+ config.list_plugins
46
46
  elsif options[:devices]
47
47
  puts Platform.device_list
48
48
  puts device_list_help
@@ -59,15 +59,15 @@ class App
59
59
  end
60
60
 
61
61
  if options[:last]
62
- show_last_lolimage
62
+ show_last_lolimage(config.loldir)
63
63
  elsif options[:browse]
64
- Launcher.open_folder(configuration.loldir)
64
+ Launcher.open_folder(config.loldir)
65
65
  elsif options[:timelapse]
66
- TimelapseGif.new(configuration).run(options[:period])
66
+ TimelapseGif.new(config).run(options[:period])
67
67
  elsif options[:config]
68
- configuration.do_configure!(options[:plugin])
68
+ config.do_configure!(options[:plugin])
69
69
  elsif options[:capture]
70
- capture_lolcommit
70
+ capture_lolcommit(config)
71
71
  end
72
72
  end
73
73
  end
@@ -75,7 +75,7 @@ class App
75
75
 
76
76
  on('--test', 'run in test mode')
77
77
  on('--debug', 'show debugging info')
78
- on('--show-config', 'show configuration file')
78
+ on('--show-config', 'show config file')
79
79
  on('--devices', 'list available capture devices (mac only)')
80
80
  on('--plugins', 'list all available plugins')
81
81
  on('--config', 'configure a plugin')
@@ -109,34 +109,17 @@ class App
109
109
  'Or: lolcommits --help'
110
110
  end
111
111
 
112
- # Gets a configuration object. If running in test mode will override the
113
- # LOLDIR for the configuration.
114
- #
115
- # @return [Lolcommits::Configuration]
116
- def self.configuration
117
- if options[:test]
118
- Configuration.new(loldir: Configuration.loldir_for('test'))
119
- else
120
- Configuration.new
121
- end
122
- end
123
-
124
112
  def self.debug_enabled?
125
113
  options[:debug] || ENV['LOLCOMMITS_DEBUG'] || false
126
114
  end
127
115
 
128
- def self.load_plugins
129
- pm = Lolcommits::PluginManager.new
130
- pm.locate_plugins
131
- pm.load_plugins
132
- end
133
-
134
116
  def self.device_list_help
135
117
  'Specify a device with --device "{device name}" or set the LOLCOMMITS_DEVICE env variable'
136
118
  end
137
119
 
138
- def self.show_last_lolimage
139
- lolimage = configuration.most_recent
120
+ def self.show_last_lolimage(loldir)
121
+ lolimage = Dir.glob(File.join(loldir, '*.{jpg,gif}')).max_by { |f| File.mtime(f) }
122
+
140
123
  if lolimage.nil?
141
124
  warn 'No lolcommits have been captured for this repository yet.'
142
125
  exit 1
@@ -150,7 +133,7 @@ class App
150
133
  result
151
134
  end
152
135
 
153
- def self.capture_lolcommit
136
+ def self.capture_lolcommit(config)
154
137
  should_we_fork = options[:fork] || ENV['LOLCOMMITS_FORK'] || false
155
138
  capture_stealth = options[:stealth] || ENV['LOLCOMMITS_STEALTH'] || false
156
139
  capture_delay = (options[:delay] || ENV['LOLCOMMITS_DELAY']).to_i
@@ -160,10 +143,10 @@ class App
160
143
  capture_stealth: capture_stealth,
161
144
  capture_device: capture_device,
162
145
  capture_animate: capture_animate,
163
- config: configuration
146
+ config: config
164
147
  }
165
148
 
166
- process_runner = ProcessRunner.new(configuration)
149
+ process_runner = ProcessRunner.new(config)
167
150
  process_runner.fork_me?(should_we_fork) do
168
151
  if options[:test]
169
152
  info '*** Capturing in test mode.'
@@ -58,22 +58,26 @@ module Lolcommits
58
58
  end
59
59
 
60
60
  def self.hook_script(capture_args = '')
61
+ # TODO: have this return a single line bash like mercurial install, and DRY
62
+ # this method (only different in git is the rebase-merge check which could
63
+ # be extracted
61
64
  ruby_path = Lolcommits::Platform.command_which('ruby', true)
62
65
  imagick_path = Lolcommits::Platform.command_which('identify', true)
66
+ capture_cmd = 'lolcommits --capture'
63
67
 
64
68
  if Lolcommits::Platform.platform_windows?
65
- hook_export = "set path \"#{ruby_path};#{imagick_path};%PATH%\"\n"
69
+ capture_cmd = 'if "%LOLCOMMITS_CAPTURE_DISABLED%"=="true" (exit)'
70
+ capture_cmd = "set path=#{ruby_path};#{imagick_path};%PATH%&&#{capture_cmd}"
66
71
  else
67
- locale_export = "export LANG=\"#{ENV['LANG']}\"\n"
68
- hook_export = "export PATH=\"#{ruby_path}:#{imagick_path}:$PATH\"\n"
72
+ locale_export = "LANG=\"#{ENV['LANG']}\""
73
+ hook_export = "PATH=\"#{ruby_path}:#{imagick_path}:$PATH\""
74
+ capture_cmd = "#{locale_export} #{hook_export} #{capture_cmd}"
69
75
  end
70
76
 
71
- capture_cmd = 'lolcommits --capture'
72
-
73
77
  <<-EOS
74
78
  ### lolcommits hook (begin) ###
75
- if [ ! -d "$GIT_DIR/rebase-merge" ]; then
76
- #{locale_export}#{hook_export}#{capture_cmd} #{capture_args}
79
+ if [ ! -d "$GIT_DIR/rebase-merge" ] && [ "$LOLCOMMITS_CAPTURE_DISABLED" != "true" ]; then
80
+ #{capture_cmd} #{capture_args}
77
81
  fi
78
82
  ### lolcommits hook (end) ###
79
83
  EOS
@@ -43,14 +43,16 @@ module Lolcommits
43
43
  capture_cmd = 'lolcommits --capture'
44
44
 
45
45
  if Lolcommits::Platform.platform_windows?
46
- capture_cmd = "set path=#{ruby_path};#{imagick_path};%PATH%&&#{capture_cmd}"
46
+ capture_cmd = 'if "%LOLCOMMITS_CAPTURE_DISABLED%"=="true" (exit)'
47
+ capture_cmd = "set path=#{ruby_path};#{imagick_path};%PATH%&&#{capture_cmd} #{capture_args}"
47
48
  else
48
49
  locale_export = "LANG=\"#{ENV['LANG']}\""
49
50
  hook_export = "PATH=\"#{ruby_path}:#{imagick_path}:$PATH\""
50
- capture_cmd = "#{locale_export} #{hook_export} #{capture_cmd}"
51
+ capture_cmd = "#{locale_export} #{hook_export} #{capture_cmd}"
52
+ capture_cmd = "if [ \"$LOLCOMMITS_CAPTURE_DISABLED\" != \"true\" ]; then #{capture_cmd} #{capture_args}; fi"
51
53
  end
52
54
 
53
- "#{capture_cmd} #{capture_args}"
55
+ capture_cmd
54
56
  end
55
57
 
56
58
  def self.repository
@@ -60,7 +62,7 @@ module Lolcommits
60
62
  # does a mercurial hook exist with lolcommits commands?
61
63
  def self.lolcommits_hook_exists?
62
64
  config = repository.config
63
- config.exists? && config.setting_exists?(HOOK_SECTION, 'post-commit.lolcommits')
65
+ config.exists? && config.setting_exists?(HOOK_SECTION, 'post-crecord.lolcommits')
64
66
  end
65
67
 
66
68
  # can we load the hgrc?
@@ -2,12 +2,11 @@ module Lolcommits
2
2
  class Configuration
3
3
  LOLCOMMITS_BASE = ENV['LOLCOMMITS_DIR'] || File.join(ENV['HOME'], '.lolcommits')
4
4
  LOLCOMMITS_ROOT = File.join(File.dirname(__FILE__), '../..')
5
- attr_writer :loldir
5
+ attr_accessor :plugin_manager, :loldir
6
6
 
7
- def initialize(attributes = {})
8
- attributes.each do |attr, val|
9
- send("#{attr}=", val)
10
- end
7
+ def initialize(plugin_manager, test_mode: false)
8
+ @plugin_manager = plugin_manager
9
+ @loldir = Configuration.loldir_for('test') if test_mode
11
10
  end
12
11
 
13
12
  def read_configuration
@@ -39,10 +38,6 @@ module Lolcommits
39
38
  dir
40
39
  end
41
40
 
42
- def most_recent
43
- Dir.glob(File.join(loldir, '*.{jpg,gif}')).max_by { |f| File.mtime(f) }
44
- end
45
-
46
41
  def jpg_images
47
42
  Dir.glob(File.join(loldir, '*.jpg')).sort_by { |f| File.mtime(f) }
48
43
  end
@@ -67,26 +62,26 @@ module Lolcommits
67
62
  File.join(loldir, 'tmp_frames')
68
63
  end
69
64
 
70
- def plugins_list
71
- "Available plugins: \n * #{Lolcommits::Runner.plugins.map(&:name).sort.join("\n * ")}"
72
- end
73
-
74
- def ask_for_plugin_name
75
- puts plugins_list
76
- print 'Name of plugin to configure: '
77
- gets.strip
65
+ def list_plugins
66
+ puts "Available plugins: \n * #{plugin_manager.plugin_names.join("\n * ")}"
78
67
  end
79
68
 
80
69
  def find_plugin(plugin_name_option)
81
70
  plugin_name = plugin_name_option.empty? ? ask_for_plugin_name : plugin_name_option
71
+ return if plugin_name.empty?
82
72
 
83
- Lolcommits::Runner.plugins.each do |plugin|
84
- return plugin.new(nil) if plugin.name == plugin_name
85
- end
73
+ plugin_klass = plugin_manager.find_by_name(plugin_name)
74
+ return plugin_klass.new(nil) if plugin_klass
86
75
 
87
76
  puts "Unable to find plugin: '#{plugin_name}'"
88
77
  return if plugin_name_option.empty?
89
- puts plugins_list
78
+ list_plugins
79
+ end
80
+
81
+ def ask_for_plugin_name
82
+ list_plugins
83
+ print 'Name of plugin to configure: '
84
+ gets.strip
90
85
  end
91
86
 
92
87
  def do_configure!(plugin_name)
@@ -1,12 +1,9 @@
1
1
  module Lolcommits
2
2
  class GemPlugin
3
- attr_accessor :name, :gem_name, :spec, :required
3
+ attr_accessor :gem_spec, :required
4
4
 
5
- def initialize(name, gem_name, spec)
6
- @name = name
7
- @gem_name = gem_name
8
- @spec = spec
9
- @required = false
5
+ def initialize(gem_spec)
6
+ @gem_spec = gem_spec
10
7
  end
11
8
 
12
9
  # activate the plugin (require the gem - enables/loads the plugin
@@ -15,13 +12,13 @@ module Lolcommits
15
12
  begin
16
13
  require gem_path unless required?
17
14
  rescue LoadError => e
18
- warn "Found plugin #{gem_name}, but could not require '#{gem_name}'"
15
+ warn "Found plugin #{name}, but could not require gem '#{gem_name}'"
19
16
  warn e
20
17
  rescue => e
21
- warn "require '#{gem_name}' # Failed, saying: #{e}"
18
+ warn "require gem '#{gem_name}' failed with: #{e}"
22
19
  end
23
20
 
24
- self.required = true
21
+ @required = true
25
22
  end
26
23
 
27
24
  alias required? required
@@ -29,7 +26,7 @@ module Lolcommits
29
26
  def supported?
30
27
  # false if the plugin gem does not support this version of Lolcommits
31
28
  lolcommits_version = Gem::Version.new(::Lolcommits::VERSION)
32
- spec.dependencies.each do |dependency|
29
+ gem_spec.dependencies.each do |dependency|
33
30
  if dependency.name == Lolcommits::GEM_NAME
34
31
  return dependency.requirement.satisfied_by?(lolcommits_version)
35
32
  end
@@ -37,10 +34,28 @@ module Lolcommits
37
34
  true
38
35
  end
39
36
 
37
+ def name
38
+ gem_name.split('-', 2).last
39
+ end
40
+
41
+ def plugin_klass
42
+ self.class.const_get(plugin_klass_name)
43
+ rescue => e
44
+ warn "failed to load constant from plugin gem '#{plugin_klass_name}: #{e}'"
45
+ end
46
+
40
47
  private
41
48
 
49
+ def gem_name
50
+ gem_spec.name
51
+ end
52
+
42
53
  def gem_path
43
54
  gem_name.gsub(/-|_/, '/')
44
55
  end
56
+
57
+ def plugin_klass_name
58
+ gem_path.split('/').map(&:capitalize).join('::')
59
+ end
45
60
  end
46
61
  end
@@ -100,10 +100,16 @@ module Lolcommits
100
100
  'plugin'
101
101
  end
102
102
 
103
- # a plugin requests to be run by the runner in one of these positions
104
- # valid options are [:precapture, :postcapture]
103
+ # Returns position(s) of when a plugin should run during the capture
104
+ # process.
105
+ #
106
+ # Defines when the plugin will execute in the capture process. This must
107
+ # be defined, if the method returns nil, or [] the plugin will never run.
108
+ #
109
+ # @return [Array] the position(s) (:precapture and/or :postcapture)
110
+ #
105
111
  def self.runner_order
106
- nil
112
+ []
107
113
  end
108
114
  end
109
115
  end
@@ -1,41 +1,63 @@
1
1
  module Lolcommits
2
2
  class PluginManager
3
- GEM_NAME_PREFIX = /^lolcommits-plugin-/
3
+ GEM_NAME_PREFIX = /^lolcommits-/
4
+
5
+ def self.init
6
+ pm = new
7
+ pm.load_plugins
8
+ pm
9
+ end
4
10
 
5
11
  def initialize
6
12
  @plugins = []
7
13
  end
8
14
 
9
- # @return [Array] find all installed and supported plugins, storing to
10
- # @plugins Array, and returns this array
11
- def locate_plugins
12
- gem_list.each do |gem|
13
- next if gem.name !~ GEM_NAME_PREFIX
14
- plugin_name = gem.name.split('-', 2).last
15
- plugin = GemPlugin.new(plugin_name, gem.name, gem)
15
+ # find and require all plugins
16
+ def load_plugins
17
+ find_plugins
18
+ @plugins.map(&:activate!)
19
+ end
16
20
 
17
- @plugins << plugin if plugin.supported? && !plugin_located?(plugin)
18
- end
19
- @plugins
21
+ def plugins_for(position)
22
+ plugin_klasses.select { |p| Array(p.runner_order).include?(position) }
20
23
  end
21
24
 
22
- # @return [Hash] A hash with all plugin names (minus the prefix) as
23
- # keys and Plugin objects as values
24
- def plugins
25
- h = {}
26
- @plugins.each do |plugin|
27
- h[plugin.name] = plugin
28
- end
29
- h
25
+ # @return [Lolcommits::Plugin] find first plugin matching name
26
+ def find_by_name(name)
27
+ plugin_klasses.find { |plugin| plugin.name =~ /^#{name}/ }
30
28
  end
31
29
 
32
- # require all plugins
33
- def load_plugins
34
- @plugins.map(&:activate!)
30
+ def plugin_names
31
+ # TODO: when all plugins are gems, get names from GemPlugin with
32
+ # @plugins.map(&:name)
33
+ plugin_klasses.map(&:name).sort
35
34
  end
36
35
 
37
36
  private
38
37
 
38
+ # @return [Array] find all classes inheriting from Lolcommits::Plugin::Base
39
+ def plugin_klasses
40
+ # TODO: when all plugins are gems, change this to
41
+ # @plugins.map(&:plugin_klass)
42
+ ObjectSpace.each_object(Class).select { |klass| klass < Lolcommits::Plugin::Base }
43
+ end
44
+
45
+ # @return [Array] find all installed and supported plugins, populate
46
+ # @plugins array and return it
47
+ def find_plugins
48
+ find_gems.map do |gem|
49
+ plugin = GemPlugin.new(gem)
50
+ @plugins << plugin if plugin.supported? && !plugin_located?(plugin)
51
+ end
52
+
53
+ @plugins
54
+ end
55
+
56
+ # @return [Array] find all installed gems matching GEM_NAME_PREFIX
57
+ def find_gems
58
+ gem_list.select { |gem| gem.name =~ GEM_NAME_PREFIX }
59
+ end
60
+
39
61
  def plugin_located?(plugin)
40
62
  @plugins.any? { |existing| existing.gem_name == plugin.gem_name }
41
63
  end
@@ -28,15 +28,11 @@ module Lolcommits
28
28
  # this used to be handled with ActiveSupport::Callbacks, but
29
29
  # now we're just using a simple procedural list
30
30
  def run
31
- # do things that need to happen before capture and plugins
32
-
33
- # do native plugins that need to happen before capture
34
- plugins_for(:precapture).each do |plugin|
31
+ # do plugins that need to happen before capture
32
+ plugin_manager.plugins_for(:precapture).each do |plugin|
35
33
  plugin.new(self).execute_precapture
36
34
  end
37
35
 
38
- # do gem plugins that need to happen before capture?
39
-
40
36
  # do main capture to snapshot_loc
41
37
  run_capture
42
38
 
@@ -51,13 +47,11 @@ module Lolcommits
51
47
  # reserve just for us and handle manually...?
52
48
  Lolcommits::Plugin::Loltext.new(self).execute_postcapture
53
49
 
54
- # do native plugins that need to happen after capture
55
- plugins_for(:postcapture).each do |plugin|
50
+ # do plugins that need to happen after capture
51
+ plugin_manager.plugins_for(:postcapture).each do |plugin|
56
52
  plugin.new(self).execute_postcapture
57
53
  end
58
54
 
59
- # do gem plugins that need to happen after capture?
60
-
61
55
  # do things that should happen last
62
56
  cleanup!
63
57
  else
@@ -66,16 +60,6 @@ module Lolcommits
66
60
  end
67
61
  end
68
62
 
69
- # TODO: - move these plugin methods to Lolcommits::PluginManager after all
70
- # plugins get "gemified"
71
- def plugins_for(position)
72
- self.class.plugins.select { |p| p.runner_order == position }
73
- end
74
-
75
- def self.plugins
76
- Lolcommits::Plugin.constants.map(&Lolcommits::Plugin.method(:const_get)) - [Lolcommits::Plugin::Base]
77
- end
78
-
79
63
  # the main capture
80
64
  def run_capture
81
65
  puts '*** Preserving this moment in history.' unless capture_stealth
@@ -99,6 +83,10 @@ module Lolcommits
99
83
 
100
84
  private
101
85
 
86
+ def plugin_manager
87
+ @plugin_manager ||= config.plugin_manager
88
+ end
89
+
102
90
  def image_file_type
103
91
  capture_animated? ? 'gif' : 'jpg'
104
92
  end
@@ -1,4 +1,4 @@
1
1
  module Lolcommits
2
- VERSION = '0.9.3.pre1'.freeze
2
+ VERSION = '0.9.3.pre2'.freeze
3
3
  GEM_NAME = 'lolcommits'.freeze
4
4
  end
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.3.pre1
4
+ version: 0.9.3.pre2
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: 2017-03-06 00:00:00.000000000 Z
12
+ date: 2017-04-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: aruba