vedeu 0.8.5 → 0.8.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/docs/dsl/by_method/geometry.md +25 -1
  3. data/docs/dsl/by_method/geometry/align.md +13 -1
  4. data/docs/events/by_name/refresh_border.md +6 -2
  5. data/docs/events/by_name/refresh_view.md +3 -0
  6. data/docs/events/by_name/refresh_view_content.md +3 -0
  7. data/integrations/expected/dsl_app_021.out +1 -1
  8. data/integrations/expected/dsl_app_022.out +1 -1
  9. data/integrations/test_runner.sh +2 -0
  10. data/lib/vedeu/application/application_view.rb +1 -2
  11. data/lib/vedeu/borders/dsl.rb +1 -2
  12. data/lib/vedeu/borders/refresh.rb +2 -4
  13. data/lib/vedeu/buffers/empty.rb +10 -8
  14. data/lib/vedeu/buffers/refresh.rb +4 -8
  15. data/lib/vedeu/buffers/view.rb +6 -6
  16. data/lib/vedeu/coercers/alignment.rb +1 -2
  17. data/lib/vedeu/coercers/colour_attributes.rb +1 -0
  18. data/lib/vedeu/coercers/horizontal_alignment.rb +1 -1
  19. data/lib/vedeu/coercers/vertical_alignment.rb +1 -1
  20. data/lib/vedeu/colours/translator.rb +1 -3
  21. data/lib/vedeu/common.rb +12 -4
  22. data/lib/vedeu/configuration/api.rb +3 -5
  23. data/lib/vedeu/configuration/configuration.rb +0 -2
  24. data/lib/vedeu/cursors/coordinate.rb +1 -2
  25. data/lib/vedeu/dsl/border.rb +2 -4
  26. data/lib/vedeu/dsl/geometry.rb +4 -31
  27. data/lib/vedeu/dsl/helpers/wordwrap.rb +1 -1
  28. data/lib/vedeu/dsl/view.rb +4 -3
  29. data/lib/vedeu/error.rb +17 -0
  30. data/lib/vedeu/geometries/dsl/dsl.rb +2 -19
  31. data/lib/vedeu/groups/refresh.rb +1 -2
  32. data/lib/vedeu/input/dsl.rb +2 -6
  33. data/lib/vedeu/input/mapper.rb +1 -2
  34. data/lib/vedeu/input/read.rb +1 -0
  35. data/lib/vedeu/interfaces/dsl.rb +1 -0
  36. data/lib/vedeu/menus/dsl.rb +1 -2
  37. data/lib/vedeu/models/page.rb +1 -0
  38. data/lib/vedeu/output/output.rb +35 -44
  39. data/lib/vedeu/renderers/html.rb +1 -10
  40. data/lib/vedeu/renderers/options.rb +16 -21
  41. data/lib/vedeu/renderers/terminal.rb +4 -0
  42. data/lib/vedeu/repositories/defaults.rb +1 -2
  43. data/lib/vedeu/repositories/repository.rb +2 -3
  44. data/lib/vedeu/runtime/router.rb +3 -6
  45. data/lib/vedeu/support/point.rb +11 -0
  46. data/lib/vedeu/templating/template.rb +1 -2
  47. data/lib/vedeu/version.rb +1 -1
  48. data/lib/vedeu/views/chars.rb +1 -2
  49. data/lib/vedeu/views/lines.rb +1 -2
  50. data/lib/vedeu/views/streams.rb +1 -2
  51. data/lib/vedeu/views/view.rb +1 -2
  52. data/test/lib/vedeu/buffers/empty_test.rb +2 -2
  53. data/test/lib/vedeu/common_test.rb +22 -0
  54. data/test/lib/vedeu/output/output_test.rb +2 -2
  55. metadata +2 -2
@@ -151,8 +151,7 @@ module Vedeu
151
151
  # @note If a block is given, store the model, return the model
152
152
  # after yielding.
153
153
  # @param model [void] A model instance.
154
- # @raise [Vedeu::Error::MissingRequired] When the name attribute
155
- # is not defined.
154
+ # @macro raise_missing_required
156
155
  # @return [void] The model instance which was stored.
157
156
  def store(model, &block)
158
157
  valid_model?(model)
@@ -179,8 +178,8 @@ module Vedeu
179
178
  message: "#{model.class.name}: '#{model.name}'")
