timetrap 1.14.2 → 1.14.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 00a629afadbecd036fa581ba17160e35f1438cb5
4
- data.tar.gz: e8cf2677661d3130083c510352be81a919113f52
3
+ metadata.gz: 250958b0809cd1e2b583424a014ea4c9e92c6b54
4
+ data.tar.gz: befa65a8e899b9bb4270dbee6364cce935780c4a
5
5
  SHA512:
6
- metadata.gz: a15337c354b845148596c5111182c59c98018f733effce4b936ecc3ef15e38f31cd1ae6e037aa9fc0a9171f1a29d8bd0b3c1ef7c73173f753e195bee2b10e3bc
7
- data.tar.gz: 49c156ca122366c0cf5dc3f25ccc8e36d770ce91787f829f3460178889b593f9efc00329ac96da02c4162f189c7ecdfa651539b7b77f8198fae95c490a4e2495
6
+ metadata.gz: 38ff8bce1804940310b7689719f4a05b3426e86e80b796308f0ea060e156648add7d4f39084ea908ce333e2d63b75dc3b28e71806d7a829c43154e394e4bc5d1
7
+ data.tar.gz: 0b37bd85eafb9188eeb19c1eec3eca7695efcc90004f02ed91ce1333e0992c692e8d5b7b6033ba2b07e27bda78e078b247ed045956f7480f321be63ddbae2626
@@ -15,3 +15,4 @@
15
15
  * Marc Addeo
16
16
  * Patrick Davey
17
17
  * Kyle Brett
18
+ * namdnguyen
data/README.md CHANGED
@@ -406,7 +406,8 @@ Commands
406
406
  usage: ``t yesterday [--ids] [--format FMT] [SHEET | all]``
407
407
 
408
408
  **week**
409
- Shortcut for display with start date set to Monday of this week
409
+ Shortcut for display with start date set to a day of this week. The default
410
+ start of the week is Monday.
410
411
 
411
412
  usage: ``t week [--ids] [--end DATE] [--format FMT] [TIMESHEET | all]``
412
413
 
@@ -469,6 +470,7 @@ See ``t configure`` for details. Currently supported options are:
469
470
  on Notes Editing for tips on using non-terminal based editors.
470
471
  Example: note_editor: "vim"
471
472
 
473
+ **week_start**: The day of the week to use as the start of the week for t week.
472
474
 
473
475
  ### Autocomplete
474
476
 
@@ -45,6 +45,8 @@ COMMAND is one of:
45
45
  note_editor: Command to launch notes editor or false if no editor use.
46
46
  If you use a non terminal based editor (e.g. sublime, atom)
47
47
  please read the notes in the README.
48
+ week_start: The day of the week to use as the start of the
49
+ week for t week.
48
50
 
49
51
  * display - Display the current timesheet or a specific. Pass `all' as SHEET
50
52
  to display all unarchived sheets or `full' to display archived and
@@ -106,7 +108,9 @@ COMMAND is one of:
106
108
  * yesterday - Shortcut for display with start and end dates as the day before the current day
107
109
  usage: t yesterday [--ids] [--format FMT] [SHEET | all]
108
110
 
109
- * week - Shortcut for display with start date set to monday of this week.
111
+ * week - Shortcut for display with start date set to a day of this week.
112
+ The default start of the week is Monday.
113
+ .
110
114
  usage: t week [--ids] [--end DATE] [--format FMT] [SHEET | all]
111
115
 
112
116
  * month - Shortcut for display with start date set to the beginning of either
@@ -443,7 +447,13 @@ COMMAND is one of:
443
447
  end
444
448
 
445
449
  def week
446
- args['-s'] = Date.today.wday == 1 ? Date.today.to_s : Date.parse(Chronic.parse(%q(last monday)).to_s).to_s
450
+ d = Chronic.parse( args['-s'] || Date.today )
451
+
452
+ today = Date.new( d.year, d.month, d.day )
453
+ end_of_week = today + 6
454
+ last_week_start = Date.parse(Chronic.parse('last '.concat(Config['week_start']).to_s, :now => today).to_s)
455
+ args['-s'] = today.wday == Date.parse(Config['week_start']).wday ? today.to_s : last_week_start.to_s
456
+ args['-e'] = end_of_week.to_s
447
457
  display
