vedeu 0.4.56 → 0.4.57

Sign up to get free protection for your applications and to get access to all the features.
Files changed (129) hide show
  1. checksums.yaml +4 -4
  2. data/examples/borders_app.rb +22 -24
  3. data/examples/colours_app.rb +4 -6
  4. data/examples/configuration_app.rb +5 -7
  5. data/examples/drb_app.rb +1 -1
  6. data/examples/focus_app.rb +1 -1
  7. data/examples/geometry_app.rb +8 -10
  8. data/examples/hello_world.rb +4 -6
  9. data/examples/material_colours_app.rb +19 -9
  10. data/examples/material_colours_app_20150721.svg +2285 -0
  11. data/examples/panel_app.rb +6 -8
  12. data/examples/typed_commands/typed_commands_app.rb +15 -17
  13. data/examples/view_templates_app/view_templates_app.rb +1 -1
  14. data/lib/vedeu/all.rb +82 -10
  15. data/lib/vedeu/api.rb +34 -14
  16. data/lib/vedeu/application.rb +0 -1
  17. data/lib/vedeu/application/application_controller.rb +0 -1
  18. data/lib/vedeu/application/application_helper.rb +0 -1
  19. data/lib/vedeu/application/application_view.rb +0 -1
  20. data/lib/vedeu/application/controller.rb +0 -1
  21. data/lib/vedeu/application/helper.rb +0 -1
  22. data/lib/vedeu/application/view.rb +0 -1
  23. data/lib/vedeu/bindings/all.rb +0 -1
  24. data/lib/vedeu/bindings/visibility.rb +2 -19
  25. data/lib/vedeu/buffers/buffer.rb +0 -1
  26. data/lib/vedeu/buffers/display_buffer.rb +0 -1
  27. data/lib/vedeu/cli/generator/application.rb +0 -1
  28. data/lib/vedeu/cli/generator/helpers.rb +0 -1
  29. data/lib/vedeu/cli/generator/view.rb +0 -1
  30. data/lib/vedeu/colours/background.rb +0 -1
  31. data/lib/vedeu/colours/colour.rb +0 -1
  32. data/lib/vedeu/colours/colour_translator.rb +0 -1
  33. data/lib/vedeu/colours/foreground.rb +0 -1
  34. data/lib/vedeu/common.rb +0 -1
  35. data/lib/vedeu/configuration/configuration.rb +0 -1
  36. data/lib/vedeu/cursor/cursor.rb +0 -1
  37. data/lib/vedeu/cursor/move.rb +0 -1
  38. data/lib/vedeu/cursor/refresh_cursor.rb +0 -1
  39. data/lib/vedeu/cursor/reposition.rb +0 -1
  40. data/lib/vedeu/distributed/client.rb +2 -0
  41. data/lib/vedeu/distributed/server.rb +2 -0
  42. data/lib/vedeu/distributed/uri.rb +2 -1
  43. data/lib/vedeu/exceptions.rb +0 -7
  44. data/lib/vedeu/geometry/area.rb +0 -1
  45. data/lib/vedeu/geometry/coordinate.rb +0 -1
  46. data/lib/vedeu/geometry/dimension.rb +14 -1
  47. data/lib/vedeu/geometry/geometry.rb +0 -1
  48. data/lib/vedeu/geometry/index_position.rb +0 -1
  49. data/lib/vedeu/geometry/position.rb +0 -1
  50. data/lib/vedeu/geometry/position_index.rb +0 -1
  51. data/lib/vedeu/geometry/position_validator.rb +0 -1
  52. data/lib/vedeu/input/input.rb +0 -1
  53. data/lib/vedeu/input/key.rb +0 -1
  54. data/lib/vedeu/input/keymap.rb +0 -1
  55. data/lib/vedeu/input/mapper.rb +0 -1
  56. data/lib/vedeu/log.rb +0 -1
  57. data/lib/vedeu/main_loop.rb +0 -1
  58. data/lib/vedeu/models/cell.rb +0 -1
  59. data/lib/vedeu/models/char.rb +0 -1
  60. data/lib/vedeu/models/composition.rb +0 -1
  61. data/lib/vedeu/models/escape.rb +0 -1
  62. data/lib/vedeu/models/focus.rb +0 -1
  63. data/lib/vedeu/models/group.rb +37 -15
  64. data/lib/vedeu/models/interface.rb +1 -2
  65. data/lib/vedeu/models/line.rb +0 -1
  66. data/lib/vedeu/models/menu.rb +0 -1
  67. data/lib/vedeu/models/stream.rb +0 -1
  68. data/lib/vedeu/models/toggleable.rb +21 -11
  69. data/lib/vedeu/null/all.rb +0 -1
  70. data/lib/vedeu/null/border.rb +0 -1
  71. data/lib/vedeu/null/buffer.rb +0 -1
  72. data/lib/vedeu/null/generic.rb +0 -1
  73. data/lib/vedeu/null/geometry.rb +0 -1
  74. data/lib/vedeu/null/interface.rb +0 -1
  75. data/lib/vedeu/output/border.rb +0 -1
  76. data/lib/vedeu/output/clear/named_group.rb +3 -2
  77. data/lib/vedeu/output/clear/named_interface.rb +2 -1
  78. data/lib/vedeu/output/compressor.rb +0 -1
  79. data/lib/vedeu/output/html_char.rb +0 -1
  80. data/lib/vedeu/output/output.rb +0 -1
  81. data/lib/vedeu/output/presentation.rb +0 -1
  82. data/lib/vedeu/output/refresh_group.rb +0 -1
  83. data/lib/vedeu/output/render_border.rb +0 -1
  84. data/lib/vedeu/output/renderers/all.rb +0 -1
  85. data/lib/vedeu/output/renderers/escape_sequence.rb +0 -1
  86. data/lib/vedeu/output/renderers/file.rb +0 -1
  87. data/lib/vedeu/output/renderers/html.rb +0 -1
  88. data/lib/vedeu/output/renderers/json.rb +0 -1
  89. data/lib/vedeu/output/renderers/null.rb +0 -1
  90. data/lib/vedeu/output/renderers/renderer_options.rb +0 -1
  91. data/lib/vedeu/output/renderers/terminal.rb +0 -1
  92. data/lib/vedeu/output/renderers/text.rb +0 -1
  93. data/lib/vedeu/output/style.rb +0 -1
  94. data/lib/vedeu/output/text.rb +0 -1
  95. data/lib/vedeu/output/viewport.rb +0 -1
  96. data/lib/vedeu/output/virtual_terminal.rb +0 -1
  97. data/lib/vedeu/output/wordwrap.rb +0 -1
  98. data/lib/vedeu/repositories/collection.rb +0 -7
  99. data/lib/vedeu/repositories/model.rb +0 -1
  100. data/lib/vedeu/repositories/registerable.rb +0 -1
  101. data/lib/vedeu/repositories/repository.rb +0 -1
  102. data/lib/vedeu/repositories/store.rb +0 -1
  103. data/lib/vedeu/templating/directive.rb +1 -1
  104. data/lib/vedeu/templating/helpers.rb +1 -1
  105. data/lib/vedeu/templating/preprocessor.rb +1 -1
  106. data/lib/vedeu/templating/template.rb +1 -1
  107. data/lib/vedeu/traps.rb +0 -1
  108. data/lib/vedeu/version.rb +1 -1
  109. data/test/lib/vedeu/application/controller_test.rb +8 -1
  110. data/test/lib/vedeu/buffers/buffer_test.rb +5 -0
  111. data/test/lib/vedeu/cursor/reposition_test.rb +5 -5
  112. data/test/lib/vedeu/models/group_test.rb +4 -3
  113. data/test/lib/vedeu/models/interface_test.rb +15 -1
  114. data/test/lib/vedeu/null/interface_test.rb +7 -21
  115. data/test/lib/vedeu/output/esc_test.rb +105 -109
  116. metadata +3 -15
  117. data/lib/vedeu/application/all.rb +0 -6
  118. data/lib/vedeu/buffers/all.rb +0 -3
  119. data/lib/vedeu/cli/all.rb +0 -1
  120. data/lib/vedeu/colours/all.rb +0 -7
  121. data/lib/vedeu/configuration/all.rb +0 -3
  122. data/lib/vedeu/cursor/all.rb +0 -7
  123. data/lib/vedeu/distributed/all.rb +0 -15
  124. data/lib/vedeu/events/all.rb +0 -5
  125. data/lib/vedeu/geometry/all.rb +0 -14
  126. data/lib/vedeu/models/all.rb +0 -16
  127. data/lib/vedeu/output/all.rb +0 -21
  128. data/lib/vedeu/output/clear/all.rb +0 -13
  129. data/lib/vedeu/templating/all.rb +0 -13
