lolcommits 0.9.3 → 0.9.4.pre1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6864a969f2a474924b420bf5043e8f0cf8c4a06b
4
- data.tar.gz: 7298c313a1747d98fb340edb3ffd36864ed8e22d
3
+ metadata.gz: 5077e567b4b5f4f7d4a11f250f85add376ab4b9c
4
+ data.tar.gz: fa7987a658c16d395612482fe053bc5354b5fbbe
5
5
  SHA512:
6
- metadata.gz: eb73b9e99c8935a5609ec43e32d7e908fe9fb62f34da8576f4fd7dd50157430866174b2defe114c5870e8cbb0d9caea5ed85a0c5febc757b7a8caa33d9382b09
7
- data.tar.gz: 969703fd3242a8ef0adcfe5b6d68da899421a882d4290ed89e2459f94584c47543e49a5cbe7452a04bc2f4c900aabf06b25200df2ee39d46003201491722f9e5
6
+ metadata.gz: 548f4a6a66e8267bc3089f2d370b48b24d4a9c64a7bb2c0bd578dbd56f324001a93c92ffe5a3a8e44d3ec1ea14a57039b803cd10a63ce13aeb8d33a85b9e2b8c
7
+ data.tar.gz: 70f8de9d99add1b58127327c09b90ce34e29ba543d45e4394319f301dcb30eb7d26039b79e28b9b34e236517c73c24cb7198c7da331808388df558d15969b22f
@@ -8,6 +8,12 @@ project adheres to [Semantic Versioning][Semver].
8
8
  * WIP - extract more plugins to gems ...
9
9
  * Your contribution here!
10
10
 
