commitphotos 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 9ad99db4cc45350c59a76c3fb510f4c6001540ec
4
+ data.tar.gz: 4209ed3518f1d94787a40a9da9f4aef825b8cc40
5
+ SHA512:
6
+ metadata.gz: a8b5f526593f162378fd7a923493101f2ee725934584074f127db75f73dc55da285568b54d2a5aac76554c06bbe3ffcf198f386b45543d26bba3476bf36f4089
7
+ data.tar.gz: 949b23389b1930e06dd33389b9a3373024bcf6e90848e6d4bbc0a11d811bb0cc063a2b3c7a731fcd264695e46cba34a84be95246e74c41d519836a61d1c6fa48
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ .DS_Store
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Colby Aley & Jackson Gariety
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,19 @@
1
+ # Commitphotos
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ $ gem install commitphotos
8
+
9
+ ## Usage
10
+
11
+ $ commitphotos install (--global)
12
+
13
+ ## Contributing
14
+
15
+ 1. Fork it
16
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
17
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
18
+ 4. Push to the branch (`git push origin my-new-feature`)
19
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ task :irb do
4
+ require File.expand_path('../lib/commitphotos.rb', __FILE__)
5
+ sh 'irb -r ./lib/commitphotos.rb'
6
+ end
data/bin/commitphotos ADDED
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'commitphotos'
4
+ require 'choice'
5
+
6
+ Choice.options do
7
+ header 'Options:'
8
+
9
+ option :global do
10
+ short '-g'
11
+ long '--global'
12
+ desc 'Install commitphotos globally so all new git repos will take photos.'
13
+ end
14
+
15
+ option :video do
16
+ short '-v'
17
+ long '--video'
18
+ desc 'Create three-second gifs instead of photos.'
19
+ end
20
+ end
21
+
22
+ case ARGV[0]
23
+ when 'install' then CommitPhoto.hook(Choice.choices[:global], Choice.choices[:video])
24
+ else puts Choice.help
25
+ end
@@ -0,0 +1,30 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'commitphotos/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "commitphotos"
8
+ spec.version = CommitPhoto::VERSION
9
+ spec.authors = ["Colby Aley", "Jackson Gariety"]
10
+ spec.email = ["colby@aley.me", "Jackson Gariety"]
11
+ spec.description = "Record yourself every time you commit and show it to the world."
12
+ spec.summary = "A photo or video on every commit."
13
+ spec.homepage = "http://commitphotos.com/"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ # Dependencies
22
+ spec.add_runtime_dependency "mini_magick"
23
+ spec.add_runtime_dependency "choice"
24
+ spec.add_runtime_dependency "rest-client"
25
+
26
+ # Development dependencies
27
+ spec.add_development_dependency "bundler", "~> 1.3"
28
+ spec.add_development_dependency "rake"
29
+ spec.add_development_dependency "rspec"
30
+ end
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require 'commitphotos'
3
+
4
+ CommitPhoto.image
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require 'commitphotos'
3
+
4
+ CommitPhoto.video
@@ -0,0 +1,19 @@
1
+ class Image < CommitPhoto
2
+ def initialize
3
+ tempfile = Tempfile.new(Time.now.to_i.to_s)
4
+ file = tempfile.path
5
+
6
+ `#{dir}/imagesnap -w 2 -q #{file}`
7
+
8
+ begin
9
+ image = MiniMagick::Image.open file
10
+ image.resize '800x800>'
11
+ image.write file
12
+ post(File.open file)
13
+ rescue => e
14
+ abort "Unable to capture photo: #{e.message}"
15
+ ensure
16
+ tempfile.unlink
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,3 @@
1
+ class CommitPhoto
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,15 @@
1
+ class Video < CommitPhoto
2
+ def initialize
3
+ path = "/tmp/#{Time.now.to_i.to_s}.mov"
4
+
5
+ `#{dir}/videosnap -t 2 --no-audio #{path}`
6
+
7
+ begin
8
+ post(File.open path)
9
+ rescue => e
10
+ abort "Unable to capture video: #{e.message}"
11
+ ensure
12
+ FileUtils.rm(path)
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,56 @@
1
+ require 'fileutils'
2
+ require 'commitphotos/version'
3
+ require 'mini_magick'
4
+ require 'rest-client'
5
+ require 'tempfile'
6
+
7
+ require 'commitphotos/video'
8
+ require 'commitphotos/image'
9
+
10
+ class CommitPhoto
11
+ # This will setup Commitphotos for the user.
12
+ def self.hook(global, video)
13
+ if global
14
+ destination = File.expand_path(`git config --get init.templatedir`.chomp)
15
+ if destination.empty?
16
+ destination = '~/.gittemplates'
17
+ mkdir_p(destination) unless File.exist?(destination)
18
+ `git config --global init.templatedir #{destination}`
19
+ end
20
+ else
21
+ destination = File.expand_path(File.join(Dir.pwd, '.git/hooks'))
22
+ abort 'Error: not a git repository.' unless File.exist? File.join(Dir.pwd, '.git')
23
+ end
24
+
25
+ type = video ? 'video' : 'image'
26
+
27
+ local_post_commit = "#{File.expand_path(File.dirname(__FILE__))}/commitphotos/hooks/post-commit-#{type}"
28
+
29
+ FileUtils.mkdir_p(destination)
30
+ FileUtils.copy(local_post_commit, File.join(destination, 'post-commit'))
31
+ end
32
+
33
+ def self.image
34
+ Image.new
35
+ end
36
+
37
+ def self.video
38
+ Video.new
39
+ end
40
+
41
+ private
42
+
43
+ def dir
44
+ File.expand_path(File.dirname(__FILE__))
45
+ end
46
+
47
+ # Take the photo or video and upload it to commitphotos.com.
48
+ def post(file)
49
+ RestClient.post('http://commitphotos.com/',
50
+ email: `git config --get user.email`.chomp,
51
+ user_name: `git config --get user.name`.chomp,
52
+ message: `git log -1 HEAD --pretty=format:%s`,
53
+ photo: File.new(file, 'rb')
54
+ )
55
+ end
56
+ end
data/lib/imagesnap ADDED
Binary file
data/lib/videosnap ADDED
Binary file
@@ -0,0 +1,74 @@
1
+ require 'fileutils'
2
+ require 'rest-client'
3
+
4
+ include FileUtils
5
+
6
+ # some variables
7
+ local_post_commit_image_path = File.expand_path('lib/commitphotos/hooks/post-commit-image')
8
+ local_post_commit_video_path = File.expand_path('lib/commitphotos/hooks/post-commit-video')
9
+ local_post_commit_path = File.expand_path('.git/hooks/post-commit')
10
+ global_post_commit_path = File.expand_path(File.join(`git config --get init.templatedir`.chomp, 'post-commit'))
11
+
12
+ describe 'commitphotos' do
13
+ before(:all) do
14
+ `gem build commitphotos.gemspec`
15
+ `gem install commitphotos-0.0.1.gem`
16
+ `rm commitphotos-0.0.1.gem`
17
+ end
18
+
19
+ describe 'hook' do
20
+ describe 'install' do
21
+ before(:all) do
22
+ `commitphotos install rspec_tmp`
23
+ end
24
+
25
+ it 'should move the image hook into the .git/hooks directory' do
26
+ compare_file(local_post_commit_image_path, local_post_commit_path)
27
+ end
28
+ end
29
+
30
+ describe 'install --global' do
31
+ before(:all) do
32
+ `commitphotos install rspec_tmp --global`
33
+ end
34
+
35
+ it 'should move the image hook into gits init.templatedir directory' do
36
+ compare_file(local_post_commit_image_path, global_post_commit_path)
37
+ end
38
+ end
39
+
40
+ describe 'install --video' do
41
+ before(:all) do
42
+ `commitphotos install rspec_tmp --video`
43
+ end
44
+
45
+ it 'should move the image hook into the .git/hooks directory' do
46
+ compare_file(local_post_commit_video_path, local_post_commit_path)
47
+ end
48
+ end
49
+
50
+ describe 'install --global --video' do
51
+ before(:all) do
52
+ `commitphotos install rspec_tmp --global --video`
53
+ end
54
+
55
+ it 'should move the image hook into the .git/hooks directory' do
56
+ compare_file(local_post_commit_video_path, global_post_commit_path)
57
+ end
58
+ end
59
+
60
+ after(:all) do
61
+ remove(local_post_commit_path)
62
+ end
63
+ end
64
+
65
+ describe 'image' do
66
+ before do
67
+ `ruby lib/commitphotos/hooks/post-commit-image`
68
+ end
69
+
70
+ it 'should upload a file to commitphotos.com' do
71
+ # `ruby`
72
+ end
73
+ end
74
+ end
metadata ADDED
@@ -0,0 +1,148 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: commitphotos
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Colby Aley
8
+ - Jackson Gariety
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2014-01-12 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: mini_magick
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - '>='
19
+ - !ruby/object:Gem::Version
20
+ version: '0'
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - '>='
26
+ - !ruby/object:Gem::Version
27
+ version: '0'
28
+ - !ruby/object:Gem::Dependency
29
+ name: choice
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - '>='
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ type: :runtime
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - '>='
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ - !ruby/object:Gem::Dependency
43
+ name: rest-client
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - '>='
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ type: :runtime
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - '>='
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ - !ruby/object:Gem::Dependency
57
+ name: bundler
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ~>
61
+ - !ruby/object:Gem::Version
62
+ version: '1.3'
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ~>
68
+ - !ruby/object:Gem::Version
69
+ version: '1.3'
70
+ - !ruby/object:Gem::Dependency
71
+ name: rake
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - '>='
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ - !ruby/object:Gem::Dependency
85
+ name: rspec
86
+ requirement: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - '>='
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ type: :development
92
+ prerelease: false
93
+ version_requirements: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - '>='
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
98
+ description: Record yourself every time you commit and show it to the world.
99
+ email:
100
+ - colby@aley.me
101
+ - Jackson Gariety
102
+ executables:
103
+ - commitphotos
104
+ extensions: []
105
+ extra_rdoc_files: []
106
+ files:
107
+ - .gitignore
108
+ - Gemfile
109
+ - LICENSE.txt
110
+ - README.md
111
+ - Rakefile
112
+ - bin/commitphotos
113
+ - commitphotos.gemspec
114
+ - lib/commitphotos.rb
115
+ - lib/commitphotos/hooks/post-commit-image
116
+ - lib/commitphotos/hooks/post-commit-video
117
+ - lib/commitphotos/image.rb
118
+ - lib/commitphotos/version.rb
119
+ - lib/commitphotos/video.rb
120
+ - lib/imagesnap
121
+ - lib/videosnap
122
+ - spec/commitphotos_spec.rb
123
+ homepage: http://commitphotos.com/
124
+ licenses:
125
+ - MIT
126
+ metadata: {}
127
+ post_install_message:
128
+ rdoc_options: []
129
+ require_paths:
130
+ - lib
131
+ required_ruby_version: !ruby/object:Gem::Requirement
132
+ requirements:
133
+ - - '>='
134
+ - !ruby/object:Gem::Version
135
+ version: '0'
136
+ required_rubygems_version: !ruby/object:Gem::Requirement
137
+ requirements:
138
+ - - '>='
139
+ - !ruby/object:Gem::Version
140
+ version: '0'
141
+ requirements: []
142
+ rubyforge_project:
143
+ rubygems_version: 2.1.11
144
+ signing_key:
145
+ specification_version: 4
146
+ summary: A photo or video on every commit.
147
+ test_files:
148
+ - spec/commitphotos_spec.rb