gitme_time 0.0.1

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/.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
+ bin/stubs
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format progress
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in basecamp-gitter.gemspec
4
+ gemspec
data/Guardfile ADDED
@@ -0,0 +1,9 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ guard 'rspec' do
5
+ watch(%r{^spec/.+_spec\.rb$})
6
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
7
+ watch('spec/spec_helper.rb') { "spec" }
8
+ end
9
+
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Nicola Racco
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,51 @@
1
+ # GitmeTime
2
+
3
+ GitmeTime is an hook for git that logs each commit on the Basecamp timeline.
4
+
5
+ Once installed and configured for your project, gitme_time will create an entry in your basecamp timeline for each commit you do.
6
+ The message of the commit will be in the format `<commit.message> (<commit.branch> : <commit.sha>)` with an empty duration.
7
+
8
+ If you specify a number between square brackets in your commit message, it will be used as time entry duration. e.g.:
9
+
10
+ ```
11
+ git commit -am "small refactoring [2]" # => entry with description "small refactoring" and duration of 2 hours
12
+ ```
13
+
14
+ # Installation
15
+
16
+ ```
17
+ gem install gitme_time
18
+ ```
19
+
20
+ # Configuration
21
+
22
+ First of all, you need to setup your basecamp credentials:
23
+
24
+ ```
25
+ git config --global --add basecamp.username <username>
26
+ git config --global --add basecamp.password <password>
27
+ ```
28
+
29
+ Then, inside your project, launch gitme_time init to configure your project:
30
+
31
+ ```
32
+ cd /path/to/git/project
33
+ gitme_time init
34
+ ```
35
+
36
+ As a final step, add a hook to your git repository:
37
+
38
+ ```
39
+ cd /path/to/git/project
40
+ ln -sf `which gitme_time` ./.git/hooks/post-commit
41
+ ```
42
+
43
+ # TODO
44
+
45
+ - Specs!
46
+
47
+ # Get ready to contribute!
48
+
49
+ - Fork this repo
50
+ - Run 'bundle install --binstubs=bin/stubs' from the repo
51
+ - Run the specs with either 'thor spec' or 'guard'
data/Thorfile ADDED
@@ -0,0 +1,30 @@
1
+ # encoding: utf-8
2
+ $:.unshift File.expand_path('../lib', __FILE__)
3
+
4
+ require 'bundler'
5
+ require 'thor/rake_compat'
6
+
7
+ class Default < Thor
8
+ include Thor::RakeCompat
9
+ Bundler::GemHelper.install_tasks
10
+
11
+ desc "build", "Build gitme_time-#{GitmeTime::VERSION}.gem into the pkg directory"
12
+ def build
13
+ Rake::Task["build"].execute
14
+ end
15
+
16
+ desc "install", "Build and install gitme_time-#{GitmeTime::VERSION}.gem into system gems"
17
+ def install
18
+ Rake::Task["install"].execute
19
+ end
20
+
21
+ desc "release", "Create tag v#{GitmeTime::VERSION} and build and push thor-#{GitmeTime::VERSION}.gem to Rubygems"
22
+ def release
23
+ Rake::Task["release"].execute
24
+ end
25
+
26
+ desc "spec", "Run RSpec code examples"
27
+ def spec
28
+ exec "rspec"
29
+ end
30
+ end
data/bin/gitme_time ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+ require 'gitme_time'
3
+ require 'gitme_time/cli'
4
+
5
+ GitmeTime::CLI::App.start
@@ -0,0 +1,28 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'gitme_time/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "gitme_time"
8
+ gem.version = GitmeTime::VERSION
9
+ gem.authors = ["MIKAMAI"]
10
+ gem.email = ["projects@mikamai.com"]
11
+ gem.description = %q{Utility to simplify your time-logging on Basecamp}
12
+ gem.summary = %q{GitmeTime is an hook for git that logs each commit on the Basecamp timeline}
13
+ gem.homepage = "https://github.com/mikamai/gitme_time"
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+
20
+ gem.add_dependency 'basecamp', '=0.0.9'
21
+ gem.add_dependency 'grit'
22
+ gem.add_dependency 'thor'
23
+
24
+ gem.add_development_dependency 'rspec'
25
+ gem.add_development_dependency 'guard-rspec'
26
+ gem.add_development_dependency 'rb-fsevent'
27
+ gem.add_development_dependency 'pry'
28
+ end
@@ -0,0 +1,13 @@
1
+ require 'basecamp'
2
+
3
+ Basecamp::TimeEntry.class_eval do
4
+ def project
5
+ Basecamp::Project.find prefix_options[:project_id]
6
+ end
7
+ end
8
+
9
+ Basecamp::Person.class_eval do
10
+ def name
11
+ "#{first_name} #{last_name}"
12
+ end
13
+ end
@@ -0,0 +1,38 @@
1
+ require 'thor'
2
+
3
+ module GitmeTime
4
+ module CLI
5
+ class App < Thor
6
+ default_task :create_entry
7
+
8
+ desc "create_entry", "Create an entry in Basecamp for the last commit"
9
+ def create_entry
10
+ after_first_validation { GitmeTime::create_entry_for_last_commit }
11
+ end
12
+
13
+ desc "init", "Init GitmeTime for the current project"
14
+ def init
15
+ after_first_validation { InitTutorial.create_project_config_file }
16
+ end
17
+
18
+ no_tasks do
19
+ def after_first_validation &block
20
+ if Config.project_directory?
21
+ if Config.username.nil? || Config.password.nil?
22
+ puts <<-eos
23
+ Cannot init GitmeTime until you have not configured your basecamp username a password.
24
+ To setup your basecamp username and password, type the following:
25
+ git config --global --add basecamp.username <username>
26
+ git config --global --add basecamp.password <password>
27
+ eos
28
+ else
29
+ yield
30
+ end
31
+ else
32
+ puts "You are not in a git repository. Launch GitmeTime from a git repository!"
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,66 @@
1
+ module GitmeTime
2
+ module CLI
3
+ module InitTutorial
4
+ def self.create_project_config_file
5
+ unless GitmeTime::Config.project_data?
6
+ puts "Project config file already exists (#{GitmeTime::Config.project_config_file}). Skipping ..."
7
+ else
8
+ puts "Generating Project config file ..."
9
+ File.open Config.project_config_file, 'w' do |f|
10
+ f.write({ 'domain' => get_domain, 'project_id' => get_project }.to_yaml)
11
+ end
12
+ puts "Project config file generated!"
13
+ end
14
+ puts "Remember to add the git hook like in the following way:"
15
+ puts "\tln -s `which gitme_time` ./.git/hooks/post-commit"
16
+ end
17
+
18
+ private
19
+
20
+ def self.get_project
21
+ projects = Basecamp::Project.all
22
+ puts "\tChoose a project from one of the following:"
23
+ projects.each_with_index do |project, index|
24
+ puts "\t\t#{index + 1} - #{project.name}"
25
+ end
26
+
27
+ project_id = nil
28
+ while project_id.nil?
29
+ puts
30
+ print "\tProject (e.g. 1): "
31
+ project_id = STDIN.gets.chomp
32
+ if project_id.empty?
33
+ puts "\t\tProject is required!"
34
+ project_id = nil
35
+ elsif project_id.to_i < 1 || project_id.to_i > projects.length
36
+ puts "\t\tA project index between 1 and #{projects.count} is required!"
37
+ project_id = nil
38
+ end
39
+ end
40
+ project_id.to_i
41
+ end
42
+
43
+ def self.get_domain
44
+ domain = nil
45
+ while domain.nil?
46
+ puts
47
+ print "\tBasecamp Domain (e.g. company.basecamphq.com): "
48
+ domain = STDIN.gets.chomp
49
+ if domain.empty?
50
+ puts "\t\tBasecamp Domain is required!"
51
+ domain = nil
52
+ else
53
+ begin
54
+ GitmeTime.connect! :domain => domain
55
+ Basecamp::Person.me # connection test
56
+ rescue SocketError
57
+ puts "\t\tCannot connect to https://#{domain} !"
58
+ domain = nil
59
+ end
60
+ end
61
+ end
62
+ domain
63
+ end
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,3 @@
1
+ dir = File.expand_path '../cli', __FILE__
2
+ require "#{dir}/init_tutorial"
3
+ require "#{dir}/app"
@@ -0,0 +1,49 @@
1
+ require 'grit'
2
+
3
+ module GitmeTime
4
+ module Config
5
+ class << self
6
+ def project_directory?
7
+ project_directory.present?
8
+ end
9
+
10
+ def project_directory
11
+ `git rev-parse --show-toplevel 2> /dev/null`.chomp
12
+ end
13
+
14
+ def domain
15
+ project_data['domain']
16
+ end
17
+
18
+ def project_id
19
+ project_data['project_id']
20
+ end
21
+
22
+ def username
23
+ user_data['basecamp.username']
24
+ end
25
+
26
+ def password
27
+ user_data['basecamp.password']
28
+ end
29
+
30
+ def project_data?
31
+ File.exists? project_config_file
32
+ end
33
+
34
+ def project_config_file
35
+ File.join project_directory, '.gitme_time.yml'
36
+ end
37
+
38
+ private
39
+
40
+ def project_data
41
+ YAML::load_file(project_config_file)
42
+ end
43
+
44
+ def user_data
45
+ Grit::Repo.new(project_directory).config
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,3 @@
1
+ module GitmeTime
2
+ class InvalidRepo < Exception; end
3
+ end
@@ -0,0 +1,3 @@
1
+ module GitmeTime
2
+ VERSION = '0.0.1'
3
+ end
data/lib/gitme_time.rb ADDED
@@ -0,0 +1,57 @@
1
+ require 'basecamp'
2
+
3
+ dir = File.expand_path '../gitme_time', __FILE__
4
+ %w(version config basecamp_ext).each do |f|
5
+ require File.join dir, f
6
+ end
7
+
8
+ module GitmeTime
9
+ def self.create_entry_for_last_commit
10
+ commit = last_commit
11
+ if commit.message =~ /\[\w+\]$/
12
+ match = commit.message.match /(.*)\[(\w+)\]$/
13
+ message, hours = match[1], match[2]
14
+ else
15
+ message = commit.message
16
+ hours = 0
17
+ end
18
+ message << " (#{current_branch} : #{commit.sha[0,6]})"
19
+ create_entry message, :hours => hours
20
+ end
21
+
22
+ private
23
+
24
+ def self.create_entry message, args = {}
25
+ connect!
26
+ entry = Basecamp::TimeEntry.new({
27
+ :project_id => Config.project_id,
28
+ :person_id => Basecamp::Person.me.id,
29
+ :date => Date.today,
30
+ :hours => args[:hours] || 0,
31
+ :description => message
32
+ })
33
+ entry.save!
34
+ puts <<-eos
35
+ Created TimeEntry on #{Config.domain} - #{entry.project.name}:
36
+ - Message: #{entry.description}
37
+ - Person : #{Basecamp::Person.me.name}
38
+ - Date : #{entry.date}
39
+ - Hours : #{entry.hours}
40
+ eos
41
+ end
42
+
43
+ def self.last_commit
44
+ Grit::Repo.new(Config.project_directory).head.commit
45
+ end
46
+
47
+ def self.current_branch
48
+ Grit::Repo.new(Config.project_directory).head.name
49
+ end
50
+
51
+ def self.connect! args = {}
52
+ domain = args[:domain] || Config.domain
53
+ username = args[:username] || Config.username
54
+ password = args[:password] || Config.password
55
+ Basecamp.establish_connection! domain, username, password, true
56
+ end
57
+ end
@@ -0,0 +1,13 @@
1
+ require File.expand_path '../../lib/gitme_time', __FILE__
2
+
3
+ RSpec.configure do |config|
4
+ config.treat_symbols_as_metadata_keys_with_true_values = true
5
+ config.run_all_when_everything_filtered = true
6
+ config.filter_run :focus
7
+
8
+ # Run specs in random order to surface order dependencies. If you find an
9
+ # order dependency and want to debug it, you can fix the order by providing
10
+ # the seed, which is printed after each run.
11
+ # --seed 1234
12
+ config.order = 'random'
13
+ end
metadata ADDED
@@ -0,0 +1,183 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gitme_time
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - MIKAMAI
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-12-06 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: basecamp
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - '='
20
+ - !ruby/object:Gem::Version
21
+ version: 0.0.9
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - '='
28
+ - !ruby/object:Gem::Version
29
+ version: 0.0.9
30
+ - !ruby/object:Gem::Dependency
31
+ name: grit
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: thor
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: rspec
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: guard-rspec
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ - !ruby/object:Gem::Dependency
95
+ name: rb-fsevent
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ - !ruby/object:Gem::Dependency
111
+ name: pry
112
+ requirement: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ! '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ! '>='
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ description: Utility to simplify your time-logging on Basecamp
127
+ email:
128
+ - projects@mikamai.com
129
+ executables:
130
+ - gitme_time
131
+ extensions: []
132
+ extra_rdoc_files: []
133
+ files:
134
+ - .gitignore
135
+ - .rspec
136
+ - Gemfile
137
+ - Guardfile
138
+ - LICENSE.txt
139
+ - README.md
140
+ - Thorfile
141
+ - bin/gitme_time
142
+ - gitme_time.gemspec
143
+ - lib/gitme_time.rb
144
+ - lib/gitme_time/basecamp_ext.rb
145
+ - lib/gitme_time/cli.rb
146
+ - lib/gitme_time/cli/app.rb
147
+ - lib/gitme_time/cli/init_tutorial.rb
148
+ - lib/gitme_time/config.rb
149
+ - lib/gitme_time/errors.rb
150
+ - lib/gitme_time/version.rb
151
+ - spec/spec_helper.rb
152
+ homepage: https://github.com/mikamai/gitme_time
153
+ licenses: []
154
+ post_install_message:
155
+ rdoc_options: []
156
+ require_paths:
157
+ - lib
158
+ required_ruby_version: !ruby/object:Gem::Requirement
159
+ none: false
160
+ requirements:
161
+ - - ! '>='
162
+ - !ruby/object:Gem::Version
163
+ version: '0'
164
+ segments:
165
+ - 0
166
+ hash: -4385769685818955981
167
+ required_rubygems_version: !ruby/object:Gem::Requirement
168
+ none: false
169
+ requirements:
170
+ - - ! '>='
171
+ - !ruby/object:Gem::Version
172
+ version: '0'
173
+ segments:
174
+ - 0
175
+ hash: -4385769685818955981
176
+ requirements: []
177
+ rubyforge_project:
178
+ rubygems_version: 1.8.24
179
+ signing_key:
180
+ specification_version: 3
181
+ summary: GitmeTime is an hook for git that logs each commit on the Basecamp timeline
182
+ test_files:
183
+ - spec/spec_helper.rb