vedeu 0.6.56 → 0.6.57

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +3 -0
  3. data/Guardfile +1 -1
  4. data/Rakefile +3 -3
  5. data/lib/vedeu/borders/all.rb +1 -0
  6. data/lib/vedeu/borders/border.rb +14 -80
  7. data/lib/vedeu/borders/caption.rb +17 -0
  8. data/lib/vedeu/borders/dsl.rb +2 -2
  9. data/lib/vedeu/borders/null.rb +14 -34
  10. data/lib/vedeu/borders/refresh.rb +28 -14
  11. data/lib/vedeu/borders/title.rb +0 -10
  12. data/lib/vedeu/buffers/buffer.rb +1 -1
  13. data/lib/vedeu/buffers/view.rb +7 -6
  14. data/lib/vedeu/colours/repository.rb +0 -15
  15. data/lib/vedeu/cursors/cursor.rb +6 -6
  16. data/lib/vedeu/cursors/refresh.rb +11 -19
  17. data/lib/vedeu/cursors/reposition.rb +3 -5
  18. data/lib/vedeu/editor/cropper.rb +9 -9
  19. data/lib/vedeu/editor/cursor.rb +5 -5
  20. data/lib/vedeu/editor/editor.rb +1 -1
  21. data/lib/vedeu/events/event.rb +1 -1
  22. data/lib/vedeu/events/trigger.rb +1 -1
  23. data/lib/vedeu/geometry/area.rb +94 -17
  24. data/lib/vedeu/geometry/coordinate.rb +15 -15
  25. data/lib/vedeu/geometry/dimension.rb +2 -2
  26. data/lib/vedeu/geometry/geometry.rb +30 -27
  27. data/lib/vedeu/geometry/null.rb +17 -11
  28. data/lib/vedeu/interfaces/clear.rb +5 -12
  29. data/lib/vedeu/output/viewport.rb +13 -13
  30. data/lib/vedeu/plugins/plugin.rb +1 -1
  31. data/lib/vedeu/repositories/repository.rb +1 -3
  32. data/lib/vedeu/version.rb +1 -1
  33. data/test/lib/vedeu/borders/border_test.rb +4 -230
  34. data/test/lib/vedeu/borders/caption_test.rb +15 -0
  35. data/test/lib/vedeu/borders/dsl_test.rb +4 -4
  36. data/test/lib/vedeu/borders/null_test.rb +3 -39
  37. data/test/lib/vedeu/buffers/view_test.rb +2 -0
  38. data/test/lib/vedeu/colours/repository_test.rb +0 -19
  39. data/test/lib/vedeu/cursors/reposition_test.rb +17 -4
  40. data/test/lib/vedeu/dsl/shared_test.rb +34 -0
  41. data/test/lib/vedeu/geometry/area_test.rb +196 -3
  42. data/test/lib/vedeu/geometry/dimension_test.rb +79 -79
  43. data/test/lib/vedeu/geometry/geometry_test.rb +4 -0
  44. data/test/lib/vedeu/groups/refresh_test.rb +1 -1
  45. data/test/lib/vedeu/logging/clock_time_test.rb +14 -0
  46. data/test/lib/vedeu/logging/ips_test.rb +43 -0
  47. data/test/lib/vedeu/output/presentation/colour_test.rb +4 -0
  48. data/test/lib/vedeu/repositories/repositories_test.rb +7 -1
  49. data/test/lib/vedeu/terminal/buffer_test.rb +10 -0
  50. data/test/support/examples/material_colours_app.rb +306 -47
  51. data/test/test_helper.rb +5 -5
  52. metadata +7 -4
  53. data/test/support/examples/borders_app.rb +0 -330
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c92681933a1db2bfff9701b5eb7150bce03b6390
4
- data.tar.gz: 3fbf5744728ed37c2557d0301a29bb82e4a255ae
3
+ metadata.gz: f6b535e5cb8b4ba8c6bc115745981c6934a899e4
4
+ data.tar.gz: 448638ef6471487754a32e81594054b6dae011e6
5
5
  SHA512:
6
- metadata.gz: 3a558c37500d76ca3b937ed1e051e31d073d402f3ac84b8b95457676bc3ca96eaa7b21ff1c2dd5e16d194690494da767a144771edb199d24f6fa5752ef256201
7
- data.tar.gz: 0f3d5c4c7decf8180d13c12911d54088090d72bcfd931b4fbb1a198b5ae1fb2dcb682d6dd74ea046f6f3b3649ba201f3f8fca953be62db00c0aa65efe3818e01
6
+ metadata.gz: e62418c3701fd759daa1f2fce52692c92ed9d2c8b8c476acfaa1ab1e40d215d5c14247ba3c1e8b2c940a0201e9707fa0bc91e5ac62e58826cfd11106ba044f30
7
+ data.tar.gz: 02b5e88a20ee7b1c7e1f04395ba533c34e9325c9a84d7b2b5257f82fd73010fdcf9186e613b13c742c4e815e450273d6569cc86d67e69a39c38c563a28debf62
data/.rubocop.yml CHANGED
@@ -97,6 +97,9 @@ Style/Next:
97
97
  - skip_modifier_ifs
98
98
  - always
99
99
 
100
+ Style/RescueModifier:
101
+ Enabled: false
102
+
100
103
  Style/SpaceAroundOperators:
101
104
  Enabled: false
102
105
 
data/Guardfile CHANGED
@@ -1,4 +1,4 @@
1
- if ENV['RUBOCOP'] == 1
1
+ if ENV['RUBOCOP'].to_i == 1
2
2
  guard :rubocop do
3
3
  watch(/.+\.rb$/)
4
4
  watch(%r{(?:.+/)?\.rubocop\.yml$}) { |m| File.dirname(m[0]) }
data/Rakefile CHANGED
@@ -8,7 +8,7 @@ Rake::TestTask.new(:test) do |task|
8
8
  task.libs.push 'test'
9
9
  task.pattern = 'test/**/*_test.rb'
10
10
  task.verbose = false
11
- task.warning = true if ENV['WARNINGS'] == 1
11
+ task.warning = true if ENV['WARNINGS'].to_i == 1
12
12
  end
13
13
 
14
14
  YARD::Rake::YardocTask.new(:yard) do |task|
@@ -51,7 +51,7 @@ RuboCop::RakeTask.new(:rubocop) do |task|
51
51
  end
52
52
 
53
53
  tasks_to_run = [:test]
54
- tasks_to_run << :rubocop if ENV['RUBOCOP'] == 1
55
- tasks_to_run << :yard if ENV['YARD'] == 1
54
+ tasks_to_run << :rubocop if ENV['RUBOCOP'].to_i == 1
55
+ tasks_to_run << :yard if ENV['YARD'].to_i == 1
56
56
 
57
57
  task default: tasks_to_run
@@ -34,6 +34,7 @@ module Vedeu
34
34
  end # Vedeu
35
35
 
36
36
  require 'vedeu/borders/title'
37
+ require 'vedeu/borders/caption'
37
38
  require 'vedeu/borders/border'
38
39
  require 'vedeu/borders/dsl'
39
40
  require 'vedeu/borders/null'
@@ -22,6 +22,10 @@ module Vedeu
22
22
  include Vedeu::Presentation
23
23
 
24
24
  def_delegators :geometry,
25
+ :bx,
26
+ :bxn,
27
+ :by,
28
+ :byn,
25
29
  :x,
26
30
  :xn,
27
31
  :y,
@@ -37,6 +41,11 @@ module Vedeu
37
41
  # border if enabled.
38
42
  attr_accessor :bottom_right
39
43
 
44
+ # @!attribute [rw] caption
45
+ # @return [String] An optional caption for when the bottom
46
+ # border is to be shown.
47
+ attr_accessor :caption
48
+
40
49
  # @!attribute [rw] horizontal
41
50
  # @return [String] The character to be used for the horizontal
42
51
  # side border.
