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/tests/tc_task.rb DELETED
@@ -1,190 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'minitest/autorun'
4
- require 'time'
5
- require 'fileutils'
6
- require 'timr'
7
-
8
-
9
- class TestTask < MiniTest::Test
10
-
11
- include TheFox::Timr
12
-
13
- def test_class_name
14
- task1 = Task.new
15
-
16
- assert_equal('TheFox::Timr::Task', task1.class.to_s)
17
- end
18
-
19
- def test_save_load
20
- task1 = Task.new
21
-
22
- file_path = task1.save_to_file('tmp')
23
- assert_equal(false, File.exist?(file_path))
24
-
25
- task1.name = 'task1'
26
- task1.description = 'hello world1'
27
- file_path = task1.save_to_file('tmp')
28
- assert_equal(true, File.exist?(file_path))
29
-
30
- task2 = Task.new
31
- task2.load_from_file(file_path)
32
-
33
- assert_equal(task1.id, task2.id)
34
- assert_equal('task1', task2.name)
35
- assert_equal('hello world1', task2.description)
36
-
37
- FileUtils.rm_r(file_path)
38
- end
39
-
40
- def test_status
41
- task1 = Task.new
42
- assert_equal(false, task1.running?)
43
- assert_equal(?., task1.status)
44
-
45
- task1.start
46
- assert_equal(true, task1.running?)
47
- assert_equal(?>, task1.status)
48
-
49
- task1.stop
50
- assert_equal(false, task1.running?)
51
- assert_equal(?., task1.status)
52
-
53
- task1.start
54
- assert_equal(true, task1.running?)
55
- assert_equal(?>, task1.status)
56
-
57
- task1.pause
58
- assert_equal(false, task1.running?)
59
- assert_equal(true, task1.paused?)
60
- assert_equal(?|, task1.status)
61
-
62
- task1.stop
63
- assert_equal(false, task1.running?)
64
- assert_equal(?., task1.status)
65
- end
66
-
67
- def test_start_stop
68
- task1 = Task.new
69
- assert_equal(false, task1.running?)
70
- assert_equal(false, task1.has_track?)
71
- assert_equal(0, task1.timeline.length)
72
-
73
- assert_equal(true, task1.start)
74
- assert_equal(true, task1.running?)
75
- assert_equal(true, task1.has_track?)
76
- assert_equal(1, task1.timeline.length)
77
-
78
- task1.stop
79
- assert_equal(false, task1.running?)
80
- assert_equal(false, task1.has_track?)
81
- assert_equal(1, task1.timeline.length)
82
-
83
- assert_equal(true, task1.start)
84
- assert_equal(true, task1.running?)
85
- assert_equal(true, task1.has_track?)
86
- assert_equal(2, task1.timeline.length)
87
-
88
- assert_equal(false, task1.start)
89
- assert_equal(true, task1.running?)
90
- assert_equal(true, task1.has_track?)
91
- assert_equal(2, task1.timeline.length)
92
-
93
- task1.stop
94
- assert_equal(false, task1.running?)
95
- assert_equal(false, task1.has_track?)
96
- assert_equal(2, task1.timeline.length)
97
-
98
- task1.toggle
99
- assert_equal(true, task1.running?)
100
- assert_equal(true, task1.has_track?)
101
- assert_equal(3, task1.timeline.length)
102
-
103
- task1.toggle
104
- assert_equal(false, task1.running?)
105
- assert_equal(true, task1.has_track?)
106
- assert_equal(3, task1.timeline.length)
107
-
108
- # Track
109
- assert_equal(true, task1.start)
110
-
111
- track1 = Track.new
112
- track1.description = 'hello world1'
113
- track2 = Track.new
114
- track2.description = 'hello world2'
115
-
116
- assert_equal(true, task1.start(track1))
117
- assert_equal(false, task1.start(track1))
118
- assert_equal(true, task1.start(track2))
119
- end
120
-
121
- def test_remove_track
122
- task1 = Task.new
123
-
124
- task1.start
125
- #track1 = task1.track
126
- task1.stop
127
- assert_equal(1, task1.timeline.length)
128
-
129
- task1.start
130
- track2 = task1.track
131
- task1.stop
132
- assert_equal(2, task1.timeline.length)
133
-
134
- task1.start
135
- #track3 = task1.track
136
- task1.stop
137
- assert_equal(3, task1.timeline.length)
138
-
139
- task1.remove_track(track2)
140
- assert_equal(2, task1.timeline.length)
141
- end
142
-
143
- def test_to_s
144
- task1 = Task.new
145
- assert_equal('', task1.to_s)
146
-
147
- task1.name = 'task1'
148
- assert_equal('task1', task1.to_s)
149
-
150
- track1 = Track.new
151
- track1.description = 'hello world1'
152
-
153
- task1.start(track1)
154
- assert_equal('task1', task1.to_s)
155
-
156
- task1.stop
157
- assert_equal('task1', task1.to_s)
158
- end
159
-
160
- def test_run_time_track
161
- task1 = Task.new
162
-
163
- task1.start
164
- task1.track.begin_time = Time.parse('1987-02-21 09:58:59')
165
- assert_equal([24, 3, 2], task1.run_time_track(Time.parse('1987-02-22 10:02:01')))
166
- end
167
-
168
- def test_run_time_total
169
- task1 = Task.new
170
- task1.toggle # running
171
- task1.toggle # paused
172
- task1.toggle # running
173
- task1.toggle # paused
174
- task1.toggle # running
175
- task1.toggle # paused
176
-
177
- timeline = task1.timeline
178
- timeline[0].begin_time = Time.parse('1986-11-20 01:01:01')
179
- timeline[0].end_time = Time.parse('1986-11-20 02:02:02')
180
- timeline[1].begin_time = Time.parse('1991-07-19 03:03:03')
181
- timeline[1].end_time = Time.parse('1991-07-19 04:04:04')
182
- timeline[2].begin_time = Time.parse('1991-08-24 05:05:05')
183
- timeline[2].end_time = Time.parse('1991-08-24 06:06:06')
184
- assert_equal([3, 3, 3], task1.run_time_total)
185
-
186
- task1.toggle
187
- timeline[3].begin_time = Time.parse('2001-01-01 07:07:07')
188
- assert_equal([4, 4, 5], task1.run_time_total(Time.parse('2001-01-01 08:08:09')))
189
- end
190
- end
data/tests/tc_track.rb DELETED
@@ -1,144 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'minitest/autorun'
4
- require 'time'
5
- require 'fileutils'
6
- require 'timr'
7
-
8
-
9
- class TestTrack < MiniTest::Test
10
-
11
- include TheFox::Timr
12
-
13
- def test_class_name
14
- track1 = Track.new
15
-
16
- assert_equal('TheFox::Timr::Track', track1.class.to_s)
17
- end
18
-
19
- def test_basic
20
- track1 = Track.new
21
- assert_equal(nil, track1.begin_time)
22
- assert_equal(nil, track1.end_time)
23
- end
24
-
25
- def test_description
26
- track1 = Track.new
27
- assert_equal(nil, track1.description)
28
-
29
- track1.description = 'hello world1'
30
-
31
- track2 = Track.new
32
- assert_equal(nil, track2.description)
33
-
34
- track2.parent = track1
35
- assert_equal(nil, track2.description)
36
-
37
- track1.description = 'hello world2'
38
- assert_equal(nil, track2.description)
39
- end
40
-
41
- def test_diff
42
- track1 = Track.new
43
- assert_equal(0, track1.diff)
44
-
45
- track1.begin_time = Time.parse('1986-04-08 13:37:02')
46
- track1.end_time = Time.parse('1986-04-08 13:38:01')
47
- assert_equal(59, track1.diff)
48
- assert_equal(Fixnum, track1.diff.class)
49
-
50
- track1.begin_time = Time.parse('2015-01-16 23:00:00')
51
- track1.end_time = Time.parse('2015-06-04 15:30:01')
52
- assert_equal(11979001, track1.diff)
53
- assert_equal(Fixnum, track1.diff.class)
54
- end
55
-
56
- def test_name
57
- task1 = Task.new
58
- task1.name = 'task1'
59
-
60
- track1 = Track.new
61
- track1.description = 'hello world1'
62
-
63
- task1.start(track1)
64
- assert_equal('hello world1', track1.name)
65
-
66
- track1.task = task1
67
- assert_equal('task1: hello world1', track1.name)
68
-
69
- task1.stop
70
- assert_equal('task1: hello world1', track1.name)
71
- end
72
-
73
- def test_to_h
74
- track1 = Track.new
75
-
76
- h = track1.to_h
77
- assert_equal(false, h['id'].nil?)
78
- assert_equal(nil, h['e'])
79
- assert_equal(nil, h['d'])
80
- assert_equal(nil, h['p'])
81
-
82
- track1.begin_time = Time.parse('1990-02-21 09:45')
83
- h = track1.to_h
84
- assert_equal('1990-02-21T08:45:00+0000', h['b'])
85
- assert_equal(nil, h['e'])
86
-
87
- track1.begin_time = Time.parse('1989-10-19 12:59')
88
- track1.end_time = Time.parse('2012-12-14 20:45')
89
- track1.description = 'hello world1'
90
- h = track1.to_h
91
- assert_equal('1989-10-19T11:59:00+0000', h['b'])
92
- assert_equal('2012-12-14T19:45:00+0000', h['e'])
93
- assert_equal('hello world1', h['d'])
94
-
95
- track1.begin_time = Time.parse('2013-11-23 23:00')
96
- track1.end_time = Time.parse('2013-11-24 09:00')
97
- track1.description = 'hello world2'
98
- h = track1.to_h
99
- assert_equal('2013-11-23T22:00:00+0000', h['b'])
100
- assert_equal('2013-11-24T08:00:00+0000', h['e'])
101
- assert_equal('hello world2', h['d'])
102
- end
103
-
104
- def test_to_s
105
- track1 = Track.new
106
- track1.begin_time = Time.parse('1990-08-29 12:34:56')
107
- assert_equal('1990-08-29 12:34 - xx:xx ', track1.to_s)
108
-
109
- task1 = Task.new
110
- task1.name = 'task1'
111
-
112
- track1 = Track.new
113
- track1.begin_time = Time.parse('1990-08-29 12:34:56')
114
- track1.task = task1
115
- assert_equal('1990-08-29 12:34 - xx:xx task1', track1.to_s)
116
-
117
- track1.begin_time = Time.parse('1987-06-11 12:00:00')
118
- track1.end_time = Time.parse('1987-06-12 23:00:00')
119
- assert_equal('1987-06-11 12:00 - 23:00 1987-06-12 task1', track1.to_s)
120
-
121
- track1.description = 'hello world'
122
- assert_equal('1987-06-11 12:00 - 23:00 1987-06-12 task1: hello world', track1.to_s)
123
- end
124
-
125
- def test_from_h
126
- track1 = Track.from_h(nil, {})
127
- assert_equal(nil, track1.begin_time)
128
- assert_equal(nil, track1.end_time)
129
-
130
- track1 = Track.from_h(nil, {
131
- 'id' => 'abc',
132
- 'b' => '1986-06-18 12:34:56+0000',
133
- 'e' => '2014-11-11 19:05:12+0000',
134
- 'd' => 'hello world',
135
- 'p' => '123',
136
- })
137
- assert_equal('abc', track1.id)
138
- assert_equal('1986-06-18 14:34:56', track1.begin_time.strftime('%Y-%m-%d %H:%M:%S'))
139
- assert_equal('2014-11-11 20:05:12', track1.end_time.strftime('%Y-%m-%d %H:%M:%S'))
140
- assert_equal('hello world', track1.description)
141
- assert_equal(nil, track1.parent)
142
- assert_equal('123', track1.parent_id)
143
- end
144
- end
data/tests/tc_window.rb DELETED
@@ -1,428 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'minitest/autorun'
4
- #require 'time'
5
- require 'fileutils'
6
- require 'timr'
7
-
8
-
9
- class TestWindow < MiniTest::Test
10
-
11
- include TheFox::Timr
12
-
13
- def test_class_name
14
- window1 = Window.new
15
-
16
- assert_equal('TheFox::Timr::Window', window1.class.to_s)
17
- end
18
-
19
- def test_content_refresh
20
- window1 = Window.new
21
- assert_equal(1, window1.content_refreshes)
22
-
23
- window1.content_length = 10
24
- window1.content_refresh
25
- assert_equal(2, window1.content_refreshes)
26
-
27
- window1.content_length = 10
28
- window1.content_refresh
29
- assert_equal(2, window1.content_refreshes)
30
-
31
- window1.content_length = 20
32
- window1.content_refresh
33
- assert_equal(3, window1.content_refreshes)
34
-
35
- window1.content_changed
36
- window1.content_refresh
37
- assert_equal(4, window1.content_refreshes)
38
- end
39
-
40
- def test_page_refreshes
41
- window1 = Window.new
42
- assert_equal(0, window1.page_refreshes)
43
-
44
- window1.content_changed
45
- window1.content_refresh
46
- window1.page
47
- assert_equal(1, window1.page_refreshes)
48
- end
49
-
50
- def test_page
51
- window1 = TestWindow.new
52
- window1.content_length = 3
53
- window1.content_refresh
54
- page = window1.page.map{ |page_item| page_item[0..7] }
55
- assert_equal(['LINE 001', 'LINE 002', 'LINE 003'], page)
56
- assert_equal(3, window1.page_length)
57
-
58
- window1.content_length = 4
59
- window1.content_refresh
60
- page = window1.page.map{ |page_item| page_item[0..7] }
61
- assert_equal(['LINE 001', 'LINE 002', 'LINE 003', 'LINE 004'], page)
62
- assert_equal(4, window1.page_length)
63
- end
64
-
65
- def test_page_object
66
- window1 = TestWindow.new
67
- assert_equal(1, window1.cursor)
68
-
69
- window1.content_length = 3
70
- window1.content_refresh
71
- assert_equal('LINE 001', window1.page_object[0..7])
72
-
73
- window1.cursor_next_line
74
- assert_equal('LINE 002', window1.page_object[0..7])
75
- end
76
-
77
- def test_has_next_page
78
- window1 = TestWindow.new
79
- window1.content_length = 3
80
- window1.content_refresh
81
- assert_equal(true, window1.next_page?)
82
-
83
- window1.content_length = 30
84
- assert_equal(false, window1.next_page?)
85
-
86
- window1.content_length = 30
87
- window1.content_refresh
88
- assert_equal(false, window1.next_page?)
89
-
90
- window1.content_length = 40
91
- assert_equal(false, window1.next_page?)
92
- end
93
-
94
- def test_has_previous_page
95
- window1 = TestWindow.new
96
- window1.content_length = 3
97
- window1.content_refresh
98
- assert_equal(false, window1.previous_page?)
99
-
100
- window1.content_length = 40
101
- window1.content_refresh
102
- assert_equal(false, window1.previous_page?)
103
- end
104
-
105
- def test_jmp_next_previous_page
106
- window1 = TestWindow.new
107
- window1.content_length = 3
108
- window1.content_refresh
109
-
110
- page = window1.page.map{ |page_item| page_item[0..7] }
111
- assert_equal((1..3).map{ |n| 'LINE %03d' % [n] }, page)
112
- assert_equal(3, window1.page_length)
113
- assert_equal(0, window1.current_line)
114
- assert_equal(1, window1.cursor)
115
-
116
- window1.next_page
117
- assert_equal(3, window1.current_line)
118
- page = window1.page.map{ |page_item| page_item[0..7] }
119
- assert_equal((4..6).map{ |n| 'LINE %03d' % [n] }, page)
120
- assert_equal(3, window1.page_length)
121
- assert_equal(1, window1.cursor)
122
-
123
- window1.next_page
124
- assert_equal(6, window1.current_line)
125
- page = window1.page.map{ |page_item| page_item[0..7] }
126
- assert_equal((7..9).map{ |n| 'LINE %03d' % [n] }, page)
127
- assert_equal(3, window1.page_length)
128
- assert_equal(1, window1.cursor)
129
-
130
- window1.content_length = 20
131
- window1.content_refresh
132
- page = window1.page.map{ |page_item| page_item[0..7] }
133
- assert_equal((7..26).map{ |n| 'LINE %03d' % [n] }, page)
134
- assert_equal(20, window1.page_length)
135
- assert_equal(6, window1.current_line)
136
- assert_equal(1, window1.cursor)
137
-
138
- window1.next_page(1)
139
- assert_equal(7, window1.current_line)
140
- page = window1.page.map{ |page_item| page_item[0..7] }
141
- assert_equal((8..27).map{ |n| 'LINE %03d' % [n] }, page)
142
- assert_equal(20, window1.page_length)
143
- assert_equal(1, window1.cursor)
144
-
145
- window1.next_page
146
- assert_equal(27, window1.current_line)
147
- page = window1.page.map{ |page_item| page_item[0..7] }
148
- assert_equal((28..30).map{ |n| 'LINE %03d' % [n] }, page)
149
- assert_equal(3, window1.page_length)
150
- assert_equal(1, window1.cursor)
151
-
152
- window1.previous_page
153
- assert_equal(7, window1.current_line)
154
- page = window1.page.map{ |page_item| page_item[0..7] }
155
- assert_equal((8..27).map{ |n| 'LINE %03d' % [n] }, page)
156
- assert_equal(20, window1.page_length)
157
- assert_equal(1, window1.cursor)
158
-
159
- window1.previous_page(1)
160
- assert_equal(6, window1.current_line)
161
- page = window1.page.map{ |page_item| page_item[0..7] }
162
- assert_equal((7..26).map{ |n| 'LINE %03d' % [n] }, page)
163
- assert_equal(20, window1.page_length)
164
- assert_equal(1, window1.cursor)
165
-
166
- window1.next_page
167
- page = window1.page.map{ |page_item| page_item[0..7] }
168
- assert_equal((27..30).map{ |n| 'LINE %03d' % [n] }, page)
169
- assert_equal(4, window1.page_length)
170
- assert_equal(1, window1.cursor)
171
-
172
- window1.previous_page(1)
173
- window1.page
174
- assert_equal(5, window1.page_length)
175
- assert_equal(1, window1.cursor)
176
-
177
- window1.first_page
178
- assert_equal(0, window1.current_line)
179
- assert_equal(1, window1.cursor)
180
-
181
- window1.first_page
182
- assert_equal(0, window1.current_line)
183
- assert_equal(1, window1.cursor)
184
-
185
- window1.next_page(1)
186
- assert_equal(1, window1.current_line)
187
- page = window1.page.map{ |page_item| page_item[0..7] }
188
- assert_equal((2..21).map{ |n| 'LINE %03d' % [n] }, page)
189
- assert_equal(20, window1.page_length)
190
- assert_equal(1, window1.cursor)
191
-
192
- window1.last_page
193
- assert_equal(10, window1.current_line)
194
- page = window1.page.map{ |page_item| page_item[0..7] }
195
- assert_equal((11..30).map{ |n| 'LINE %03d' % [n] }, page)
196
- assert_equal(20, window1.page_length)
197
- assert_equal(20, window1.cursor)
198
-
199
- window1.first_page
200
- window1.content_length = 6
201
- window1.content_refresh
202
- assert_equal(0, window1.current_line)
203
- assert_equal(1, window1.cursor)
204
- page = window1.page.map{ |page_item| page_item[0..7] }
205
- assert_equal((1..6).map{ |n| 'LINE %03d' % [n] }, page)
206
-
207
- window1.cursor_next_line
208
- assert_equal(2, window1.cursor)
209
- page = window1.page.map{ |page_item| page_item[0..7] }
210
- assert_equal((1..6).map{ |n| 'LINE %03d' % [n] }, page)
211
-
212
- window1.cursor_next_line
213
- assert_equal(3, window1.cursor)
214
- page = window1.page.map{ |page_item| page_item[0..7] }
215
- assert_equal((1..6).map{ |n| 'LINE %03d' % [n] }, page)
216
-
217
- window1.cursor_next_line
218
- assert_equal(4, window1.cursor)
219
- page = window1.page.map{ |page_item| page_item[0..7] }
220
- assert_equal((1..6).map{ |n| 'LINE %03d' % [n] }, page)
221
-
222
- window1.cursor_next_line
223
- assert_equal(4, window1.cursor)
224
- page = window1.page.map{ |page_item| page_item[0..7] }
225
- assert_equal((2..7).map{ |n| 'LINE %03d' % [n] }, page)
226
-
227
- (0..21).each do |n|
228
- window1.cursor_next_line
229
- end
230
- assert_equal(4, window1.cursor)
231
- page = window1.page.map{ |page_item| page_item[0..7] }
232
- assert_equal((24..29).map{ |n| 'LINE %03d' % [n] }, page)
233
-
234
- window1.cursor_next_line
235
- assert_equal(4, window1.cursor)
236
- page = window1.page.map{ |page_item| page_item[0..7] }
237
- assert_equal((25..30).map{ |n| 'LINE %03d' % [n] }, page)
238
-
239
- window1.cursor_next_line
240
- assert_equal(5, window1.cursor)
241
- page = window1.page.map{ |page_item| page_item[0..7] }
242
- assert_equal((25..30).map{ |n| 'LINE %03d' % [n] }, page)
243
-
244
- window1.cursor_next_line
245
- assert_equal(6, window1.cursor)
246
- page = window1.page.map{ |page_item| page_item[0..7] }
247
- assert_equal((25..30).map{ |n| 'LINE %03d' % [n] }, page)
248
-
249
- window1.cursor_next_line
250
- assert_equal(6, window1.cursor)
251
- page = window1.page.map{ |page_item| page_item[0..7] }
252
- assert_equal((25..30).map{ |n| 'LINE %03d' % [n] }, page)
253
-
254
- window1.cursor_previous_line
255
- assert_equal(5, window1.cursor)
256
- page = window1.page.map{ |page_item| page_item[0..7] }
257
- assert_equal((25..30).map{ |n| 'LINE %03d' % [n] }, page)
258
-
259
- window1.cursor_previous_line
260
- assert_equal(4, window1.cursor)
261
- page = window1.page.map{ |page_item| page_item[0..7] }
262
- assert_equal((25..30).map{ |n| 'LINE %03d' % [n] }, page)
263
-
264
- window1.cursor_previous_line
265
- assert_equal(3, window1.cursor)
266
- page = window1.page.map{ |page_item| page_item[0..7] }
267
- assert_equal((25..30).map{ |n| 'LINE %03d' % [n] }, page)
268
-
269
- window1.cursor_previous_line
270
- assert_equal(3, window1.cursor)
271
- page = window1.page.map{ |page_item| page_item[0..7] }
272
- assert_equal((24..29).map{ |n| 'LINE %03d' % [n] }, page)
273
-
274
- (0..21).each do |n|
275
- window1.cursor_previous_line
276
- end
277
- assert_equal(3, window1.cursor)
278
- page = window1.page.map{ |page_item| page_item[0..7] }
279
- assert_equal((2..7).map{ |n| 'LINE %03d' % [n] }, page)
280
-
281
- window1.cursor_previous_line
282
- assert_equal(3, window1.cursor)
283
- page = window1.page.map{ |page_item| page_item[0..7] }
284
- assert_equal((1..6).map{ |n| 'LINE %03d' % [n] }, page)
285
-
286
- window1.cursor_previous_line
287
- assert_equal(2, window1.cursor)
288
- page = window1.page.map{ |page_item| page_item[0..7] }
289
- assert_equal((1..6).map{ |n| 'LINE %03d' % [n] }, page)
290
-
291
- window1.cursor_previous_line
292
- assert_equal(1, window1.cursor)
293
- page = window1.page.map{ |page_item| page_item[0..7] }
294
- assert_equal((1..6).map{ |n| 'LINE %03d' % [n] }, page)
295
-
296
- window1.cursor_previous_line
297
- assert_equal(1, window1.cursor)
298
- page = window1.page.map{ |page_item| page_item[0..7] }
299
- assert_equal((1..6).map{ |n| 'LINE %03d' % [n] }, page)
300
-
301
-
302
- window1.content = ['line 1', 'line 2', 'line 3']
303
- window1.content_refresh
304
- page = window1.page.map{ |page_item| page_item }
305
- assert_equal((1..3).map{ |n| 'line %d' % [n] }, page)
306
- end
307
-
308
- def test_cursor_border_top_bottom
309
- window1 = TestWindow.new
310
- window1.content_length = 7
311
- window1.content_refresh
312
- assert_equal(1, window1.cursor_border_top)
313
- assert_equal(5, window1.cursor_border_bottom)
314
-
315
- window1.cursor_next_line
316
- assert_equal(1, window1.cursor_border_top)
317
- assert_equal(5, window1.cursor_border_bottom)
318
-
319
- window1.cursor_next_line
320
- assert_equal(1, window1.cursor_border_top)
321
- assert_equal(5, window1.cursor_border_bottom)
322
-
323
- window1.cursor_next_line
324
- assert_equal(1, window1.cursor_border_top)
325
- assert_equal(5, window1.cursor_border_bottom)
326
-
327
- window1.cursor_next_line
328
- assert_equal(1, window1.cursor_border_top)
329
- assert_equal(5, window1.cursor_border_bottom)
330
-
331
- window1.cursor_next_line
332
- assert_equal(3, window1.cursor_border_top)
333
- assert_equal(5, window1.cursor_border_bottom)
334
-
335
- 21.times.each do
336
- window1.cursor_next_line
337
- assert_equal(3, window1.cursor_border_top)
338
- assert_equal(5, window1.cursor_border_bottom)
339
- end
340
-
341
- 2.times.each do
342
- window1.cursor_next_line
343
- assert_equal(3, window1.cursor_border_top)
344
- assert_equal(7, window1.cursor_border_bottom)
345
- end
346
- end
347
-
348
- def test_cursor_on_inner_range_multiple_pages
349
- window1 = TestWindow.new
350
- window1.content_length = 7
351
- window1.content_refresh
352
- assert_equal(true, window1.cursor_on_inner_range?)
353
-
354
- window1.cursor_next_line
355
- assert_equal(true, window1.cursor_on_inner_range?)
356
-
357
- window1.cursor_next_line
358
- assert_equal(true, window1.cursor_on_inner_range?)
359
-
360
- window1.cursor_next_line
361
- assert_equal(true, window1.cursor_on_inner_range?)
362
-
363
- window1.cursor_next_line
364
- assert_equal(true, window1.cursor_on_inner_range?)
365
-
366
- window1.cursor_next_line
367
- assert_equal(false, window1.cursor_on_inner_range?)
368
-
369
- window1.cursor_previous_line
370
- assert_equal(true, window1.cursor_on_inner_range?)
371
- window1.cursor_next_line
372
-
373
- 21.times.each do
374
- window1.cursor_next_line
375
- assert_equal(false, window1.cursor_on_inner_range?)
376
- end
377
-
378
- window1.cursor_next_line
379
- assert_equal(true, window1.cursor_on_inner_range?)
380
-
381
- window1.cursor_next_line
382
- assert_equal(true, window1.cursor_on_inner_range?)
383
-
384
- window1.cursor_next_line
385
- assert_equal(true, window1.cursor_on_inner_range?)
386
-
387
- window1.cursor_previous_line
388
- assert_equal(true, window1.cursor_on_inner_range?)
389
-
390
- window1.cursor_previous_line
391
- assert_equal(true, window1.cursor_on_inner_range?)
392
-
393
- window1.cursor_previous_line
394
- assert_equal(true, window1.cursor_on_inner_range?)
395
-
396
- window1.cursor_previous_line
397
- assert_equal(true, window1.cursor_on_inner_range?)
398
-
399
- window1.cursor_previous_line
400
- assert_equal(false, window1.cursor_on_inner_range?)
401
-
402
- 21.times.each do
403
- window1.cursor_previous_line
404
- assert_equal(false, window1.cursor_on_inner_range?)
405
- end
406
-
407
- window1.cursor_previous_line
408
- assert_equal(true, window1.cursor_on_inner_range?)
409
-
410
- window1.cursor_previous_line
411
- assert_equal(true, window1.cursor_on_inner_range?)
412
-
413
- window1.cursor_previous_line
414
- assert_equal(true, window1.cursor_on_inner_range?)
415
- end
416
-
417
- def test_cursor_on_inner_range_one_page
418
- window1 = TestWindow.new
419
- window1.content_length = 35
420
- window1.content_refresh
421
- assert_equal(true, window1.cursor_on_inner_range?)
422
-
423
- 29.times.each do
424
- window1.cursor_next_line
425
- assert_equal(true, window1.cursor_on_inner_range?)
426
- end
427
- end
428
- end