gitme_time 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -76,8 +76,9 @@ load Gem.bin_path('gitme_time', 'gitme_time')
76
76
  puts "Project config file already exists (#{GitmeTime::Config.project_config_file}). Skipping ..."
77
77
  else
78
78
  puts "Generating Project config file ..."
79
+ config = { 'domain' => get_domain, 'project_id' => get_project, 'tag' => get_tag, 'track_empty_hours' => get_track_empty_hours }
79
80
  File.open Config.project_config_file, 'w' do |f|
80
- f.write({ 'domain' => get_domain, 'project_id' => get_project }.to_yaml)
81
+ f.write(config.to_yaml)
81
82
  end
82
83
  puts "Project config file generated!"
83
84
  end
@@ -85,6 +86,28 @@ load Gem.bin_path('gitme_time', 'gitme_time')
85
86
 
86
87
  private
87
88
 
89
+ def get_track_empty_hours
90
+ print "\tDo you want to track all commit (saying no will track only commits with hours specification): "
91
+ track_empty_hours = nil
92
+ while track_empty_hours.nil?
93
+ track_empty_hours = STDIN.gets.chomp.downcase
94
+ if %w(y yes true).include? track_empty_hours
95
+ track_empty_hours = true
96
+ elsif %w(n no false).include? track_empty_hours
97
+ track_empty_hours = false
98
+ else
99
+ print "\tUse y/yes/true to agree, n/no/false to disagree: "
100
+ track_empty_hours = nil
101
+ end
102
+ end
103
+ track_empty_hours
104
+ end
105
+
106
+ def get_tag
107
+ print "\tInsert a tag to prepend to all the time entries (leave blank for no tag): "
108
+ STDIN.gets.chomp
109
+ end
110
+
88
111
  def get_project
89
112
  projects = Basecamp::Project.all
90
113
  puts "\tChoose a project from one of the following:"
@@ -11,6 +11,14 @@ module GitmeTime
11
11
  `git rev-parse --show-toplevel 2> /dev/null`.chomp
12
12
  end
13
13
 
14
+ def project_tag
15
+ project_data['tag']
16
+ end
17
+
18
+ def track_empty_hours?
19
+ project_data['track_empty_hours']
20
+ end
21
+
14
22
  def domain
15
23
  project_data['domain']
16
24
  end
@@ -1,3 +1,3 @@
1
1
  module GitmeTime
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.1'
3
3
  end
data/lib/gitme_time.rb CHANGED
@@ -8,21 +8,29 @@ end
8
8
  module GitmeTime
9
9
  def self.create_entry_for_last_commit
10
10
  commit = last_commit
11
+ hours = nil
11
12
  if commit.message =~ /\[\w+\]$/
12
13
  match = commit.message.match /(.*)\[(\w+)\]$/
13
14
  message, hours = match[1], match[2]
14
- else
15
+ elsif Config.track_empty_hours?
15
16
  message = commit.message
16
17
  hours = 0
17
18
  end
18
- message << " [#{current_branch} #{commit.sha[0,6]}]"
19
- create_entry message, :hours => hours
19
+ # hours is nil when commit does not have hours specification and
20
+ # we do not have to track empty hours
21
+ if hours
22
+ message << " [#{current_branch} #{commit.sha[0,6]}]"
23
+ create_entry message, :hours => hours
24
+ else
25
+ puts " TimeEntry creation ignored (no hours specification in commit)"
26
+ end
20
27
  end
21
28
 
22
29
  private
23
30
 
24
31
  def self.create_entry message, args = {}
25
32
  connect!
33
+ message = "[#{Config.project_tag}] #{message}" if Config.project_tag.present?
26
34
  entry = Basecamp::TimeEntry.new({
27
35
  :project_id => Config.project_id,
28
36
  :person_id => Basecamp::Person.me.id,
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gitme_time
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
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-12-06 00:00:00.000000000 Z
12
+ date: 2012-12-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: basecamp
@@ -161,12 +161,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
161
161
  - - ! '>='
162
162
  - !ruby/object:Gem::Version
163
163
  version: '0'
164
+ segments:
165
+ - 0
166
+ hash: -973034721650163537
164
167
  required_rubygems_version: !ruby/object:Gem::Requirement
165
168
  none: false
166
169
  requirements:
167
170
  - - ! '>='
168
171
  - !ruby/object:Gem::Version
169
172
  version: '0'
173
+ segments:
174
+ - 0
175
+ hash: -973034721650163537
170
176
  requirements: []
171
177
  rubyforge_project:
172
178
  rubygems_version: 1.8.24