timr 0.1.0.pre.dev.5 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,304 @@
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
+ def test_class_name
11
+ window = TheFox::Timr::Window.new
12
+
13
+ assert_equal('TheFox::Timr::Window', window.class.to_s)
14
+ end
15
+
16
+ def test_content_refresh
17
+ window = TheFox::Timr::Window.new
18
+ assert_equal(1, window.content_refreshes)
19
+
20
+ window.content_length = 10
21
+ window.content_refresh
22
+ assert_equal(2, window.content_refreshes)
23
+
24
+ window.content_length = 10
25
+ window.content_refresh
26
+ assert_equal(2, window.content_refreshes)
27
+
28
+ window.content_length = 20
29
+ window.content_refresh
30
+ assert_equal(3, window.content_refreshes)
31
+
32
+ window.content_changed
33
+ window.content_refresh
34
+ assert_equal(4, window.content_refreshes)
35
+ end
36
+
37
+ def test_page_refreshes
38
+ window = TheFox::Timr::Window.new
39
+ assert_equal(0, window.page_refreshes)
40
+
41
+ window.content_changed
42
+ window.content_refresh
43
+ window.page
44
+ assert_equal(1, window.page_refreshes)
45
+ end
46
+
47
+ def test_page
48
+ window = TheFox::Timr::TestWindow.new
49
+ window.content_length = 3
50
+ window.content_refresh
51
+ page = window.page.map{ |page_item| page_item[0..7] }
52
+ assert_equal(['LINE 001', 'LINE 002', 'LINE 003'], page)
53
+ assert_equal(3, window.page_length)
54
+
55
+ window.content_length = 4
56
+ window.content_refresh
57
+ page = window.page.map{ |page_item| page_item[0..7] }
58
+ assert_equal(['LINE 001', 'LINE 002', 'LINE 003', 'LINE 004'], page)
59
+ assert_equal(4, window.page_length)
60
+ end
61
+
62
+ def test_page_object
63
+ window = TheFox::Timr::TestWindow.new
64
+ assert_equal(1, window.cursor)
65
+
66
+ window.content_length = 3
67
+ window.content_refresh
68
+ assert_equal('LINE 001', window.page_object[0..7])
69
+
70
+ window.cursor_next_line
71
+ assert_equal('LINE 002', window.page_object[0..7])
72
+ end
73
+
74
+ def test_has_next_page
75
+ window = TheFox::Timr::TestWindow.new
76
+ window.content_length = 3
77
+ window.content_refresh
78
+ assert_equal(true, window.next_page?)
79
+
80
+ window.content_length = 30
81
+ assert_equal(false, window.next_page?)
82
+
83
+ window.content_length = 30
84
+ window.content_refresh
85
+ assert_equal(false, window.next_page?)
86
+
87
+ window.content_length = 40
88
+ assert_equal(false, window.next_page?)
89
+ end
90
+
91
+ def test_has_previous_page
92
+ window = TheFox::Timr::TestWindow.new
93
+ window.content_length = 3
94
+ window.content_refresh
95
+ assert_equal(false, window.previous_page?)
96
+
97
+ window.content_length = 40
98
+ window.content_refresh
99
+ assert_equal(false, window.previous_page?)
100
+ end
101
+
102
+ def test_jmp_next_previous_page
103
+ window = TheFox::Timr::TestWindow.new
104
+ window.content_length = 3
105
+ window.content_refresh
106
+
107
+ page = window.page.map{ |page_item| page_item[0..7] }
108
+ assert_equal((1..3).map{ |n| 'LINE %03d' % [n] }, page)
109
+ assert_equal(3, window.page_length)
110
+ assert_equal(0, window.current_line)
111
+ assert_equal(1, window.cursor)
112
+
113
+ window.next_page
114
+ assert_equal(3, window.current_line)
115
+ page = window.page.map{ |page_item| page_item[0..7] }
116
+ assert_equal((4..6).map{ |n| 'LINE %03d' % [n] }, page)
117
+ assert_equal(3, window.page_length)
118
+ assert_equal(1, window.cursor)
119
+
120
+ window.next_page
121
+ assert_equal(6, window.current_line)
122
+ page = window.page.map{ |page_item| page_item[0..7] }
123
+ assert_equal((7..9).map{ |n| 'LINE %03d' % [n] }, page)
124
+ assert_equal(3, window.page_length)
125
+ assert_equal(1, window.cursor)
126
+
127
+ window.content_length = 20
128
+ window.content_refresh
129
+ page = window.page.map{ |page_item| page_item[0..7] }
130
+ assert_equal((7..26).map{ |n| 'LINE %03d' % [n] }, page)
131
+ assert_equal(20, window.page_length)
132
+ assert_equal(6, window.current_line)
133
+ assert_equal(1, window.cursor)
134
+
135
+ window.next_page(1)
136
+ assert_equal(7, window.current_line)
137
+ page = window.page.map{ |page_item| page_item[0..7] }
138
+ assert_equal((8..27).map{ |n| 'LINE %03d' % [n] }, page)
139
+ assert_equal(20, window.page_length)
140
+ assert_equal(1, window.cursor)
141
+
142
+ window.next_page
143
+ assert_equal(27, window.current_line)
144
+ page = window.page.map{ |page_item| page_item[0..7] }
145
+ assert_equal((28..30).map{ |n| 'LINE %03d' % [n] }, page)
146
+ assert_equal(3, window.page_length)
147
+ assert_equal(1, window.cursor)
148
+
149
+ window.previous_page
150
+ assert_equal(7, window.current_line)
151
+ page = window.page.map{ |page_item| page_item[0..7] }
152
+ assert_equal((8..27).map{ |n| 'LINE %03d' % [n] }, page)
153
+ assert_equal(20, window.page_length)
154
+ assert_equal(1, window.cursor)
155
+
156
+ window.previous_page(1)
157
+ assert_equal(6, window.current_line)
158
+ page = window.page.map{ |page_item| page_item[0..7] }
159
+ assert_equal((7..26).map{ |n| 'LINE %03d' % [n] }, page)
160
+ assert_equal(20, window.page_length)
161
+ assert_equal(1, window.cursor)
162
+
163
+ window.next_page
164
+ page = window.page.map{ |page_item| page_item[0..7] }
165
+ assert_equal((27..30).map{ |n| 'LINE %03d' % [n] }, page)
166
+ assert_equal(4, window.page_length)
167
+ assert_equal(1, window.cursor)
168
+
169
+ window.previous_page(1)
170
+ window.page
171
+ assert_equal(5, window.page_length)
172
+ assert_equal(1, window.cursor)
173
+
174
+ window.first_page
175
+ assert_equal(0, window.current_line)
176
+ assert_equal(1, window.cursor)
177
+
178
+ window.first_page
179
+ assert_equal(0, window.current_line)
180
+ assert_equal(1, window.cursor)
181
+
182
+ window.next_page(1)
183
+ assert_equal(1, window.current_line)
184
+ page = window.page.map{ |page_item| page_item[0..7] }
185
+ assert_equal((2..21).map{ |n| 'LINE %03d' % [n] }, page)
186
+ assert_equal(20, window.page_length)
187
+ assert_equal(1, window.cursor)
188
+
189
+ window.last_page
190
+ assert_equal(10, window.current_line)
191
+ page = window.page.map{ |page_item| page_item[0..7] }
192
+ assert_equal((11..30).map{ |n| 'LINE %03d' % [n] }, page)
193
+ assert_equal(20, window.page_length)
194
+ assert_equal(20, window.cursor)
195
+
196
+ window.first_page
197
+ window.content_length = 6
198
+ window.content_refresh
199
+ assert_equal(0, window.current_line)
200
+ assert_equal(1, window.cursor)
201
+ page = window.page.map{ |page_item| page_item[0..7] }
202
+ assert_equal((1..6).map{ |n| 'LINE %03d' % [n] }, page)
203
+
204
+ window.cursor_next_line
205
+ assert_equal(2, window.cursor)
206
+ page = window.page.map{ |page_item| page_item[0..7] }
207
+ assert_equal((1..6).map{ |n| 'LINE %03d' % [n] }, page)
208
+
209
+ window.cursor_next_line
210
+ assert_equal(3, window.cursor)
211
+ page = window.page.map{ |page_item| page_item[0..7] }
212
+ assert_equal((1..6).map{ |n| 'LINE %03d' % [n] }, page)
213
+
214
+ window.cursor_next_line
215
+ assert_equal(4, window.cursor)
216
+ page = window.page.map{ |page_item| page_item[0..7] }
217
+ assert_equal((1..6).map{ |n| 'LINE %03d' % [n] }, page)
218
+
219
+ window.cursor_next_line
220
+ assert_equal(4, window.cursor)
221
+ page = window.page.map{ |page_item| page_item[0..7] }
222
+ assert_equal((2..7).map{ |n| 'LINE %03d' % [n] }, page)
223
+
224
+ (0..21).each do |n|
225
+ window.cursor_next_line
226
+ end
227
+ assert_equal(4, window.cursor)
228
+ page = window.page.map{ |page_item| page_item[0..7] }
229
+ assert_equal((24..29).map{ |n| 'LINE %03d' % [n] }, page)
230
+
231
+ window.cursor_next_line
232
+ assert_equal(4, window.cursor)
233
+ page = window.page.map{ |page_item| page_item[0..7] }
234
+ assert_equal((25..30).map{ |n| 'LINE %03d' % [n] }, page)
235
+
236
+ window.cursor_next_line
237
+ assert_equal(5, window.cursor)
238
+ page = window.page.map{ |page_item| page_item[0..7] }
239
+ assert_equal((25..30).map{ |n| 'LINE %03d' % [n] }, page)
240
+
241
+ window.cursor_next_line
242
+ assert_equal(6, window.cursor)
243
+ page = window.page.map{ |page_item| page_item[0..7] }
244
+ assert_equal((25..30).map{ |n| 'LINE %03d' % [n] }, page)
245
+
246
+ window.cursor_next_line
247
+ assert_equal(6, window.cursor)
248
+ page = window.page.map{ |page_item| page_item[0..7] }
249
+ assert_equal((25..30).map{ |n| 'LINE %03d' % [n] }, page)
250
+
251
+ window.cursor_previous_line
252
+ assert_equal(5, window.cursor)
253
+ page = window.page.map{ |page_item| page_item[0..7] }
254
+ assert_equal((25..30).map{ |n| 'LINE %03d' % [n] }, page)
255
+
256
+ window.cursor_previous_line
257
+ assert_equal(4, window.cursor)
258
+ page = window.page.map{ |page_item| page_item[0..7] }
259
+ assert_equal((25..30).map{ |n| 'LINE %03d' % [n] }, page)
260
+
261
+ window.cursor_previous_line
262
+ assert_equal(3, window.cursor)
263
+ page = window.page.map{ |page_item| page_item[0..7] }
264
+ assert_equal((25..30).map{ |n| 'LINE %03d' % [n] }, page)
265
+
266
+ window.cursor_previous_line
267
+ assert_equal(3, window.cursor)
268
+ page = window.page.map{ |page_item| page_item[0..7] }
269
+ assert_equal((24..29).map{ |n| 'LINE %03d' % [n] }, page)
270
+
271
+ (0..21).each do |n|
272
+ window.cursor_previous_line
273
+ end
274
+ assert_equal(3, window.cursor)
275
+ page = window.page.map{ |page_item| page_item[0..7] }
276
+ assert_equal((2..7).map{ |n| 'LINE %03d' % [n] }, page)
277
+
278
+ window.cursor_previous_line
279
+ assert_equal(3, window.cursor)
280
+ page = window.page.map{ |page_item| page_item[0..7] }
281
+ assert_equal((1..6).map{ |n| 'LINE %03d' % [n] }, page)
282
+
283
+ window.cursor_previous_line
284
+ assert_equal(2, window.cursor)
285
+ page = window.page.map{ |page_item| page_item[0..7] }
286
+ assert_equal((1..6).map{ |n| 'LINE %03d' % [n] }, page)
287
+
288
+ window.cursor_previous_line
289
+ assert_equal(1, window.cursor)
290
+ page = window.page.map{ |page_item| page_item[0..7] }
291
+ assert_equal((1..6).map{ |n| 'LINE %03d' % [n] }, page)
292
+
293
+ window.cursor_previous_line
294
+ assert_equal(1, window.cursor)
295
+ page = window.page.map{ |page_item| page_item[0..7] }
296
+ assert_equal((1..6).map{ |n| 'LINE %03d' % [n] }, page)
297
+
298
+
299
+ window.content = ['line 1', 'line 2', 'line 3']
300
+ window.content_refresh
301
+ page = window.page.map{ |page_item| page_item }
302
+ assert_equal((1..3).map{ |n| 'line %d' % [n] }, page)
303
+ end
304
+ end
data/tests/ts_all.rb ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative 'tc_stack'
4
+ require_relative 'tc_task'
5
+ require_relative 'tc_track'
6
+ require_relative 'tc_window'
data/timr.gemspec CHANGED
@@ -13,7 +13,7 @@ Gem::Specification.new do |spec|
13
13
  spec.email = 'christian@fox21.at'