448
458
  end
449
459
 
@@ -37,7 +37,9 @@ module Timetrap
37
37
  # interactively prompt for a note if one isn't passed when checking in.
38
38
  'require_note' => false,
39
39
  # command to launch external editor (false if no external editor used)
40
- 'note_editor' => false
40
+ 'note_editor' => false,
41
+ # set day of the week when determining start of the week.
42
+ 'week_start' => "Monday",
41
43
  }
42
44
  end
43
45
 
@@ -1,3 +1,3 @@
1
1
  module Timetrap
2
- VERSION = '1.14.2'
2
+ VERSION = '1.14.3'
3
3
  end
@@ -986,6 +986,92 @@ END:VCALENDAR
986
986
  $stdout.string.should include Time.now.strftime('%a %b %d, %Y')
987
987
  $stdout.string.should_not include 'Feb 01, 2012'
988
988
  end
989
+
990
+ describe "with week_start config option set" do
991
+ let(:week_start_config) { 'Tuesday' }
992
+ before do
993
+ with_stubbed_config 'week_start' => week_start_config
994
+ end
995
+
996
+ #https://github.com/samg/timetrap/issues/161
997
+ it "should work at the end of the month" do
998
+ Date.should_receive(:today).and_return(Date.new(2017, 7, 30))
999
+
1000
+ create_entry(
1001
+ :start => Time.local(2017, 7, 29, 1, 2, 3),
1002
+ :end => Time.local(2017, 7, 29, 2, 2, 3)
1003
+ )
1004
+ invoke "week"
1005
+ $stdout.string.should include 'Jul 29, 2017'
1006
+
1007
+ end
1008
+
1009
+ it "should not show entries prior to defined start of week" do
1010
+ create_entry(
1011
+ :start => Time.local(2012, 2, 5, 1, 2, 3),
1012
+ :end => Time.local(2012, 2, 5, 2, 2, 3)
1013
+ )
1014
+ create_entry(
1015
+ :start => Time.local(2012, 2, 8, 1, 2, 3),
1016
+ :end => Time.local(2012, 2, 8, 2, 2, 3)
1017
+ )
1018
+ create_entry(
1019
+ :start => Time.local(2012, 2, 9, 1, 2, 3),
1020
+ :end => Time.local(2012, 2, 9, 2, 2, 3)
1021
+ )
1022
+
1023
+ Date.should_receive(:today).and_return(Date.new(2012, 2, 9))
1024
+ invoke 'week'
1025
+
1026
+ $stdout.string.should include 'Feb 08, 2012'
1027
+ $stdout.string.should include 'Feb 09, 2012'
1028
+ $stdout.string.should_not include 'Feb 05, 2012'
1029
+ end
1030
+
1031
+ it "should only show entries from today if today is start of week" do
1032
+ create_entry(
1033
+ :start => Time.local(2012, 1, 31, 1, 2, 3),
1034
+ :end => Time.local(2012, 1, 31, 2, 2, 3)
1035
+ )
1036
+ create_entry(
1037
+ :start => Time.local(2012, 2, 5, 1, 2, 3),
1038
+ :end => Time.local(2012, 2, 5, 2, 2, 3)
1039
+ )
1040
+ create_entry(
1041
+ :start => Time.local(2012, 2, 7, 1, 2, 3),
1042
+ :end => Time.local(2012, 2, 7, 2, 2, 3)
1043
+ )
1044
+
1045
+ Date.should_receive(:today).and_return(Date.new(2012, 2, 7))
1046
+ invoke 'week'
1047
+
1048
+ $stdout.string.should include 'Feb 07, 2012'
1049
+ $stdout.string.should_not include 'Jan 31, 2012'
1050
+ $stdout.string.should_not include 'Feb 05, 2012'
1051
+ end
1052
+
1053
+ it "should not show entries 7 days past start of week" do
1054
+ create_entry(
1055
+ :start => Time.local(2012, 2, 9, 1, 2, 3),
1056
+ :end => Time.local(2012, 2, 9, 2, 2, 3)
1057
+ )
1058
+ create_entry(
1059
+ :start => Time.local(2012, 2, 14, 1, 2, 3),
1060
+ :end => Time.local(2012, 2, 14, 2, 2, 3)
1061
+ )
1062
+ create_entry(
1063
+ :start => Time.local(2012, 2, 16, 1, 2, 3),
1064
+ :end => Time.local(2012, 2, 16, 2, 2, 3)
1065
+ )
1066
+
1067
+ Date.should_receive(:today).and_return(Date.new(2012, 2, 7))
1068
+ invoke 'week'
1069
+
1070
+ $stdout.string.should include 'Feb 09, 2012'
1071
+ $stdout.string.should_not include 'Feb 14, 2012'
1072
+ $stdout.string.should_not include 'Feb 16, 2012'
1073
+ end
1074
+ end
989
1075
  end