@@ -4,7 +4,6 @@ module Vedeu
4
4
 
5
5
  # Renders a {Vedeu::VirtualBuffer} or {Vedeu::Output} as JSON.
6
6
  #
7
- # @api private
8
7
  class JSON < Vedeu::Renderers::File
9
8
 
10
9
  # Returns a new instance of Vedeu::Renderers::JSON.
@@ -4,7 +4,6 @@ module Vedeu
4
4
 
5
5
  # A renderer which returns nothing.
6
6
  #
7
- # @api private
8
7
  class Null
9
8
 
10
9
  include Vedeu::RendererOptions
@@ -2,7 +2,6 @@ module Vedeu
2
2
 
3
3
  # Provides shared functionality to Vedeu::Renderer classes.
4
4
  #
5
- # @api private
6
5
  module RendererOptions
7
6
 
8
7
  # :nocov:
@@ -5,7 +5,6 @@ module Vedeu
5
5
  # Converts a grid of {Vedeu::Char} objects into a stream of escape sequences
6
6
  # and content suitable for a terminal.
7
7
  #
8
- # @api private
9
8
  class Terminal
10
9
 
11
10
  include Vedeu::RendererOptions
@@ -5,7 +5,6 @@ module Vedeu
5
5
  # Converts a grid of {Vedeu::Char} objects into a stream of escape sequences