14
14
 
15
15
  spec.summary = %q{Timr}
16
- spec.description = %q{Time Tracking Tool for the Command-line.}
16
+ spec.description = %q{Time Tracking for Hackers.}
17
17
  spec.homepage = TheFox::Timr::HOMEPAGE
18
18
  spec.license = 'GPL-3.0'
19
19
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: timr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.pre.dev.5
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christian Mayer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-10 00:00:00.000000000 Z
11
+ date: 2016-05-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest
@@ -66,7 +66,7 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '1.4'
69
- description: Time Tracking Tool for the Command-line.
69
+ description: Time Tracking for Hackers.
70
70
  email: christian@fox21.at
71
71
  executables:
72
72
  - timr
@@ -75,6 +75,7 @@ extra_rdoc_files: []
75
75
  files:
76
76
  - ".editorconfig"
77
77
  - ".gitignore"
78
+ - ".travis.yml"
78
79
  - Gemfile
79
80
  - Gemfile.lock
80
81
  - Makefile
@@ -92,6 +93,11 @@ files:
92
93
  - lib/timr/window_tasks.rb
93
94
  - lib/timr/window_test.rb
94
95
  - lib/timr/window_timeline.rb
96
+ - tests/tc_stack.rb
97
+ - tests/tc_task.rb
98
+ - tests/tc_track.rb
99
+ - tests/tc_window.rb
100
+ - tests/ts_all.rb
95
101
  - timr.gemspec
96
102
  - timr.sublime-project
97
103
  homepage: https://github.com/TheFox/timr
@@ -109,9 +115,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
109
115
  version: 2.1.0
110
116
  required_rubygems_version: !ruby/object:Gem::Requirement
111
117
  requirements:
112
- - - ">"
118
+ - - ">="
113
119
  - !ruby/object:Gem::Version
114
- version: 1.3.1
120
+ version: '0'
115
121
  requirements: []
116
122
  rubyforge_project:
117
123
  rubygems_version: 2.4.7