11
+ ## [0.9.4][] (17 April 2017)
12
+ * Add captureready plugin hook (@matthutchinson [#342][])
13
+ * README changes (@mroth [#341][])
14
+ * Extract tranzlate plugin to gem (@matthutchinson [#340][])
15
+ * Extract loltext plugin to gem (@matthutchinson [#339][])
16
+
11
17
  ## [0.9.3][] (5 April 2017)
12
18
  * LOLCOMMITS_CAPTURE_DISABLED env var (@williamboman [#338][])
13
19
  * Plugin Manager and Gem plugin support (@matthutchinson [#332][])
@@ -273,7 +279,8 @@ project adheres to [Semantic Versioning][Semver].
273
279
  instead of compositing multiply image Caption objects (this seems to be more
274
280
  reliable to not glitch.)
275
281
 
276
- [Unreleased]: https://github.com/mroth/lolcommits/compare/v0.9.3...HEAD
282
+ [Unreleased]: https://github.com/mroth/lolcommits/compare/v0.9.4...HEAD
283
+ [0.9.4]: https://github.com/mroth/lolcommits/compare/v0.9.3...v0.9.4
277
284
  [0.9.3]: https://github.com/mroth/lolcommits/compare/v0.9.2...v0.9.3
278
285
  [0.9.2]: https://github.com/mroth/lolcommits/compare/v0.9.1...v0.9.2
279
286
  [0.9.1]: https://github.com/mroth/lolcommits/compare/v0.9.0...v0.9.1
@@ -432,3 +439,7 @@ project adheres to [Semantic Versioning][Semver].
432
439
  [#331]: https://github.com/mroth/lolcommits/pull/331
433
440
  [#332]: https://github.com/mroth/lolcommits/pull/332
434
441
  [#338]: https://github.com/mroth/lolcommits/pull/338
442
+ [#339]: https://github.com/mroth/lolcommits/pull/339
443
+ [#340]: https://github.com/mroth/lolcommits/pull/340
444
+ [#341]: https://github.com/mroth/lolcommits/pull/341
445
+ [#342]: https://github.com/mroth/lolcommits/pull/342
data/README.md CHANGED
@@ -1,4 +1,5 @@
1
- # lolcommits (git + webcam = lol)
1
+ # lolcommits
2
+ > git-based selfies for software developers
2
3
 
3
4
  lolcommits takes a snapshot with your webcam every time you git commit code, and
4
5
  archives a lolcat style image with it. Git blame has never been so much fun.
@@ -45,7 +46,7 @@ Then install with:
45
46
  [sudo] gem install lolcommits
46
47
 
47
48
  If you're using RVM (or rbenv), you can/should probably omit the sudo, but the
48
- default macOS Ruby install is dumb and requires it.
49
+ default macOS Ruby install usually requires it.
49
50
 
50
51
  Lolcommits v0.8.1 was the last release to support Ruby < 2.0. If you'd like to
51
52
  use older Rubies try:
@@ -191,25 +192,25 @@ page](https://github.com/mroth/lolcommits/wiki/Configuring-Plugins).
191
192
 
192
193
  Until recently, all plugins lived inside the main lolcommits gem. We are in the
193
194
  process of extracting them to individual gems. For [gem
194
- plugins](https://github.com/lolcommits), you'll need
195
- to install the gem first:
195
+ plugins](https://github.com/search?q=topic%3Alolcommits-plugin+org%3Alolcommits&type=Repositories),
196
+ you'll need to install the gem first:
196
197
 
197
198
  [sudo] gem install lolcommits-plugin-sample
198
199
 
199
- To list available/installed plugins use:
200
+ To list all installed plugins use:
200
201
 
201
202
  lolcommits --plugins
202
203
 
203
- Plugins can be easily enabled, configured or disabled with the `--config`
204
- option:
204
+ Installed plugins can be easily enabled, configured or disabled with the
205
+ `--config` option:
205
206
 
206
207
  lolcommits --config
207
208
  # or
208
- lolcommits --config -p loltxt
209
+ lolcommits --config -p loltext
209
210
 
210
211
  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.
212
+ guide](https://github.com/lolcommits/lolcommits-plugin-sample) at the
213
+ Lolcommits Plugin Sample README.
213
214
 
214
215
 
215
216
  ## Timelapse
@@ -114,54 +114,6 @@ Feature: Basic UI functionality
114
114
  When I successfully run `lolcommits --plugins`
115
115
  Then the output should contain a list of plugins
116
116
 
117
- Scenario: Configuring loltext plugin
118
- Given I am in a git repo named "config-test"
119
- When I run `lolcommits --config` interactively
120
- And I wait for output to contain "Name of plugin to configure:"
121
- Then I type "loltext"
122
- And I wait for output to contain "enabled:"
123
- Then I type "true"
124
- And I wait for output to contain "message:"
125
- And I wait for output to contain "color"
126
- Then I type "red"
127
- And I wait for output to contain "font"
128
- Then I type "my-font.ttf"
129
- And I wait for output to contain "position"
130
- Then I type "SE"
131
- And I wait for output to contain "size"
132
- Then I type "32"
133
- And I wait for output to contain "stroke color"
134
- Then I type "white"
135
- And I wait for output to contain "uppercase"
136
- Then I type "true"
137
- And I wait for output to contain "sha"
138
- Then I type ""
139
- Then I type ""
140
- Then I type ""
141
- Then I type ""
142
- Then I type ""
143
- Then I type ""
144
- And I wait for output to contain "overlay:"
145
- Then I type "true"
146
- And I wait for output to contain "overlay colors"
147
- Then I type "#2884ae,#7e231f"
148
- And I wait for output to contain "overlay percent"
149
- Then I type "40"
150
- Then the output should contain "Successfully configured plugin: loltext"
151
- And the output should contain a list of plugins
152
- And a file named "~/.lolcommits/config-test/config.yml" should exist
153
- When I successfully run `lolcommits --show-config`
154
- Then the output should match /enabled: true/
155
- And the output should match /:font: my-font\.ttf/
156
- And the output should match /:size: 32/
157
- And the output should match /:position: S/
158
- And the output should match /:color: red/
159
- And the output should match /:stroke_color: white/
160
- And the output should match /:uppercase: true/
161
- And the output should match /:overlay:.*\n.*:enabled: true/
162
- And the output should match /:overlay_colors:.*\n.*['"]#2884ae['"].*\n.*['"]#7e231f['"].*\n/
163
- And the output should match /:overlay_percent: 40/
164
-
165
117
  Scenario: Configuring loltext plugin in test mode affects test loldir not repo loldir
166
118
  Given I am in a git repo named "testmode-config-test"
167
119
  When I run `lolcommits --config --test -p loltext` interactively
@@ -25,7 +25,7 @@ Before do
25
25
  set_env 'GIT_COMMITTER_EMAIL', author_email
26
26
  end
27
27
 
28
- # for tasks that may take an insanely long time (e.g. network related)
28
+ # for tasks that may take an incredibly long time (e.g. network related)
29
29
  # we should strive to not have any of these in our scenarios, naturally.
30
30
  Before('@slow_process') do
31
31
  @aruba_io_wait_seconds = 5
@@ -29,9 +29,7 @@ require 'lolcommits/backends/git_info'
29
29
  require 'lolcommits/backends/mercurial_info'
30
30
 
31
31
  require 'lolcommits/plugin/base'
32
- require 'lolcommits/plugin/loltext'
33
32
  require 'lolcommits/plugin/dot_com'
34
- require 'lolcommits/plugin/tranzlate'
35
33
  require 'lolcommits/plugin/lol_twitter'
36
34
  require 'lolcommits/plugin/uploldz'
37
35
  require 'lolcommits/plugin/term_output'
@@ -44,12 +44,12 @@ module Lolcommits
44
44
  warn "failed to load constant from plugin gem '#{plugin_klass_name}: #{e}'"
45
45
  end
46
46
 
47
- private
48
-
49
47
  def gem_name
50
48
  gem_spec.name
51
49
  end
52
50
 
51
+ private
52
+
53
53
  def gem_path
54
54
  gem_name.gsub(/-|_/, '/')
55
55
  end
@@ -9,23 +9,29 @@ module Lolcommits
9
9
  end
10
10
 
11
11
  def execute_precapture
12
- return unless valid_configuration?
13
- return unless enabled?
12
+ return unless configured_and_enabled?
14
13
  debug 'I am enabled, about to run precapture'
15
14
  run_precapture
16
15
  end
17
16
 
18
17
  def execute_postcapture
19
- return unless valid_configuration?
20
- return unless enabled?
18
+ return unless configured_and_enabled?
21
19
  debug 'I am enabled, about to run postcapture'
22
20
  run_postcapture
23
21
  end
24
22
 
23
+ def execute_captureready
24
+ return unless configured_and_enabled?
25
+ debug 'I am enabled, about to run captureready'
26
+ run_captureready
27
+ end
28
+
25
29
  def run_precapture; end
26
30
 
27
31
  def run_postcapture; end
28
32
 
33
+ def run_captureready; end
34
+
29
35
  def configuration
30
36
  config = runner.config.read_configuration if runner
31
37
  return {} unless config
@@ -63,6 +69,10 @@ module Lolcommits
63
69
  end
64
70
  end
65
71
 
72
+ def configured_and_enabled?
73
+ valid_configuration? && enabled?
74
+ end
75
+
66
76
  def enabled?
67
77
  configuration['enabled'] == true
68
78
  end
@@ -105,8 +115,11 @@ module Lolcommits
105
115
  #
106
116
  # Defines when the plugin will execute in the capture process. This must
107
117
  # be defined, if the method returns nil, or [] the plugin will never run.
118
+ # Three hook positions exist, your plugin code can execute in one or more
119
+ # of these.
108
120
  #
109
- # @return [Array] the position(s) (:precapture and/or :postcapture)
121
+ # @return [Array] the position(s) (:precapture, :postcapture,
122
+ # :captureready)
110
123
  #
111
124
  def self.runner_order
112
125
  []
@@ -10,7 +10,7 @@ module Lolcommits
10
10
  options.concat(%w(api_key api_secret repo_id))
11
11
  end
12
12
 
13
- def run_postcapture
13
+ def run_captureready
14
14
  t = Time.now.to_i.to_s
15
15
  HTTMultiParty.post(
16
16
  "#{BASE_URL}/git_commits.json",
@@ -43,7 +43,7 @@ module Lolcommits
43
43
  end
44
44
 
45
45
  def self.runner_order
46
- :postcapture
46
+ :captureready
47
47
  end
48
48
  end
49
49
  end
@@ -11,7 +11,7 @@ module Lolcommits
11
11
  end
12
12
 
13
13
  def self.runner_order
14
- :postcapture
14
+ :captureready
15
15
  end
16
16
 
17
17
  def configured?
@@ -45,7 +45,7 @@ module Lolcommits
45
45
  options
46
46
  end
47
47
 
48
- def run_postcapture
48
+ def run_captureready
49
49
  retries = RETRY_COUNT
50
50
  begin
51
51
 
@@ -32,7 +32,7 @@ module Lolcommits
32
32
  }
33
33
  end
34
34
 
35
- def run_postcapture
35
+ def run_captureready
36
36
  http = Net::HTTP.new(api_url.host, api_url.port)
37
37
  # http.set_debug_output $stderr # nice for debugging, never ever release with it
38
38
  http.start do |connection|
@@ -117,7 +117,7 @@ module Lolcommits
117
117
  end
118
118
 
119
119
  def self.runner_order
120
- :postcapture
120
+ :captureready
121
121
  end
122
122
  end
123
123
  end
@@ -8,7 +8,7 @@ module Lolcommits
8
8
  options.concat(%w(api_token api_endpoint))
9
9
  end
10
10
 
11
- def run_postcapture
11
+ def run_captureready
12
12
  debug "Posting capture to #{configuration['endpoint']}"
13
13
  RestClient.post(
14
14
  api_url,
@@ -61,7 +61,7 @@ module Lolcommits
61
61
  end
62
62
 
63
63
  def self.runner_order
64
- :postcapture
64
+ :captureready
65
65
  end
66
66
  end
67
67
  end
@@ -11,7 +11,7 @@ module Lolcommits
11
11
  end
12
12
 
13
13
  def self.runner_order
14
- :postcapture
14
+ :captureready
15
15
  end
16
16
 
17
17
  def configured?
@@ -40,7 +40,7 @@ module Lolcommits
40
40
  options
41
41
  end
42
42
 
43
- def run_postcapture
43
+ def run_captureready
44
44
  retries = RETRY_COUNT
45
45
  begin
46
46
 
@@ -11,7 +11,7 @@ module Lolcommits
11
11
  TUMBLR_CONSUMER_KEY = '2FtMEDpEPkxjoUdkpHh42h9wqTu9IVS7Ra0QyNZGixdCvhllN2'.freeze
12
12
  TUMBLR_CONSUMER_SECRET = 'qWuvxgFUR2YyWKtbWOkDTMAiBEbj7ZGaNLaNQPba0PI1N4JpBs'.freeze
13
13
 
14
- def run_postcapture
14
+ def run_captureready
15
15
  puts 'Posting to Tumblr'
16
16
  r = client.photo(configuration['tumblr_name'], data: runner.main_image)
17
17
  if r.key?('id')
@@ -111,7 +111,7 @@ module Lolcommits
111
111
  end
112
112
 
113
113
  def self.runner_order
114
- :postcapture
114
+ :captureready
115
115
  end
116
116
 
117
117
  protected
@@ -15,7 +15,7 @@ module Lolcommits
15
15
  TWITTER_PIN_REGEX = /^\d{4,}$/ # 4 or more digits
16
16
  DEFAULT_SUFFIX = '#lolcommits'.freeze
17
17
 
18
- def run_postcapture
18
+ def run_captureready
19
19
  tweet = build_tweet(runner.message)
20
20
 
21
21
  attempts = 0
@@ -169,7 +169,7 @@ module Lolcommits
169
169
  end
170
170
 
171
171
  def self.runner_order
172
- :postcapture
172
+ :captureready
173
173
  end
174
174
  end
175
175
  end
@@ -15,7 +15,7 @@ module Lolcommits
15
15
  end
16
16
 
17
17
  def self.runner_order
18
- :postcapture
18
+ :captureready
19
19
  end
20
20
 
21
21
  def configured?
@@ -53,7 +53,7 @@ module Lolcommits
53
53
  options
54
54
  end
55
55
 
56
- def run_postcapture
56
+ def run_captureready
57
57
  commit_msg = runner.message
58
58
  post = "#{commit_msg} #lolcommits"
59
59
  puts "Yammer post: #{post}" unless runner.capture_stealth
@@ -10,7 +10,7 @@ module Lolcommits
10
10
  options << 'server'
11
11
  end
12
12
 
13
- def run_postcapture
13
+ def run_captureready
14
14
  fork { sync }
15
15
  end
16
16
 
@@ -51,7 +51,7 @@ module Lolcommits
51
51
  end
52
52
 
53
53
  def self.runner_order
54
- :postcapture
54
+ :captureready
55
55
  end
56
56
  end
57
57
  end
@@ -3,7 +3,7 @@ require 'base64'
3
3
  module Lolcommits
4
4
  module Plugin
5
5
  class TermOutput < Base
6
- def run_postcapture
6
+ def run_captureready
7
7
  if terminal_supported?
8
8
  if !runner.vcs_info || runner.vcs_info.repo.empty?
9
9
  debug 'repo is empty, skipping term output'
@@ -21,7 +21,7 @@ module Lolcommits
21
21
  end
22
22
 
23
23
  def self.runner_order
24
- :postcapture
24
+ :captureready
25
25
  end
26
26
 
27
27
  def configure_options!
@@ -18,7 +18,7 @@ module Lolcommits
18
18
  )
19
19
  end
20
20
 
21
- def run_postcapture
21
+ def run_captureready
22
22
  if !runner.vcs_info || runner.vcs_info.repo.empty?
23
23
  puts 'Repo is empty, skipping upload'
24
24
  else
@@ -58,7 +58,7 @@ module Lolcommits
58
58
  end
59
59
 
60
60
  def self.runner_order
61
- :postcapture
61
+ :captureready
62
62
  end
63
63
  end
64
64
  end
@@ -38,21 +38,20 @@ module Lolcommits
38
38
 
39
39
  # check capture succeded, file must exist
40
40
  if File.exist?(snapshot_loc)
41
-
42
41
  ## resize snapshot first
43
42
  resize_snapshot!
44
43
 
45
- # do native plugins that need to happen immediately after capture and
46
- # resize this is effectively the "image processing" phase for now,
47
- # reserve just for us and handle manually...?
48
- Lolcommits::Plugin::Loltext.new(self).execute_postcapture
49
-
50
- # do plugins that need to happen after capture
44
+ # execute postcapture plugins, use to alter the capture
51
45
  plugin_manager.plugins_for(:postcapture).each do |plugin|
52
46
  plugin.new(self).execute_postcapture
53
47
  end
54
48
 
55
- # do things that should happen last
49
+ # execute captureready plugins, capture is ready for export/sharing
50
+ plugin_manager.plugins_for(:captureready).each do |plugin|
51
+ plugin.new(self).execute_captureready
52
+ end
53
+
54
+ # clean away any tmp files
56
55
  cleanup!
57
56
  else
58
57
  debug 'Runner: failed to capture a snapshot'
@@ -95,7 +94,7 @@ module Lolcommits
95
94
  debug 'Runner: resizing snapshot'
96
95
  image = MiniMagick::Image.open(snapshot_loc)
97
96
  if image[:width] > 640 || image[:height] > 480
98
- # this is ghetto resize-to-fill
97
+ # this is hacky resize-to-fill
99
98
  image.combine_options do |c|
100
99
  c.resize '640x480^'
101
100
  c.gravity 'center'
@@ -1,4 +1,4 @@
1
1
  module Lolcommits
2
- VERSION = '0.9.3'.freeze
2
+ VERSION = '0.9.4.pre1'.freeze
3
3
  GEM_NAME = 'lolcommits'.freeze
4
4
  end
@@ -41,6 +41,9 @@ Gem::Specification.new do |s|
41
41
  s.add_runtime_dependency('open4', '~> 1.3.4')
42
42
  s.add_runtime_dependency('git', '~> 1.3.0')
43
43
 
44
+ # built-in lolcommits plugin
45
+ s.add_runtime_dependency('lolcommits-loltext')
46
+
44
47
  # plugin gems
45
48
  s.add_runtime_dependency('yam', '~> 2.5.0') # yammer
46
49
  s.add_runtime_dependency('httmultiparty', '~> 0.3.16') # dot_com
@@ -18,13 +18,10 @@ class LolTest < MiniTest::Test
18
18
  # this will test the permissions but only locally, important before building a gem package!
19
19
  #
20
20
  def test_permissions
21
- impact_perms = File.lstat(Lolcommits::Plugin::Loltext::DEFAULT_FONT_PATH).mode & 0o777
22
21
  imagesnap_perms = File.lstat(File.join(Configuration::LOLCOMMITS_ROOT, 'vendor', 'ext', 'imagesnap', 'imagesnap')).mode & 0o777
23
22
  videosnap_perms = File.lstat(File.join(Configuration::LOLCOMMITS_ROOT, 'vendor', 'ext', 'videosnap', 'videosnap')).mode & 0o777
24
23
  commandcam_perms = File.lstat(File.join(Configuration::LOLCOMMITS_ROOT, 'vendor', 'ext', 'CommandCam', 'CommandCam.exe')).mode & 0o777
25
24
 
26
- assert impact_perms == 0o644 || impact_perms == 0o664,
27
- "expected perms of 644/664 but instead got #{format '%o', impact_perms}"
28
25
  assert imagesnap_perms == 0o755 || imagesnap_perms == 0o775,
29
26
  "expected perms of 755/775 but instead got #{format '%o', imagesnap_perms}"
30
27
  assert videosnap_perms == 0o755 || videosnap_perms == 0o775,
@@ -13,19 +13,8 @@ require 'lolcommits'
13
13
  include Lolcommits
14
14
 
15
15
  class PluginsTest < MiniTest::Test
16
- #
17
- # issue #57, https://github.com/mroth/lolcommits/issues/57
18
- #
19
- def test_tranzlate
20
- [['what the hell', '(WH|W)UT TEH HELL'], ['seriously wtf', 'SRSLEH WTF']].each do |normal, lol|
21
- tranzlated = Lolcommits::Plugin::Tranzlate.tranzlate(normal)
22
- assert_match(/^#{lol}/, tranzlated)
23
- end
24
- end
25
-
26
- #
27
- # issue #136, https://github.com/mroth/lolcommits/issues/136
28
16
  def test_lol_twitter_build_tweet
17
+ # issue #136, https://github.com/mroth/lolcommits/issues/136
29
18
  long_commit_message = FFaker::Lorem.sentence(500)
30
19
  plugin = Lolcommits::Plugin::LolTwitter.new(nil)
31
20
  max_tweet_size = 116
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
4
+ version: 0.9.4.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: 2017-04-05 00:00:00.000000000 Z
12
+ date: 2017-04-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: aruba
@@ -137,6 +137,20 @@ dependencies:
137
137
  - - "~>"
138
138
  - !ruby/object:Gem::Version
139
139
  version: 1.3.0
140
+ - !ruby/object:Gem::Dependency
141
+ name: lolcommits-loltext
142
+ requirement: !ruby/object:Gem::Requirement
143
+ requirements:
144
+ - - ">="
145
+ - !ruby/object:Gem::Version
146
+ version: '0'
147
+ type: :runtime
148
+ prerelease: false
149
+ version_requirements: !ruby/object:Gem::Requirement
150
+ requirements:
151
+ - - ">="
152
+ - !ruby/object:Gem::Version
153
+ version: '0'
140
154
  - !ruby/object:Gem::Dependency
141
155
  name: yam
142
156
  requirement: !ruby/object:Gem::Requirement
@@ -362,9 +376,7 @@ files:
362
376
  - lib/lolcommits/plugin/lol_twitter.rb
363
377
  - lib/lolcommits/plugin/lol_yammer.rb
364
378
  - lib/lolcommits/plugin/lolsrv.rb
365
- - lib/lolcommits/plugin/loltext.rb
366
379
  - lib/lolcommits/plugin/term_output.rb
367
- - lib/lolcommits/plugin/tranzlate.rb
368
380
  - lib/lolcommits/plugin/uploldz.rb
369
381
  - lib/lolcommits/plugin_manager.rb
370
382
  - lib/lolcommits/runner.rb
@@ -382,7 +394,6 @@ files:
382
394
  - vendor/ext/imagesnap/ReadMeOrDont.rtf
383
395
  - vendor/ext/imagesnap/imagesnap
384
396
  - vendor/ext/videosnap/videosnap
385
- - vendor/fonts/Impact.ttf
386
397
  homepage: http://mroth.github.com/lolcommits/
387
398
  licenses:
388
399
  - LGPL-3
@@ -398,14 +409,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
398
409
  version: '2.0'
399
410
  required_rubygems_version: !ruby/object:Gem::Requirement
400
411
  requirements:
401
- - - ">="
412
+ - - ">"
402
413
  - !ruby/object:Gem::Version
403
- version: '0'
414
+ version: 1.3.1
404
415
  requirements:
405
416
  - imagemagick
406
417
  - a webcam
407
418
  rubyforge_project:
408
- rubygems_version: 2.4.8
419
+ rubygems_version: 2.4.5
409
420
  signing_key:
410
421
  specification_version: 4
411
422
  summary: Capture webcam image on git commit for lulz.
@@ -1,190 +0,0 @@
1
- module Lolcommits
2
- module Plugin
3
- class Loltext < Base
4
- DEFAULT_FONT_PATH = File.join(Configuration::LOLCOMMITS_ROOT, 'vendor', 'fonts', 'Impact.ttf')
5
-
6
- def self.name
7
- 'loltext'
8
- end
9
-
10
- # enabled by default (if no configuration exists)
11
- def enabled?
12
- !configured? || super
13
- end
14
-
15
- # valid by default (if no config exists)
16
- def valid_configuration?
17
- !configured? || super
18
- end
19
-
20
- def run_postcapture
21
- debug 'Annotating image via MiniMagick'
22
- image = MiniMagick::Image.open(runner.main_image)
23
- if config_option(:overlay, :enabled)
24
- image.combine_options do |c|
25
- c.fill config_option(:overlay, :overlay_colors).sample
26
- c.colorize config_option(:overlay, :overlay_percent)
27
- end
28
- end
29
-
30
- annotate(image, :message, clean_msg(runner.message))
31
- annotate(image, :sha, runner.sha)
32
- debug "Writing changed file to #{runner.main_image}"
33
- image.write runner.main_image
34
- end
35
-
36
- def annotate(image, type, string)
37
- debug("annotating #{type} to image with #{string}")
38
-
39
- transformed_position = position_transform(config_option(type, :position))
40
- annotate_location = '0'
41
- if transformed_position == 'South'
42
- annotate_location = '+0+20' # Move South gravity off the edge of the image.
43
- end
44
-
45
- string.upcase! if config_option(type, :uppercase)
46
-
47
- image.combine_options do |c|
48
- c.strokewidth runner.capture_animated? ? '1' : '2'
49
- c.interline_spacing(-(config_option(type, :size) / 5))
50
- c.stroke config_option(type, :stroke_color)
51
- c.fill config_option(type, :color)
52
- c.gravity transformed_position
53
- c.pointsize runner.capture_animated? ? (config_option(type, :size) / 2) : config_option(type, :size)
54
- c.font config_option(type, :font)
55
- c.annotate annotate_location, string
56
- end
57
- end
58
-
59
- def configure_options!
60
- options = super
61
- # ask user to configure text options when enabling
62
- if options['enabled']
63
- puts '---------------------------------------------------------------'
64
- puts ' LolText options '
65
- puts ''
66
- puts ' * any blank options will use the (default)'
67
- puts ' * always use the full absolute path to fonts'
68
- puts ' * valid text positions are NE, NW, SE, SW, S, C (centered)'
69
- puts ' * colors can be hex #FC0 value or a string \'white\''
70
- puts ' - use `none` for no stroke color'
71
- puts ' * overlay fills your image with a random color'
72
- puts ' - set one or more overlay_colors with a comma seperator'
73
- puts ' - overlay_percent (0-100) sets the fill colorize strength'
74
- puts '---------------------------------------------------------------'
75
-
76
- options[:message] = configure_sub_options(:message)
77
- options[:sha] = configure_sub_options(:sha)
78
- options[:overlay] = configure_sub_options(:overlay)
79
- end
80
- options
81
- end
82
-
83
- # TODO: consider this type of configuration prompting in the base Plugin
84
- # class, working with hash of defaults
85
- def configure_sub_options(type)
86
- print "#{type}:\n"
87
- defaults = config_defaults[type]
88
-
89
- # sort option keys since different `Hash#keys` varys across Ruby versions
90
- defaults.keys.sort_by(&:to_s).reduce({}) do |acc, opt|
91
- # if we have an enabled key set to false, abort asking for any more options
92
- if acc.key?(:enabled) && acc[:enabled] != true
93
- acc
94
- else
95
- print " #{opt.to_s.tr('_', ' ')} (#{defaults[opt]}): "
96
- val = parse_user_input(gets.chomp.strip)
97
- # handle array options (comma seperated string)
98
- if defaults[opt].is_a?(Array) && !val.nil?
99
- val = val.split(',').map(&:strip).delete_if(&:empty?)
100
- end
101
- acc.merge(opt => val)
102
- end
103
- end
104
- end
105
-
106
- def config_defaults
107
- {
108
- message: {
109
- color: 'white',
110
- font: DEFAULT_FONT_PATH,
111
- position: 'SW',
112
- size: 48,
113
- stroke_color: 'black',
114
- uppercase: false
115
- },
116
- sha: {
117
- color: 'white',
118
- font: DEFAULT_FONT_PATH,
119
- position: 'NE',
120
- size: 32,
121
- stroke_color: 'black',
122
- uppercase: false
123
- },
124
- overlay: {
125
- enabled: false,
126
- overlay_colors: [
127
- '#2e4970', '#674685', '#ca242f', '#1e7882', '#2884ae', '#4ba000',
128
- '#187296', '#7e231f', '#017d9f', '#e52d7b', '#0f5eaa', '#e40087',
129
- '#5566ac', '#ed8833', '#f8991c', '#408c93', '#ba9109'
130
- ],
131
- overlay_percent: 50
132
- }
133
- }
134
- end
135
-
136
- def config_option(type, option)
137
- default_option = config_defaults[type][option]
138
- if configuration[type]
139
- configuration[type][option] || default_option
140
- else
141
- default_option
142
- end
143
- end
144
-
145
- private
146
-
147
- # explode psuedo-names for text position
148
- def position_transform(position)
149
- case position
150
- when 'NE'
151
- 'NorthEast'
152
- when 'NW'
153
- 'NorthWest'
154
- when 'SE'
155
- 'SouthEast'
156
- when 'SW'
157
- 'SouthWest'
158
- when 'C'
159
- 'Center'
160
- when 'S'
161
- 'South'
162
- end
163
- end
164
-
165
- # do whatever is required to commit message to get it clean and ready for imagemagick
166
- def clean_msg(text)
167
- wrapped_text = word_wrap text
168
- escape_quotes wrapped_text
169
- escape_ats wrapped_text
170
- end
171
-
172
- # conversion for quotation marks to avoid shell interpretation
173
- # does not seem to be a safe way to escape cross-platform?
174
- def escape_quotes(text)
175
- text.gsub(/"/, "''")
176
- end
177
-
178
- def escape_ats(text)
179
- text.gsub(/@/, '\@')
180
- end
181
-
182
- # convenience method for word wrapping
183
- # based on https://github.com/cmdrkeene/memegen/blob/master/lib/meme_generator.rb
184
- def word_wrap(text, col = 27)
185
- wrapped = text.gsub(/(.{1,#{col + 4}})(\s+|\Z)/, "\\1\n")
186
- wrapped.chomp!
187
- end
188
- end
189
- end
190
- end
@@ -1,113 +0,0 @@
1
- # Adapted and expanded from https://github.com/rwtnorton/moar-lolspeak
2
-
3
- module Lolspeak
4
- LOL_DICTIONARY = {
5
- /what/ => %w(wut whut),
6
- /you\b/ => %w(yu yous yoo u yooz),
7
- /cture/ => %w(kshur),
8
- /ss\b/ => %w(s zz z),
9
- /the\b/ => %w(teh),
10
- /more/ => %w(moar),
11
- /my/ => %w(mah mai),
12
- /are/ => %w(is ar),
13
- /eese/ => %w(eez),
14
- /ph/ => %w(f),
15
- /as\b/ => %w(az),
16
- /seriously/ => %w(srsly),
17
- /sion/ => %w(shun),
18
- /just/ => %w(jus),
19
- /ose\b/ => %w(oze),
20
- /eady/ => %w(eddy),
21
- /ome?\b/ => %w(um),
22
- /of\b/ => %w(of ov of),
23
- /uestion/ => %w(wesjun),
24
- /want/ => %w(wants),
25
- /ead\b/ => %w(edd),
26
- /ck/ => %w(kk kkk),
27
- /cat|kitten|kitty/ => %w(kitteh kittehz cat fuzzeh fuzzyrumpus foozles fuzzbut fluffernutter beast mew),
28
- /eak/ => %w(ekk),
29
- /age/ => %w(uj),
30
- /like/ => %w(likez liek licks),
31
- /love/ => %w(lovez lub lubs luv lurve lurves),
32
- /\bis\b/ => ['ar teh', 'ar'],
33
- /nd\b/ => %w(n n'),
34
- /who/ => %w(hoo),
35
- /'/ => [''],
36
- /ese\b/ => %w(eez),
37
- /outh/ => %w(owf),
38
- /scio/ => %w(shu),
39
- /esque/ => %w(esk),
40
- /ture/ => %w(chur),
41
- /\btoo?\b/ => %w(to t 2 to t),
42
- /tious/ => %w(shus),
43
- /sure\b/ => %w(shur),
44
- /tty\b/ => %w(tteh),
45
- /were/ => %w(was),
46
- /ok\b|okay/ => %w(kthxbye!),
47
- /\ba\b/ => %w(uh),
48
- /ym/ => %w(im),
49
- /fish/ => %w(ghoti),
50
- /thy\b/ => %w(fee),
51
- /\wly\w/ => %w(li),
52
- /que\w/ => %w(kwe),
53
- /\both/ => %w(udd),
54
- /though\b/ => %w(tho),
55
- /(t|r|en)ough/ => %w(\1uff),
56
- /ought/ => %w(awt),
57
- /ease/ => %w(eez),
58
- /ing\b/ => %w(in ins ng ing in'),
59
- /have/ => ['haz', 'hav', 'haz a'],
60
- /has/ => %w(haz gots),
61
- /your/ => %w(yur ur yore yoar),
62
- /ove\b/ => %w(oov ove uuv uv oove),
63
- /for/ => %w(for 4 fr fur for foar),
64
- /thank/ => %w(fank tank thx thnx),
65
- /good/ => %w(gud goed guud gude gewd goot gut),
66
- /really/ => %w(rly rily rilly rilleh),
67
- /world/ => %w(wurrld whirld wurld wrld),
68
- /i'?m\b/ => ['im', 'i yam', 'i iz'],
69
- /(?!e)ight/ => %w(ite),
70
- /(?!ues)tion/ => %w(shun),
71
- /you'?re/ => %w(yore yr),
72
- /er\b|are|ere/ => %w(r),
73
- /y\b|ey\b/ => %w(eh),
74
- /ea/ => %w(ee),
75
- /can\si\s(?:ple(?:a|e)(?:s|z)e?)?\s?have\sa/ => ['i can haz'],
76
- /(?:hello|\bhi\b|\bhey\b|howdy|\byo\b),?/ => ['oh hai,'],
77
- /(?:god\b|allah|buddah?|diety|lord)/ => ['ceiling cat']
78
- }.freeze
79
-
80
- def tranzlate(str)
81
- lolstr = str.dup
82
- LOL_DICTIONARY.each do |english, lolspeak|
83
- lolstr.gsub!(english, lolspeak.sample)
84
- end
85
-
86
- lolstr << '! kthxbye!' if rand(10) == 2
87
- lolstr.gsub!(/(\?|!|,|\.)+/, '!')
88
-
89
- lolstr.upcase
90
- end
91
- end
92
-
93
- module Lolcommits
94
- module Plugin
95
- class Tranzlate < Base
96
- extend Lolspeak
97
-
98
- def run_precapture
99
- debug "Commit message before: #{runner.message}"
100
- runner.message = self.class.tranzlate(runner.message)
101
- debug "Commit message after: #{runner.message}"
102
- end
103
-
104
- def self.name
105
- 'tranzlate'
106
- end
107
-
108
- def self.runner_order
109
- :precapture
110
- end
111
- end
112
- end
113
- end
Binary file