6
6
  # and content.
7
7
  #
8
- # @api private
9
8
  class Text
10
9
 
11
10
  include Vedeu::RendererOptions
@@ -9,7 +9,6 @@ module Vedeu
9
9
  # Styles are applied as encountered.
10
10
  #
11
11
  # @see Vedeu::Esc
12
- # @api private
13
12
  class Style
14
13
 
15
14
  include Vedeu::Common
@@ -2,7 +2,6 @@ module Vedeu
2
2
 
3
3
  # Present a string (or object responding to `to_s`).
4
4
  #
5
- # @api private
6
5
  class Text
7
6
 
8
7
  # @see Vedeu::DSL::Text#text
@@ -6,7 +6,6 @@ module Vedeu
6
6
  # the defined width of the interface, the Viewport class provides 'scrolling'
7
7
  # via the cursor's position.
8
8
  #
9
- # @api private
10
9
  class Viewport
11
10
 
12
11
  extend Forwardable
@@ -2,7 +2,6 @@ module Vedeu
2
2
 
3
3
  # Represents a {Vedeu::Terminal} view as a grid of {Vedeu::Cell} objects.
4
4
  #
5
- # @api private
6
5
  class VirtualTerminal
7
6
 
8
7
  # @!attribute [rw] renderer
@@ -2,7 +2,6 @@ module Vedeu
2
2
 
3
3
  # Wrap or prune text.
4
4
  #
5
- # @api private
6
5
  class Wordwrap
7
6
 
8
7
  # @see {Vedeu::Wordwrap#initialize}
@@ -3,7 +3,6 @@ module Vedeu
3
3
  # Convert an Array into an object which has some meaning in the context it
4
4
  # is being used.
5
5
  #
6
- # @api private
7
6
  class Collection
8
7
 
9
8
  include Enumerable
@@ -98,42 +97,36 @@ module Vedeu
98
97
 
99
98
  # A collection of {Vedeu::Char} instances.
100
99
  #
101
- # @api private
102
100
  class Chars < Vedeu::Collection
103
101
 
104
102
  end # Chars
105
103
 
106
104
  # A collection of {Vedeu::Event} instances.
107
105
  #
108
- # @api private
109
106
  class EventCollection < Vedeu::Collection
110
107
 
111
108
  end # EventCollection
112
109
 
113
110
  # A collection of {Vedeu::Interface} instances.
114
111
  #
115
- # @api private
116
112
  class InterfaceCollection < Vedeu::Collection
117
113
 
