lolcommits 0.2.0 → 0.3.0.pre1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -6,3 +6,5 @@ pkg/*
6
6
  results.html
7
7
  html
8
8
  tmp
9
+ *.swp
10
+ *.swo
@@ -3,8 +3,13 @@ rvm:
3
3
  - 1.8.7
4
4
  - 1.9.2
5
5
  - 1.9.3
6
+ - ruby-head
6
7
 
7
8
  before_install:
8
- - sudo apt-get update
9
- - sudo apt-get install mplayer libmagick9-dev
9
+ - sudo apt-get -qq update
10
+ - sudo apt-get -qq -y install mplayer libmagick9-dev
10
11
 
12
+ #test against ruby-head as well so we know what's coming down the pipe
13
+ matrix:
14
+ allow_failures:
15
+ - rvm: ruby-head
data/CHANGELOG CHANGED
@@ -1,3 +1,7 @@
1
+ 0.3.0 (in development)
2
+ * fix bug involving git repositories with spaces in the name
3
+ * internal refactoring for modularity (thanks @kenmazaika!)
4
+
1
5
  0.2.0 (6 July 2012)
2
6
  * improved build system and testing with cucumber/methadone
3
7
  - goal is to get into a better framework to start doing major feature work
data/NOTES ADDED
@@ -0,0 +1,17 @@
1
+
2
+ AFTER:
3
+ * update version (.pre)
4
+ * update README
5
+ * open3 and unit assertions in cuke tests, can remove with aruba ?
6
+ * better plugin list output, showing enabled status etc
7
+ * GET RID OF LOLCOMMITS_DIR in TEST ENV and FAKE $HOME instead
8
+ * clean up bin/lolcommits or refactor or whatever it's a mess
9
+
10
+ MUCH LATER:
11
+ * auto version detection? (to encourage people to update)
12
+ * push stats to statsd or something so i know how many people are using it!
13
+ * pimp twitter
14
+ - in readme
15
+ - in post_install_message from gemspec
16
+ * a real website
17
+
data/README.md CHANGED
@@ -10,7 +10,7 @@ By default, the lolimages are stored by a Github style short SHA in a `~/.lolcom
10
10
  ## Installation (Mac OS X)
11
11
  You'll need ImageMagick installed. [Homebrew](http://mxcl.github.com/homebrew/) makes this easy. Simply do:
12
12
 
13
- brew install imagemagick --from-source
13
+ brew install imagemagick
14
14
 
15
15
  Then simply do:
16
16
 
@@ -72,8 +72,11 @@ environment variables.
72
72
  * Set webcam device on mac - set `LOLCOMMITS_DEVICE` environment variable.
73
73
  * Set delay persistently (for slow to warmup webcams) - set
74
74
  `LOLCOMMITS_DELAY` var to time in seconds.
75
- * TRANZLATE YOAR COMMIT_MSG TO LOLSPEKK - set
76
- `LOLCOMMITS_TRANZLATE=1`.
75
+
76
+ ## Plugins
77
+
78
+ * TRANZLATE YOAR COMMIT_MSG TO LOLSPEKK - do
79
+ `lolcommits --config -p tranzlate` and set enabled to `true`.
77
80
 
78
81
  ## Contributing
79
82
 
data/Rakefile CHANGED
@@ -21,7 +21,9 @@ end
21
21
  CUKE_RESULTS = 'results.html'
22
22
  CLEAN << CUKE_RESULTS
23
23
  Cucumber::Rake::Task.new(:features) do |t|
24
- t.cucumber_opts = "features --format html -o #{CUKE_RESULTS} --format pretty --no-source -x"
24
+ optstr = "features --format html -o #{CUKE_RESULTS} --format pretty --no-source -x"
25
+ optstr << " -t @#{ENV["tag"]}" unless ENV["tag"].nil?
26
+ t.cucumber_opts = optstr
25
27
  t.fork = false
26
28
  end
27
29
 
@@ -38,6 +40,7 @@ task :default => [:test,:features]
38
40
 
39
41
  desc "Migrate an existing local .lolcommits directory to Dropbox"
40
42
  task :dropboxify do
43
+ $home = ENV['HOME']
41
44
  dropbox_loldir = "#{$home}/Dropbox/lolcommits"
42
45
  loldir = "#{$home}/.lolcommits"
43
46
  backup_loldir = "#{$home}/.lolcommits.old"
@@ -8,6 +8,8 @@ rescue LoadError
8
8
  end
9
9
 
10
10
  include Lolcommits
11
+ require "launchy"
12
+ require "choice"
11
13
 
12
14
  #
13
15
  # CHECK FOR FURTHER DEPENDENCIES
@@ -19,28 +21,32 @@ def command?(name)
19
21
  $?.success?
20
22
  end
21
23
 
22
- if is_mac?
23
- # this dependency now satisfied with bundled copy of imagesnap
24
- #if not command?('imagesnap')
25
- # puts "Couldn't find imagesnap in your PATH!"
26
- # puts "Easiest way to get it is to install homebrew and do `brew install imagesnap`"
27
- # exit 1
28
- #end
29
- unless File.executable? File.join(LOLCOMMITS_ROOT, "ext", "imagesnap", "imagesnap")
24
+ if Configuration.is_mac?
25
+ unless File.executable? File.join(Configuration::LOLCOMMITS_ROOT, "ext", "imagesnap", "imagesnap")
30
26
  puts "Couldn't properly execute imagesnap for some reason, please file a bug?!"
31
27
  exit 1
32
28
  end
33
- elsif is_linux?
29
+ elsif Configuration.is_linux?
34
30
  if not command?('mplayer')
35
31
  puts "Couldn't find mplayer in your PATH!"
36
32
  exit 1
37
33
  end
38
34
  end
39
- unless File.readable? File.join(LOLCOMMITS_ROOT, "fonts", "Impact.ttf")
35
+ unless File.readable? File.join(Configuration::LOLCOMMITS_ROOT, "fonts", "Impact.ttf")
40
36
  puts "Couldn't properly read Impact font from gem package, please file a bug?!"
41
37
  exit 1
42
38
  end
43
39
 
40
+ def die_if_not_git_repo!
41
+ begin
42
+ g=Git.open('.')
43
+ rescue ArgumentError
44
+ # ruby-git throws an argument error if path isnt for a valid git repo...
45
+ puts "Erm? Can't do that since we're not in a valid git repository!"
46
+ exit 1
47
+ end
48
+ end
49
+
44
50
  #
45
51
  # NO ARGUMENTS SPECIFIED, HELP THE USER OUT
46
52
  #
@@ -48,6 +54,7 @@ def do_noargs
48
54
  #TODO: make this a contextual helper to know status of whether lolcommits is enabled
49
55
  puts "Do what exactly?"
50
56
  puts "Try: lolcommits --enable (when in a git repository)"
57
+ puts "Or: lolcommits --help"
51
58
  end
52
59
 
53
60
  HOOK_PATH = File.join ".git", "hooks", "post-commit"
@@ -96,6 +103,14 @@ def do_disable
96
103
  end
97
104
  end
98
105
 
106
+ def configuration
107
+ if Choice.choices[:test]
108
+ Configuration.new(:loldir => Configuration.loldir_for('test'))
109
+ else
110
+ Configuration.new
111
+ end
112
+ end
113
+
99
114
  #
100
115
  # IF --CAPTURE, DO CAPTURE
101
116
  #
@@ -104,11 +119,37 @@ def do_capture
104
119
  capture_device = Choice.choices[:device] || ENV['LOLCOMMITS_DEVICE'] || nil
105
120
 
106
121
  if Choice.choices[:test]
107
- puts "*** capturing in test mode"
108
- Lolcommits.capture(capture_delay, capture_device, true, Choice.choices[:msg], Choice.choices[:sha])
122
+ puts "*** Capturing in test mode."
123
+ runner = Lolcommits::Runner.new(:capture_delay => capture_delay,
124
+ :capture_device => capture_device,
125
+ :message => Choice.choices[:msg],
126
+ :sha => Choice.choices[:sha],
127
+ :config => configuration
128
+ )
129
+ runner.run
130
+
131
+ Launchy.open(runner.main_image)
109
132
  else
110
- Lolcommits.capture(capture_delay, capture_device)
133
+ runner = Lolcommits::Runner.new(:capture_delay => capture_delay,
134
+ :capture_device => capture_device,
135
+ :config => configuration
136
+ )
137
+ runner.run
138
+ end
139
+ end
140
+
141
+ def do_configure
142
+ configuration.do_configure! Choice.choices[:plugin]
143
+ end
144
+
145
+ def do_last
146
+ die_if_not_git_repo!
147
+ lolimage = configuration.most_recent
148
+ if lolimage.nil?
149
+ puts "No lolcommits have been captured for this repository yet."
150
+ exit 1
111
151
  end
152
+ Launchy.open lolimage
112
153
  end
113
154
 
114
155
  #
@@ -140,18 +181,35 @@ Choice.options do
140
181
  long "--last"
141
182
  short "-l"
142
183
  desc "view the most recent lolcommit"
143
- action do
144
- Launchy.open Lolcommits.most_recent
145
- end
146
184
  end
147
185
 
148
186
  option :browse do
149
187
  long "--browse"
150
188
  short "-b"
151
189
  desc "browse this repo's lolcommits"
152
- action do
153
- Launchy.open Lolcommits.loldir
154
- end
190
+ end
191
+
192
+ option :configure do
193
+ long "--config"
194
+ desc "configure a plugin"
195
+ end
196
+
197
+ option :show_config do
198
+ short "-sc"
199
+ long "--show-config"
200
+ desc "display configuration file"
201
+ end
202
+
203
+ option :plugin do
204
+ desc "pass plugin name for --config"
205
+ long "--plugin"
206
+ short "-p"
207
+ default nil
208
+ end
209
+
210
+ option :plugins do
211
+ desc "list all available plugins"
212
+ long "--plugins"
155
213
  end
156
214
 
157
215
  option :test do
@@ -160,14 +218,14 @@ Choice.options do
160
218
  end
161
219
 
162
220
  option :sha do
163
- desc "pass SHA manually (for test only)"
221
+ desc "pass SHA manually [TEST-MODE]"
164
222
  long "--sha"
165
223
  short '-s'
166
224
  default "test-#{rand(10 ** 10)}"
167
225
  end
168
226
 
169
227
  option :msg do
170
- desc "pass commit msg manually (for test only)"
228
+ desc "pass commit msg manually [TEST-MODE]"
171
229
  long "--msg"
172
230
  short '-m'
173
231
  default "this is a test message i didnt really commit something"
@@ -189,9 +247,20 @@ end
189
247
  #
190
248
  # Handle actions manually since choice seems weird
191
249
  #
192
- if not (Choice.choices[:enable] || Choice.choices[:disable] || Choice.choices[:last] || Choice.choices[:browse])
250
+ if not (Choice.choices[:enable] || Choice.choices[:disable])
193
251
  if Choice.choices[:capture]
194
252
  do_capture()
253
+ elsif Choice.choices[:configure]
254
+ do_configure()
255
+ elsif Choice.choices[:show_config]
256
+ puts configuration.user_configuration.to_yaml
257
+ elsif Choice.choices[:plugins]
258
+ configuration.puts_plugins()
259
+ elsif Choice.choices[:last]
260
+ do_last()
261
+ elsif Choice.choices[:browse]
262
+ die_if_not_git_repo!
263
+ Launchy.open configuration.loldir
195
264
  else
196
265
  do_noargs()
197
266
  end
@@ -0,0 +1,30 @@
1
+ Feature: Bug regression testing
2
+ As a developer
3
+ I want to ensure fixed bugs stay fixed
4
+ So that I don't have to fix them again!
5
+
6
+ #
7
+ # issue #58, https://github.com/mroth/lolcommits/issues/58
8
+ #
9
+ Scenario: handle git repos with spaces in directory name
10
+ Given a git repository named "test lolol"
11
+ And an empty file named "test lolol/FOOBAR"
12
+
13
+ When I cd to "test lolol"
14
+ And I successfully run `lolcommits --enable`
15
+ And I successfully run `git add .`
16
+ And I successfully run `git commit -m 'can haz commit'`
17
+ Then the output should contain "*** Preserving this moment in history."
18
+ And a directory named "../.lolcommits/test-lolol" should exist
19
+
20
+
21
+ #
22
+ # issue #53, https://github.com/mroth/lolcommits/issues/53
23
+ #
24
+ #@fake-root @simulate-env
25
+ #Scenario: error if can't read font file
26
+ # Given "fonts/Impact.ttf" packaged file is not readable
27
+ # When I run `lolcommits --test --capture`
28
+ # Then the output should contain "Couldn't properly read Impact font from gem package"
29
+ # And the exit status should be 1
30
+
@@ -1,4 +1,4 @@
1
- Feature: Basic functionality
1
+ Feature: Basic UI functionality
2
2
 
3
3
  Scenario: App just runs
4
4
  When I get help for "lolcommits"
@@ -6,36 +6,150 @@ Feature: Basic functionality
6
6
  And the banner should be present
7
7
 
8
8
  Scenario: Enable in a naked git repository
9
- Given a git repository named "loltest"
10
- And the git repository named "loltest" has no "post-commit" hook
11
-
9
+ Given a git repository named "loltest" with no "post-commit" hook
12
10
  When I cd to "loltest"
13
11
  And I successfully run `lolcommits --enable`
14
-
15
12
  Then the output should contain "installed lolcommmit hook as:"
16
13
  And the output should contain "(to remove later, you can use: lolcommits --disable)"
17
14
  And a file named ".git/hooks/post-commit" should exist
18
15
  And the exit status should be 0
19
16
 
20
17
  Scenario: Disable in a enabled git repository
21
- Given a git repository named "lolenabled"
22
- And the git repository named "lolenabled" has a "post-commit" hook
23
-
18
+ Given a git repository named "lolenabled" with a "post-commit" hook
24
19
  When I cd to "lolenabled"
25
20
  And I successfully run `lolcommits --disable`
26
-
27
21
  Then the output should contain "removed"
28
22
  And a file named ".git/hooks/post-commit" should not exist
29
23
  And the exit status should be 0
30
24
 
31
- @simulate-capture
32
- Scenario: Commiting in an enabled repo triggers capture
25
+ Scenario: Trying to enable while not in a git repo fails
26
+ Given a directory named "svnrulez"
27
+ When I cd to "svnrulez"
28
+ And I run `lolcommits --enable`
29
+ Then the output should contain "You don't appear to be in the base directory of a git project."
30
+ And the exit status should be 1
31
+
32
+ Scenario: Commiting in an enabled repo triggers successful capture
33
33
  Given a git repository named "testcapture"
34
34
  And an empty file named "testcapture/FOOBAR"
35
-
36
35
  When I cd to "testcapture"
37
36
  And I successfully run `lolcommits --enable`
38
37
  And I successfully run `git add .`
39
38
  And I successfully run `git commit -m 'can haz commit'`
40
39
  Then the output should contain "*** Preserving this moment in history."
40
+ And a directory named "../.lolcommits/testcapture" should exist
41
+ And a file named "../.lolcommits/testcapture/tmp_snapshot.jpg" should not exist
42
+ And there should be 1 jpg in "../.lolcommits/testcapture"
43
+
44
+ Scenario: Commiting in an enabled repo subdirectory triggers successful capture of parent repo
45
+ Given a git repository named "testcapture"
46
+ And a directory named "testcapture/subdir"
47
+ And an empty file named "testcapture/subdir/FOOBAR"
48
+ When I cd to "testcapture/"
49
+ And I successfully run `lolcommits --enable`
50
+ Then I cd to "subdir/"
51
+ And I successfully run `git add .`
52
+ And I successfully run `git commit -m 'can haz commit'`
53
+ Then the output should contain "*** Preserving this moment in history."
54
+ And a directory named "../../.lolcommits/testcapture" should exist
55
+ And a file named "../../.lolcommits/testcapture/tmp_snapshot.jpg" should not exist
56
+ And there should be 1 jpg in "../../.lolcommits/testcapture"
57
+
58
+ Scenario: Show plugins
59
+ When I successfully run `lolcommits --plugins`
60
+ Then the output should contain a list of plugins
61
+
62
+ #
63
+ # a stab at recreating ken's scenarios with native aruba steps, not quite there yet in terms
64
+ # of elegance, but its passing so might as well leave in for now.
65
+ #
66
+ Scenario: Configuring plugin (with native aruba steps)
67
+ Given a git repository named "config-test"
68
+ When I cd to "config-test"
69
+ And I run `lolcommits --config` interactively
70
+ When I type "loltext"
71
+ When I type "true"
72
+ Then the output should contain a list of plugins
73
+ And the output should contain "Name of plugin to configure:"
74
+ Then the output should contain "enabled:"
75
+ Then the output should contain "Successfully Configured"
76
+ And a file named "../.lolcommits/config-test/config.yml" should exist
77
+ When I successfully run `lolcommits --show-config`
78
+ Then the output should contain "loltext:"
79
+ And the output should contain "enabled: true"
80
+
81
+ Scenario: Configuring Plugin
82
+ Given a git repository named "config-test"
83
+ When I cd to "config-test"
84
+ And I run `lolcommits --config` and wait for output
85
+ When I enter "loltext" for "Name of plugin to configure"
86
+ And I enter "true" for "enabled"
87
+ Then I should be presented "Successfully Configured"
88
+ And a file named "../.lolcommits/config-test/config.yml" should exist
89
+ When I successfully run `lolcommits --show-config`
90
+ Then the output should contain "loltext:"
91
+ And the output should contain "enabled: true"
92
+
93
+ Scenario: Configuring Plugin In Test Mode
94
+ Given a git repository named "testmode-config-test"
95
+ When I cd to "testmode-config-test"
96
+ And I run `lolcommits --config --test` and wait for output
97
+ And I enter "loltext" for "Name of plugin to configure"
98
+ And I enter "true" for "enabled"
99
+ Then I should be presented "Successfully Configured"
100
+ And a file named "../.lolcommits/test/config.yml" should exist
101
+ When I successfully run `lolcommits --test --show-config`
102
+ Then the output should contain "loltext:"
103
+ And the output should contain "enabled: true"
104
+
105
+ Scenario: test capture should work regardless of whether in a git repository
106
+ Given a directory named "nothingtoseehere"
107
+ When I cd to "nothingtoseehere"
108
+ And I run `lolcommits --test --capture`
109
+ Then the output should contain "*** Capturing in test mode."
110
+ And the output should not contain "path does not exist (ArgumentError)"
111
+ And the exit status should be 0
112
+
113
+ Scenario: test capture should store in its own test directory
114
+ Given a git repository named "randomgitrepo"
115
+ When I cd to "randomgitrepo"
116
+ And I successfully run `lolcommits --test --capture`
117
+ Then a directory named "../.lolcommits/test" should exist
118
+ And a directory named "../.lolcommits/randomgitrepo" should not exist
119
+
120
+ Scenario: last command should work properly when in a lolrepo
121
+ Given a git repository named "randomgitrepo"
122
+ And a loldir named "randomgitrepo" with 2 lolimages
123
+ And I cd to "randomgitrepo"
124
+ When I run `lolcommits --last`
125
+ Then the exit status should be 0
126
+
127
+ Scenario: last command should fail gracefully if not in a lolrepo
128
+ Given a directory named "gitsuxcvs4eva"
129
+ And I cd to "gitsuxcvs4eva"
130
+ When I run `lolcommits --last`
131
+ Then the output should contain "Can't do that since we're not in a valid git repository!"
132
+ Then the exit status should be 1
133
+
134
+ Scenario: last command should fail gracefully if zero lolimages in lolrepo
135
+ Given a git repository named "randomgitrepo"
136
+ And a loldir named "randomgitrepo" with 0 lolimages
137
+ And I cd to "randomgitrepo"
138
+ When I run `lolcommits --last`
139
+ Then the output should contain "No lolcommits have been captured for this repository yet."
140
+ Then the exit status should be 1
141
+
142
+ Scenario: browse command should work properly when in a lolrepo
143
+ Given a git repository named "randomgitrepo"
144
+ And a loldir named "randomgitrepo" with 2 lolimages
145
+ And I cd to "randomgitrepo"
146
+ When I run `lolcommits --browse`
147
+ Then the exit status should be 0
148
+
149
+ Scenario: browse command should fail gracefully when not in a lolrepo
150
+ Given a directory named "gitsuxcvs4eva"
151
+ And I cd to "gitsuxcvs4eva"
152
+ When I run `lolcommits --browse`
153
+ Then the output should contain "Can't do that since we're not in a valid git repository!"
154
+ Then the exit status should be 1
41
155