lolcommits 0.2.0 → 0.3.0.pre1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +2 -0
- data/.travis.yml +7 -2
- data/CHANGELOG +4 -0
- data/NOTES +17 -0
- data/README.md +6 -3
- data/Rakefile +4 -1
- data/bin/lolcommits +91 -22
- data/features/bugs.feature +30 -0
- data/features/lolcommits.feature +126 -12
- data/features/plugins.feature +33 -0
- data/features/step_definitions/lolcommits_steps.rb +37 -0
- data/features/support/env.rb +27 -7
- data/lib/core_ext/class.rb +7 -0
- data/lib/lolcommits.rb +24 -178
- data/lib/lolcommits/capture_fake.rb +10 -0
- data/lib/lolcommits/capture_linux.rb +20 -0
- data/lib/lolcommits/capture_mac.rb +17 -0
- data/lib/lolcommits/capture_windows.rb +18 -0
- data/lib/lolcommits/capturer.rb +10 -0
- data/lib/lolcommits/configuration.rb +128 -0
- data/lib/lolcommits/git_info.rb +12 -0
- data/lib/lolcommits/plugin.rb +29 -0
- data/lib/lolcommits/plugins/dot_com.rb +32 -0
- data/lib/lolcommits/plugins/loltext.rb +45 -0
- data/lib/lolcommits/plugins/tranzlate.rb +16 -0
- data/lib/lolcommits/runner.rb +71 -0
- data/lib/lolcommits/version.rb +1 -1
- data/lolcommits.gemspec +4 -1
- data/test/test_lolcommits.rb +9 -3
- metadata +59 -9
@@ -0,0 +1,29 @@
|
|
1
|
+
module Lolcommits
|
2
|
+
class Plugin
|
3
|
+
attr_accessor :default, :name, :runner, :options
|
4
|
+
|
5
|
+
def configuration
|
6
|
+
config = runner.config.user_configuration
|
7
|
+
return Hash.new if config.nil?
|
8
|
+
config[self.name] || Hash.new
|
9
|
+
end
|
10
|
+
|
11
|
+
def initialize(runner)
|
12
|
+
self.runner = runner
|
13
|
+
self.options = ['enabled']
|
14
|
+
end
|
15
|
+
|
16
|
+
def is_enabled?
|
17
|
+
enabled_config = configuration['enabled']
|
18
|
+
return self.default if enabled_config.nil? || enabled_config == ''
|
19
|
+
return enabled_config
|
20
|
+
end
|
21
|
+
|
22
|
+
|
23
|
+
def execute
|
24
|
+
if is_enabled?
|
25
|
+
run
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'httmultiparty'
|
2
|
+
|
3
|
+
module Lolcommits
|
4
|
+
class DotCom < Plugin
|
5
|
+
def initialize(runner)
|
6
|
+
super
|
7
|
+
|
8
|
+
self.name = 'dot_com'
|
9
|
+
self.default = false
|
10
|
+
self.options.concat(['api_key', 'api_secret', 'repo_id'])
|
11
|
+
end
|
12
|
+
|
13
|
+
def run
|
14
|
+
t = Time.now.to_i.to_s
|
15
|
+
resp = HTTMultiParty.post('http://www.lolcommits.com/git_commits.json',
|
16
|
+
:body => {
|
17
|
+
:git_commit => {
|
18
|
+
:sha => self.runner.sha,
|
19
|
+
:repo_external_id => configuration['repo_id'],
|
20
|
+
:image => File.open(self.runner.main_image),
|
21
|
+
:raw => File.open(self.runner.snapshot_loc)
|
22
|
+
},
|
23
|
+
|
24
|
+
:key => configuration['api_key'],
|
25
|
+
:t => t,
|
26
|
+
:token => Digest::SHA1.hexdigest(configuration['api_secret'] + t)
|
27
|
+
}
|
28
|
+
)
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module Lolcommits
|
2
|
+
class Loltext < Plugin
|
3
|
+
include Magick
|
4
|
+
|
5
|
+
def initialize(runner)
|
6
|
+
super
|
7
|
+
|
8
|
+
self.name = 'loltext'
|
9
|
+
self.default = true
|
10
|
+
end
|
11
|
+
|
12
|
+
def run
|
13
|
+
canvas = ImageList.new(self.runner.main_image)
|
14
|
+
draw = Magick::Draw.new
|
15
|
+
draw.font = File.join(Configuration::LOLCOMMITS_ROOT, "fonts", "Impact.ttf")
|
16
|
+
|
17
|
+
draw.fill = 'white'
|
18
|
+
draw.stroke = 'black'
|
19
|
+
|
20
|
+
draw.annotate(canvas, 0, 0, 0, 0, self.runner.sha) do
|
21
|
+
self.gravity = NorthEastGravity
|
22
|
+
self.pointsize = 32
|
23
|
+
self.stroke_width = 2
|
24
|
+
end
|
25
|
+
|
26
|
+
draw.annotate(canvas, 0, 0, 0, 0, word_wrap(self.runner.message)) do
|
27
|
+
self.gravity = SouthWestGravity
|
28
|
+
self.pointsize = 48
|
29
|
+
self.interline_spacing = -(48 / 5) if self.respond_to?(:interline_spacing)
|
30
|
+
self.stroke_width = 2
|
31
|
+
end
|
32
|
+
|
33
|
+
canvas.write(runner.main_image)
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
# convenience method for word wrapping
|
39
|
+
# based on https://github.com/cmdrkeene/memegen/blob/master/lib/meme_generator.rb
|
40
|
+
def word_wrap(text, col = 27)
|
41
|
+
wrapped = text.gsub(/(.{1,#{col + 4}})(\s+|\Z)/, "\\1\n")
|
42
|
+
wrapped.chomp!
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require "tranzlate/lolspeak"
|
2
|
+
|
3
|
+
module Lolcommits
|
4
|
+
class Tranzlate < Plugin
|
5
|
+
def initialize(runner)
|
6
|
+
super
|
7
|
+
|
8
|
+
self.name = 'tranzlate'
|
9
|
+
self.default = false
|
10
|
+
end
|
11
|
+
|
12
|
+
def run
|
13
|
+
self.runner.message = self.runner.message.tranzlate
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
module Lolcommits
|
2
|
+
PLUGINS = Lolcommits::Plugin.subclasses
|
3
|
+
include Magick
|
4
|
+
|
5
|
+
class Runner
|
6
|
+
attr_accessor :capture_delay, :capture_device, :message, :sha,
|
7
|
+
:snapshot_loc, :main_image, :repo, :config
|
8
|
+
|
9
|
+
include ActiveSupport::Callbacks
|
10
|
+
define_callbacks :run
|
11
|
+
set_callback :run, :before, :execute_lolcommits_tranzlate
|
12
|
+
|
13
|
+
# Executed Last
|
14
|
+
set_callback :run, :after, :cleanup!
|
15
|
+
set_callback :run, :after, :execute_lolcommits_dot_com
|
16
|
+
set_callback :run, :after, :execute_lolcommits_loltext
|
17
|
+
# Executed First
|
18
|
+
|
19
|
+
def initialize(attributes={})
|
20
|
+
attributes.each do |attr, val|
|
21
|
+
self.send("#{attr}=", val)
|
22
|
+
end
|
23
|
+
|
24
|
+
if self.sha.nil? || self.message.nil?
|
25
|
+
git_info = GitInfo.new
|
26
|
+
self.sha = git_info.sha if self.sha.nil?
|
27
|
+
self.message = git_info.message if self.message.nil?
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def run
|
32
|
+
run_callbacks :run do
|
33
|
+
puts "*** Preserving this moment in history."
|
34
|
+
self.snapshot_loc = self.config.raw_image
|
35
|
+
self.main_image = self.config.main_image(self.sha)
|
36
|
+
capturer = "Lolcommits::Capture#{Configuration.platform}".constantize.new(
|
37
|
+
:capture_device => self.capture_device,
|
38
|
+
:capture_delay => self.capture_delay,
|
39
|
+
:snapshot_location => self.snapshot_loc
|
40
|
+
)
|
41
|
+
capturer.capture
|
42
|
+
resize_snapshot!
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
protected
|
48
|
+
|
49
|
+
def resize_snapshot!
|
50
|
+
canvas = ImageList.new(self.snapshot_loc)
|
51
|
+
if (canvas.columns > 640 || canvas.rows > 480)
|
52
|
+
canvas.resize_to_fill!(640,480)
|
53
|
+
end
|
54
|
+
canvas.write(self.snapshot_loc)
|
55
|
+
FileUtils.cp(self.snapshot_loc, self.main_image)
|
56
|
+
end
|
57
|
+
|
58
|
+
def cleanup!
|
59
|
+
#clean up the captured image
|
60
|
+
FileUtils.rm(self.snapshot_loc)
|
61
|
+
end
|
62
|
+
|
63
|
+
# register a method called "execute_lolcommits_#{plugin_name}"
|
64
|
+
# for each subclass of plugin. these methods should be used as
|
65
|
+
# callbacks to the run method.
|
66
|
+
Lolcommits::PLUGINS.each do |plugin|
|
67
|
+
define_method "execute_#{plugin.to_s.underscore.gsub('/', '_')}" do
|
68
|
+
plugin.new(self).execute
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
data/lib/lolcommits/version.rb
CHANGED
data/lolcommits.gemspec
CHANGED
@@ -21,10 +21,13 @@ Gem::Specification.new do |s|
|
|
21
21
|
s.add_runtime_dependency('rmagick', '~> 2.13.1')
|
22
22
|
s.add_runtime_dependency('git', '~> 1.2.5')
|
23
23
|
s.add_runtime_dependency('choice', '~> 0.1.6')
|
24
|
-
s.add_runtime_dependency('launchy')
|
24
|
+
s.add_runtime_dependency('launchy', '~> 2.1.1')
|
25
25
|
|
26
26
|
s.add_development_dependency('rdoc')
|
27
27
|
s.add_development_dependency('aruba')
|
28
28
|
s.add_development_dependency('rake','~> 0.9.2')
|
29
|
+
|
29
30
|
s.add_dependency('methadone', '~>1.2.1')
|
31
|
+
s.add_runtime_dependency('httmultiparty')
|
32
|
+
s.add_runtime_dependency('active_support')
|
30
33
|
end
|
data/test/test_lolcommits.rb
CHANGED
@@ -10,7 +10,9 @@ include Lolcommits
|
|
10
10
|
class LolTest < Test::Unit::TestCase
|
11
11
|
def test_can_parse_git
|
12
12
|
assert_nothing_raised do
|
13
|
-
|
13
|
+
gi = GitInfo.new
|
14
|
+
assert_not_nil gi.message
|
15
|
+
assert_not_nil gi.sha
|
14
16
|
end
|
15
17
|
end
|
16
18
|
|
@@ -29,8 +31,12 @@ class LolTest < Test::Unit::TestCase
|
|
29
31
|
# this will test the permissions but only locally, important before building a gem package!
|
30
32
|
#
|
31
33
|
def test_permissions
|
32
|
-
|
33
|
-
|
34
|
+
impact_perms = File.lstat(File.join(Configuration::LOLCOMMITS_ROOT, "fonts", "Impact.ttf")).mode & 0777
|
35
|
+
imagesnap_perms = File.lstat(File.join(Configuration::LOLCOMMITS_ROOT, "ext", "imagesnap", "imagesnap")).mode & 0777
|
36
|
+
assert impact_perms == 0644 || impact_perms == 0664,
|
37
|
+
"expected perms of 644/664 but instead got #{sprintf '%o', impact_perms}"
|
38
|
+
assert imagesnap_perms == 0755 || imagesnap_perms == 0775,
|
39
|
+
"expected perms of 755/775 but instead got #{sprintf '%o', imagesnap_perms}"
|
34
40
|
end
|
35
41
|
|
36
42
|
# Hmm.. webcam capture breaks travis-ci tests
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lolcommits
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.3.0.pre1
|
5
|
+
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Matthew Rothenberg
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-07-
|
12
|
+
date: 2012-07-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rmagick
|
@@ -64,17 +64,17 @@ dependencies:
|
|
64
64
|
requirement: !ruby/object:Gem::Requirement
|
65
65
|
none: false
|
66
66
|
requirements:
|
67
|
-
- -
|
67
|
+
- - ~>
|
68
68
|
- !ruby/object:Gem::Version
|
69
|
-
version:
|
69
|
+
version: 2.1.1
|
70
70
|
type: :runtime
|
71
71
|
prerelease: false
|
72
72
|
version_requirements: !ruby/object:Gem::Requirement
|
73
73
|
none: false
|
74
74
|
requirements:
|
75
|
-
- -
|
75
|
+
- - ~>
|
76
76
|
- !ruby/object:Gem::Version
|
77
|
-
version:
|
77
|
+
version: 2.1.1
|
78
78
|
- !ruby/object:Gem::Dependency
|
79
79
|
name: rdoc
|
80
80
|
requirement: !ruby/object:Gem::Requirement
|
@@ -139,6 +139,38 @@ dependencies:
|
|
139
139
|
- - ~>
|
140
140
|
- !ruby/object:Gem::Version
|
141
141
|
version: 1.2.1
|
142
|
+
- !ruby/object:Gem::Dependency
|
143
|
+
name: httmultiparty
|
144
|
+
requirement: !ruby/object:Gem::Requirement
|
145
|
+
none: false
|
146
|
+
requirements:
|
147
|
+
- - ! '>='
|
148
|
+
- !ruby/object:Gem::Version
|
149
|
+
version: '0'
|
150
|
+
type: :runtime
|
151
|
+
prerelease: false
|
152
|
+
version_requirements: !ruby/object:Gem::Requirement
|
153
|
+
none: false
|
154
|
+
requirements:
|
155
|
+
- - ! '>='
|
156
|
+
- !ruby/object:Gem::Version
|
157
|
+
version: '0'
|
158
|
+
- !ruby/object:Gem::Dependency
|
159
|
+
name: active_support
|
160
|
+
requirement: !ruby/object:Gem::Requirement
|
161
|
+
none: false
|
162
|
+
requirements:
|
163
|
+
- - ! '>='
|
164
|
+
- !ruby/object:Gem::Version
|
165
|
+
version: '0'
|
166
|
+
type: :runtime
|
167
|
+
prerelease: false
|
168
|
+
version_requirements: !ruby/object:Gem::Requirement
|
169
|
+
none: false
|
170
|
+
requirements:
|
171
|
+
- - ! '>='
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0'
|
142
174
|
description: Takes a snapshot with your Mac's built-in iSight/FaceTime webcam (or
|
143
175
|
any working webcam on Linux or Windows) every time you git commit code, and archives
|
144
176
|
a lolcat style image with it.
|
@@ -154,6 +186,7 @@ files:
|
|
154
186
|
- CHANGELOG
|
155
187
|
- Gemfile
|
156
188
|
- LICENSE
|
189
|
+
- NOTES
|
157
190
|
- README.md
|
158
191
|
- Rakefile
|
159
192
|
- bin/lolcommits
|
@@ -162,11 +195,26 @@ files:
|
|
162
195
|
- ext/CommandCam/LICENSE
|
163
196
|
- ext/imagesnap/ReadMeOrDont.rtf
|
164
197
|
- ext/imagesnap/imagesnap
|
198
|
+
- features/bugs.feature
|
165
199
|
- features/lolcommits.feature
|
200
|
+
- features/plugins.feature
|
166
201
|
- features/step_definitions/lolcommits_steps.rb
|
167
202
|
- features/support/env.rb
|
168
203
|
- fonts/Impact.ttf
|
204
|
+
- lib/core_ext/class.rb
|
169
205
|
- lib/lolcommits.rb
|
206
|
+
- lib/lolcommits/capture_fake.rb
|
207
|
+
- lib/lolcommits/capture_linux.rb
|
208
|
+
- lib/lolcommits/capture_mac.rb
|
209
|
+
- lib/lolcommits/capture_windows.rb
|
210
|
+
- lib/lolcommits/capturer.rb
|
211
|
+
- lib/lolcommits/configuration.rb
|
212
|
+
- lib/lolcommits/git_info.rb
|
213
|
+
- lib/lolcommits/plugin.rb
|
214
|
+
- lib/lolcommits/plugins/dot_com.rb
|
215
|
+
- lib/lolcommits/plugins/loltext.rb
|
216
|
+
- lib/lolcommits/plugins/tranzlate.rb
|
217
|
+
- lib/lolcommits/runner.rb
|
170
218
|
- lib/lolcommits/version.rb
|
171
219
|
- lib/tranzlate/lolspeak.rb
|
172
220
|
- lolcommits.gemspec
|
@@ -188,9 +236,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
188
236
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
189
237
|
none: false
|
190
238
|
requirements:
|
191
|
-
- - ! '
|
239
|
+
- - ! '>'
|
192
240
|
- !ruby/object:Gem::Version
|
193
|
-
version:
|
241
|
+
version: 1.3.1
|
194
242
|
requirements: []
|
195
243
|
rubyforge_project: lolcommits
|
196
244
|
rubygems_version: 1.8.23
|
@@ -198,7 +246,9 @@ signing_key:
|
|
198
246
|
specification_version: 3
|
199
247
|
summary: Capture webcam image on git commit for lulz.
|
200
248
|
test_files:
|
249
|
+
- features/bugs.feature
|
201
250
|
- features/lolcommits.feature
|
251
|
+
- features/plugins.feature
|
202
252
|
- features/step_definitions/lolcommits_steps.rb
|
203
253
|
- features/support/env.rb
|
204
254
|
- test/images/test_image.jpg
|