118
114
  end # InterfaceCollection
119
115
 
120
116
  # A collection of {Vedeu::Key} instances.
121
117
  #
122
- # @api private
123
118
  class Keys < Vedeu::Collection
124
119
 
125
120
  end # Keys
126
121
 
127
122
  # A collection of {Vedeu::Line} instances.
128
123
  #
129
- # @api private
130
124
  class Lines < Vedeu::Collection
131
125
 
132
126
  end # Lines
133
127
 
134
128
  # A collection of {Vedeu::Stream} instances.
135
129
  #
136
- # @api private
137
130
  class Streams < Vedeu::Collection
138
131
 
139
132
  end # Streams
@@ -5,7 +5,6 @@ module Vedeu
5
5
  # When included into a class, provides the mechanism to store the class in a
6
6
  # repository for later retrieval.
7
7
  #
8
- # @api private
9
8
  module Model
10
9
 
11
10
  include Vedeu::Common
@@ -3,7 +3,6 @@ module Vedeu
3
3
  # Repositories contain registerables, this module provides convenience methods
4
4
  # for them.
5
5
  #
6
- # @api private
7
6
  module Registerable
8
7
 
9
8
  # These class methods are mixed into the repository.
@@ -9,7 +9,6 @@ module Vedeu
9
9
  #
10
10
  # { 'models' => [Model] }
11
11
  #
12
- # @api private
13
12
  class Repository
14
13
 
15
14
  include Vedeu::Common
@@ -2,7 +2,6 @@ module Vedeu
2
2
 
3
3
  # Provides generic repository related behaviour.
4
4
  #
5
- # @api private
6
5
  module Store
7
6
 
8
7
  include Enumerable
@@ -1,10 +1,10 @@
1
1
  module Vedeu
2
2
 
3
+ # Provides means to use templates with Vedeu.
3
4
  module Templating
4
5
 
5
6
  # Converts a directive found in a template into a Vedeu::Stream object.
6
7
  #
7
- # @api private
8
8
  class Directive
9
9
 
10
10
  include Vedeu::Templating::Helpers
@@ -1,10 +1,10 @@
1
1
  module Vedeu
2
2
 
3
+ # Provides means to use templates with Vedeu.
3
4
  module Templating
4
5
 
5
6
  # Provide helpers to be used with your Vedeu templates.
6
7
  #
7
- # @api private
8
8
  module Helpers
9
9
 
10
10
  # @example
@@ -1,5 +1,6 @@
1
1
  module Vedeu
2
2
 
3
+ # Provides means to use templates with Vedeu.
3
4
  module Templating
4
5
 
5
6
  # preprocess
@@ -15,7 +16,6 @@ module Vedeu
15
16
  # Pre-processes a template, to convert all lines and lines with directives
16
17
  # into Vedeu::Streams.
17
18
  #
18
- # @api private
19
19
  class Preprocessor
20
20
 
21
21
  # @param lines [Array<String>]
@@ -2,11 +2,11 @@ require 'vedeu/templating/preprocessor'
2
2
 
3
3
  module Vedeu
4
4
 
5
+ # Provides means to use templates with Vedeu.
5
6
  module Templating
6
7
 
7
8
  # Generic class to loading a template and parsing it via ERb.
8
9
  #
9
- # @api private
10
10
  class Template
11
11
 
12
12
  # @param (see Vedeu::Templating::Template#new)
data/lib/vedeu/traps.rb CHANGED
@@ -2,7 +2,6 @@ module Vedeu
2
2
 
3
3
  # Vedeu can respond to various signals which are handled here.
4
4
  #
5
- # @api private
6
5
  module Traps
7
6
 
8
7
  # :nocov:
data/lib/vedeu/version.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  module Vedeu
2
2
 
3
3
  # The current version of Vedeu.
4
- VERSION = '0.4.56'
4
+ VERSION = '0.4.57'
5
5
 
6
6
  end
@@ -14,7 +14,14 @@ module Vedeu
14
14
  let(:instance) { described.new }
15
15
 
16
16
  context 'ClassMethods' do
17
- # @todo
17
+ let(:_name) { :vedeu_controller_test }
18
+
19
+ subject { ControllerTestClass.controller_name(_name) }
20
+
21
+ it {
22
+ Vedeu.expects(:bind).with(:show_vedeu_controller_test)
23
+ subject
24
+ }
18
25
  end
19
26
 
20
27
  end # Controller
@@ -161,6 +161,11 @@ module Vedeu
161
161
 
162
162
  subject { instance.render }
163
163
 
164
+ it {
165
+ Vedeu::Output.expects(:render)
166
+ subject
167
+ }
168
+
164
169
  # @todo
165
170
  # it { skip }
166
171
  # it { subject.must_be_instance_of(Array) }
@@ -27,17 +27,13 @@ module Vedeu
27
27
  end
28
28
 
29
29
  describe '.to' do
30
- it { described.must_respond_to(:to) }
31
- end
32
-
33
- describe '#to' do
34
30
  # let(:new_entity) { Vedeu::Cursor.new(name: _name, y: 8, x: 5, oy: 7, ox: 4) }
35
31
 
36
32
  # before do
37
33
  # entity.stubs(:new).returns(new_entity)
38
34
  # end
39
35
 
40
- subject { instance.to }
36
+ subject { described.to(entity, _name, y, x) }
41
37
 
42
38
  it { subject.must_be_instance_of(entity) }
43
39
 
@@ -62,6 +58,10 @@ module Vedeu
62
58
  it { subject.oy.must_equal(7) }
63
59
  end
64
60
 
61
+ describe '#to' do
62
+ it { instance.must_respond_to(:to) }
63
+ end
64
+
65
65
  end # Reposition
66
66
 
67
67
  end # Vedeu
@@ -10,12 +10,13 @@ module Vedeu
10
10
  {
11
11
  name: _name,
12
12
  members: members,
13
- repository: Vedeu.groups,
13
+ repository: repository,
14
14
  visible: visible,
15
15
  }
16
16
  }
17
17
  let(:_name) { 'organics' }
18
- let(:members) { ['carbon', 'nitrogen', 'oxygen'] }
18
+ let(:members) { Set.new(['carbon', 'nitrogen', 'oxygen']) }
19
+ let(:repository) { Vedeu.groups }
19
20
  let(:visible) { true }
20
21
 
21
22
  describe '#initialize' do
@@ -26,7 +27,7 @@ module Vedeu
26
27
  it { instance.instance_variable_get('@members').must_equal(members) }
27
28
  it { instance.instance_variable_get('@name').must_equal(_name) }
28
29
  it {
29
- instance.instance_variable_get('@repository').must_equal(Vedeu.groups)
30
+ instance.instance_variable_get('@repository').must_equal(repository)
30
31
  }
31
32
  it { instance.instance_variable_get('@visible').must_equal(visible) }
32
33
  end
@@ -73,6 +73,13 @@ module Vedeu
73
73
  it { instance.must_respond_to(:add) }
74
74
  end
75
75
 
76
+ describe '#hide' do
77
+ subject { instance.hide }
78
+
79
+ # @todo
80
+ # it { skip }
81
+ end
82
+
76
83
  describe '#inspect' do
77
84
  subject { instance.inspect }
78
85
 
@@ -143,7 +150,7 @@ module Vedeu
143
150
  subject
144
151
  }
145
152
 
146
- it { subject.must_equal([:clear, :border, :view]) }
153
+ it { subject.must_equal([:clear, :view, :border]) }
147
154
  end
148
155
 
149
156
  context 'when the interface is not visible' do
@@ -153,6 +160,13 @@ module Vedeu
153
160
  end
154
161
  end
155
162
 
163
+ describe '#show' do
164
+ subject { instance.show }
165
+
166
+ # @todo
167
+ # it { skip }
168
+ end
169
+
156
170
  describe '#store' do
157
171
  subject { instance.store }
158
172
 
@@ -29,45 +29,31 @@ module Vedeu
29
29
  end
30
30
 
31
31
  describe '#hide' do
32
- subject { instance.hide }
33
-
34
- it { subject.must_be_instance_of(NilClass) }
32
+ it { instance.hide.must_be_instance_of(NilClass) }
35
33
  end
36
34
 
37
35
  describe '#null?' do
38
- subject { instance.null? }
39
-
40
- it { subject.must_be_instance_of(TrueClass) }
36
+ it { instance.null?.must_be_instance_of(TrueClass) }
41
37
  end
