vedeu 0.4.46 → 0.4.47

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. checksums.yaml +4 -4
  2. data/lib/vedeu/api.rb +3 -3
  3. data/lib/vedeu/bindings/bindings.rb +14 -4
  4. data/lib/vedeu/bindings/drb.rb +2 -0
  5. data/lib/vedeu/bindings/menus.rb +2 -0
  6. data/lib/vedeu/bindings/movement.rb +2 -0
  7. data/lib/vedeu/bindings/visibility.rb +2 -0
  8. data/lib/vedeu/buffers/buffer.rb +1 -1
  9. data/lib/vedeu/cursor/cursor.rb +2 -2
  10. data/lib/vedeu/geometry/dimension.rb +16 -13
  11. data/lib/vedeu/geometry/geometry.rb +3 -1
  12. data/lib/vedeu/geometry/index_position.rb +1 -1
  13. data/lib/vedeu/geometry/position_index.rb +1 -1
  14. data/lib/vedeu/input/input.rb +2 -1
  15. data/lib/vedeu/input/keymap.rb +1 -0
  16. data/lib/vedeu/models/char.rb +7 -6
  17. data/lib/vedeu/models/interface.rb +2 -12
  18. data/lib/vedeu/models/line.rb +2 -2
  19. data/lib/vedeu/models/stream.rb +2 -2
  20. data/lib/vedeu/null/geometry.rb +3 -6
  21. data/lib/vedeu/output/all.rb +1 -1
  22. data/lib/vedeu/output/border.rb +5 -5
  23. data/lib/vedeu/output/clear/all.rb +2 -0
  24. data/lib/vedeu/output/clear/named_group.rb +52 -0
  25. data/lib/vedeu/output/clear/named_interface.rb +99 -0
  26. data/lib/vedeu/output/esc.rb +1 -1
  27. data/lib/vedeu/output/viewport.rb +10 -2
  28. data/lib/vedeu/repositories/registerable.rb +9 -1
  29. data/lib/vedeu/repositories/repositories/borders.rb +0 -11
  30. data/lib/vedeu/repositories/repositories/buffers.rb +0 -11
  31. data/lib/vedeu/repositories/repositories/cursors.rb +4 -11
  32. data/lib/vedeu/repositories/repositories/geometries.rb +0 -11
  33. data/lib/vedeu/repositories/repositories/groups.rb +4 -11
  34. data/lib/vedeu/repositories/repositories/interfaces.rb +0 -11
  35. data/lib/vedeu/repositories/repositories/keymaps.rb +4 -11
  36. data/lib/vedeu/repositories/repositories/menus.rb +4 -11
  37. data/lib/vedeu/repositories/repository.rb +1 -11
  38. data/lib/vedeu/storage/store.rb +15 -0
  39. data/lib/vedeu/support/log.rb +1 -0
  40. data/lib/vedeu/support/terminal.rb +1 -10
  41. data/lib/vedeu/support/visibility.rb +0 -1
  42. data/lib/vedeu/version.rb +1 -1
  43. data/test/lib/vedeu/geometry/geometry_test.rb +4 -0
  44. data/test/lib/vedeu/geometry/position_test.rb +25 -8
  45. data/test/lib/vedeu/models/char_test.rb +4 -4
  46. data/test/lib/vedeu/models/interface_test.rb +7 -2
  47. data/test/lib/vedeu/output/clear/named_group_test.rb +41 -0
  48. data/test/lib/vedeu/output/clear/named_interface_test.rb +68 -0
  49. data/test/lib/vedeu/output/render_border_test.rb +47 -5
  50. data/test/lib/vedeu/repositories/registerable_test.rb +30 -3
  51. data/test/lib/vedeu/repositories/repositories/borders_test.rb +0 -13
  52. data/test/lib/vedeu/repositories/repositories/buffers_test.rb +0 -11
  53. data/test/lib/vedeu/repositories/repositories/cursors_test.rb +0 -11
  54. data/test/lib/vedeu/repositories/repositories/geometries_test.rb +0 -11
  55. data/test/lib/vedeu/repositories/repositories/groups_test.rb +0 -11
  56. data/test/lib/vedeu/repositories/repositories/interfaces_test.rb +0 -11
  57. data/test/lib/vedeu/repositories/repositories/keymaps_test.rb +0 -11
  58. data/test/lib/vedeu/repositories/repositories/menus_test.rb +0 -11
  59. data/test/lib/vedeu/repositories/repository_test.rb +0 -37
  60. data/test/lib/vedeu/storage/store_test.rb +41 -0
  61. data/test/test_helper.rb +3 -1
  62. metadata +9 -5
  63. data/lib/vedeu/output/clear.rb +0 -207
  64. data/test/lib/vedeu/output/clear_test.rb +0 -105
