lolcommits 0.1.3 → 0.1.4

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/CHANGELOG CHANGED
@@ -1,3 +1,7 @@
1
+ 0.1.4 (28 May 2012)
2
+ * set device on mac via --device (or LOLCOMMITS_DEVICE env variable) --
3
+ thanks @pioz (pull #51)
4
+
1
5
  0.1.3 (18 May 2012)
2
6
  * add LGPLv3 license
3
7
  * add option to translate your commit message to lolspeak! (thx
data/README.md CHANGED
@@ -68,6 +68,9 @@ Please add your own lolcommit! Add to the [People Using Lolcommits](https://gith
68
68
  lolcommits has some options for additional lulz. You can enable via
69
69
  environment variables.
70
70
 
71
+ * Set webcam device on mac - set `LOLCOMMITS_DEVICE` environment variable.
72
+ * Set delay persistently (for slow to warmup webcams) - set
73
+ `LOLCOMMITS_DELAY` var to time in seconds.
71
74
  * TRANZLATE YOAR COMMIT_MSG TO LOLSPEKK - set
72
75
  `LOLCOMMITS_TRANZLATE=1`.
73
76
 
data/bin/lolcommits CHANGED
@@ -53,18 +53,18 @@ def do_enable
53
53
  puts "You don't appear to be in the base directory of a git project."
54
54
  exit 1
55
55
  end
56
-
56
+
57
57
  #its possible a hooks dir doesnt exist, so create it if so
58
58
  if not File.directory?(HOOK_DIR)
59
59
  Dir.mkdir(HOOK_DIR)
60
60
  end
61
-
61
+
62
62
  if File.exists? HOOK_PATH
63
63
  puts "A post-commit hook already exists for this project."
64
64
  #TODO: disambiguate between OUR post-commit hook and something else
65
65
  exit 1
66
66
  end
67
-
67
+
68
68
  doc = "#!/bin/sh\nlolcommits --capture\n"
69
69
  File.open(HOOK_PATH, 'w') {|f| f.write(doc) }
70
70
  FileUtils.chmod 0755, HOOK_PATH
@@ -93,12 +93,13 @@ end
93
93
  #
94
94
  def do_capture
95
95
  capture_delay = Choice.choices[:delay] || ENV['LOLCOMMITS_DELAY'] || 0
96
+ capture_device = Choice.choices[:device] || ENV['LOLCOMMITS_DEVICE'] || nil
96
97
 
97
98
  if Choice.choices[:test]
98
99
  puts "*** capturing in test mode"
99
- Lolcommits.capture(capture_delay, true, Choice.choices[:msg], Choice.choices[:sha])
100
+ Lolcommits.capture(capture_delay, capture_device, true, Choice.choices[:msg], Choice.choices[:sha])
100
101
  else
101
- Lolcommits.capture(capture_delay)
102
+ Lolcommits.capture(capture_delay, capture_device)
102
103
  end
103
104
  end
104
105
 
@@ -113,14 +114,14 @@ Choice.options do
113
114
  action { do_enable }
114
115
  desc "install lolcommits for this repo"
115
116
  end
116
-
117
+
117
118
  option :disable do
118
119
  long "--disable"
119
120
  short '-d'
120
121
  action { do_disable }
121
122
  desc "uninstall lolcommits for this repo"
122
123
  end
123
-
124
+
124
125
  option :capture do
125
126
  long "--capture"
126
127
  short '-c'
@@ -135,7 +136,7 @@ Choice.options do
135
136
  Launchy.open Lolcommits.most_recent
136
137
  end
137
138
  end
138
-
139
+
139
140
  option :browse do
140
141
  long "--browse"
141
142
  short "-b"
@@ -144,19 +145,19 @@ Choice.options do
144
145
  Launchy.open Lolcommits.loldir
145
146
  end
146
147
  end
147
-
148
+
148
149
  option :test do
149
150
  long "--test"
150
151
  desc "Run in test mode"
151
152
  end
152
-
153
+
153
154
  option :sha do
154
155
  desc "pass SHA manually (for test only)"
155
156
  long "--sha"
156
157
  short '-s'
157
158
  default "test-#{rand(10 ** 10)}"
158
159
  end
159
-
160
+
160
161
  option :msg do
161
162
  desc "pass commit msg manually (for test only)"
162
163
  long "--msg"
@@ -170,6 +171,11 @@ Choice.options do
170
171
  cast Integer
171
172
  short '-w'
172
173
  end
174
+
175
+ option :device do
176
+ long "--device=DEVICE"
177
+ desc "the device name used to take the snapshot (only mac)"
178
+ end
173
179
  end
174
180
 
175
181
  #
data/lib/lolcommits.rb CHANGED
@@ -33,12 +33,12 @@ module Lolcommits
33
33
  loldir, commit_sha, commit_msg = parse_git
34
34
  Dir.glob(File.join loldir, "*").max_by {|f| File.mtime(f)}
35
35
  end
36
-
36
+
37
37
  def loldir(dir='.')
38
38
  loldir, commit_sha, commit_msg = parse_git
39
39
  return loldir
40
40
  end
41
-
41
+
42
42
  def parse_git(dir='.')
43
43
  g = Git.open('.')
44
44
  commit = g.log.first
@@ -50,7 +50,7 @@ module Lolcommits
50
50
  return loldir, commit_sha, commit_msg
51
51
  end
52
52
 
53
- def capture(capture_delay=0, is_test=false, test_msg=nil, test_sha=nil)
53
+ def capture(capture_delay=0, capture_device=nil, is_test=false, test_msg=nil, test_sha=nil)
54
54
  #
55
55
  # Read the git repo information from the current working directory
56
56
  #
@@ -61,7 +61,7 @@ module Lolcommits
61
61
  commit_sha = test_sha
62
62
  loldir = File.join LOLBASEDIR, "test"
63
63
  end
64
-
64
+
65
65
  #
66
66
  # lolspeak translate the message
67
67
  #
@@ -86,7 +86,8 @@ module Lolcommits
86
86
  snapshot_loc = File.join loldir, "tmp_snapshot.jpg"
87
87
  if is_mac?
88
88
  imagesnap_bin = File.join LOLCOMMITS_ROOT, "ext", "imagesnap", "imagesnap"
89
- system("#{imagesnap_bin} -q #{snapshot_loc} -w #{capture_delay}")
89
+ capture_device = "-d '#{capture_device}'" if capture_device
90
+ system("#{imagesnap_bin} -q #{snapshot_loc} -w #{capture_delay} #{capture_device}")
90
91
  elsif is_linux?
91
92
  tmpdir = File.expand_path "#{loldir}/tmpdir#{rand(1000)}/"
92
93
  FileUtils.mkdir_p( tmpdir )
@@ -1,3 +1,3 @@
1
1
  module Lolcommits
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
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.1.3
4
+ version: 0.1.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-05-18 00:00:00.000000000 Z
12
+ date: 2012-05-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake