time_cop 0.6.0 → 0.7.0
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.
- checksums.yaml +4 -4
- data/README.md +11 -1
- data/lib/time_cop/accountability.rb +7 -5
- data/lib/time_cop/runner.rb +51 -37
- data/lib/time_cop/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 79389be668d32868c727b13d6ce34ac5ece7f70b
|
4
|
+
data.tar.gz: f15e624a821ff4ef3aa312313278c968dd876f9f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 48ed8649132f365a3732e1b30ca10b49ea082bdb0a0df7c8d250d480ace3e0b11aa9590eb8255a719a9bcb8653f0d0bb5f6f922ee801e5c25b932cfc7ac2628f
|
7
|
+
data.tar.gz: 427c2a6458541ee41c8fc655d741492015d33277c7404fdaad2dc946123fc3fc49079397827d023f642a51cfe6dec457479be686dd4abf63f354d699b3c57249
|
data/README.md
CHANGED
@@ -15,9 +15,20 @@ And then execute:
|
|
15
15
|
$ time_cop
|
16
16
|
|
17
17
|
## Usage
|
18
|
+
### Simple Usage
|
18
19
|
|
19
20
|
$ time_cop --username=user@wild.land --password=super_secret_password
|
20
21
|
|
22
|
+
### Interactive Mode
|
23
|
+
This is an interactive mode which prompt you for report options.
|
24
|
+
|
25
|
+
$ time_cop -i
|
26
|
+
|
27
|
+
Interactive mode supports the following `ENV` variables which will autofill the prompts:
|
28
|
+
- `HARVEST_USERNAME` your username. You can set it `$ export HARVEST_USERNAME="user@wild.land"`
|
29
|
+
- `HARVEST_PASSWORD` your password. You can set it `$ export HARVEST_PASSWORD="secret_password"`
|
30
|
+
- `HARVEST_HOURS_PER_WEEK` your hours per week. You can set it `$ export HARVEST_HOURS_PER_WEEK="34.0"`
|
31
|
+
|
21
32
|
## Development
|
22
33
|
|
23
34
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
@@ -29,4 +40,3 @@ To release a new version, update the version number in `version.rb`, and then ru
|
|
29
40
|
## Contributing
|
30
41
|
|
31
42
|
Bug reports and pull requests are welcome on GitHub at https://github.com/wildland/time_cop. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
32
|
-
|
@@ -77,7 +77,7 @@ module TimeCop
|
|
77
77
|
end
|
78
78
|
|
79
79
|
def total_quarter_time_tracked
|
80
|
-
quarterly_tracked_time_by_user.map { |t| t.hours }.reduce(:+)
|
80
|
+
quarterly_tracked_time_by_user.map { |t| t.hours }.reduce(0, :+)
|
81
81
|
end
|
82
82
|
|
83
83
|
def total_quarter_days
|
@@ -118,8 +118,8 @@ module TimeCop
|
|
118
118
|
|
119
119
|
def summary_hash
|
120
120
|
{
|
121
|
-
quarter: {
|
122
|
-
start: start_of_quarter_date,
|
121
|
+
quarter: {
|
122
|
+
start: start_of_quarter_date,
|
123
123
|
end: end_of_quarter_date,
|
124
124
|
weekdays_in_quarter: weekdays_between(@report_builder.start_date, @report_builder.end_date)
|
125
125
|
},
|
@@ -137,8 +137,10 @@ module TimeCop
|
|
137
137
|
puts "Current Surplus(+)/Deficit(-): #{current_hours_delta.round(2)}"
|
138
138
|
puts "Quarterly Hour Target: #{expected_quarter_hours.round(2)}"
|
139
139
|
puts "Current Quarterly Charged Hours: #{total_quarter_time_tracked.round(2)}"
|
140
|
-
|
141
|
-
|
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)}"
|
143
|
+
end
|
142
144
|
end
|
143
145
|
end
|
144
146
|
end
|
data/lib/time_cop/runner.rb
CHANGED
@@ -11,63 +11,77 @@ module TimeCop
|
|
11
11
|
|
12
12
|
if (options[:interactive])
|
13
13
|
cli = HighLine.new
|
14
|
-
username = cli.ask('Harvest Username: ')
|
15
|
-
password = cli.ask('Harvest Password: ') { |q| q.echo = false }
|
16
|
-
interactive_hash[:hours_per_week] = cli.ask('Hours per week?
|
14
|
+
username = ENV['HARVEST_USERNAME'].nil? ? cli.ask('Harvest Username: ') : ENV['HARVEST_USERNAME']
|
15
|
+
password = ENV['HARVEST_PASSWORD'].nil? ? cli.ask('Harvest Password: ') { |q| q.echo = false } : ENV['HARVEST_PASSWORD']
|
16
|
+
interactive_hash[:hours_per_week] = ENV['HARVEST_HOURS_PER_WEEK'].nil? ? cli.ask('Hours per week? Defaults to Full Time (34)') { |q| q.default = 34 }.to_f : ENV['HARVEST_HOURS_PER_WEEK'].to_f
|
17
|
+
year = cli.ask("Year? Defaults to #{Date.today.year}") { |q| q.default = Date.today.year }.to_i
|
17
18
|
accountability_options = {
|
18
19
|
username: (username.nil? ? options[:username] : username),
|
19
20
|
password: (password.nil? ? options[:password] : password),
|
20
21
|
email: options[:email]
|
21
22
|
}
|
22
23
|
q_dates = [
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
24
|
+
{
|
25
|
+
range: Date.new(year, 1, 1)...Date.new(year, 3, 31),
|
26
|
+
choice: :Q1
|
27
|
+
},
|
28
|
+
{
|
29
|
+
range: Date.new(year, 4, 1)...Date.new(year, 6, 30),
|
30
|
+
choice: :Q2
|
31
|
+
},
|
32
|
+
{
|
33
|
+
range: Date.new(year, 7, 1)...Date.new(year, 9, 30),
|
34
|
+
choice: :Q3
|
35
|
+
},
|
36
|
+
{
|
37
|
+
range: Date.new(year, 10, 1)...Date.new(year, 12, 31),
|
38
|
+
choice: :Q4
|
39
|
+
}
|
27
40
|
]
|
28
|
-
|
41
|
+
default_quarter = q_dates.find{|q_date| q_date[:range].include?(Date.today)}
|
42
|
+
default_choice = default_quarter.nil? ? '' : "Defaults to #{default_quarter[:choice]}"
|
29
43
|
cli.choose do |menu|
|
30
|
-
menu.prompt =
|
31
|
-
|
32
|
-
|
33
|
-
Accountability.new(interactive_hash.merge(accountability_options)).print_report
|
34
|
-
end
|
35
|
-
menu.choice(:Q2) do
|
36
|
-
interactive_hash[:date] = q_dates[1]
|
37
|
-
Accountability.new(interactive_hash.merge(accountability_options)).print_report
|
38
|
-
end
|
39
|
-
menu.choice(:Q3) do
|
40
|
-
interactive_hash[:date] = q_dates[2]
|
41
|
-
Accountability.new(interactive_hash.merge(accountability_options)).print_report
|
44
|
+
menu.prompt = "Which Quarter? #{default_choice}"
|
45
|
+
unless default_quarter.nil?
|
46
|
+
menu.default = default_quarter[:choice]
|
42
47
|
end
|
43
|
-
|
44
|
-
|
45
|
-
|
48
|
+
q_dates.each do |q_date|
|
49
|
+
menu.choice(q_date[:choice]) do
|
50
|
+
interactive_hash[:date] = q_date[:range].begin
|
51
|
+
puts 'Fetching data...'
|
52
|
+
Accountability.new(interactive_hash.merge(accountability_options)).print_report
|
53
|
+
end
|
46
54
|
end
|
47
55
|
menu.choice(:Year) do
|
48
|
-
summary = q_dates.map do |
|
49
|
-
interactive_hash[:date] =
|
56
|
+
summary = q_dates.map do |q_date|
|
57
|
+
interactive_hash[:date] = q_date[:range].begin
|
58
|
+
puts "Fetching data for #{q_date[:choice]}..."
|
50
59
|
Accountability.new(interactive_hash.merge(accountability_options)).summary_hash
|
51
60
|
end
|
52
61
|
logged = summary.inject(0){|sum, s| sum + s[:hours][:charged]}
|
53
62
|
needed = summary.inject(0){|sum, s| sum + s[:hours][:needed]}.round(2 )
|
54
63
|
diff = (logged - needed).round(2)
|
55
|
-
weekdays = (Date.today..Date.new(
|
56
|
-
weekdays_so_far = (Date.new(
|
64
|
+
weekdays = (Date.today..Date.new(year, 12, 31)).select{|d| (1..5).include?(d.wday)}.size
|
65
|
+
weekdays_so_far = (Date.new(year, 1, 1)..Date.today).select{|d| (1..5).include?(d.wday)}.size
|
57
66
|
average_needed = (-1 * diff / weekdays).round(2)
|
58
67
|
average_clocked = (logged / weekdays_so_far).round(2)
|
59
68
|
projected_diff = ((logged + (weekdays * average_clocked)) - needed).round(2)
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
69
|
+
if (year == Date.today.year)
|
70
|
+
puts "Business Days Left In Year: #{weekdays}"
|
71
|
+
puts "Current Year End Surplus(+)/Deficit(-): #{diff}"
|
72
|
+
puts "Projected Year End Surplus(+)/Deficit(-): #{projected_diff}"
|
73
|
+
puts ""
|
74
|
+
else
|
75
|
+
puts "#{year} Surplus(+)/Deficit(-): #{diff}"
|
76
|
+
end
|
77
|
+
puts "Total Harvest Hours for #{year}: #{logged}"
|
66
78
|
puts "Average Harvest Hours Per Business Day: #{average_clocked}"
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
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}"
|
83
|
+
end
|
84
|
+
end
|
71
85
|
end
|
72
86
|
else
|
73
87
|
accountability_options = {
|
data/lib/time_cop/version.rb
CHANGED
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.
|
4
|
+
version: 0.7.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:
|
11
|
+
date: 2018-03-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: harvested
|