timr 0.3.0 → 0.4.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.
Files changed (106) hide show
  1. checksums.yaml +4 -4
  2. data/.ackrc +9 -0
  3. data/.editorconfig +1 -0
  4. data/.env.example +7 -0
  5. data/.github/CONTRIBUTING.md +32 -0
  6. data/.github/ISSUE_TEMPLATE.md +13 -0
  7. data/.gitignore +8 -2
  8. data/.rdoc_options +21 -0
  9. data/.travis.yml +10 -7
  10. data/Gemfile +8 -0
  11. data/README.md +216 -3
  12. data/bin/.gitignore +2 -0
  13. data/bin/README.md +17 -0
  14. data/bin/build.sh +14 -0
  15. data/bin/build_api.sh +14 -0
  16. data/bin/build_coverage.sh +23 -0
  17. data/bin/build_info.sh +27 -0
  18. data/bin/build_man.sh +41 -0
  19. data/bin/clean.sh +14 -0
  20. data/bin/dev_setup.sh +19 -0
  21. data/bin/install.sh +49 -0
  22. data/bin/publish +38 -0
  23. data/bin/release.sh +35 -0
  24. data/bin/test.sh +19 -0
  25. data/bin/timr +20 -40
  26. data/bin/timr_bash_completion.sh +337 -0
  27. data/bin/uninstall.sh +24 -0
  28. data/lib/timr.rb +36 -8
  29. data/lib/timr/command/basic_command.rb +170 -0
  30. data/lib/timr/command/continue_command.rb +86 -0
  31. data/lib/timr/command/help_command.rb +137 -0
  32. data/lib/timr/command/log_command.rb +297 -0
  33. data/lib/timr/command/pause_command.rb +89 -0
  34. data/lib/timr/command/pop_command.rb +176 -0
  35. data/lib/timr/command/push_command.rb +141 -0
  36. data/lib/timr/command/report_command.rb +689 -0
  37. data/lib/timr/command/start_command.rb +172 -0
  38. data/lib/timr/command/status_command.rb +198 -0
  39. data/lib/timr/command/stop_command.rb +127 -0
  40. data/lib/timr/command/task_command.rb +318 -0
  41. data/lib/timr/command/track_command.rb +381 -0
  42. data/lib/timr/command/version_command.rb +18 -0
  43. data/lib/timr/duration.rb +159 -0
  44. data/lib/timr/exception/timr_error.rb +113 -0
  45. data/lib/timr/ext/time.rb +12 -0
  46. data/lib/timr/helper/datetime_helper.rb +128 -0
  47. data/lib/timr/helper/terminal_helper.rb +58 -0
  48. data/lib/timr/helper/translation_helper.rb +45 -0
  49. data/lib/timr/model/basic_model.rb +287 -0
  50. data/lib/timr/model/config.rb +48 -0
  51. data/lib/timr/model/foreign_id_db.rb +84 -0
  52. data/lib/timr/model/stack.rb +161 -0
  53. data/lib/timr/model/task.rb +1039 -0
  54. data/lib/timr/model/track.rb +589 -0
  55. data/lib/timr/progressbar.rb +41 -0
  56. data/lib/timr/simple_opt_parser.rb +230 -0
  57. data/lib/timr/status.rb +70 -0
  58. data/lib/timr/table.rb +88 -0
  59. data/lib/timr/timr.rb +500 -558
  60. data/lib/timr/version.rb +4 -15
  61. data/man/.gitignore +2 -0
  62. data/man/_footer +3 -0
  63. data/man/timr-continue.1 +48 -0
  64. data/man/timr-continue.1.ronn +39 -0
  65. data/man/timr-ftime.7 +77 -0
  66. data/man/timr-ftime.7.ronn +57 -0
  67. data/man/timr-log.1 +109 -0
  68. data/man/timr-log.1.ronn +87 -0
  69. data/man/timr-pause.1 +56 -0
  70. data/man/timr-pause.1.ronn +45 -0
  71. data/man/timr-pop.1 +66 -0
  72. data/man/timr-pop.1.ronn +53 -0
  73. data/man/timr-push.1 +25 -0
  74. data/man/timr-push.1.ronn +20 -0
  75. data/man/timr-report.1 +228 -0
  76. data/man/timr-report.1.ronn +193 -0
  77. data/man/timr-start.1 +100 -0
  78. data/man/timr-start.1.ronn +82 -0
  79. data/man/timr-status.1 +53 -0
  80. data/man/timr-status.1.ronn +42 -0
  81. data/man/timr-stop.1 +75 -0
  82. data/man/timr-stop.1.ronn +60 -0
  83. data/man/timr-task.1 +147 -0
  84. data/man/timr-task.1.ronn +115 -0
  85. data/man/timr-track.1 +109 -0
  86. data/man/timr-track.1.ronn +89 -0
  87. data/man/timr.1 +119 -0
  88. data/man/timr.1.ronn +68 -0
  89. data/timr.gemspec +18 -3
  90. data/timr.sublime-project +20 -1
  91. metadata +142 -23
  92. data/Makefile +0 -12
  93. data/Makefile.common +0 -56
  94. data/lib/timr/stack.rb +0 -81
  95. data/lib/timr/task.rb +0 -258
  96. data/lib/timr/track.rb +0 -167
  97. data/lib/timr/window.rb +0 -259
  98. data/lib/timr/window_help.rb +0 -41
  99. data/lib/timr/window_tasks.rb +0 -30
  100. data/lib/timr/window_test.rb +0 -20
  101. data/lib/timr/window_timeline.rb +0 -33
  102. data/tests/tc_stack.rb +0 -121
  103. data/tests/tc_task.rb +0 -190
  104. data/tests/tc_track.rb +0 -144
  105. data/tests/tc_window.rb +0 -428
  106. data/tests/ts_all.rb +0 -6