@@ -66,15 +75,10 @@ module Vedeu
66
75
  attr_accessor :show_top
67
76
  alias_method :top?, :show_top
68
77
 
69
- # # @!attribute [rw] caption
70
- # # @return [String] An optional caption for when the bottom
71
- # border is to be shown.
72
- # attr_accessor :caption
73
-
74
78
  # @!attribute [rw] title
75
- # @return [String] An optional title for when the top
76
- # border is to be shown.
77
- # attr_accessor :title
79
+ # @return [String] An optional title for when the top border is
80
+ # to be shown.
81
+ attr_accessor :title
78
82
 
79
83
  # @!attribute [rw] top_left
80
84
  # @return [String] The character to be used for the top left
@@ -92,8 +96,8 @@ module Vedeu
92
96
  attr_accessor :vertical
93
97
 
94
98
  # @!attribute [r] name
95
- # @return [String] Associates the border with the same-named
96
- # interface/view.
99
+ # @return [String|Symbol] Associates the border with the
100
+ # same-named interface/view.
97
101
  attr_reader :name
98
102
 
99
103
  # @!attribute [r] parent
@@ -175,60 +179,6 @@ module Vedeu
175
179
  }
176
180
  end
177
181
 
178
- # Return the column position for 1 character right of the left
179
- # border.
180
- #
181
- # @return [Fixnum]
182
- def bx
183
- (enabled? && left?) ? x + 1 : x
184
- end
185
-
186
- # Return the column position for 1 character left of the right
187
- # border.
188
- #
189
- # @return [Fixnum]
190
- def bxn
191
- (enabled? && right?) ? xn - 1 : xn
192
- end
193
-
194
- # Return the row position for 1 character under of the top
195
- # border.
196
- #
197
- # @return [Fixnum]
198
- def by
199
- (enabled? && top?) ? y + 1 : y
200
- end
201
-
202
- # Return the column position for 1 character above of the bottom
203
- # border.
204
- #
205
- # @return [Fixnum]
206
- def byn
207
- (enabled? && bottom?) ? yn - 1 : yn
208
- end
209
-
210
- # @return [Vedeu::Borders::Caption]
211
- def caption
212
- Vedeu::Borders::Caption.coerce(@caption, width)
213
- end
214
-
215
- # @param value [String]
216
- # @return [Vedeu::Borders::Caption]
217
- def caption=(value)
218
- @caption = Vedeu::Borders::Caption.coerce(value, width)
219
- end
220
-
221
- # @return [Vedeu::Borders::Title]
222
- def title
223
- Vedeu::Borders::Title.coerce(@title, width)
224
- end
225
-
226
- # @param value [String]
227
- # @return [Vedeu::Borders::Title]
228
- def title=(value)
229
- @title = Vedeu::Borders::Title.coerce(value, width)
230
- end
231
-
232
182
  # Returns a DSL instance responsible for defining the DSL
233
183
  # methods of this model.
234
184
  #
@@ -241,22 +191,6 @@ module Vedeu
241
191
  Vedeu::Borders::DSL.new(self, client)
242
192
  end
243
193
 
244
- # Returns the width of the interface determined by whether a
245
- # left, right, both or neither borders are shown.
246
- #
247
- # @return [Fixnum]
248
- def width
249
- (bx..bxn).size
250
- end
251
-
252
- # Returns the height of the interface determined by whether a
253
- # top, bottom, both or neither borders are shown.
254
- #
255
- # @return [Fixnum]
256
- def height
257
- (by..byn).size
258
- end
259
-
260
194
  private
261
195
 
262
196
  # Returns the geometry for the interface.
@@ -0,0 +1,17 @@
1
+ module Vedeu
2
+
3
+ module Borders
4
+
5
+ # When a {Vedeu::Borders::Border} has a caption, truncate it if
6
+ # the caption is longer than the interface is wide, and pad with a
7
+ # space either side.
8
+ #
9
+ # @api private
10
+ #
11
+ class Caption < Title
12
+
13
+ end # Caption
14
+
15
+ end # Borders
16
+
17
+ end # Vedeu
@@ -233,7 +233,7 @@ module Vedeu
233
233
  # +- My Cool Title --------------------------------+