@@ -30,17 +30,6 @@ module Vedeu
30
30
  end
31
31
  end
32
32
 
33
- describe '.reset!' do
34
- subject { described.reset! }
35
-
36
- it { described.must_respond_to(:reset) }
37
-
38
- it {
39
- described.expects(:register).with(Vedeu::Cursor)
40
- subject
41
- }
42
- end
43
-
44
33
  describe '#by_name' do
45
34
  let(:_name) { 'carbon' }
46
35
 
@@ -10,17 +10,6 @@ module Vedeu
10
10
 
11
11
  it { described.must_respond_to(:geometries) }
12
12
 
13
- describe '.reset!' do
14
- subject { described.reset! }
15
-
16
- it { described.must_respond_to(:reset) }
17
-
18
- it {
19
- described.expects(:register).with(Vedeu::Geometry)
20
- subject
21
- }
22
- end
23
-
24
13
  end # Geometries
25
14
 
26
15
  end # Vedeu
@@ -8,17 +8,6 @@ module Vedeu
8
8
 
9
9
  it { described.must_respond_to(:groups) }
10
10
 
11
- describe '.reset!' do
12
- subject { described.reset! }
13
-
14
- it { described.must_respond_to(:reset) }
15
-
16
- it {
17
- described.expects(:register).with(Vedeu::Group)
18
- subject
19
- }
20
- end
21
-
22
11
  describe '#by_name' do
23
12
  let(:_name) { 'carbon' }
24
13
 
@@ -8,17 +8,6 @@ module Vedeu
8
8
 
9
9
  it { described.must_respond_to(:interfaces) }
10
10
 
11
- describe '.reset!' do
12
- subject { described.reset! }
13
-
14
- it { described.must_respond_to(:reset) }
15
-
16
- it {
17
- described.expects(:register).with(Vedeu::Interface)
18
- subject
19
- }
20
- end
21
-
22
11
  describe '#zindexed' do
23
12
  before do
24
13
  @hydrogen = Vedeu.interface 'hydrogen' do
@@ -8,17 +8,6 @@ module Vedeu
8
8
 
9
9
  it { described.must_respond_to(:keymaps) }
10
10
 
11
- describe '.reset!' do
12
- subject { described.reset! }
13
-
14
- it { described.must_respond_to(:reset) }
15
-
16
- it {
17
- described.expects(:register).with(Vedeu::Keymap)
18
- subject
19
- }
20
- end
21
-
22
11
  end # Keymaps
23
12
 
24
13
  end # Vedeu
@@ -8,17 +8,6 @@ module Vedeu
8
8
 
9
9
  it { described.must_respond_to(:menus) }
10
10
 
11
- describe '.reset!' do
12
- subject { described.reset! }
13
-
14
- it { described.must_respond_to(:reset) }
15
-
16
- it {
17
- described.expects(:register).with(Vedeu::Menu)
18
- subject
19
- }
20
- end
21
-
22
11
  end # Menus
23
12
 
24
13
  end # Vedeu
@@ -198,43 +198,6 @@ module Vedeu
198
198
  end
199
199
  end
200
200
 
201
- describe '#registered' do
202
- it 'returns an Array' do
203
- RepositoriesTestClass.new.registered.must_be_instance_of(Array)
204
- end
205
-
206
- context 'when the storage is a Hash' do
207
- it 'returns a collection of the names of all the registered entities' do
208
- repo = RepositoriesTestClass.new
209
- repo.add('rutherfordium' => { name: 'rutherfordium' })
210
-
211
- repo.registered.must_equal(['rutherfordium'])
212
- end
213
- end
214
-
215
- context 'when the storage is an Array' do
216
- it 'returns the registered entities' do
217
- repo = RepositoriesTestClass.new([])
218
- repo.add('rutherfordium')
219
-
220
- repo.registered.must_equal(['rutherfordium'])
221
- end
222
- end
223
-
224
- context 'when the storage is a Set' do
225
- it 'returns the registered entities' do
226
- repo = RepositoriesTestClass.new(Set.new)
227
- repo.add('rutherfordium')
228
-
229
- repo.registered.must_equal(['rutherfordium'])
230
- end
231
- end
232
-
233
- it 'returns an empty collection when the storage is empty' do
234
- RepositoriesTestClass.new.registered.must_equal([])
235
- end
236
- end
237
-
238
201
  describe '#registered?' do
239
202
  it 'returns false with no name' do
240
203
  RepositoriesTestClass.new.registered?('').must_equal(false)
@@ -84,6 +84,46 @@ module Vedeu
84
84
  it { instance.must_respond_to(:registered?) }
85
85
  end
86
86
 