180
179
  end
181
180
 
182
- #
183
181
  # @param model [void] A model instance.
182
+ # @macro raise_missing_required
184
183
  # @return [Boolean]
185
184
  def valid_model?(model)
186
185
  fail Vedeu::Error::MissingRequired,
@@ -18,8 +18,7 @@ module Vedeu
18
18
  #
19
19
  # @param controller [Symbol]
20
20
  # @param klass [String]
21
- # @raise [Vedeu::Error::MissingRequired] When the controller
22
- # name is not given.
21
+ # @macro raise_missing_required
23
22
  # @return [void]
24
23
  def add_controller(controller, klass)
25
24
  unless present?(controller)
@@ -46,8 +45,7 @@ module Vedeu
46
45
  #
47
46
  # @param controller [Symbol]
48
47
  # @param action [Symbol]
49
- # @raise [Vedeu::Error::MissingRequired] When the controller
50
- # name or action name is not given.
48
+ # @macro raise_missing_required
51
49
  # @return [void]
52
50
  def add_action(controller, action)
53
51
  if present?(controller) && present?(action)
@@ -143,8 +141,7 @@ module Vedeu
143
141
  # Fetch the class for the controller by name.
144
142
  #
145
143
  # @param controller [Symbol]
146
- # @raise [Vedeu::Error::MissingRequired] When the given
147
- # controller name does not have a class defined.
144
+ # @macro raise_missing_required
148
145
  # @return [String]
149
146
  def klass_for(controller)
150
147
  if registered?(controller) && klass_defined?(controller)
@@ -1,8 +1,16 @@
1
1
  module Vedeu
2
2
 
3
+ # A `Vedeu::Point` represents part of a coordinate within the 2D
4
+ # space of a terminal. This class is specifically used to coerce
5
+ # a coordinate to be within boundaries. The `min` and `max`
6
+ # arguments are used to define this boundary.
7
+ #
8
+ # @api private
9
+ #
3
10
  class Point
4
11
 
5
12
  # @param (see #initialize)
13
+ # @macro raise_invalid_syntax
6
14
  # @return (see #initialize)
7
15
  def self.coerce(value: nil, min: 1, max: nil)
8
16
  new(value: value, min: min, max: max).coerce
@@ -24,6 +32,7 @@ module Vedeu
24
32
  @value = value
25
33
  end
26
34
 
35
+ # @macro raise_invalid_syntax
27
36
  # @return [Vedeu::Point]
28
37
  def coerce
29
38
  fail Vedeu::Error::InvalidSyntax,
@@ -53,6 +62,7 @@ module Vedeu
53
62
 
54
63
  private
55
64
 
65
+ # @macro raise_invalid_syntax
56
66
  # @return [Fixnum]
57
67
  def min
58
68
  return @min if @min.is_a?(Fixnum)
@@ -60,6 +70,7 @@ module Vedeu
60
70
  fail Vedeu::Error::InvalidSyntax, "Expecting 'min' to be a Fixnum."
61
71
  end
62
72
 
73
+ # @macro raise_invalid_syntax
63
74
  # @return [Fixnum]
64
75
  def max
65
76
  return @max if @max.is_a?(Fixnum)
@@ -49,8 +49,7 @@ module Vedeu
49
49
  File.read(path)
50
50
  end
51
51
 
52
- # @raise [Vedeu::Error::MissingRequired] When the path is empty
53
- # or does not exist.
52
+ # @macro raise_missing_required
54
53
  # @return [String]
55
54
  def path
56
55
  fail Vedeu::Error::MissingRequired,
@@ -3,6 +3,6 @@
3
3
  module Vedeu
4
4
 
5
5
  # The current version of Vedeu.
6
- VERSION = '0.8.5'
6
+ VERSION = '0.8.6'
7
7
 
8
8
  end
@@ -13,8 +13,7 @@ module Vedeu
13
13
  # @param collection [void]
14
14
  # @param parent [Vedeu::Views::Stream]
15
15
  # @param name [NilClass|Symbol|String]
16
- # @raise [Vedeu::Error::InvalidSyntax] When the collection
17
- # cannot be coerced since it is unrecognised or unsupported.
16
+ # @macro raise_invalid_syntax
18
17
  # @return [Vedeu::Views::Chars]
