time_cop 0.7.0 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 79389be668d32868c727b13d6ce34ac5ece7f70b
4
- data.tar.gz: f15e624a821ff4ef3aa312313278c968dd876f9f
3
+ metadata.gz: d92283db162ec5be4691e842d3af922fadb985af
4
+ data.tar.gz: 3d7dc0135dae7784ab0dfbea08f0b88f4d918a5e
5
5
  SHA512:
6
- metadata.gz: 48ed8649132f365a3732e1b30ca10b49ea082bdb0a0df7c8d250d480ace3e0b11aa9590eb8255a719a9bcb8653f0d0bb5f6f922ee801e5c25b932cfc7ac2628f
7
- data.tar.gz: 427c2a6458541ee41c8fc655d741492015d33277c7404fdaad2dc946123fc3fc49079397827d023f642a51cfe6dec457479be686dd4abf63f354d699b3c57249
6
+ metadata.gz: 707941008f8ea575c15242bf06d8fc5a965ee8baa0779364803828eae8b2b1aad1172f1007bfa9ba65f82055a4f644b210ea61f302ec0f20fdd22efef3f22383
7
+ data.tar.gz: 83e1af161c88299a0661f6b028487da1893946252d91d41ca2ffdbeed5907d5f7c8cf01f54ea7be098369d979b5047318d2550dfcdef3a407fd0d3e713d742b8
@@ -1,5 +1,6 @@
1
1
  require 'harvested'
2
2
  require 'date'
3
+ require 'paint'
3
4
 
4
5
  module TimeCop
5
6
  class Accountability
@@ -60,6 +61,11 @@ module TimeCop
60
61
  end
61
62
  end
62
63
 
64
+ def active_quarter?
65
+ quarter_range = (date_from_period(get_quarter[0])...date_from_period(get_quarter[1]))
66
+ quarter_range.include?(Date.today)
67
+ end
68
+
63
69
  def get_quarter
64
70
  select_quarter.first[1]
65
71
  end
@@ -84,6 +90,22 @@ module TimeCop
84
90
  (end_of_quarter_date - start_of_quarter_date).to_i
85
91
  end
86
92
 
93
+ def weekdays_left(include_today = false)
94
+ if include_today
95
+ weekdays_between(Date.today, end_of_quarter_date)
96
+ else
97
+ weekdays_between(Date.today + 1, end_of_quarter_date)
98
+ end
99
+ end
100
+
101
+ def weekdays_so_far(include_today = true)
102
+ if include_today
103
+ weekdays_between(start_of_quarter_date, Date.today)
104
+ else
105
+ weekdays_between(start_of_quarter_date, Date.today - 1)
106
+ end
107
+ end
108
+
87
109
  def weekdays_between(start_date, end_date)
88
110
  (start_date..end_date).select{|d| (1..5).include?(d.wday)}.size
89
111
  end
@@ -100,6 +122,18 @@ module TimeCop
100
122
  weekdays_between(start_of_quarter_date, today < end_of_quarter_date ? Date.today : end_of_quarter_date) * hours_per_day
101
123
  end
102
124
 
125
+ def average_quarter_hours_per_day
126
+ if weekdays_so_far(false) > 0
127
+ total_quarter_time_tracked / weekdays_so_far(false)
128
+ else
129
+ 0
130
+ end
131
+ end
132
+
133
+ def projected_quarter_hours
134
+ ((total_quarter_time_tracked + (weekdays_left(false) * average_quarter_hours_per_day)) - expected_quarter_hours)
135
+ end
136
+
103
137
  def current_hours_delta
104
138
  total_quarter_time_tracked - expected_quarter_hours_to_today
105
139
  end
@@ -116,31 +150,47 @@ module TimeCop
116
150
  end
117
151
  end
118
152
 
153
+ def self.paint_number(number)
154
+ Paint[number, (number >= 0 ? :green : :red)]
155
+ end
156
+
119
157
  def summary_hash
120
158
  {
121
159
  quarter: {
122
160
  start: start_of_quarter_date,
123
161
  end: end_of_quarter_date,
124
- weekdays_in_quarter: weekdays_between(@report_builder.start_date, @report_builder.end_date)
162
+ weekdays_in_quarter: weekdays_between(@report_builder.start_date, @report_builder.end_date),
163
+ weekdays_so_far: weekdays_so_far,
164
+ weekdays_left: weekdays_left
125
165
  },
126
166
  hours_per_week: @hours_per_week,
127
167
  hours: {
128
168
  charged: total_quarter_time_tracked,
129
169
  needed: expected_quarter_hours,
170
+ average_charged: average_quarter_hours_per_day,
171
+ average_needed: quarterly_hours_per_business_day_needed,
172
+ total_projected: projected_quarter_hours
130
173
  }
131
174
  }
132
175
  end
133
176
 
134
177
  def print_report
135
- puts "Quarter Period: #{start_of_quarter_date} #{end_of_quarter_date}"
178
+ puts "Quarter Period: #{start_of_quarter_date} - #{end_of_quarter_date}"
136
179
  puts "Hours Per Week: #{@hours_per_week}"