87
+ describe '#registered' do
88
+ subject { instance.registered }
89
+
90
+ it { subject.must_be_instance_of(Array) }
91
+
92
+ context 'when the storage is a Hash' do
93
+ let(:storage) {
94
+ {
95
+ 'rutherfordium' => { name: 'rutherfordium' }
96
+ }
97
+ }
98
+
99
+ it 'returns a collection of the names of all the registered entities' do
100
+ subject.must_equal(['rutherfordium'])
101
+ end
102
+ end
103
+
104
+ context 'when the storage is an Array' do
105
+ let(:storage) { ['rutherfordium'] }
106
+
107
+ it 'returns the registered entities' do
108
+ subject.must_equal(['rutherfordium'])
109
+ end
110
+ end
111
+
112
+ context 'when the storage is a Set' do
113
+ let(:storage) { Set['rutherfordium'] }
114
+
115
+ it 'returns the registered entities' do
116
+ subject.must_equal(['rutherfordium'])
117
+ end
118
+ end
119
+
120
+ context 'when the storage is empty' do
121
+ it 'returns an empty collection' do
122
+ subject.must_equal([])
123
+ end
124
+ end
125
+ end
126
+
87
127
  describe '#reset' do
88
128
  it 'returns a Hash' do
89
129
  instance.reset.must_be_instance_of(Hash)
@@ -94,6 +134,7 @@ module Vedeu
94
134
  end
95
135
 
96
136
  it { instance.must_respond_to(:reset!) }
137
+ it { instance.must_respond_to(:clear) }
97
138
  end
98
139
 
99
140
  describe '#size' do
@@ -33,7 +33,9 @@ end unless ENV['NO_SIMPLECOV']
33
33
 
34
34
  module VedeuMiniTestPlugin
35
35
  # def before_setup
36
- # Vedeu::Repositories.reset!
36
+ # # Vedeu::Repositories.reset!
37
+ # # Vedeu.log(type: :debug, message: "#{self.class}")
38
+ #
37
39
  # super
38
40
  # end
39
41
 
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.4.46
4
+ version: 0.4.47
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gavin Laking
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-10 00:00:00.000000000 Z
11
+ date: 2015-07-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: guard
@@ -417,7 +417,9 @@ files:
417
417
  - lib/vedeu/output/all.rb
418
418
  - lib/vedeu/output/background.rb
419
419
  - lib/vedeu/output/border.rb
420
- - lib/vedeu/output/clear.rb
420
+ - lib/vedeu/output/clear/all.rb
421
+ - lib/vedeu/output/clear/named_group.rb
422
+ - lib/vedeu/output/clear/named_interface.rb
421
423
  - lib/vedeu/output/colour.rb
422
424
  - lib/vedeu/output/compressor.rb
423
425
  - lib/vedeu/output/esc.rb
@@ -563,7 +565,8 @@ files:
563
565
  - test/lib/vedeu/null/interface_test.rb
564
566
  - test/lib/vedeu/output/background_test.rb
565
567
  - test/lib/vedeu/output/border_test.rb
566
- - test/lib/vedeu/output/clear_test.rb
568
+ - test/lib/vedeu/output/clear/named_group_test.rb
569
+ - test/lib/vedeu/output/clear/named_interface_test.rb
567
570
  - test/lib/vedeu/output/colour_test.rb
568
571
  - test/lib/vedeu/output/compressor_test.rb
569
572
  - test/lib/vedeu/output/esc_test.rb
@@ -733,7 +736,8 @@ test_files:
733
736
  - test/lib/vedeu/null/interface_test.rb
734
737
  - test/lib/vedeu/output/background_test.rb
735
738
  - test/lib/vedeu/output/border_test.rb
736
- - test/lib/vedeu/output/clear_test.rb
739
+ - test/lib/vedeu/output/clear/named_group_test.rb
740
+ - test/lib/vedeu/output/clear/named_interface_test.rb
737
741
  - test/lib/vedeu/output/colour_test.rb
738
742
  - test/lib/vedeu/output/compressor_test.rb
739
743
  - test/lib/vedeu/output/esc_test.rb
