lolcommits 0.5.7 → 0.5.8.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.
- checksums.yaml +8 -8
- data/.rubocop.yml +1 -0
- data/.rubocop_todo.yml +16 -161
- data/.travis.yml +11 -4
- data/Gemfile +2 -2
- data/Rakefile +24 -32
- data/bin/lolcommits +62 -125
- data/features/bugs.feature +24 -9
- data/features/lolcommits.feature +136 -145
- data/features/plugins.feature +16 -33
- data/features/step_definitions/lolcommits_steps.rb +91 -71
- data/features/support/env.rb +18 -48
- data/features/support/path_helpers.rb +9 -8
- data/lib/lolcommits.rb +3 -10
- data/lib/lolcommits/capturer.rb +10 -2
- data/lib/lolcommits/capturer/capture_linux.rb +1 -1
- data/lib/lolcommits/capturer/capture_linux_animated.rb +12 -13
- data/lib/lolcommits/capturer/capture_mac_animated.rb +12 -13
- data/lib/lolcommits/cli/fatals.rb +77 -0
- data/lib/lolcommits/cli/launcher.rb +29 -0
- data/lib/lolcommits/cli/process_runner.rb +48 -0
- data/lib/lolcommits/cli/timelapse_gif.rb +45 -0
- data/lib/lolcommits/configuration.rb +30 -133
- data/lib/lolcommits/git_info.rb +58 -28
- data/lib/lolcommits/installation.rb +11 -21
- data/lib/lolcommits/platform.rb +134 -0
- data/lib/lolcommits/plugin.rb +2 -2
- data/lib/lolcommits/plugins/dot_com.rb +15 -15
- data/lib/lolcommits/plugins/lol_protonet.rb +68 -0
- data/lib/lolcommits/plugins/lol_twitter.rb +12 -15
- data/lib/lolcommits/plugins/lol_yammer.rb +4 -6
- data/lib/lolcommits/plugins/lolsrv.rb +8 -11
- data/lib/lolcommits/plugins/loltext.rb +7 -7
- data/lib/lolcommits/plugins/tranzlate.rb +70 -70
- data/lib/lolcommits/plugins/uploldz.rb +8 -8
- data/lib/lolcommits/runner.rb +36 -35
- data/lib/lolcommits/version.rb +1 -1
- data/lolcommits.gemspec +11 -10
- data/test/lolcommits_test.rb +35 -0
- data/test/plugins_test.rb +52 -0
- metadata +41 -20
- data/test/test_lolcommits.rb +0 -78
data/features/plugins.feature
CHANGED
@@ -1,37 +1,20 @@
|
|
1
1
|
Feature: Plugins Work
|
2
2
|
|
3
|
+
Background:
|
4
|
+
Given a mocked home directory
|
5
|
+
|
3
6
|
@slow_process @unstable
|
4
7
|
Scenario: Lolcommits.com integration works
|
5
|
-
Given I am in a git
|
6
|
-
When I run `lolcommits --config`
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
Given I am in a git repository named "loltext" with lolcommits enabled
|
19
|
-
And I run `lolcommits --config` and wait for output
|
20
|
-
And I enter "loltext" for "Plugin Name"
|
21
|
-
And I enter "false" for "enabled"
|
22
|
-
Then I should be presented "Successfully configured plugin: loltext"
|
23
|
-
When I do a git commit
|
24
|
-
Then the output should contain "*** Preserving this moment in history."
|
25
|
-
And there should be exactly 1 jpg in "../.lolcommits/loltext"
|
26
|
-
|
27
|
-
Scenario: lolsrv integration works
|
28
|
-
Given I am in a git repository named "lolsrv" with lolcommits enabled
|
29
|
-
When I run `lolcommits --config` and wait for output
|
30
|
-
And I enter "lolsrv" for "Plugin Name"
|
31
|
-
And I enter "true" for "enabled"
|
32
|
-
And I enter "http://localhost" for "server"
|
33
|
-
Then I should be presented "Successfully configured plugin: lolsrv"
|
34
|
-
When I do a git commit
|
35
|
-
Then the output should contain "*** Preserving this moment in history."
|
36
|
-
And there should be exactly 1 jpg in "../.lolcommits/lolsrv"
|
37
|
-
|
8
|
+
Given I am in a git repo named "dot_com" with lolcommits enabled
|
9
|
+
When I run `lolcommits --config` interactively
|
10
|
+
And I wait for output to contain "Name of plugin to configure:"
|
11
|
+
Then I type "dot_com"
|
12
|
+
And I wait for output to contain "enabled:"
|
13
|
+
Then I type "true"
|
14
|
+
And I wait for output to contain "api_key:"
|
15
|
+
Then I type "b2a70ac0b64e012fa61522000a8c42dc"
|
16
|
+
And I wait for output to contain "api_secret:"
|
17
|
+
Then I type "b2a70ac0b64e012fa61522000a8c42dc"
|
18
|
+
And I wait for output to contain "repo_id:"
|
19
|
+
Then I type "b2a70ac0b64e012fa61522000a8c42dc"
|
20
|
+
Then the output should contain "Successfully configured plugin: dot_com"
|
@@ -1,122 +1,142 @@
|
|
1
1
|
# -*- encoding : utf-8 -*-
|
2
|
-
|
2
|
+
require 'fileutils'
|
3
|
+
require 'aruba/api'
|
3
4
|
|
4
|
-
|
5
|
-
|
5
|
+
def postcommit_hook
|
6
|
+
'.git/hooks/post-commit'
|
7
|
+
end
|
8
|
+
|
9
|
+
def default_repo
|
10
|
+
'mygit'
|
11
|
+
end
|
12
|
+
|
13
|
+
def default_loldir
|
14
|
+
absolute_path("~/.lolcommits/#{default_repo}")
|
15
|
+
end
|
16
|
+
|
17
|
+
Given(/^I am in a directory named "(.*?)"$/) do |dir_name|
|
18
|
+
steps %(
|
6
19
|
Given a directory named "#{dir_name}"
|
7
20
|
And I cd to "#{dir_name}"
|
8
|
-
|
21
|
+
)
|
9
22
|
end
|
10
23
|
|
11
|
-
Given
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
system 'git init --quiet .'
|
16
|
-
system "git config user.name 'Testy McTesterson'"
|
17
|
-
system "git config user.email 'testy@tester.com'"
|
18
|
-
end
|
24
|
+
Given(/^a git repo named "(.*?)"$/) do |repo_name|
|
25
|
+
steps %(
|
26
|
+
Given I successfully run `git init --quiet "#{repo_name}"`
|
27
|
+
)
|
19
28
|
end
|
20
29
|
|
21
|
-
Given
|
22
|
-
|
23
|
-
|
30
|
+
Given(/^I am in a git repo named "(.*?)"$/) do |repo|
|
31
|
+
steps %(
|
32
|
+
Given a git repo named "#{repo}"
|
33
|
+
And I cd to "#{repo}"
|
34
|
+
)
|
24
35
|
end
|
25
36
|
|
26
|
-
Given
|
27
|
-
|
28
|
-
|
37
|
+
Given(/^I am in a git repo$/) do
|
38
|
+
steps %(
|
39
|
+
Given I am in a git repo named "#{default_repo}"
|
40
|
+
)
|
29
41
|
end
|
30
42
|
|
31
|
-
Given
|
32
|
-
|
33
|
-
|
34
|
-
|
43
|
+
Given(/^I am in a git repo named "(.*?)" with lolcommits enabled$/) do |repo|
|
44
|
+
steps %(
|
45
|
+
Given I am in a git repo named "#{repo}"
|
46
|
+
And I successfully run `lolcommits --enable`
|
47
|
+
)
|
35
48
|
end
|
36
49
|
|
37
|
-
Given
|
38
|
-
|
39
|
-
|
50
|
+
Given(/^I am in a git repo with lolcommits enabled$/) do
|
51
|
+
steps %(
|
52
|
+
Given I am in a git repo named "#{default_repo}" with lolcommits enabled
|
53
|
+
)
|
40
54
|
end
|
41
55
|
|
42
|
-
Given
|
43
|
-
steps %
|
44
|
-
Given a
|
45
|
-
|
46
|
-
|
56
|
+
Given(/^a post\-commit hook with "(.*?)"$/) do |file_content|
|
57
|
+
steps %(
|
58
|
+
Given a file named "#{postcommit_hook}" with:
|
59
|
+
"""
|
60
|
+
#{file_content}
|
61
|
+
"""
|
62
|
+
)
|
47
63
|
end
|
48
64
|
|
49
|
-
|
50
|
-
steps %
|
51
|
-
|
52
|
-
|
53
|
-
|
65
|
+
Then(/^the lolcommits post\-commit hook should be properly installed$/) do
|
66
|
+
steps %(
|
67
|
+
Then the post-commit hook should contain "lolcommits --capture"
|
68
|
+
)
|
69
|
+
end
|
70
|
+
|
71
|
+
Then(/^the post\-commit hook (should|should not) contain "(.*?)"$/) do |should, content|
|
72
|
+
steps %(
|
73
|
+
Then the file "#{postcommit_hook}" #{should} contain "#{content}"
|
74
|
+
)
|
54
75
|
end
|
55
76
|
|
56
|
-
Given
|
77
|
+
Given(/^I have environment variable (.*?) set to (.*?)$/) do |var, value|
|
57
78
|
set_env var, value
|
58
79
|
end
|
59
80
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
81
|
+
Given(/^its loldir has (\d+) lolimages$/) do |num_images|
|
82
|
+
steps %(
|
83
|
+
Given a loldir named "#{default_repo}" with #{num_images} lolimages
|
84
|
+
)
|
64
85
|
end
|
65
86
|
|
66
|
-
Given
|
67
|
-
loldir = "
|
68
|
-
mkdir_p loldir
|
87
|
+
Given(/^a loldir named "(.*?)" with (\d+) lolimages$/) do |repo, num_images|
|
88
|
+
loldir = absolute_path("~/.lolcommits/#{repo}")
|
89
|
+
FileUtils.mkdir_p loldir
|
69
90
|
num_images.to_i.times do
|
70
|
-
|
71
|
-
cp 'test/images/test_image.jpg', File.join(loldir, "#{
|
91
|
+
hex = "#{format '%011x', (rand * 0xfffffffffff)}"
|
92
|
+
FileUtils.cp 'test/images/test_image.jpg', File.join(loldir, "#{hex}.jpg")
|
72
93
|
end
|
73
94
|
end
|
74
95
|
|
75
|
-
Then
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
When /^I enter "(.*?)" for "(.*?)"$/ do |input, field|
|
80
|
-
@fields[field] = input
|
81
|
-
@stdin.puts input
|
96
|
+
Then(/^there should be exactly (.*?) (jpg|gif|pid)s? in its loldir$/) do |n, type|
|
97
|
+
steps %(
|
98
|
+
Then there should be exactly #{n} #{type} in "#{default_loldir}"
|
99
|
+
)
|
82
100
|
end
|
83
101
|
|
84
|
-
Then
|
85
|
-
|
102
|
+
Then(/^there should be exactly (.*?) (jpg|gif|pid)s? in "(.*?)"$/) do |n, type, folder|
|
103
|
+
expect(Dir[absolute_path(folder, "*.#{type}")].count).to eq(n.to_i)
|
86
104
|
end
|
87
105
|
|
88
|
-
Then
|
89
|
-
step %
|
106
|
+
Then(/^the output should contain a list of plugins$/) do
|
107
|
+
step %(the output should contain "Available plugins: ")
|
90
108
|
end
|
91
109
|
|
92
|
-
When
|
110
|
+
When(/^I do a git commit with commit message "(.*?)"$/) do |commit_msg|
|
93
111
|
filename = Faker::Lorem.words(1).first
|
94
|
-
|
95
|
-
|
96
|
-
|
112
|
+
steps %(
|
113
|
+
Given a 98 byte file named "#{filename}"
|
114
|
+
And I successfully run `git add #{filename}`
|
115
|
+
And I successfully run `git commit -m "#{commit_msg}"`
|
116
|
+
)
|
97
117
|
end
|
98
118
|
|
99
|
-
When
|
100
|
-
|
101
|
-
step %{I do a git commit with commit message "#{commit_msg}"}
|
119
|
+
When(/^I do a git commit$/) do
|
120
|
+
step %(I do a git commit with commit message "#{Faker::Lorem.sentence}")
|
102
121
|
end
|
103
122
|
|
104
|
-
When
|
123
|
+
When(/^I do (\d+) git commits$/) do |n|
|
105
124
|
n.to_i.times do
|
106
|
-
step %
|
125
|
+
step %(I do a git commit)
|
107
126
|
sleep 0.1
|
108
127
|
end
|
109
128
|
end
|
110
129
|
|
111
|
-
Then
|
130
|
+
Then(/^there should be (\d+) commit entries in the git log$/) do |n|
|
112
131
|
sleep 1 # let the file writing catch up
|
113
|
-
|
132
|
+
expect(n.to_i).to eq `git shortlog | grep -E '^[ ]+\w+' | wc -l`.chomp.to_i
|
114
133
|
end
|
115
134
|
|
116
|
-
Given
|
117
|
-
|
135
|
+
Given(/^I am using a "(.*?)" platform$/) do |platform_name|
|
136
|
+
set_env 'LOLCOMMITS_FAKEPLATFORM', platform_name
|
118
137
|
end
|
119
138
|
|
120
|
-
When
|
121
|
-
|
139
|
+
When(/^I wait for the child process to exit in "(.*?)"$/) do |repo_name|
|
140
|
+
pid_loc = absolute_path("~/.lolcommits/#{repo_name}/lolcommits.pid")
|
141
|
+
sleep 0.1 while File.exist?(pid_loc)
|
122
142
|
end
|
data/features/support/env.rb
CHANGED
@@ -2,16 +2,12 @@
|
|
2
2
|
require 'aruba/cucumber'
|
3
3
|
require 'methadone/cucumber'
|
4
4
|
require 'open3'
|
5
|
-
require 'test/unit/assertions'
|
6
|
-
include Test::Unit::Assertions
|
7
5
|
require 'ffaker'
|
8
|
-
require '
|
6
|
+
require 'fileutils'
|
7
|
+
|
9
8
|
require File.join(File.expand_path(File.dirname(__FILE__)), 'path_helpers')
|
10
9
|
include Lolcommits
|
11
10
|
|
12
|
-
ENV['PATH'] = "#{File.expand_path(File.dirname(__FILE__) + '/../../bin')}#{File::PATH_SEPARATOR}#{ENV['PATH']}"
|
13
|
-
LIB_DIR = File.join(File.expand_path(File.dirname(__FILE__)), '..', '..', 'lib')
|
14
|
-
|
15
11
|
World(PathHelpers)
|
16
12
|
|
17
13
|
Before do
|
@@ -19,70 +15,44 @@ Before do
|
|
19
15
|
@puts = true
|
20
16
|
@aruba_timeout_seconds = 20
|
21
17
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
@original_fakecapture = ENV['LOLCOMMITS_FAKECAPTURE']
|
26
|
-
ENV['LOLCOMMITS_FAKECAPTURE'] = '1'
|
27
|
-
|
28
|
-
# @original_loldir = ENV['LOLCOMMITS_DIR']
|
29
|
-
# ENV['LOLCOMMITS_DIR'] = File.expand_path( File.join(current_dir, ".lolcommits") )
|
30
|
-
|
31
|
-
@original_home = ENV['HOME']
|
32
|
-
ENV['HOME'] = File.expand_path(current_dir)
|
33
|
-
|
34
|
-
ENV['LAUNCHY_DRY_RUN'] = 'true'
|
35
|
-
end
|
36
|
-
|
37
|
-
After do
|
38
|
-
ENV['RUBYLIB'] = @original_rubylib
|
39
|
-
ENV['LOLCOMMITS_FAKECAPTURE'] = @original_fakecapture
|
40
|
-
# ENV['LOLCOMMITS_DIR'] = @original_loldir
|
41
|
-
ENV['HOME'] = @original_home
|
42
|
-
ENV['LAUNCHY_DRY_RUN'] = nil
|
43
|
-
ENV['LOLCOMMITS_FAKEPLATFORM'] = nil
|
44
|
-
end
|
45
|
-
|
46
|
-
Before('@fake-interactive-rebase') do
|
47
|
-
# in order to fake an interactive rebase,
|
48
|
-
# we replace the editor with a script that simply squashes a few random commits
|
49
|
-
@original_git_editor = ENV['GIT_EDITOR']
|
50
|
-
# ENV['GIT_EDITOR'] = "sed -i -e 'n;s/pick/squash/g'" #every other commit
|
51
|
-
ENV['GIT_EDITOR'] = "sed -i -e '3,5 s/pick/squash/g'" # lines 3-5
|
52
|
-
end
|
18
|
+
set_env 'LOLCOMMITS_FAKECAPTURE', '1'
|
19
|
+
set_env 'LAUNCHY_DRY_RUN', 'true'
|
53
20
|
|
54
|
-
|
55
|
-
|
21
|
+
author_name = 'Testy McTesterson'
|
22
|
+
author_email = 'testy@tester.com'
|
23
|
+
set_env 'GIT_AUTHOR_NAME', author_name
|
24
|
+
set_env 'GIT_COMMITTER_NAME', author_name
|
25
|
+
set_env 'GIT_AUTHOR_EMAIL', author_email
|
26
|
+
set_env 'GIT_COMMITTER_EMAIL', author_email
|
56
27
|
end
|
57
28
|
|
29
|
+
# for tasks that may take an insanely long time (e.g. network related)
|
30
|
+
# we should strive to not have any of these in our scenarios, naturally.
|
58
31
|
Before('@slow_process') do
|
59
32
|
@aruba_io_wait_seconds = 5
|
60
33
|
@aruba_timeout_seconds = 60
|
61
34
|
end
|
62
35
|
|
36
|
+
# in order to fake an interactive rebase, we replace the editor with a script
|
37
|
+
# to simply squash a few random commits. in this case, using lines 3-5.
|
38
|
+
Before('@fake-interactive-rebase') do
|
39
|
+
set_env 'GIT_EDITOR', "sed -i -e '3,5 s/pick/squash/g'"
|
40
|
+
end
|
41
|
+
|
63
42
|
# adjust the path so tests dont see a global imagemagick install
|
64
43
|
Before('@fake-no-imagemagick') do
|
65
44
|
reject_paths_with_cmd('mogrify')
|
66
45
|
end
|
67
46
|
|
68
|
-
After('@fake-no-imagemagick') do
|
69
|
-
reset_path
|
70
|
-
end
|
71
|
-
|
72
47
|
# adjust the path so tests dont see a global ffmpeg install
|
73
48
|
Before('@fake-no-ffmpeg') do
|
74
49
|
reject_paths_with_cmd('ffmpeg')
|
75
50
|
end
|
76
51
|
|
77
|
-
After('@fake-no-ffmpeg') do
|
78
|
-
reset_path
|
79
|
-
end
|
80
|
-
|
81
52
|
# do test in temporary directory so our own git repo-ness doesn't affect it
|
82
53
|
Before('@in-tempdir') do
|
83
54
|
@dirs = [Dir.mktmpdir]
|
84
55
|
end
|
85
|
-
|
86
56
|
After('@in-tempdir') do
|
87
57
|
FileUtils.rm_rf(@dirs.first)
|
88
58
|
end
|
@@ -1,12 +1,15 @@
|
|
1
1
|
# -*- encoding : utf-8 -*-
|
2
|
+
require 'fileutils'
|
3
|
+
require 'aruba/api'
|
4
|
+
require 'lolcommits/platform'
|
5
|
+
|
2
6
|
module PathHelpers
|
3
7
|
def reject_paths_with_cmd(cmd)
|
4
|
-
@original_path = ENV['PATH']
|
5
8
|
# make a new subdir that still contains cmds
|
6
9
|
tmpbindir = File.expand_path(File.join @dirs, 'bin')
|
7
10
|
FileUtils.mkdir_p tmpbindir
|
8
11
|
|
9
|
-
preseve_cmds_in_path(
|
12
|
+
preseve_cmds_in_path(%w(git mplayer), tmpbindir)
|
10
13
|
|
11
14
|
exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
|
12
15
|
newpaths = ENV['PATH'].split(File::PATH_SEPARATOR).reject do |path|
|
@@ -20,19 +23,17 @@ module PathHelpers
|
|
20
23
|
|
21
24
|
# add the temporary directory with git in it back into the path
|
22
25
|
newpaths << tmpbindir
|
23
|
-
|
26
|
+
|
27
|
+
# use aruba/api set_env to set PATH, which will be automaticaly restored
|
28
|
+
set_env 'PATH', newpaths.join(File::PATH_SEPARATOR)
|
24
29
|
end
|
25
30
|
|
26
31
|
def preseve_cmds_in_path(cmds, tmpbindir)
|
27
32
|
cmds.each do |cmd|
|
28
|
-
whichcmd = Lolcommits::
|
33
|
+
whichcmd = Lolcommits::Platform.command_which(cmd)
|
29
34
|
unless whichcmd.nil?
|
30
35
|
FileUtils.ln_s whichcmd, File.join(tmpbindir, File.basename(whichcmd))
|
31
36
|
end
|
32
37
|
end
|
33
38
|
end
|
34
|
-
|
35
|
-
def reset_path
|
36
|
-
ENV['PATH'] = @original_path
|
37
|
-
end
|
38
39
|
end
|
data/lib/lolcommits.rb
CHANGED
@@ -11,20 +11,12 @@ require 'date'
|
|
11
11
|
|
12
12
|
require 'lolcommits/version'
|
13
13
|
require 'lolcommits/configuration'
|
14
|
-
|
15
14
|
require 'lolcommits/capturer'
|
16
|
-
require 'lolcommits/capturer/capture_mac'
|
17
|
-
require 'lolcommits/capturer/capture_mac_animated'
|
18
|
-
require 'lolcommits/capturer/capture_linux'
|
19
|
-
require 'lolcommits/capturer/capture_linux_animated'
|
20
|
-
require 'lolcommits/capturer/capture_windows'
|
21
|
-
require 'lolcommits/capturer/capture_cygwin'
|
22
|
-
require 'lolcommits/capturer/capture_fake'
|
23
|
-
|
24
15
|
require 'lolcommits/git_info'
|
25
16
|
require 'lolcommits/installation'
|
26
|
-
|
27
17
|
require 'lolcommits/plugin'
|
18
|
+
require 'lolcommits/platform'
|
19
|
+
|
28
20
|
require 'lolcommits/plugins/loltext'
|
29
21
|
require 'lolcommits/plugins/dot_com'
|
30
22
|
require 'lolcommits/plugins/tranzlate'
|
@@ -32,6 +24,7 @@ require 'lolcommits/plugins/lol_twitter'
|
|
32
24
|
require 'lolcommits/plugins/uploldz'
|
33
25
|
require 'lolcommits/plugins/lolsrv'
|
34
26
|
require 'lolcommits/plugins/lol_yammer'
|
27
|
+
require 'lolcommits/plugins/lol_protonet'
|
35
28
|
|
36
29
|
# require runner after all the plugins have been required
|
37
30
|
require 'lolcommits/runner'
|
data/lib/lolcommits/capturer.rb
CHANGED
@@ -8,9 +8,17 @@ module Lolcommits
|
|
8
8
|
|
9
9
|
def initialize(attributes = {})
|
10
10
|
attributes.each do |attr, val|
|
11
|
-
|
11
|
+
send("#{attr}=", val)
|
12
12
|
end
|
13
|
-
debug 'Capturer: initializing new instance ' +
|
13
|
+
debug 'Capturer: initializing new instance ' + to_s
|
14
14
|
end
|
15
15
|
end
|
16
16
|
end
|
17
|
+
|
18
|
+
require 'lolcommits/capturer/capture_mac'
|
19
|
+
require 'lolcommits/capturer/capture_mac_animated'
|
20
|
+
require 'lolcommits/capturer/capture_linux'
|
21
|
+
require 'lolcommits/capturer/capture_linux_animated'
|
22
|
+
require 'lolcommits/capturer/capture_windows'
|
23
|
+
require 'lolcommits/capturer/capture_cygwin'
|
24
|
+
require 'lolcommits/capturer/capture_fake'
|