42
38
 
43
39
  describe '#parent' do
44
- subject { instance.parent }
45
-
46
- it { subject.must_be_instance_of(NilClass) }
40
+ it { instance.parent.must_be_instance_of(NilClass) }
47
41
  end
48
42
 
49
43
  describe '#show' do
50
- subject { instance.show }
51
-
52
- it { subject.must_be_instance_of(NilClass) }
44
+ it { instance.show.must_be_instance_of(NilClass) }
53
45
  end
54
46
 
55
47
  describe '#store' do
56
- subject { instance.store }
57
-
58
- it { subject.must_be_instance_of(Vedeu::Null::Interface) }
48
+ it { instance.store.must_be_instance_of(Vedeu::Null::Interface) }
59
49
  end
60
50
 
61
51
  describe '#toggle' do
62
- subject { instance.toggle }
63
-
64
- it { subject.must_be_instance_of(NilClass) }
52
+ it { instance.toggle.must_be_instance_of(NilClass) }
65
53
  end
66
54
 
67
55
  describe '#visible?' do
68
- subject { instance.visible? }
69
-
70
- it { subject.must_be_instance_of(FalseClass) }
56
+ it { instance.visible?.must_be_instance_of(FalseClass) }
71
57
  end
72
58
 
73
59
  describe '#visible=' do
@@ -8,14 +8,24 @@ module Vedeu
8
8
 
9
9
  before { Vedeu::Terminal.stubs(:size).returns([80, 25]) }
10
10
 
11
- describe 'alias methods' do
12
- it { described.must_respond_to(:foreground_codes) }
13
- end
14
-
15
- describe 'colours defined via define_method' do
16
- it 'returns an escape sequence for the foreground colour' do
17
- described.magenta.must_equal("\e[35m")
18
- end
11
+ describe 'foreground colour methods' do
12
+ it { described.black.must_equal("\e[30m") }
13
+ it { described.red.must_equal("\e[31m") }
14
+ it { described.green.must_equal("\e[32m") }
15
+ it { described.yellow.must_equal("\e[33m") }
16
+ it { described.blue.must_equal("\e[34m") }
17
+ it { described.magenta.must_equal("\e[35m") }
18
+ it { described.cyan.must_equal("\e[36m") }
19
+ it { described.light_grey.must_equal("\e[37m") }
20
+ it { described.default.must_equal("\e[39m") }
21
+ it { described.dark_grey.must_equal("\e[90m") }
22
+ it { described.light_red.must_equal("\e[91m") }
23
+ it { described.light_green.must_equal("\e[92m") }
24
+ it { described.light_yellow.must_equal("\e[93m") }
25
+ it { described.light_blue.must_equal("\e[94m") }
26
+ it { described.light_magenta.must_equal("\e[95m") }
27
+ it { described.light_cyan.must_equal("\e[96m") }
28
+ it { described.white.must_equal("\e[97m") }
19
29
 
20
30
  it 'returns an escape sequence for the foreground colour and resets ' \
21
31
  'after calling the block' do
@@ -23,10 +33,35 @@ module Vedeu
23
33
  'ununpentium'
24
34
  end.must_equal("\e[36mununpentium\e[39m")
25
35
  end
36
+ end
26
37
 
27
- it 'returns an escape sequence for the background colour' do
28
- described.on_yellow.must_equal("\e[43m")
29
- end
38
+ describe '.codes' do
39
+ it { described.codes.must_be_instance_of(Hash) }
40
+ it { described.must_respond_to(:foreground_codes) }
41
+ end
42
+
43
+ describe '.background_codes' do
44
+ it { described.background_codes.must_be_instance_of(Hash) }
45
+ end
46
+
47
+ describe 'background colour methods' do
48
+ it { described.on_black.must_equal("\e[40m") }
49
+ it { described.on_red.must_equal("\e[41m") }
50
+ it { described.on_green.must_equal("\e[42m") }
51
+ it { described.on_yellow.must_equal("\e[43m") }
52
+ it { described.on_blue.must_equal("\e[44m") }
53
+ it { described.on_magenta.must_equal("\e[45m") }
54
+ it { described.on_cyan.must_equal("\e[46m") }
55
+ it { described.on_light_grey.must_equal("\e[47m") }
56
+ it { described.on_default.must_equal("\e[49m") }
57
+ it { described.on_dark_grey.must_equal("\e[100m") }
58
+ it { described.on_light_red.must_equal("\e[101m") }
59
+ it { described.on_light_green.must_equal("\e[102m") }
60
+ it { described.on_light_yellow.must_equal("\e[103m") }
61
+ it { described.on_light_blue.must_equal("\e[104m") }
62
+ it { described.on_light_magenta.must_equal("\e[105m") }
63
+ it { described.on_light_cyan.must_equal("\e[106m") }
64
+ it { described.on_white.must_equal("\e[107m") }
30
65
 