990
1076
 
991
1077
  describe "month" do
metadata CHANGED
@@ -1,139 +1,139 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: timetrap
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.14.2
4
+ version: 1.14.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Goldstein
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-07-07 00:00:00.000000000 Z
11
+ date: 2017-07-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ~>
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.3'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ~>
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.3'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - '>='
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - '>='
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ~>
46
46
  - !ruby/object:Gem::Version
47
47
  version: 3.5.0
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ~>
53
53
  - !ruby/object:Gem::Version
54
54
  version: 3.5.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: fakefs
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ">="
59
+ - - '>='
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ">="
66
+ - - '>='
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: icalendar
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - "~>"
73
+ - - ~>
74
74
  - !ruby/object:Gem::Version
75
75
  version: 1.3.0
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - "~>"
80
+ - - ~>
81
81
  - !ruby/object:Gem::Version
82
82
  version: 1.3.0
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: json
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ">="
87
+ - - '>='
88
88
  - !ruby/object:Gem::Version
89
89
  version: '0'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ">="
94
+ - - '>='
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: sequel
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - "~>"
101
+ - - ~>
102
102
  - !ruby/object:Gem::Version
103
103
  version: 4.43.0
104
104
  type: :runtime
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - "~>"
108
+ - - ~>
109
109
  - !ruby/object:Gem::Version
110
110
  version: 4.43.0
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: sqlite3
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - "~>"
115
+ - - ~>
116
116
  - !ruby/object:Gem::Version
117
117
  version: 1.3.3
118
118
  type: :runtime
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - "~>"
122
+ - - ~>
123
123
  - !ruby/object:Gem::Version
124
124
  version: 1.3.3
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: chronic
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
- - - "~>"
129
+ - - ~>
130
130
  - !ruby/object:Gem::Version
131
131
  version: 0.10.2
132
132
  type: :runtime
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
- - - "~>"
136
+ - - ~>
137
137
  - !ruby/object:Gem::Version
138
138
  version: 0.10.2
139
139
  description: Command line time tracker
@@ -146,9 +146,9 @@ executables:
146
146
  extensions: []
147
147
  extra_rdoc_files: []
148
148
  files:
149
- - ".gitignore"
150
- - ".rspec"
151
- - ".travis.yml"
149
+ - .gitignore
150
+ - .rspec
151
+ - .travis.yml
152
152
  - CONTRIBUTORS
153
153
  - Gemfile
154
154
  - LICENSE.txt
@@ -194,17 +194,17 @@ require_paths:
194
194
  - lib
195
195
  required_ruby_version: !ruby/object:Gem::Requirement
196
196
  requirements:
197
- - - ">="
197
+ - - '>='
198
198
  - !ruby/object:Gem::Version
199
199
  version: '0'
200
200
  required_rubygems_version: !ruby/object:Gem::Requirement
201
201
  requirements:
202
- - - ">="
202
+ - - '>='
203
203
  - !ruby/object:Gem::Version
204
204
  version: '0'
205
205
  requirements: []
206
206
  rubyforge_project:
207
- rubygems_version: 2.5.2
207
+ rubygems_version: 2.0.14.1
208
208
  signing_key:
209
209
  specification_version: 4
210
210
  summary: Command line time tracker