137
- puts "Current Surplus(+)/Deficit(-): #{current_hours_delta.round(2)}"
180
+ puts ""
138
181
  puts "Quarterly Hour Target: #{expected_quarter_hours.round(2)}"
139
- puts "Current Quarterly Charged Hours: #{total_quarter_time_tracked.round(2)}"
140
- if (@date.year == Date.today.year)
141
- puts "Total Hours Needed By End Of Quarter: #{quarterly_hours_delta.round(2)}"
142
- puts "Hours Per Business Day Average Needed To Reach Goal: #{quarterly_hours_per_business_day_needed.round(2)}"
182
+ puts "Quarterly Hours Charged: #{total_quarter_time_tracked.round(2)}"
183
+ if active_quarter?
184
+ puts ""
185
+ puts "Business Days Left In The Quarter (Excluding Today): #{weekdays_left(false)}"
186
+ puts ""
187
+ puts "Additional Hours Needed By End Of Quarter: #{quarterly_hours_delta.round(2)}"
188
+ puts "Average Hours Per Business Day Worked: #{average_quarter_hours_per_day.round(2)}"
189
+ puts "Hours Per Business Day Average Needed: #{quarterly_hours_per_business_day_needed.round(2)}"
143
190
  end
191
+ puts""
192
+ puts "Quarter Surplus(+)/Deficit(-): #{Accountability.paint_number(current_hours_delta.round(2))}"
193
+ puts "Projected Surplus(+)/Deficit(-): #{Accountability.paint_number(projected_quarter_hours.round(2))}" if active_quarter?
144
194
  end
145
195
  end
146
196
  end
@@ -58,6 +58,7 @@ module TimeCop
58
58
  puts "Fetching data for #{q_date[:choice]}..."
59
59
  Accountability.new(interactive_hash.merge(accountability_options)).summary_hash
60
60
  end
61
+ puts ""
61
62
  logged = summary.inject(0){|sum, s| sum + s[:hours][:charged]}
62
63
  needed = summary.inject(0){|sum, s| sum + s[:hours][:needed]}.round(2 )
63
64
  diff = (logged - needed).round(2)
@@ -66,20 +67,18 @@ module TimeCop
66
67
  average_needed = (-1 * diff / weekdays).round(2)
67
68
  average_clocked = (logged / weekdays_so_far).round(2)
68
69
  projected_diff = ((logged + (weekdays * average_clocked)) - needed).round(2)
70
+ puts "Total Hours for #{year}: #{logged}"
71
+ puts "Average Hours Per Business Day: #{average_clocked}"
69
72
  if (year == Date.today.year)
73
+ puts "Total Hours Needed By End Of Year: #{needed}"
74
+ puts ""
70
75
  puts "Business Days Left In Year: #{weekdays}"
71
- puts "Current Year End Surplus(+)/Deficit(-): #{diff}"
72
- puts "Projected Year End Surplus(+)/Deficit(-): #{projected_diff}"
76
+ puts "Average Hours Per Business Day Needed To Reach Goal: #{average_needed}"
73
77
  puts ""
78
+ puts "Current Year End Surplus(+)/Deficit(-): #{Accountability.paint_number(diff)}"
79
+ puts "Projected Year End Surplus(+)/Deficit(-): #{Accountability.paint_number(projected_diff)}"
74
80
  else
75
- puts "#{year} Surplus(+)/Deficit(-): #{diff}"
76
- end
77
- puts "Total Harvest Hours for #{year}: #{logged}"
78
- puts "Average Harvest Hours Per Business Day: #{average_clocked}"
79
- if (year == Date.today.year)
80
- puts ""
81
- puts "Total Hours Needed By End Of Year: #{needed}"
82
- puts "Average Hours Per Business Day Needed To Reach Goal: #{average_needed}"
81
+ puts "#{year} Surplus(+)/Deficit(-): #{Accountability.paint_number(diff)}"
83
82
  end
84
83
  end
85
84
  end
@@ -1,3 +1,3 @@
1
1
  module TimeCop
2
- VERSION = "0.7.0"
2
+ VERSION = "0.8.0"
3
3
  end
data/time_cop.gemspec CHANGED
@@ -32,6 +32,7 @@ Gem::Specification.new do |spec|
32
32
  spec.add_runtime_dependency "harvested", "~> 3.1.1"
33
33
  spec.add_runtime_dependency "highline", "~> 1.7.8"
34
34
  spec.add_runtime_dependency 'activesupport', '~> 5.0'
35
+ spec.add_runtime_dependency 'paint', '~> 2.0.1'
35
36
 
36
37
  spec.add_development_dependency "bundler", "~> 1.13"
37
38
  spec.add_development_dependency "rake", "~> 10.0"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: time_cop
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Clopton
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-03-22 00:00:00.000000000 Z
11
+ date: 2018-06-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: harvested
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '5.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: paint
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 2.0.1
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 2.0.1
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: bundler
57
71
  requirement: !ruby/object:Gem::Requirement