data/lib/timr/window.rb DELETED
@@ -1,259 +0,0 @@
1
-
2
- module TheFox
3
- module Timr
4
-
5
- class Window
6
-
7
- def initialize(data = [])
8
- @data = data
9
- @content_length = 0
10
- @current_line = 0
11
- @cursor = 1
12
- @has_cursor = false
13
- @content_changed = true
14
- @content_refreshes = 0
15
- @page = []
16
- @page_changed = true
17
- @page_refreshes = 0
18
-
19
- setup
20
- content_refresh
21
- end
22
-
23
- def setup
24
-
25
- end
26
-
27
- def content_length=(content_length)
28
- if @content_length != content_length
29
- @content_changed = true
30
- end
31
- @content_length = content_length
32
- end
33
-
34
- def content=(data)
35
- @content_changed = true
36
- @data = data
37
- end
38
-
39
- def content
40
- @data
41
- end
42
-
43
- def content_changed
44
- @content_changed = true
45
- end
46
-
47
- def content_refreshes
48
- @content_refreshes
49
- end
50
-
51
- def content_refresh
52
- if @content_changed
53
- @content = content
54
- @content_refreshes += 1
55
- @content_changed = false
56
-
57
- @page_changed = true
58
- end
59
- end
60
-
61
- def page_refreshes
62
- @page_refreshes
63
- end
64
-
65
- def page
66
- if @page_changed
67
- @page = @content[@current_line, @content_length]
68
- @page_refreshes += 1
69
- @page_changed = false
70
- end
71
-
72
- @page
73
- end
74
-
75
- def page_object
76
- page[@cursor - 1]
77
- end
78
-
79
- def page_length
80
- cpage = page
81
- if cpage.nil?
82
- 0
83
- else
84
- cpage.length
85
- end
86
- end
87
-
88
- def next_page?
89
- has = false
90
- new_current_line = @current_line + @content_length
91
- new_page = @content[new_current_line, @content_length]
92
- if !new_page.nil?
93
- new_page_length = new_page.length
94
- if new_page_length > 0
95
- has = true
96
- end
97
- end
98
- has
99
- end
100
-
101
- def next_page(add_lines = nil)
102
- if add_lines.nil?
103
- add_lines = @content_length
104
- end
105
-
106
- @page_changed = true
107
- @current_line += add_lines if next_page?
108
- cursor_set_to_last_if_out_of_range
109
- end
110
-
111
- def previous_page?
112
- @current_line > 0
113
- end
114
-
115
- def previous_page(length = @content_length)
116
- if previous_page?
117
- @page_changed = true
118
- @current_line -= length
119
- if @current_line < 0
120
- @current_line = 0
121
- end
122
- end
123
- end
124
-
125
- def first_page
126
- @page_changed = true
127
- @current_line = 0
128
- cursor_first_line
129
- end
130
-
131
- def last_page?
132
- !next_page?
133
- end
134
-
135
- def last_page
136
- if !last_page?
137
- @page_changed = true
138
-
139
- new_current_line = @content.length - @content_length
140
- if new_current_line >= 0
141
- @current_line = @content.length - @content_length
142
- end
143
- end
144
- cursor_last_line
145
- end
146
-
147
- def next_line
148
- @page_changed = true
149
- next_page(1)
150
- end
151
-
152
- def previous_line
153
- @page_changed = true
154
- previous_page(1)
155
- end
156
-
157
- def current_line
158
- @current_line
159
- end
160
-
161
- def cursor
162
- @cursor
163
- end
164
-
165
- def has_cursor?
166
- @has_cursor
167
- end
168
-
169
- def cursor_next_line
170
- @cursor += 1
171
- border = @content_length - 2
172
- if @cursor > border
173
- if last_page?
174
- if @cursor > @content_length
175
- @cursor = @content_length
176
- end
177
- else
178
- @cursor = border
179
- next_line
180
- end
181
- else
182
-
183
- end
184
-
185
- cursor_set_to_last_if_out_of_range
186
- end
187
-
188
- def cursor_previous_line
189
- @cursor -= 1
190
- border = 3
191
- if @cursor < 1
192
- @cursor = 1
193
-
194
- if previous_page?
195
- previous_line
196
- else
197
-
198
- end
199
- elsif @cursor < border
200
- if previous_page?
201
- @cursor = border
202
- previous_line
203
- end
204
- else
205
-
206
- end
207
- end
208
-
209
- def cursor_last_line
210
- @cursor = @content_length
211
- if page_length < @content_length
212
- @cursor = page_length
213
- end
214
- end
215
-
216
- def cursor_first_line
217
- @cursor = 1
218
- end
219
-
220
- def cursor_set_to_last_if_out_of_range
221
- plength = page_length
222
- if @cursor > plength
223
- @cursor = plength
224
- end
225
- end
226
-
227
- def cursor_border_top
228
- previous_page? ? 3 : 1
229
- end
230
-
231
- def cursor_border_bottom
232
- #next_page? ? @content_length - 2 : -1
233
- next_page? ? @content_length - 2 : @content_length
234
- end
235
-
236
- def cursor_on_inner_range?
237
- if previous_page?
238
- if next_page?
239
- # Middle
240
- @cursor > cursor_border_top && @cursor < cursor_border_bottom
241
- else
242
- # Bottom
243
- @cursor >= cursor_border_top
244
- end
245
- else
246
- if next_page?
247
- # First page.
248
- @cursor <= cursor_border_bottom
249
- else
250
- # Only one page, so middle.
251
- true
252
- end
253
- end
254
- end
255
-
256
- end
257
-
258
- end
259
- end
@@ -1,41 +0,0 @@
1
-
2
- module TheFox
3
- module Timr
4
-
5
- class HelpWindow < Window
6
-
7
- def setup
8
- @data = [
9
- '#### Help ####',
10
- '',
11
- ' n .. Create a new Task and start',
12
- ' t .. Create a new Task',
13
- ' c .. Current Task: Toggle Start/Continue',
14
- ' x .. Current Task: Pause',
15
- ' v .. Current Task: Stop and Pop from Stack',
16
- ' f .. Stop and deselect all Tasks on the Stack',
17
- ' p, b .. Push and start selected Task.',
18
- ' r .. Refresh Window',
19
- ' w .. Write all changes.',
20
- ' q .. Exit',
21
- ' h .. Help',
22
- ' 1 .. Timeline Window',
23
- ' 2 .. Tasks Window',
24
- ' RETURN .. Start selected Task.',
25
- ' # .. Start selected Task, edit Track Description.',
26
- ' KEY UP .. Move Cursor up.',
27
- ' KEY DOWN .. Move Cursor down.',
28
- '',
29
- 'Current Task Status',
30
- '',
31
- " #{TASK_NO_TASK_LOADED_CHAR} .. No Task loaded.",
32
- ' . .. Task is stopped.',
33
- ' | .. Task is paused.',
34
- ' > .. Task is running.',
35
- ]
36
- end
37
-
38
- end
39
-
40
- end
41
- end
@@ -1,30 +0,0 @@
1
-
2
- module TheFox
3
- module Timr
4
-
5
- class TasksWindow < Window
6
-
7
- def content
8
- if @data.nil? || @data.length == 0
9
- @has_cursor = false
10
- [
11
- '',
12
- '#### NO TASKS YET ####',
13
- '',
14
- "Press 'n' to create a new task.",
15
- " Or 'h' to jump to the help page.",
16
- ]
17
- else
18
- @has_cursor = true
19
- @data
20
- .sort_by{ |k, v|
21
- v.name.downcase
22
- }
23
- .map{ |a| a[1] }
24
- end
25
- end
26
-
27
- end
28
-
29
- end
30
- end
@@ -1,20 +0,0 @@
1
-
2
- module TheFox
3
- module Timr
4
-
5
- class TestWindow < Window
6
-
7
- def setup
8
- @has_cursor = true
9
-
10
- @data = []
11
- (1..30).each do |n|
12
- @data << 'LINE %03d 123456789_123456789_123456789_123456789_123456789_123456789' % [n]
13
- end
14
- @data
15
- end
16
-
17
- end
18
-
19
- end
20
- end
@@ -1,33 +0,0 @@
1
-
2
- module TheFox
3
- module Timr
4
-
5
- class TimelineWindow < Window
6
-
7
- def content
8
- if @data.nil? || @data.length == 0
9
- @has_cursor = false
10
- [
11
- '',
12
- '#### NO TRACKS YET ####',
13
- '',
14
- "Press 'n' to create a new task.",
15
- " Or 'h' to jump to the help page.",
16
- ]
17
- else
18
- @has_cursor = true
19
- @data
20
- .map{ |task_id, task|
21
- task.timeline
22
- }
23
- .flatten
24
- .sort{ |task_a, task_b|
25
- task_a.begin_time <=> task_b.begin_time || task_a.end_time <=> task_b.end_time
26
- }
27
- end
28
- end
29
-
30
- end
31
-
32
- end
33
- end
data/tests/tc_stack.rb DELETED
@@ -1,121 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'minitest/autorun'
4
- require 'timr'
5
-
6
-
7
- class TestStack < MiniTest::Test
8
-
9
- include TheFox::Timr
10
-
11
- def test_class_name
12
- stack1 = Stack.new
13
-
14
- assert_equal('TheFox::Timr::Stack', stack1.class.to_s)
15
- end
16
-
17
- def test_has_task
18
- stack1 = Stack.new
19
- assert_equal(false, stack1.has_task?)
20
- end
21
-
22
- def test_push_pop
23
- task1 = Task.new
24
- task1.name = 'task1'
25
- task2 = Task.new
26
- task2.name = 'task2'
27
-
28
- stack1 = Stack.new
29
- assert_equal([], stack1.tasks_texts)
30
- assert_equal(nil, stack1.task)
31
- assert_equal(0, stack1.size)
32
-
33
- push_res = stack1.push(task1)
34
- assert_equal(true, push_res)
35
- assert_equal(task1, stack1.task)
36
- assert_equal(1, stack1.size)
37
- assert_equal(true, task1.running?)
38
- assert_equal(['* task1'], stack1.tasks_texts)
39
-
40
- push_res = stack1.push(task2)
41
- assert_equal(true, push_res)
42
- assert_equal(task2, stack1.task)
43
- assert_equal(2, stack1.size)
44
- assert_equal(true, task2.running?)
45
- assert_equal(false, task1.running?)
46
- assert_equal(['| task1', '* task2'], stack1.tasks_texts)
47
-
48
- # if !@tasks.include?(task)
49
- push_res = stack1.push(task2)
50
- assert_equal(false, push_res)
51
- assert_equal(2, stack1.size)
52
-
53
- pop_res = stack1.pop
54
- assert_equal(true, pop_res)
55
- assert_equal(task1, stack1.task)
56
- assert_equal(1, stack1.size)
57
- assert_equal(true, task1.running?)
58
- assert_equal(false, task2.running?)
59
- assert_equal(['* task1'], stack1.tasks_texts)
60
-
61
- pop_res = stack1.pop
62
- assert_equal(true, pop_res)
63
- assert_equal([], stack1.tasks_texts)
64
- assert_equal(nil, stack1.task)
65
- assert_equal(0, stack1.size)
66
-
67
- # if !old.nil?
68
- pop_res = stack1.pop
69
- assert_equal(false, pop_res)
70
- end
71
-
72
- def test_pop_all
73
- task3 = Task.new
74
- #task3.name = 'task3'
75
- task4 = Task.new
76
- #task4.name = 'task4'
77
- task5 = Task.new
78
- #task5.name = 'task5'
79
-
80
- stack1 = Stack.new
81
-
82
- stack1.push(task3)
83
- assert_equal(true, task3.running?)
84
- assert_equal(false, task4.running?)
85
- assert_equal(false, task5.running?)
86
-
87
- stack1.push(task4)
88
- assert_equal(2, stack1.size)
89
- assert_equal(false, task3.running?)
90
- assert_equal(true, task4.running?)
91
- assert_equal(false, task5.running?)
92
-
93
- assert_equal(true, stack1.pop_all(task5))
94
- assert_equal(1, stack1.size)
95
-
96
- assert_equal(false, stack1.pop_all(task5))
97
- assert_equal(1, stack1.size)
98
- assert_equal(false, task3.running?)
99
- assert_equal(false, task4.running?)
100
- assert_equal(true, task5.running?)
101
-
102
- task5_track = task5.track
103
- assert_equal(false, task5_track.nil?)
104
-
105
- assert_equal(false, stack1.pop_all(task5))
106
- assert_equal(false, task3.running?)
107
- assert_equal(false, task4.running?)
108
- assert_equal(true, task5.running?)
109
-
110
- task5_track = task5.track
111
- assert_equal(false, task5_track.nil?)
112
- assert_equal(false, stack1.pop_all(task5, task5_track))
113
-
114
- # Pop All with no new Task.
115
- assert_equal(true, stack1.pop_all)
116
- assert_equal(0, stack1.size)
117
- assert_equal(false, task3.running?)
118
- assert_equal(false, task4.running?)
119
- assert_equal(false, task5.running?)
120
- end
121
- end