19
18
  def self.coerce(collection = [], parent = nil, name = nil)
20
19
  if collection.is_a?(Vedeu::Views::Chars)
@@ -11,8 +11,7 @@ module Vedeu
11
11
  class Lines < Vedeu::Repositories::Collection
12
12
 
13
13
  # @param (see Vedeu::Repositories::Collection#initialize)
14
- # @raise [Vedeu::Error::InvalidSyntax] When the collection
15
- # cannot be coerced since it is unrecognised or unsupported.
14
+ # @macro raise_invalid_syntax
16
15
  # @return [Vedeu::Views::Lines]
17
16
  def self.coerce(collection = [], parent = nil, name = nil)
18
17
  if collection.is_a?(Vedeu::Views::Lines)
@@ -11,8 +11,7 @@ module Vedeu
11
11
  class Streams < Vedeu::Repositories::Collection
12
12
 
13
13
  # @param (see Vedeu::Repositories::Collection#initialize)
14
- # @raise [Vedeu::Error::InvalidSyntax] When the collection
15
- # cannot be coerced since it is unrecognised or unsupported.
14
+ # @macro raise_invalid_syntax
16
15
  # @return [Vedeu::Views::Streams]
17
16
  def self.coerce(collection = [], parent = nil, name = nil)
18
17
  if collection.is_a?(Vedeu::Views::Streams)
@@ -113,8 +113,7 @@ module Vedeu
113
113
  #
114
114
  # @param refresh [Boolean] Should the buffer of the view be
115
115
  # refreshed once stored? Default: false.
116
- # @raise [Vedeu::Error::MissingRequired] When the name of the
117
- # view is not defined.
116
+ # @macro raise_missing_required
118
117
  # @return [Vedeu::Views::View]
119
118
  def update_buffer(refresh = false)
120
119
  if present?(name)
@@ -90,8 +90,8 @@ module Vedeu
90
90
  it { subject.first.must_be_instance_of(Array) }
91
91
  it { subject.first.first.must_be_instance_of(Vedeu::Cells::Empty) }
92
92
 
93
- it { subject.size.must_equal(height) }
94
- it { subject.first.size.must_equal(width) }
93
+ it { subject.size.must_equal(height + 1) }
94
+ it { subject.first.size.must_equal(width + 1) }
95
95
  it { subject.first.first.position.must_equal(position) }
96
96
  end
97
97
 
@@ -123,6 +123,28 @@ module Vedeu
123
123
  end
124
124
  end
125
125
 
126
+ describe '#escape?' do
127
+ subject { instance.escape?(_value) }
128
+
129
+ context 'when the value is a Vedeu::Cells::Escape' do
130
+ let(:_value) { Vedeu::Cells::Escape.new(value: "\e[0m") }
131
+
132
+ it { subject.must_equal(true) }
133
+ end
134
+
135
+ context 'when the value is a Vedeu::Cells::Cursor' do
136
+ let(:_value) { Vedeu::Cells::Cursor.new(value: "\e[?25h") }
137
+
138
+ it { subject.must_equal(true) }
139
+ end
140
+
141
+ context 'when the value is anything else' do
142
+ let(:_value) { 'anything' }
143
+
144
+ it { subject.must_equal(false) }
145
+ end
146
+ end
147
+
126
148
  describe '#falsy?' do
127
149
  subject { instance.falsy?(_value) }
128
150
 
@@ -26,7 +26,7 @@ module Vedeu
26
26
  end
27
27
 
28
28
  context 'when the output is not empty' do
29
- let(:output) { Vedeu::Models::Page.new }
29
+ let(:output) { Vedeu::Cells::Char.new(value: 'a') }
30
30
 
31
31
  it do
32
32
  Vedeu::Buffers::Terminal.expects(:write).with(output)
@@ -74,7 +74,7 @@ module Vedeu
74
74
  end
75
75
 
76
76
  context 'and the output is not an escape sequence' do
77
- let(:output) { Vedeu::Models::Page.new }
77
+ let(:output) { Vedeu::Cells::Char.new(value: 'a') }
78
78
 
79
79
  it do
80
80
  Vedeu::Buffers::Terminal.expects(:write).with(output)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vedeu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.5
4
+ version: 0.8.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gavin Laking
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-11 00:00:00.000000000 Z
11
+ date: 2016-01-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: guard