acmcommits 0.0.1
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 +12 -0
- data/.travis.yml +20 -0
- data/CHANGELOG +99 -0
- data/CONTRIBUTING +11 -0
- data/Gemfile +4 -0
- data/LICENSE +165 -0
- data/README.md +74 -0
- data/Rakefile +69 -0
- data/acmcommits.gemspec +39 -0
- data/bin/lolcommits +309 -0
- data/features/bugs.feature +58 -0
- data/features/lolcommits.feature +147 -0
- data/features/plugins.feature +34 -0
- data/features/step_definitions/lolcommits_steps.rb +98 -0
- data/features/support/env.rb +94 -0
- data/lib/core_ext/class.rb +7 -0
- data/lib/lolcommits/capture_fake.rb +10 -0
- data/lib/lolcommits/capture_linux.rb +28 -0
- data/lib/lolcommits/capture_mac.rb +19 -0
- data/lib/lolcommits/capture_windows.rb +18 -0
- data/lib/lolcommits/capturer.rb +13 -0
- data/lib/lolcommits/configuration.rb +160 -0
- data/lib/lolcommits/git_info.rb +27 -0
- data/lib/lolcommits/plugin.rb +40 -0
- data/lib/lolcommits/plugins/lolsrv.rb +73 -0
- data/lib/lolcommits/plugins/loltext.rb +79 -0
- data/lib/lolcommits/plugins/statsd.rb +25 -0
- data/lib/lolcommits/runner.rb +97 -0
- data/lib/lolcommits/version.rb +3 -0
- data/lib/lolcommits.rb +27 -0
- data/test/images/test_image.jpg +0 -0
- data/test/test_lolcommits.rb +49 -0
- data/vendor/ext/CommandCam/COPYING +674 -0
- data/vendor/ext/CommandCam/CommandCam.exe +0 -0
- data/vendor/ext/CommandCam/LICENSE +16 -0
- data/vendor/ext/imagesnap/ReadMeOrDont.rtf +117 -0
- data/vendor/ext/imagesnap/imagesnap +0 -0
- data/vendor/fonts/Impact.ttf +0 -0
- metadata +228 -0
@@ -0,0 +1,97 @@
|
|
1
|
+
module Lolcommits
|
2
|
+
PLUGINS = Lolcommits::Plugin.subclasses
|
3
|
+
|
4
|
+
class Runner
|
5
|
+
attr_accessor :capture_delay, :capture_device, :message, :sha,
|
6
|
+
:snapshot_loc, :main_image, :repo, :config, :repo_internal_path,
|
7
|
+
:font
|
8
|
+
|
9
|
+
include Methadone::CLILogging
|
10
|
+
include ActiveSupport::Callbacks
|
11
|
+
define_callbacks :run
|
12
|
+
set_callback :run, :before, :execute_lolcommits_tranzlate
|
13
|
+
|
14
|
+
# Executed Last
|
15
|
+
set_callback :run, :after, :cleanup!
|
16
|
+
set_callback :run, :after, :execute_lolcommits_lolsrv
|
17
|
+
set_callback :run, :after, :execute_lolcommits_stats_d
|
18
|
+
set_callback :run, :after, :execute_lolcommits_loltext
|
19
|
+
# Executed First
|
20
|
+
|
21
|
+
def initialize(attributes={})
|
22
|
+
attributes.each do |attr, val|
|
23
|
+
self.send("#{attr}=", val)
|
24
|
+
end
|
25
|
+
|
26
|
+
if self.sha.nil? || self.message.nil?
|
27
|
+
git_info = GitInfo.new
|
28
|
+
self.sha = git_info.sha if self.sha.nil?
|
29
|
+
self.message = git_info.message if self.message.nil?
|
30
|
+
self.repo_internal_path = git_info.repo_internal_path
|
31
|
+
self.repo = git_info.repo
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def run
|
36
|
+
die_if_rebasing!
|
37
|
+
|
38
|
+
run_callbacks :run do
|
39
|
+
puts "*** Preserving this moment in history."
|
40
|
+
self.snapshot_loc = self.config.raw_image
|
41
|
+
self.main_image = self.config.main_image(self.sha)
|
42
|
+
capturer = "Lolcommits::Capture#{Configuration.platform}".constantize.new(
|
43
|
+
:capture_device => self.capture_device,
|
44
|
+
:capture_delay => self.capture_delay,
|
45
|
+
:snapshot_location => self.snapshot_loc,
|
46
|
+
:font => self.font
|
47
|
+
)
|
48
|
+
capturer.capture
|
49
|
+
resize_snapshot!
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
protected
|
55
|
+
def die_if_rebasing!
|
56
|
+
debug "Runner: Making sure user isn't rebasing"
|
57
|
+
if not self.repo_internal_path.nil?
|
58
|
+
mergeclue = File.join self.repo_internal_path, "rebase-merge"
|
59
|
+
if File.directory? mergeclue
|
60
|
+
debug "Runner: Rebase detected, silently exiting!"
|
61
|
+
exit 0
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def resize_snapshot!
|
67
|
+
debug "Runner: resizing snapshot"
|
68
|
+
image = MiniMagick::Image.open(self.snapshot_loc)
|
69
|
+
if (image[:width] > 640 || image[:height] > 480)
|
70
|
+
#this is ghetto resize-to-fill
|
71
|
+
image.combine_options do |c|
|
72
|
+
c.resize '640x480^'
|
73
|
+
c.gravity 'center'
|
74
|
+
c.extent '640x480'
|
75
|
+
end
|
76
|
+
debug "Runner: writing resized image to #{self.snapshot_loc}"
|
77
|
+
image.write self.snapshot_loc
|
78
|
+
end
|
79
|
+
debug "Runner: copying resized image to #{self.main_image}"
|
80
|
+
FileUtils.cp(self.snapshot_loc, self.main_image)
|
81
|
+
end
|
82
|
+
|
83
|
+
def cleanup!
|
84
|
+
debug "Runner: running cleanup"
|
85
|
+
#clean up the captured image
|
86
|
+
FileUtils.rm(self.snapshot_loc)
|
87
|
+
end
|
88
|
+
|
89
|
+
# register a method called "execute_lolcommits_#{plugin_name}"
|
90
|
+
# for each subclass of plugin. these methods should be used as
|
91
|
+
# callbacks to the run method.
|
92
|
+
Lolcommits::PLUGINS.each do |plugin|
|
93
|
+
define_method "execute_#{plugin.to_s.underscore.gsub('/', '_')}" do
|
94
|
+
plugin.new(self).execute
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
data/lib/lolcommits.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
$:.unshift File.expand_path('.')
|
2
|
+
|
3
|
+
require 'core_ext/class'
|
4
|
+
require 'mini_magick'
|
5
|
+
require 'fileutils'
|
6
|
+
require 'git'
|
7
|
+
require 'open3'
|
8
|
+
require 'active_support/inflector'
|
9
|
+
require 'active_support/concern'
|
10
|
+
require 'active_support/callbacks'
|
11
|
+
require 'methadone'
|
12
|
+
|
13
|
+
require 'lolcommits/version'
|
14
|
+
require 'lolcommits/configuration'
|
15
|
+
require 'lolcommits/capturer'
|
16
|
+
require 'lolcommits/capture_mac'
|
17
|
+
require 'lolcommits/capture_linux'
|
18
|
+
require 'lolcommits/capture_windows'
|
19
|
+
require 'lolcommits/capture_fake'
|
20
|
+
require 'lolcommits/git_info'
|
21
|
+
require 'lolcommits/plugin'
|
22
|
+
require 'lolcommits/plugins/loltext'
|
23
|
+
require 'lolcommits/plugins/statsd'
|
24
|
+
require 'lolcommits/plugins/lolsrv'
|
25
|
+
|
26
|
+
# require runner after all the plugins have been required
|
27
|
+
require 'lolcommits/runner'
|
Binary file
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
# Loads lolcommits directly from the lib folder so don't have to create
|
3
|
+
# a gem before testing
|
4
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
5
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
6
|
+
require 'lolcommits'
|
7
|
+
|
8
|
+
include Lolcommits
|
9
|
+
|
10
|
+
class LolTest < Test::Unit::TestCase
|
11
|
+
def test_can_parse_git
|
12
|
+
assert_nothing_raised do
|
13
|
+
gi = GitInfo.new
|
14
|
+
assert_not_nil gi.message
|
15
|
+
assert_not_nil gi.sha
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
#
|
20
|
+
# issue #57, https://github.com/mroth/lolcommits/issues/57
|
21
|
+
#
|
22
|
+
# def test_tranzlate
|
23
|
+
# [["what the hell","(WH|W)UT TEH HELL"],["seriously wtf", "SRSLEH WTF"]].each do |normal, lol|
|
24
|
+
# tranzlated = normal.tranzlate
|
25
|
+
# assert_match /^#{lol}/, tranzlated
|
26
|
+
# end
|
27
|
+
# end
|
28
|
+
|
29
|
+
#
|
30
|
+
# issue #53, https://github.com/mroth/lolcommits/issues/53
|
31
|
+
# this will test the permissions but only locally, important before building a gem package!
|
32
|
+
#
|
33
|
+
def test_permissions
|
34
|
+
impact_perms = File.lstat(File.join(Configuration::LOLCOMMITS_ROOT, "vendor", "fonts", "Impact.ttf")).mode & 0777
|
35
|
+
imagesnap_perms = File.lstat(File.join(Configuration::LOLCOMMITS_ROOT, "vendor", "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}"
|
40
|
+
end
|
41
|
+
|
42
|
+
# Hmm.. webcam capture breaks travis-ci tests
|
43
|
+
#def test_can_capture
|
44
|
+
# assert_nothing_raised do
|
45
|
+
# Lolcommits.capture(0,true,'test commit message','test-sha-001')
|
46
|
+
# end
|
47
|
+
#end
|
48
|
+
|
49
|
+
end
|