31
66
  it 'returns an escape sequence for the background colour and resets ' \
32
67
  'after calling the block' do
@@ -36,6 +71,30 @@ module Vedeu
36
71
  end
37
72
  end
38
73
 
74
+ describe 'action methods' do
75
+ it { described.hide_cursor.must_equal("\e[?25l") }
76
+ it { described.show_cursor.must_equal("\e[?25h") }
77
+ it { described.cursor_position.must_equal("\e[6n") }
78
+ it { described.bg_reset.must_equal("\e[49m") }
79
+ it { described.blink.must_equal("\e[5m") }
80
+ it { described.blink_off.must_equal("\e[25m") }
81
+ it { described.bold.must_equal("\e[1m") }
82
+ it { described.bold_off.must_equal("\e[22m") }
83
+ it { described.border_on.must_equal("\e(0") }
84
+ it { described.border_off.must_equal("\e(B") }
85
+ it { described.dim.must_equal("\e[2m") }
86
+ it { described.fg_reset.must_equal("\e[39m") }
87
+ it { described.negative.must_equal("\e[7m") }
88
+ it { described.positive.must_equal("\e[27m") }
89
+ it { described.reset.must_equal("\e[0m") }
90
+ it { described.underline.must_equal("\e[4m") }
91
+ it { described.underline_off.must_equal("\e[24m") }
92
+ end
93
+
94
+ describe '.actions' do
95
+ it { described.actions.must_be_instance_of(Hash) }
96
+ end
97
+
39
98
  describe '.escape' do
40
99
  let(:stream) { "\e[0m\e[38;2;39m\e[48;2;49m\e[2J\e[?25l" }
41
100
 
@@ -54,108 +113,45 @@ module Vedeu
54
113
  end
55
114
  end
56
115
 
57
- describe '.hide_cursor' do
58
- subject { described.hide_cursor }
59
-
60
- it { subject.must_be_instance_of(String) }
61
- it { subject.must_equal("\e[?25l") }
62
- end
63
-
64
- describe '.show_cursor' do
65
- subject { described.show_cursor }
66
-
67
- it { subject.must_be_instance_of(String) }
68
- it { subject.must_equal("\e[?25h") }
69
- end
70
-
71
- describe '.string' do
72
- it 'returns an empty string when the style is not provided' do
73
- described.string.must_equal('')
74
- end
75
-
76
- it 'returns an escape sequence when the style is bg_reset' do
77
- described.string('bg_reset').must_equal("\e[49m")
78
- end
79
-
80
- it 'returns an escape sequence when the style is blink' do
81
- described.string('blink').must_equal("\e[5m")
82
- end
83
-
84
- it 'returns an escape sequence when the style is blink off' do
85
- described.string('blink_off').must_equal("\e[25m")
86
- end
87
-
88
- it 'returns an escape sequence when the style is bold' do
89
- described.string('bold').must_equal("\e[1m")
116
+ describe '.border' do
117
+ context 'when the block is given' do
118
+ it { described.border { 'b' }.must_equal("\e(0b\e(B") }
90
119
  end
91
120
 