234
234
  #
235
235
  # @param value [String] The title.
236
- # @return [Vedeu::Borders::Title]
236
+ # @return [String]
237
237
  def title(value)
238
238
  model.title = value
239
239
  model.title
@@ -253,7 +253,7 @@ module Vedeu
253
253
  # +------------------------------ My Cool Caption -+
254
254
  #
255
255
  # @param value [String] The caption.
256
- # @return [Vedeu::Borders::Caption]
256
+ # @return [String]
257
257
  def caption(value)
258
258
  model.caption = value
259
259
  model.caption
@@ -9,6 +9,20 @@ module Vedeu
9
9
  #
10
10
  class Null
11
11
 
12
+ extend Forwardable
13
+
14
+ def_delegators :geometry,
15
+ :bordered_width,
16
+ :bordered_height,
17
+ :bx,
18
+ :bxn,
19
+ :by,
20
+ :byn,
21
+ :x,
22
+ :xn,
23
+ :y,
24
+ :yn
25
+
12
26
  # @!attribute [r] name
13
27
  # @return [String|Symbol|NilClass]
14
28
  attr_reader :name
@@ -23,50 +37,16 @@ module Vedeu
23
37
  @name = @attributes[:name]
24
38
  end
25
39
 
26
- # @return [Fixnum]
27
- def bx
28
- geometry.x
29
- end
30
- alias_method :x, :bx
31
-
32
- # @return [Fixnum]
33
- def bxn
34
- geometry.xn
35
- end
36
- alias_method :xn, :bxn
37
-
38
- # @return [Fixnum]
39
- def by
40
- geometry.y
41
- end
42
- alias_method :y, :by
43
-
44
- # @return [Fixnum]
45
- def byn
46
- geometry.yn
47
- end
48
- alias_method :yn, :byn
49
-
50
40
  # @return [Boolean]
51
41
  def enabled?
52
42
  false
53
43
  end
54
44
 
55
- # @return [Fixnum]
56
- def height
57
- (by..byn).size
58
- end
59
-
60
45
  # @return [Array]
61
46
  def render
62
47
  []
63
48
  end
64
49
 
65
- # @return [Fixnum]
66
- def width
67
- (bx..bxn).size
68
- end
69
-
70
50
  private
71
51
 
72
52
  # Returns the geometry for the interface.
@@ -15,14 +15,9 @@ module Vedeu
15
15
  :bottom?,
16
16
  :bottom_left,
17
17
  :bottom_right,
18
- :bx,
19
- :bxn,
20
- :by,
21
- :byn,
22
18
  :caption,
23
19
  :colour,
24
20
  :enabled?,
25
- :height,
26
21
  :horizontal,
27
22
  :left?,
28
23
  :right?,
@@ -31,10 +26,17 @@ module Vedeu
31
26
  :top?,
32
27
  :top_left,
33
28
  :top_right,
34
- :width,
35
29
  :vertical
36
30
 
37
31
  def_delegators :geometry,
32
+ :bordered_height,
33
+ :bordered_width,
34
+ :bx,
35
+ :bxn,
36
+ :by,
37
+ :byn,
38
+ :height,
39
+ :width,
38
40
  :x,
39
41
  :xn,
40
42
  :y,
@@ -89,12 +91,24 @@ module Vedeu
89
91
  Vedeu.timer("Drawing border: '#{name}'".freeze) do
90
92
  out = [top, bottom]
91
93
 
92
- height.times { |y| out << [left(y), right(y)] }
94
+ bordered_height.times { |y| out << [left(y), right(y)] }
93
95
 
94
96
  out.flatten
95
97
  end
96
98
  end
97
99
 
