time_cop 0.6.0 → 0.7.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: 5386380ae098f3a9daa1a1e7861a44fb346db8e8
4
- data.tar.gz: 6aa3386caa796aca933336607980e764aced49f3
3
+ metadata.gz: 79389be668d32868c727b13d6ce34ac5ece7f70b
4
+ data.tar.gz: f15e624a821ff4ef3aa312313278c968dd876f9f
5
5
  SHA512:
6
- metadata.gz: 9a4c4d9e71d174573580c90dc35f2f90f48de1059369d084d93411972a44b60c669af0cf9e59b807ccbc2128f3b015e48e01587d8e09a0f75570b4741010f6cd
7
- data.tar.gz: 05f65255b494f94b81891a522a94e0635b17712cfbc60a3df8e49c8ed4ad18fdd4fa5e067c3df9715d31d3ed7c91c51eeeb5cbc663a1d1133299348387517f49
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
- puts "Total Hours Needed By End Of Quarter: #{quarterly_hours_delta.round(2)}"
141
- puts "Hours Per Business Day Average Needed To Reach Goal: #{quarterly_hours_per_business_day_needed.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)}"
143
+ end
142
144
  end
143
145
  end
144
146
  end
@@ -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? (Full Time 34)') { |q| q.default = 34 }.to_f
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
- Date.new(Date.today.year, 1, 1),
24
- Date.new(Date.today.year, 4, 1),
25
- Date.new(Date.today.year, 7, 1),
26
- Date.new(Date.today.year, 10, 1)
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 = 'Which Quarter? '
31
- menu.choice(:Q1) do
32
- interactive_hash[:date] = q_dates[0]
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
- menu.choice(:Q4) do
44
- interactive_hash[:date] = q_dates[3]
45
- Accountability.new(interactive_hash.merge(accountability_options)).print_report
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 |d|
49
- interactive_hash[:date] = d
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(Date.today.year, 12, 31)).select{|d| (1..5).include?(d.wday)}.size
56
- weekdays_so_far = (Date.new(Date.today.year, 1, 1)..Date.today).select{|d| (1..5).include?(d.wday)}.size
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
- puts "Business Days Left In Year: #{weekdays}"
62
- puts "Current Year End Surplus(+)/Deficit(-): #{diff}"
63
- puts "Projected Year End Surplus(+)/Deficit(-): #{projected_diff}"
64
- puts ""
65
- puts "Total Harvest Hours This Year: #{logged}"
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
- puts ""
68
- puts "Total Hours Needed By End Of Year: #{needed}"
69
- puts "Average Hours Per Business Day Needed To Reach Goal: #{average_needed}"
70
- end
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 = {
@@ -1,3 +1,3 @@
1
1
  module TimeCop
2
- VERSION = "0.6.0"
2
+ VERSION = "0.7.0"
3
3
  end
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.6.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: 2017-10-27 00:00:00.000000000 Z
11
+ date: 2018-03-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: harvested