@@ -1,207 +0,0 @@
1
- module Vedeu
2
-
3
- # Clears the area defined by an interface.
4
- #
5
- # @api private
6
- class Clear
7
-
8
- extend Forwardable
9
-
10
- def_delegators :border,
11
- :bx,
12
- :by
13
-
14
- def_delegators :geometry,
15
- :x,
16
- :y
17
-
18
- def_delegators :interface,
19
- :colour,
20
- :name,
21
- :style,
22
- :visible?
23
-
24
- class << self
25
-
26
- # @param group [String]
27
- # @return [void]
28
- def by_group(group = nil)
29
- return unless group
30
-
31
- Vedeu.groups.find(group).members.each { |name| clear(name) }
32
- end
33
- alias_method :clear_by_group, :by_group
34
-
35
- # @param name [String]
36
- # @return [void]
37
- def by_name(name = nil)
38
- return Vedeu::Terminal.clear unless name
39
-
40
- clear(Vedeu.interfaces.by_name(name),
41
- clear_border: true,
42
- use_terminal_colours: true)
43
- end
44
- alias_method :clear_by_name, :by_name
45
-
46
- # Clears the area defined by the interface.
47
- #
48
- # @return [Array|String]
49
- # @see #initialize
50
- def clear(interface, options = {})
51
- if interface.visible?
52
- new(interface, options).write
53
-
54
- else
55
- []
56
-
57
- end
58
- end
59
- alias_method :render, :clear
60
-
61
- end # Eigenclass
62
-
63
- # Return a new instance of Vedeu::Clear.
64
- #
65
- # @param interface [Interface]
66
- # @param options [Hash]
67
- # @option options clear_border [Boolean] see {#clear_border?}
68
- # @option options use_terminal_colours [Boolean] see
69
- # {#use_terminal_colours?}
70
- # @return [Vedeu::Clear]
71
- def initialize(interface, options = {})
72
- @interface = interface
73
- @options = options
74
- end
75
-
76
- # For each visible line of the interface, set the foreground and background
77
- # colours to those specified when the interface was defined, then starting
78
- # write space characters over the area which the interface occupies.
79
- #
80
- # @return [Array<Array<Vedeu::Char>>]
81
- def clear
82
- if visible?
83
- Vedeu.timer("Clearing: #{name}") do
84
- y, x = *position
85
-
86
- @clear ||= Array.new(height) do |iy|
87
- Array.new(width) do |ix|
88
- Vedeu::Char.new(value: ' ',
89
- colour: clear_colour,
90
- style: style,
91
- position: Vedeu::Position[y + iy, x + ix])
92
- end
93
- end
94
- end
95
- else
96
- []
97
-
98
- end
99
- end
100
- alias_method :render, :clear
101
- alias_method :rendered, :clear
102
-
103
- # Clear the view and send to the terminal.
104
- #
105
- # @return [Array]
106
- def write
107
- Vedeu::Output.render(rendered)
108
- end
109
-
110
- protected
111
-
112
- # @!attribute [r] interface
113
- # @return [Interface]
114
- attr_reader :interface
115
-
116
- private
117
-
118
- # @see Vedeu::Borders#by_name
119
- def border
120
- @border ||= Vedeu.borders.by_name(name)
121
- end
122
-
123
- # @return [Boolean] Indicates whether the area occupied by the border of the
124
- # interface should be cleared also.
125
- def clear_border?
126
- options[:clear_border]
127
- end
128
-
129
- # @return [Vedeu::Colour] The default background and foreground colours for
130
- # the terminal, or the colours of the interface.
131
- def clear_colour
132
- @colour ||= if use_terminal_colours?
133
- Vedeu::Colour.new(background: :default,
134
- foreground: :default)
135
-
136
- else
137
- colour
138
-
139
- end
140
- end
141
-
142
- # Returns the default options/attributes for this class.
143
- #
144
- # @return [Hash<Symbol => Boolean>]
145
- def defaults
146
- {
147
- clear_border: false,
148
- use_terminal_colours: false,
149
- }
150
- end
151
-
152
- # @see Vedeu::Geometries#by_name
153
- def geometry
154
- @geometry ||= Vedeu.geometries.by_name(name)
155
- end
156
-
157
- # Returns the height of the area to be cleared.
158
- #
159
- # @return [Fixnum]
160
- def height
161
- if clear_border?
162
- geometry.height
163
-
164
- else
165
- border.height
166
-
167
- end
168
- end
169
-
170
- # @return [Hash<Symbol => Boolean>]
171
- def options
172
- @_options ||= defaults.merge!(@options)
173
- end
174
-
175
- # @return [Vedeu::IndexPosition]
176
- def position
177
- @position ||= if clear_border?
178
- [y, x]
179
-
180
- else
181
- [by, bx]
182
-
183
- end
184
- end
185
-
186
- # @return [Boolean] Indicates whether the default terminal colours should be
187
- # used to clear the area.
188
- def use_terminal_colours?
189
- options[:use_terminal_colours]
190
- end
191
-
192
- # Returns the width of the area to be cleared.
193
- #
194
- # @return [Fixnum]
195
- def width
196
- if clear_border?
197
- geometry.width
198
-
199
- else
200
- border.width
201
-
202
- end
203
- end
204
-
205
- end # Clear
206
-
207
- end # Vedeu