tempest_time 1.0.3 → 1.1.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: e479a195a96ae924bc6d8b48ff396e258be6fb20
4
- data.tar.gz: 82b865f17b276335ec8527db4e91ecdf269b0824
3
+ metadata.gz: 97b895b41af4c2e73bd189b4ff68606b3f032b02
4
+ data.tar.gz: 95548d0b3807c5975808640714ee9d8cb5e6a450
5
5
  SHA512:
6
- metadata.gz: ee10e2b110b67578753768e0f7eef0f2928bb88e142f0799be8996b402e2e9c27ff54b9e8dc18dd0f3c493f3240fa40555b3922f8d964dc7a1c7fab67a070fca
7
- data.tar.gz: 988c454bd0cc4728aa26008c9d9be9173793ac138d86ecf4020c642808da6941fe1a50d4f157fdb0e4dbb61401099a2673f1e4075439dfc7b2d1a8ab112c0456
6
+ metadata.gz: 1c947e642c9ac21e6762060a2b97bfd1dbbff1e095e0ee9015d0f03b844d7eadcf22869b667834f53a8ec5d57fda4cd3c8780b4179504412f48d4fd875ab07bf
7
+ data.tar.gz: 1fb03ccc8bc8a8b81bc581854351844aab2e59553b17f5f4ddfa500ba44b0decbcaf51e570bf0ea6ac8e2442b9b08ad204a0d533d91ee809ee18a373d2b84a6d
@@ -10,7 +10,7 @@ module TempoAPI
10
10
  @remaining = options['remaining']
11
11
  @issue = options['issue']
12
12
  @message = options['message']
13
- @date = options['date'] ? Date.parse(options['date']) : Date.today
13
+ @date = options['date'] ? options['date'] : Date.today
14
14
  @billable = options['billable']
15
15
  end
16
16
 
@@ -53,13 +53,14 @@ module TempestTime
53
53
  )
54
54
  end
55
55
 
56
- def date_prompt(message, past_days: 6)
56
+ def date_prompt(message, days_before: 3, days_after: 3)
57
57
  require 'tty-prompt'
58
- dates = past_date_selections(past_days)
59
- TTY::Prompt.new.select(
58
+ dates = dates_in_range(days_before: days_before, days_after: days_after)
59
+ TTY::Prompt.new.multi_select(
60
60
  message,
61
61
  dates,
62
- per_page: 5
62
+ per_page: 5,
63
+ default: dates.find_index { |k, v| v == Date.today } + 1
63
64
  )
64
65
  end
65
66
 
@@ -8,24 +8,29 @@ module TempestTime
8
8
  class List < TempestTime::Command
9
9
  def initialize(options)
10
10
  @user = options[:user]
11
- @date = options[:date] ? Date.parse(options[:date]) : nil
11
+ @dates = options[:date] ? [Date.parse(options[:date])] : nil
12
12
  end
13
13
 
14
14
  def execute!
15
- @date ||= date_prompt('Please select a date.')
16
-
17
- with_spinner("Retrieving logs for #{formatted_date(@date)}...") do |spin|
18
- @response = TempoAPI::Requests::ListWorklogs.new(
19
- @date,
20
- end_date: nil,
21
- requested_user: @user
22
- ).send_request
23
- spin.stop(pastel.green('Done!'))
24
- prompt.say(render_table)
25
- prompt.say(
26
- 'Total Time Logged: '\
27
- "#{pastel.green("#{@response.total_hours_spent} hours")}"
28
- )
15
+ @dates ||= date_prompt(
16
+ 'Please select the dates you wish to view.',
17
+ days_before: 13,
18
+ days_after: 13
19
+ ).sort
20
+ @dates.each do |date|
21
+ with_spinner("Retrieving logs for #{pastel.yellow(formatted_date(date))}...") do |spin|
22
+ @response = TempoAPI::Requests::ListWorklogs.new(
23
+ date,
24
+ end_date: nil,
25
+ requested_user: @user
26
+ ).send_request
27
+ spin.stop(pastel.green('Done!'))
28
+ prompt.say(render_table)
29
+ prompt.say(
30
+ 'Total Time Logged: '\
31
+ "#{pastel.green("#{@response.total_hours_spent} hours")}"
32
+ )
33
+ end
29
34
  end
30
35
  end
31
36
 
@@ -13,17 +13,19 @@ module TempestTime
13
13
  @options = options
14
14
  @issues = issues.any? ? issues.map(&:upcase) : [automatic_issue]
15
15
  @time = parsed_time(time) / @issues.count
16
+ @dates = options[:date] ? [Date.parse(options[:date])] : nil
16
17
  end
17
18
 
18
19
  def execute!
19
- unless @options[:autoconfirm]
20
- prompt_message = "Track #{formatted_time(time)}, "\
21
- "#{billability(options)}, "\
22
- "to #{issues.join(', ')}?"
23
- abort unless prompt.yes?(prompt_message, convert: :bool)
20
+ dates
21
+ unless options[:autoconfirm]
22
+ confirm_prompt
23
+ end
24
+ dates.each do |date|
25
+ issues.each do |issue|
26
+ track_time(time, options.merge({ issue: issue, date: date }))
27
+ end
24
28
  end
25
-
26
- issues.each { |issue| track_time(time, options.merge('issue' => issue)) }
27
29
  end
28
30
 
29
31
  private
@@ -40,6 +42,23 @@ module TempestTime
40
42
  end
41
43
  end
42
44
 
45
+ def dates
46
+ @dates ||= if options[:autoconfirm]
47
+ [Date.today]
48
+ else
49
+ date_prompt("Select the day(s) to log this time to.",
50
+ days_before: 13,
51
+ days_after: 365).sort
52
+ end
53
+ end
54
+
55
+ def confirm_prompt
56
+ prompt_message = "Track #{formatted_time(time)}, "\
57
+ "#{billability(options)}, "\
58
+ "to #{issues.join(', ')}?"
59
+ abort unless prompt.yes?(prompt_message, convert: :bool)
60
+ end
61
+
43
62
  def remaining_estimate(issue, time)
44
63
  request = JiraAPI::Requests::GetIssue.new(issue)
45
64
  request.send_request
@@ -64,10 +64,23 @@ module TempestTime
64
64
  weeks
65
65
  end
66
66
 
67
- def past_date_selections(number_of_days)
67
+ def dates_in_range(days_before: 0, days_after: 0)
68
+ future_dates(days_after).merge(past_dates(days_before))
69
+ end
70
+
71
+ def past_dates(number_of_days)
72
+ dates = {}
73
+ (0..number_of_days).each do |num|
74
+ date = Date.today - num
75
+ dates[formatted_date(date)] = date
76
+ end
77
+ dates
78
+ end
79
+
80
+ def future_dates(number_of_days)
68
81
  dates = {}
69
- (0..number_of_days).each do |n|
70
- date = Date.today - n
82
+ number_of_days.downto(0).each do |num|
83
+ date = Date.today + num
71
84
  dates[formatted_date(date)] = date
72
85
  end
73
86
  dates
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TempestTime
4
- VERSION = '1.0.3'
4
+ VERSION = '1.1.0'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tempest_time
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Devan Hurst