100
+ # @return [Vedeu::Borders::Caption] An optional caption for when
101
+ # the bottom border is to be shown.
102
+ def render_caption
103
+ @_caption ||= Vedeu::Borders::Caption.coerce(caption, width)
104
+ end
105
+
106
+ # @return [Vedeu::Borders::Title] An optional title for when the
107
+ # top border is to be shown.
108
+ def render_title
109
+ @_title ||= Vedeu::Borders::Title.coerce(title, width)
110
+ end
111
+
98
112
  # @param value [String]
99
113
  # @param type [Symbol|NilClass]
100
114
  # @param iy [Fixnum]
@@ -178,7 +192,7 @@ module Vedeu
178
192
  # @param y_coordinate [Fixnum] The value of either y or yn.
179
193
  # @return [Array<Vedeu::Views::Char>]
180
194
  def build_horizontal(position, y_coordinate)
181
- Array.new(width) do |ix|
195
+ Array.new(bordered_width) do |ix|
182
196
  build(horizontal, position, y_coordinate, (bx + ix))
183
197
  end
184
198
  end
@@ -233,16 +247,16 @@ module Vedeu
233
247
  #
234
248
  # @return [Array<Vedeu::Views::Char>]
235
249
  def captionbar
236
- return build_bottom if caption.empty?
250
+ return build_bottom if render_caption.empty?
237
251
 
238
- caption_starts_at = (width - caption.size) - 2
252
+ caption_starts_at = (width - render_caption.size) - 2
239
253
 
240
254
  caption_index = 0
241
255
  build_bottom.each_with_index do |char, index|
242
256
  next if index <= caption_starts_at || index > (width - 2)
243
257
 
244
258
  char.border = nil
245
- char.value = caption.characters[caption_index]
259
+ char.value = render_caption.characters[caption_index]
246
260
  caption_index += 1
247
261
  end
248
262
  end
@@ -252,13 +266,13 @@ module Vedeu
252
266
  #
253
267
  # @return [Array<Vedeu::Views::Char>]
254
268
  def titlebar
255
- return build_top if title.empty?
269
+ return build_top if render_title.empty?
256
270
 
257
271
  build_top.each_with_index do |char, index|
258
- next if index == 0 || index > title.size
272
+ next if index == 0 || index > render_title.size
259
273
 
260
274
  char.border = nil
261
- char.value = title.characters[index - 1]
275
+ char.value = render_title.characters[index - 1]
262
276
  end
263
277
  end
264
278
 
@@ -127,16 +127,6 @@ module Vedeu
127
127
 
128
128
  end # Title
129
129
 
130
- # When a {Vedeu::Borders::Border} has a caption, truncate it if
131
- # the caption is longer than the interface is wide, and pad with a
132
- # space either side.
133
- #
134
- # @api private
135
- #
136
- class Caption < Title
137
-
138
- end # Caption
139
-
140
130
  end # Borders
141
131
 
142
132
  end # Vedeu
@@ -31,7 +31,7 @@ module Vedeu
31
31
  attr_accessor :previous
32
32
 
33
33
  # @!attribute [r] name
34
- # @return [String]
34
+ # @return [String|Symbol]
35
35
  attr_reader :name
36
36
 
37
37
  # Return a new instance of Buffer. Generally a Buffer is
@@ -21,16 +21,17 @@ module Vedeu
21
21
 
22
22
  private
23
23
 
24
- # @return [Vedeu::Borders::Border]
25
- def border
26
- Vedeu.borders.by_name(name)
24
+ # @return [Vedeu::Geometry::Geometry]
25
+ def geometry
26
+ Vedeu.geometries.by_name(name)
27
27
  end
28
28
 
29
29
  # @return [Vedeu::Buffers::Empty]
30
30
  def buffer
31
- @_buffer ||= Vedeu::Buffers::Empty.new(height: border.height,
32
- name: name,
33
- width: border.width).buffer
31
+ @_buffer ||= Vedeu::Buffers::Empty
32
+ .new(height: geometry.bordered_height,
33
+ name: name,
34
+ width: geometry.bordered_width).buffer
34
35
  end
35
36
 
36
37
  # @return [Vedeu::Buffers::Empty]