92
- it 'returns an escape sequence when the style is bold off' do
93
- described.string('bold_off').must_equal("\e[22m")
94
- end
95
-
96
- it 'returns an escape sequence when the style is clear' do
97
- described.string('clear').must_equal("\e[39m\e[49m\e[2J")
98
- end
99
-
100
- it 'returns an escape sequence when the style is clear_line' do
101
- described.string('clear_line').must_equal("\e[39m\e[49m\e[2K")
102
- end
103
-
104
- it 'returns an escape sequence when the style is colour_reset' do
105
- described.string('colour_reset').must_equal("\e[39m\e[49m")
106
- end
107
-
108
- it 'returns an escape sequence when the style is fg_reset' do
109
- described.string('fg_reset').must_equal("\e[39m")
110
- end
111
-
112
- it 'returns an escape sequence when the style is hide_cursor' do
113
- described.string('hide_cursor').must_equal("\e[?25l")
114
- end
115
-
116
- it 'returns an escape sequence when the style is screen_init' do
117
- described.string('screen_init').must_equal("\e[0m\e[39m\e[49m\e[2J\e[?25l")
118
- end
119
-
120
- it 'returns an escape sequence when the style is screen_exit' do
121
- described.string('screen_exit')
122
- .must_equal("\e[?25h\e[39m\e[49m\e[0m\e[80;25H\n")
123
- end
124
-
125
- it 'returns an escape sequence when the style is negative' do
126
- described.string('negative').must_equal("\e[7m")
127
- end
128
-
129
- it 'returns an escape sequence when the style is positive' do
130
- described.string('positive').must_equal("\e[27m")
131
- end
132
-
133
- it 'returns an escape sequence when the style is reset' do
134
- described.string('reset').must_equal("\e[0m")
135
- end
136
-
137
- it 'returns an escape sequence when the style is normal' do
138
- described.string('normal').must_equal("\e[24m\e[22m\e[27m")
139
- end
140
-
141
- it 'returns an escape sequence when the style is dim' do
142
- described.string('dim').must_equal("\e[2m")
143
- end
144
-
145
- it 'returns an escape sequence when the style is show_cursor' do
146
- described.string('show_cursor').must_equal("\e[?25h")
147
- end
148
-
149
- it 'returns an escape sequence when the style is underline' do
150
- described.string('underline').must_equal("\e[4m")
151
- end
152
-
153
- it 'returns an escape sequence when the style is underline off' do
154
- described.string('underline_off').must_equal("\e[24m")
121
+ context 'when the block is not given' do
122
+ it { described.border.must_equal('') }
155
123
  end
124
+ end
156
125
 
157
- it 'returns an escape sequence when the style is underline off' do
158
- described.string('cursor_position').must_equal("\e[6n")
126
+ describe '.string' do
127
+ context 'when the style is not provided' do
128
+ it { described.string.must_equal('') }
129
+ end
130
+
131
+ context 'when the style is provided' do
132
+ it { described.string('bg_reset').must_equal("\e[49m") }
133
+ it { described.string('blink').must_equal("\e[5m") }
134
+ it { described.string('blink_off').must_equal("\e[25m") }
135
+ it { described.string('bold').must_equal("\e[1m") }
136
+ it { described.string('bold_off').must_equal("\e[22m") }
137
+ it { described.string('clear').must_equal("\e[39m\e[49m\e[2J") }
138
+ it { described.string('clear_line').must_equal("\e[39m\e[49m\e[2K") }
139
+ it { described.string('colour_reset').must_equal("\e[39m\e[49m") }
140
+ it { described.string('fg_reset').must_equal("\e[39m") }
141
+ it { described.string('hide_cursor').must_equal("\e[?25l") }
142
+ it { described.string('screen_init').
143
+ must_equal("\e[0m\e[39m\e[49m\e[2J\e[?25l") }
144
+ it { described.string('screen_exit').
145
+ must_equal("\e[?25h\e[39m\e[49m\e[0m\e[80;25H\n") }
146
+ it { described.string('negative').must_equal("\e[7m") }
147
+ it { described.string('positive').must_equal("\e[27m") }
148
+ it { described.string('reset').must_equal("\e[0m") }
149
+ it { described.string('normal').must_equal("\e[24m\e[22m\e[27m") }
150
+ it { described.string('dim').must_equal("\e[2m") }
151
+ it { described.string('show_cursor').must_equal("\e[?25h") }
152
+ it { described.string('underline').must_equal("\e[4m") }
153
+ it { described.string('underline_off').must_equal("\e[24m") }
154
+ it { described.string('cursor_position').must_equal("\e[6n") }
159
155
  end
160
156
  end
161
157