lolcommits 0.0.3 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.travis.yml ADDED
@@ -0,0 +1,10 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.8.7
4
+ - 1.9.2
5
+ - 1.9.3
6
+
7
+ before_install:
8
+ - sudo apt-get update
9
+ - sudo apt-get install mplayer libmagick9-dev
10
+
data/CHANGELOG CHANGED
@@ -1,3 +1,6 @@
1
+ 0.1.0 (in development)
2
+ * Linux compatibility! Thanks to @madjar, @cscorely, and @Prydonius.
3
+
1
4
  0.0.3 (16 April 2012)
2
5
  * use only first line for multi-line commit msgs (pull req #21)
3
6
  * clean up some command line options
data/README.md CHANGED
@@ -1,12 +1,12 @@
1
+ [![Build Status](https://secure.travis-ci.org/mroth/lolcommits.png?branch=master)](http://travis-ci.org/mroth/lolcommits)
2
+
1
3
  # git + webcam = lol
2
4
 
3
- Takes a snapshot with your Mac's built-in iSight/FaceTime webcam every time you git commit code, and archives a lolcat style image with it.
5
+ Takes a snapshot with your Mac's built-in iSight/FaceTime webcam (or any working webcam on Linux) every time you git commit code, and archives a lolcat style image with it.
4
6
 
5
7
  By default, the lolimages are stored by a Github style short SHA in a `~/.lolcommits` directory created for you.
6
8
 
7
9
  ## Installation (for Mac OS X)
8
- We've gotten rid of most of the dependency chain, yay!
9
-
10
10
  You'll need imagesnap and imagemagick installed. [Homebrew](http://mxcl.github.com/homebrew/) makes this easy. Simply do:
11
11
 
12
12
  brew install imagemagick
@@ -24,6 +24,17 @@ You're all set! To enable lolcommits for a git repo, go to the base directory o
24
24
 
25
25
  Likewise, you can disable it via `lolcommits --disable`. For a full list of options, you can do `lolcommits --help`.
26
26
 
27
+ ## Installation (for Linux)
28
+ Install dependencies using your package manager of choice, for example in Ubuntu:
29
+
30
+ sudo apt-get install mplayer imagemagick libmagick9-dev
31
+
32
+ Then install the lolcommits gem:
33
+
34
+ gem install lolcommits
35
+
36
+ Then you can `lolcommits --enable` in any git repo as above.
37
+
27
38
  ## Sample images
28
39
  Please add your own lolcommit to these samples! Just fork this repo, add it to this section of the README, and send me a pull request.
29
40
  <img width='320' height='240' src="https://github.com/mroth/lolcommits/raw/gh-pages/sample2.jpg" />
data/Rakefile CHANGED
@@ -1,4 +1,13 @@
1
1
  require "bundler/gem_tasks"
2
+ require 'rake/testtask'
3
+
4
+ Rake::TestTask.new do |t|
5
+ #t.libs << 'test'
6
+ t.test_files = Dir.glob('test/test_*.rb')
7
+ end
8
+
9
+ desc "Run tests"
10
+ task :default => :test
2
11
 
3
12
  desc "Migrate an existing local .lolcommits directory to Dropbox"
4
13
  task :dropboxify do
data/bin/lolcommits CHANGED
@@ -19,10 +19,17 @@ def command?(name)
19
19
  $?.success?
20
20
  end
21
21
 
22
- if not command?('imagesnap')
23
- puts "Couldn't find imagesnap in your PATH!"
24
- puts "Easiest way to get it is to install homebrew and do `brew install imagesnap`"
25
- exit 1
22
+ if is_mac?
23
+ if not command?('imagesnap')
24
+ puts "Couldn't find imagesnap in your PATH!"
25
+ puts "Easiest way to get it is to install homebrew and do `brew install imagesnap`"
26
+ exit 1
27
+ end
28
+ elsif is_linux?
29
+ if not command?('mplayer')
30
+ puts "Couldn't find mplayer in your PATH!"
31
+ exit 1
32
+ end
26
33
  end
27
34
 
28
35
  #
@@ -117,7 +124,7 @@ Choice.options do
117
124
  short "-l"
118
125
  desc "view the most recent lolcommit"
119
126
  action do
120
- system "open #{Lolcommits.most_recent}"
127
+ Launchy.open Lolcommits.most_recent
121
128
  end
122
129
  end
123
130
 
@@ -126,7 +133,7 @@ Choice.options do
126
133
  short "-b"
127
134
  desc "browse this repo's lolcommits"
128
135
  action do
129
- system "open #{Lolcommits.loldir}"
136
+ Launchy.open Lolcommits.loldir
130
137
  end
131
138
  end
132
139
 
data/fonts/Impact.ttf ADDED
Binary file
data/lib/lolcommits.rb CHANGED
@@ -3,13 +3,23 @@ require "choice"
3
3
  require "fileutils"
4
4
  require "git"
5
5
  require "RMagick"
6
+ require "open3"
7
+ require "launchy"
6
8
  include Magick
7
9
 
8
10
  module Lolcommits
9
11
  # Your code goes here...
10
12
  $home = ENV['HOME']
11
13
  LOLBASEDIR = "#{$home}/.lolcommits"
12
-
14
+
15
+ def is_mac?
16
+ RUBY_PLATFORM.downcase.include?("darwin")
17
+ end
18
+
19
+ def is_linux?
20
+ RUBY_PLATFORM.downcase.include?("linux")
21
+ end
22
+
13
23
  def most_recent(dir='.')
14
24
  loldir, commit_sha, commit_msg = parse_git
15
25
  Dir.glob("#{loldir}/*").max_by {|f| File.mtime(f)}
@@ -38,13 +48,11 @@ module Lolcommits
38
48
  if not is_test
39
49
  loldir, commit_sha, commit_msg = parse_git
40
50
  else
41
- commit_msg = test_msg #Choice.choices[:msg]
42
- commit_sha = test_sha #Choice.choices[:sha]
51
+ commit_msg = test_msg
52
+ commit_sha = test_sha
43
53
  loldir = "#{LOLBASEDIR}/test"
44
54
  end
45
55
 
46
- #puts "#{commit_sha}: #{commit_msg}"
47
-
48
56
  #
49
57
  # Create a directory to hold the lolimages
50
58
  #
@@ -60,9 +68,24 @@ module Lolcommits
60
68
  #
61
69
  puts "*** Preserving this moment in history."
62
70
  snapshot_loc = "#{loldir}/tmp_snapshot.jpg"
63
- system("imagesnap -q #{snapshot_loc} -w #{capture_delay}")
64
-
65
-
71
+ if is_mac?
72
+ system("imagesnap -q #{snapshot_loc} -w #{capture_delay}")
73
+ elsif is_linux?
74
+ tmpdir = File.expand_path "#{loldir}/tmpdir#{rand(1000)}/"
75
+ FileUtils.mkdir_p( tmpdir )
76
+ # There's no way to give a capture delay in mplayer, but a number of frame
77
+ # I've found that 6 is a good value for me.
78
+ frames = if capture_delay != 0 then capture_delay else 6 end
79
+
80
+ # mplayer's output is ugly and useless, let's throw it away
81
+ _, r, _ = Open3.popen3("mplayer -vo jpeg:outdir=#{tmpdir} -frames #{frames} tv://")
82
+ # looks like we still need to read the outpot for something to happen
83
+ r.read
84
+ FileUtils.mv(tmpdir + "/%08d.jpg" % frames, snapshot_loc)
85
+ FileUtils.rm_rf( tmpdir )
86
+ end
87
+
88
+
66
89
  #
67
90
  # Process the image with ImageMagick to add loltext
68
91
  #
@@ -75,7 +98,13 @@ module Lolcommits
75
98
 
76
99
  # create a draw object for annotation
77
100
  draw = Magick::Draw.new
78
- draw.font = "/Library/Fonts/Impact.ttf"
101
+ #if is_mac?
102
+ # draw.font = "/Library/Fonts/Impact.ttf"
103
+ #else
104
+ # draw.font = "/usr/share/fonts/TTF/impact.ttf"
105
+ #end
106
+ draw.font = File.join(File.dirname(__FILE__), "..", "fonts", "Impact.ttf")
107
+
79
108
  draw.fill = 'white'
80
109
  draw.stroke = 'black'
81
110
 
@@ -107,8 +136,8 @@ module Lolcommits
107
136
  FileUtils.rm("#{snapshot_loc}")
108
137
 
109
138
  #if in test mode, open image for inspection
110
- if Choice.choices[:test]
111
- system("open #{loldir}/#{commit_sha}.jpg")
139
+ if is_test
140
+ Launchy.open("#{loldir}/#{commit_sha}.jpg")
112
141
  end
113
142
 
114
143
 
@@ -1,3 +1,3 @@
1
1
  module Lolcommits
2
- VERSION = "0.0.3"
2
+ VERSION = "0.1.0"
3
3
  end
data/lolcommits.gemspec CHANGED
@@ -8,8 +8,8 @@ Gem::Specification.new do |s|
8
8
  s.authors = ["Matthew Rothenberg"]
9
9
  s.email = ["mrothenberg@gmail.com"]
10
10
  s.homepage = "http://github.com/mroth/lolcommits"
11
- s.summary = %q{Capture webcam image on git commit}
12
- s.description = %q{Capture webcam image on git commit for lulz}
11
+ s.summary = %q{Capture webcam image on git commit for lulz.}
12
+ s.description = %q{Capture webcam image on git commit for lulz. Works with Mac OS X and Linux.}
13
13
 
14
14
  s.rubyforge_project = "lolcommits"
15
15
 
@@ -21,7 +21,9 @@ Gem::Specification.new do |s|
21
21
  # specify any dependencies here; for example:
22
22
  # s.add_development_dependency "rspec"
23
23
  # s.add_runtime_dependency "rest-client"
24
+ s.add_development_dependency "rake"
24
25
  s.add_runtime_dependency "rmagick"
25
26
  s.add_runtime_dependency "git"
26
27
  s.add_runtime_dependency "choice", ">= 0.1.6"
28
+ s.add_runtime_dependency "launchy"
27
29
  end
@@ -0,0 +1,25 @@
1
+ require 'test/unit'
2
+
3
+ begin
4
+ require 'lolcommits'
5
+ rescue LoadError
6
+ require 'rubygems'
7
+ require 'lolcommits'
8
+ end
9
+
10
+ include Lolcommits
11
+
12
+ class LolTest < Test::Unit::TestCase
13
+ def test_can_parse_git
14
+ assert_nothing_raised do
15
+ Lolcommits.parse_git()
16
+ end
17
+ end
18
+
19
+ # Hmm.. webcam capture breaks travis-ci tests
20
+ #def test_can_capture
21
+ # assert_nothing_raised do
22
+ # Lolcommits.capture(0,true,'test commit message','test-sha-001')
23
+ # end
24
+ #end
25
+ 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.0.3
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,27 +9,33 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-04-16 00:00:00.000000000 Z
12
+ date: 2012-04-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
- name: rmagick
16
- requirement: !ruby/object:Gem::Requirement
15
+ name: rake
16
+ requirement: &70219465154200 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
20
20
  - !ruby/object:Gem::Version
21
21
  version: '0'
22
- type: :runtime
22
+ type: :development
23
23
  prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
24
+ version_requirements: *70219465154200
25
+ - !ruby/object:Gem::Dependency
26
+ name: rmagick
27
+ requirement: &70219465153700 !ruby/object:Gem::Requirement
25
28
  none: false
26
29
  requirements:
27
30
  - - ! '>='
28
31
  - !ruby/object:Gem::Version
29
32
  version: '0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *70219465153700
30
36
  - !ruby/object:Gem::Dependency
31
37
  name: git
32
- requirement: !ruby/object:Gem::Requirement
38
+ requirement: &70219465153240 !ruby/object:Gem::Requirement
33
39
  none: false
34
40
  requirements:
35
41
  - - ! '>='
@@ -37,15 +43,10 @@ dependencies:
37
43
  version: '0'
38
44
  type: :runtime
39
45
  prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
43
- - - ! '>='
44
- - !ruby/object:Gem::Version
45
- version: '0'
46
+ version_requirements: *70219465153240
46
47
  - !ruby/object:Gem::Dependency
47
48
  name: choice
48
- requirement: !ruby/object:Gem::Requirement
49
+ requirement: &70219465152660 !ruby/object:Gem::Requirement
49
50
  none: false
50
51
  requirements:
51
52
  - - ! '>='
@@ -53,13 +54,20 @@ dependencies:
53
54
  version: 0.1.6
54
55
  type: :runtime
55
56
  prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
57
+ version_requirements: *70219465152660
58
+ - !ruby/object:Gem::Dependency
59
+ name: launchy
60
+ requirement: &70219465152180 !ruby/object:Gem::Requirement
57
61
  none: false
58
62
  requirements:
59
63
  - - ! '>='
60
64
  - !ruby/object:Gem::Version
61
- version: 0.1.6
62
- description: Capture webcam image on git commit for lulz
65
+ version: '0'
66
+ type: :runtime
67
+ prerelease: false
68
+ version_requirements: *70219465152180
69
+ description: Capture webcam image on git commit for lulz. Works with Mac OS X and
70
+ Linux.
63
71
  email:
64
72
  - mrothenberg@gmail.com
65
73
  executables:
@@ -68,14 +76,17 @@ extensions: []
68
76
  extra_rdoc_files: []
69
77
  files:
70
78
  - .gitignore
79
+ - .travis.yml
71
80
  - CHANGELOG
72
81
  - Gemfile
73
82
  - README.md
74
83
  - Rakefile
75
84
  - bin/lolcommits
85
+ - fonts/Impact.ttf
76
86
  - lib/lolcommits.rb
77
87
  - lib/lolcommits/version.rb
78
88
  - lolcommits.gemspec
89
+ - test/test_lolcommits.rb
79
90
  homepage: http://github.com/mroth/lolcommits
80
91
  licenses: []
81
92
  post_install_message:
@@ -96,8 +107,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
96
107
  version: '0'
97
108
  requirements: []
98
109
  rubyforge_project: lolcommits
99
- rubygems_version: 1.8.21
110
+ rubygems_version: 1.8.17
100
111
  signing_key:
101
112
  specification_version: 3
102
- summary: Capture webcam image on git commit
103
- test_files: []
113
+ summary: Capture webcam image on git commit for lulz.
114
+ test_files:
115
+ - test/test_lolcommits.rb