vedeu 0.5.4 → 0.5.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/docs/dsl.md +3 -3
- data/examples/borders_app.rb +2 -0
- data/examples/colours_app.rb +2 -0
- data/examples/configuration_app.rb +2 -0
- data/examples/drb_app.rb +2 -0
- data/examples/focus_app.rb +2 -0
- data/examples/hello_world.rb +2 -0
- data/examples/material_colours_app.rb +2 -0
- data/lib/vedeu.rb +2 -0
- data/lib/vedeu/all.rb +4 -13
- data/lib/vedeu/api.rb +7 -6
- data/lib/vedeu/borders/border.rb +1 -1
- data/lib/vedeu/borders/render_border.rb +18 -18
- data/lib/vedeu/buffers/buffer.rb +18 -28
- data/lib/vedeu/colours/colour.rb +1 -1
- data/lib/vedeu/colours/colour_translator.rb +1 -1
- data/lib/vedeu/cursor/cursor.rb +9 -6
- data/lib/vedeu/dsl/border.rb +1 -1
- data/lib/vedeu/dsl/composition.rb +5 -5
- data/lib/vedeu/dsl/geometry.rb +1 -1
- data/lib/vedeu/dsl/group.rb +1 -1
- data/lib/vedeu/dsl/interface.rb +69 -93
- data/lib/vedeu/dsl/keymap.rb +1 -1
- data/lib/vedeu/dsl/line.rb +11 -11
- data/lib/vedeu/dsl/shared.rb +81 -0
- data/lib/vedeu/dsl/stream.rb +3 -3
- data/lib/vedeu/dsl/view.rb +76 -64
- data/lib/vedeu/models/escape.rb +1 -1
- data/lib/vedeu/models/interface.rb +3 -57
- data/lib/vedeu/models/menu.rb +1 -1
- data/lib/vedeu/models/views/all.rb +22 -0
- data/lib/vedeu/models/views/char.rb +175 -0
- data/lib/vedeu/models/views/chars.rb +13 -0
- data/lib/vedeu/models/views/composition.rb +73 -0
- data/lib/vedeu/models/views/line.rb +111 -0
- data/lib/vedeu/models/views/lines.rb +13 -0
- data/lib/vedeu/models/views/stream.rb +122 -0
- data/lib/vedeu/models/views/streams.rb +13 -0
- data/lib/vedeu/models/views/view.rb +157 -0
- data/lib/vedeu/models/views/view_collection.rb +13 -0
- data/lib/vedeu/null/view.rb +67 -0
- data/lib/vedeu/output/clear/named_interface.rb +4 -4
- data/lib/vedeu/output/compressor.rb +6 -6
- data/lib/vedeu/output/html_char.rb +6 -6
- data/lib/vedeu/output/output.rb +3 -3
- data/lib/vedeu/output/presentation.rb +1 -1
- data/lib/vedeu/output/renderers/escape_sequence.rb +1 -1
- data/lib/vedeu/output/renderers/file.rb +1 -1
- data/lib/vedeu/output/renderers/html.rb +3 -3
- data/lib/vedeu/output/renderers/json.rb +4 -4
- data/lib/vedeu/output/renderers/null.rb +1 -1
- data/lib/vedeu/output/renderers/terminal.rb +5 -5
- data/lib/vedeu/output/renderers/text.rb +3 -3
- data/lib/vedeu/output/style.rb +1 -1
- data/lib/vedeu/output/text.rb +20 -15
- data/lib/vedeu/output/viewport.rb +16 -23
- data/lib/vedeu/output/virtual_buffer.rb +9 -8
- data/lib/vedeu/output/virtual_terminal.rb +11 -11
- data/lib/vedeu/output/wordwrap.rb +5 -5
- data/lib/vedeu/runtime/application.rb +1 -1
- data/lib/vedeu/runtime/main_loop.rb +1 -1
- data/lib/vedeu/templating/helpers.rb +11 -10
- data/lib/vedeu/templating/template.rb +1 -1
- data/lib/vedeu/templating/view_template.rb +6 -6
- data/lib/vedeu/version.rb +1 -2
- data/test/lib/vedeu/api_test.rb +30 -30
- data/test/lib/vedeu/buffers/buffer_test.rb +5 -139
- data/test/lib/vedeu/colours/colour_translator_test.rb +3 -3
- data/test/lib/vedeu/configuration/api_test.rb +3 -3
- data/test/lib/vedeu/cursor/refresh_cursor_test.rb +1 -1
- data/test/lib/vedeu/dsl/composition_test.rb +7 -7
- data/test/lib/vedeu/dsl/group_test.rb +2 -2
- data/test/lib/vedeu/dsl/interface_test.rb +31 -21
- data/test/lib/vedeu/dsl/keymap_test.rb +4 -4
- data/test/lib/vedeu/dsl/line_test.rb +8 -8
- data/test/lib/vedeu/dsl/stream_test.rb +4 -4
- data/test/lib/vedeu/dsl/text_test.rb +11 -11
- data/test/lib/vedeu/dsl/view_test.rb +24 -29
- data/test/lib/vedeu/geometry/grid_test.rb +4 -4
- data/test/lib/vedeu/input/key_test.rb +1 -1
- data/test/lib/vedeu/internal_api_test.rb +18 -18
- data/test/lib/vedeu/models/focus_test.rb +54 -54
- data/test/lib/vedeu/models/interface_test.rb +11 -105
- data/test/lib/vedeu/models/menu_test.rb +1 -1
- data/test/lib/vedeu/models/views/char_test.rb +257 -0
- data/test/lib/vedeu/models/views/chars_test.rb +22 -0
- data/test/lib/vedeu/models/views/composition_test.rb +61 -0
- data/test/lib/vedeu/models/views/line_test.rb +189 -0
- data/test/lib/vedeu/models/views/lines_test.rb +22 -0
- data/test/lib/vedeu/models/views/stream_test.rb +138 -0
- data/test/lib/vedeu/models/views/streams_test.rb +22 -0
- data/test/lib/vedeu/models/views/view_test.rb +40 -0
- data/test/lib/vedeu/null/view_test.rb +12 -0
- data/test/lib/vedeu/output/clear/named_interface_test.rb +4 -4
- data/test/lib/vedeu/output/compressor_test.rb +28 -28
- data/test/lib/vedeu/output/html_char_test.rb +2 -2
- data/test/lib/vedeu/output/presentation_test.rb +10 -14
- data/test/lib/vedeu/output/renderers/escape_sequence_test.rb +20 -4
- data/test/lib/vedeu/output/renderers/html_test.rb +4 -4
- data/test/lib/vedeu/output/renderers/json_test.rb +3 -3
- data/test/lib/vedeu/output/text_test.rb +10 -10
- data/test/lib/vedeu/output/viewport_test.rb +21 -23
- data/test/lib/vedeu/output/virtual_buffer_test.rb +1 -1
- data/test/lib/vedeu/output/virtual_terminal_test.rb +1 -1
- data/test/lib/vedeu/output/wordwrap_test.rb +9 -9
- data/test/lib/vedeu/repositories/repository_test.rb +2 -2
- data/test/lib/vedeu/templating/helpers_test.rb +6 -39
- data/test/lib/vedeu/templating/template_test.rb +2 -2
- data/test/lib/vedeu/templating/view_template_test.rb +91 -91
- data/test/lib/vedeu/terminal_test.rb +1 -1
- metadata +33 -27
- data/lib/vedeu/buffers/display_buffer.rb +0 -39
- data/lib/vedeu/models/char.rb +0 -170
- data/lib/vedeu/models/chars.rb +0 -9
- data/lib/vedeu/models/composition.rb +0 -66
- data/lib/vedeu/models/line.rb +0 -112
- data/lib/vedeu/models/lines.rb +0 -9
- data/lib/vedeu/models/stream.rb +0 -122
- data/lib/vedeu/models/streams.rb +0 -9
- data/test/lib/vedeu/buffers/display_buffer_test.rb +0 -61
- data/test/lib/vedeu/models/char_test.rb +0 -253
- data/test/lib/vedeu/models/chars_test.rb +0 -18
- data/test/lib/vedeu/models/composition_test.rb +0 -57
- data/test/lib/vedeu/models/line_test.rb +0 -189
- data/test/lib/vedeu/models/lines_test.rb +0 -18
- data/test/lib/vedeu/models/stream_test.rb +0 -141
- data/test/lib/vedeu/models/streams_test.rb +0 -18
@@ -14,7 +14,7 @@ module Vedeu
|
|
14
14
|
|
15
15
|
describe '.open' do
|
16
16
|
context 'when a block was not given' do
|
17
|
-
it { proc { Terminal.open }.must_raise(InvalidSyntax) }
|
17
|
+
it { proc { Terminal.open }.must_raise(Vedeu::InvalidSyntax) }
|
18
18
|
end
|
19
19
|
|
20
20
|
it 'opens a new terminal console in raw mode' do
|
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.5.
|
4
|
+
version: 0.5.5
|
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-
|
11
|
+
date: 2015-08-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: guard
|
@@ -277,7 +277,6 @@ files:
|
|
277
277
|
- lib/vedeu/borders/render_border.rb
|
278
278
|
- lib/vedeu/buffers/buffer.rb
|
279
279
|
- lib/vedeu/buffers/buffers.rb
|
280
|
-
- lib/vedeu/buffers/display_buffer.rb
|
281
280
|
- lib/vedeu/cli/generator/all.rb
|
282
281
|
- lib/vedeu/cli/generator/application.rb
|
283
282
|
- lib/vedeu/cli/generator/helpers.rb
|
@@ -345,6 +344,7 @@ files:
|
|
345
344
|
- lib/vedeu/dsl/line.rb
|
346
345
|
- lib/vedeu/dsl/menu.rb
|
347
346
|
- lib/vedeu/dsl/presentation.rb
|
347
|
+
- lib/vedeu/dsl/shared.rb
|
348
348
|
- lib/vedeu/dsl/stream.rb
|
349
349
|
- lib/vedeu/dsl/text.rb
|
350
350
|
- lib/vedeu/dsl/use.rb
|
@@ -374,9 +374,6 @@ files:
|
|
374
374
|
- lib/vedeu/log/log.rb
|
375
375
|
- lib/vedeu/log/timer.rb
|
376
376
|
- lib/vedeu/models/cell.rb
|
377
|
-
- lib/vedeu/models/char.rb
|
378
|
-
- lib/vedeu/models/chars.rb
|
379
|
-
- lib/vedeu/models/composition.rb
|
380
377
|
- lib/vedeu/models/escape.rb
|
381
378
|
- lib/vedeu/models/focus.rb
|
382
379
|
- lib/vedeu/models/group.rb
|
@@ -384,13 +381,19 @@ files:
|
|
384
381
|
- lib/vedeu/models/interface.rb
|
385
382
|
- lib/vedeu/models/interface_collection.rb
|
386
383
|
- lib/vedeu/models/interfaces.rb
|
387
|
-
- lib/vedeu/models/line.rb
|
388
|
-
- lib/vedeu/models/lines.rb
|
389
384
|
- lib/vedeu/models/menu.rb
|
390
385
|
- lib/vedeu/models/menus.rb
|
391
|
-
- lib/vedeu/models/stream.rb
|
392
|
-
- lib/vedeu/models/streams.rb
|
393
386
|
- lib/vedeu/models/toggleable.rb
|
387
|
+
- lib/vedeu/models/views/all.rb
|
388
|
+
- lib/vedeu/models/views/char.rb
|
389
|
+
- lib/vedeu/models/views/chars.rb
|
390
|
+
- lib/vedeu/models/views/composition.rb
|
391
|
+
- lib/vedeu/models/views/line.rb
|
392
|
+
- lib/vedeu/models/views/lines.rb
|
393
|
+
- lib/vedeu/models/views/stream.rb
|
394
|
+
- lib/vedeu/models/views/streams.rb
|
395
|
+
- lib/vedeu/models/views/view.rb
|
396
|
+
- lib/vedeu/models/views/view_collection.rb
|
394
397
|
- lib/vedeu/null.rb
|
395
398
|
- lib/vedeu/null/border.rb
|
396
399
|
- lib/vedeu/null/buffer.rb
|
@@ -398,6 +401,7 @@ files:
|
|
398
401
|
- lib/vedeu/null/geometry.rb
|
399
402
|
- lib/vedeu/null/interface.rb
|
400
403
|
- lib/vedeu/null/menu.rb
|
404
|
+
- lib/vedeu/null/view.rb
|
401
405
|
- lib/vedeu/output/clear/named_group.rb
|
402
406
|
- lib/vedeu/output/clear/named_interface.rb
|
403
407
|
- lib/vedeu/output/compressor.rb
|
@@ -468,7 +472,6 @@ files:
|
|
468
472
|
- test/lib/vedeu/borders/render_border_test.rb
|
469
473
|
- test/lib/vedeu/buffers/buffer_test.rb
|
470
474
|
- test/lib/vedeu/buffers/buffers_test.rb
|
471
|
-
- test/lib/vedeu/buffers/display_buffer_test.rb
|
472
475
|
- test/lib/vedeu/cli/generator/application_test.rb
|
473
476
|
- test/lib/vedeu/cli/generator/helpers_test.rb
|
474
477
|
- test/lib/vedeu/cli/generator/view_test.rb
|
@@ -533,9 +536,6 @@ files:
|
|
533
536
|
- test/lib/vedeu/log/log_test.rb
|
534
537
|
- test/lib/vedeu/log/timer_test.rb
|
535
538
|
- test/lib/vedeu/models/cell_test.rb
|
536
|
-
- test/lib/vedeu/models/char_test.rb
|
537
|
-
- test/lib/vedeu/models/chars_test.rb
|
538
|
-
- test/lib/vedeu/models/composition_test.rb
|
539
539
|
- test/lib/vedeu/models/escape_test.rb
|
540
540
|
- test/lib/vedeu/models/focus_test.rb
|
541
541
|
- test/lib/vedeu/models/group_test.rb
|
@@ -543,19 +543,24 @@ files:
|
|
543
543
|
- test/lib/vedeu/models/interface_collection_test.rb
|
544
544
|
- test/lib/vedeu/models/interface_test.rb
|
545
545
|
- test/lib/vedeu/models/interfaces_test.rb
|
546
|
-
- test/lib/vedeu/models/line_test.rb
|
547
|
-
- test/lib/vedeu/models/lines_test.rb
|
548
546
|
- test/lib/vedeu/models/menu_test.rb
|
549
547
|
- test/lib/vedeu/models/menus_test.rb
|
550
|
-
- test/lib/vedeu/models/stream_test.rb
|
551
|
-
- test/lib/vedeu/models/streams_test.rb
|
552
548
|
- test/lib/vedeu/models/toggleable_test.rb
|
549
|
+
- test/lib/vedeu/models/views/char_test.rb
|
550
|
+
- test/lib/vedeu/models/views/chars_test.rb
|
551
|
+
- test/lib/vedeu/models/views/composition_test.rb
|
552
|
+
- test/lib/vedeu/models/views/line_test.rb
|
553
|
+
- test/lib/vedeu/models/views/lines_test.rb
|
554
|
+
- test/lib/vedeu/models/views/stream_test.rb
|
555
|
+
- test/lib/vedeu/models/views/streams_test.rb
|
556
|
+
- test/lib/vedeu/models/views/view_test.rb
|
553
557
|
- test/lib/vedeu/null/border_test.rb
|
554
558
|
- test/lib/vedeu/null/buffer_test.rb
|
555
559
|
- test/lib/vedeu/null/generic_test.rb
|
556
560
|
- test/lib/vedeu/null/geometry_test.rb
|
557
561
|
- test/lib/vedeu/null/interface_test.rb
|
558
562
|
- test/lib/vedeu/null/menu_test.rb
|
563
|
+
- test/lib/vedeu/null/view_test.rb
|
559
564
|
- test/lib/vedeu/output/clear/named_group_test.rb
|
560
565
|
- test/lib/vedeu/output/clear/named_interface_test.rb
|
561
566
|
- test/lib/vedeu/output/compressor_test.rb
|
@@ -631,7 +636,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
631
636
|
version: '0'
|
632
637
|
requirements: []
|
633
638
|
rubyforge_project:
|
634
|
-
rubygems_version: 2.4.
|
639
|
+
rubygems_version: 2.4.5
|
635
640
|
signing_key:
|
636
641
|
specification_version: 4
|
637
642
|
summary: A terminal case of wonderland.
|
@@ -655,7 +660,6 @@ test_files:
|
|
655
660
|
- test/lib/vedeu/borders/render_border_test.rb
|
656
661
|
- test/lib/vedeu/buffers/buffer_test.rb
|
657
662
|
- test/lib/vedeu/buffers/buffers_test.rb
|
658
|
-
- test/lib/vedeu/buffers/display_buffer_test.rb
|
659
663
|
- test/lib/vedeu/cli/generator/application_test.rb
|
660
664
|
- test/lib/vedeu/cli/generator/helpers_test.rb
|
661
665
|
- test/lib/vedeu/cli/generator/view_test.rb
|
@@ -720,9 +724,6 @@ test_files:
|
|
720
724
|
- test/lib/vedeu/log/log_test.rb
|
721
725
|
- test/lib/vedeu/log/timer_test.rb
|
722
726
|
- test/lib/vedeu/models/cell_test.rb
|
723
|
-
- test/lib/vedeu/models/char_test.rb
|
724
|
-
- test/lib/vedeu/models/chars_test.rb
|
725
|
-
- test/lib/vedeu/models/composition_test.rb
|
726
727
|
- test/lib/vedeu/models/escape_test.rb
|
727
728
|
- test/lib/vedeu/models/focus_test.rb
|
728
729
|
- test/lib/vedeu/models/group_test.rb
|
@@ -730,19 +731,24 @@ test_files:
|
|
730
731
|
- test/lib/vedeu/models/interface_collection_test.rb
|
731
732
|
- test/lib/vedeu/models/interface_test.rb
|
732
733
|
- test/lib/vedeu/models/interfaces_test.rb
|
733
|
-
- test/lib/vedeu/models/line_test.rb
|
734
|
-
- test/lib/vedeu/models/lines_test.rb
|
735
734
|
- test/lib/vedeu/models/menu_test.rb
|
736
735
|
- test/lib/vedeu/models/menus_test.rb
|
737
|
-
- test/lib/vedeu/models/stream_test.rb
|
738
|
-
- test/lib/vedeu/models/streams_test.rb
|
739
736
|
- test/lib/vedeu/models/toggleable_test.rb
|
737
|
+
- test/lib/vedeu/models/views/char_test.rb
|
738
|
+
- test/lib/vedeu/models/views/chars_test.rb
|
739
|
+
- test/lib/vedeu/models/views/composition_test.rb
|
740
|
+
- test/lib/vedeu/models/views/line_test.rb
|
741
|
+
- test/lib/vedeu/models/views/lines_test.rb
|
742
|
+
- test/lib/vedeu/models/views/stream_test.rb
|
743
|
+
- test/lib/vedeu/models/views/streams_test.rb
|
744
|
+
- test/lib/vedeu/models/views/view_test.rb
|
740
745
|
- test/lib/vedeu/null/border_test.rb
|
741
746
|
- test/lib/vedeu/null/buffer_test.rb
|
742
747
|
- test/lib/vedeu/null/generic_test.rb
|
743
748
|
- test/lib/vedeu/null/geometry_test.rb
|
744
749
|
- test/lib/vedeu/null/interface_test.rb
|
745
750
|
- test/lib/vedeu/null/menu_test.rb
|
751
|
+
- test/lib/vedeu/null/view_test.rb
|
746
752
|
- test/lib/vedeu/output/clear/named_group_test.rb
|
747
753
|
- test/lib/vedeu/output/clear/named_interface_test.rb
|
748
754
|
- test/lib/vedeu/output/compressor_test.rb
|
@@ -1,39 +0,0 @@
|
|
1
|
-
module Vedeu
|
2
|
-
|
3
|
-
# This module is included in Vedeu::Interface to provide means to store client
|
4
|
-
# application views created with {Vedeu.renders} or {Vedeu.views}.
|
5
|
-
#
|
6
|
-
module DisplayBuffer
|
7
|
-
|
8
|
-
include Vedeu::Common
|
9
|
-
|
10
|
-
# Store the view and immediately refresh it; causing to be pushed to the
|
11
|
-
# Terminal.
|
12
|
-
#
|
13
|
-
# @return [Vedeu::Interface]
|
14
|
-
def store_immediate
|
15
|
-
store_deferred
|
16
|
-
|
17
|
-
Vedeu::Refresh.by_name(name)
|
18
|
-
|
19
|
-
self
|
20
|
-
end
|
21
|
-
|
22
|
-
# When a name is given, the view is stored with this name. This view will be
|
23
|
-
# shown next time the refresh event is triggered for the interface.
|
24
|
-
#
|
25
|
-
# @raise [Vedeu::InvalidSyntax] The name is not defined.
|
26
|
-
# @return [Vedeu::Interface]
|
27
|
-
def store_deferred
|
28
|
-
unless present?(name)
|
29
|
-
fail Vedeu::InvalidSyntax, 'Cannot store an interface without a name.'
|
30
|
-
end
|
31
|
-
|
32
|
-
Vedeu.buffers.by_name(name).add(self)
|
33
|
-
|
34
|
-
self
|
35
|
-
end
|
36
|
-
|
37
|
-
end # DisplayBuffer
|
38
|
-
|
39
|
-
end # Vedeu
|
data/lib/vedeu/models/char.rb
DELETED
@@ -1,170 +0,0 @@
|
|
1
|
-
module Vedeu
|
2
|
-
|
3
|
-
# A Char represents a single character of the terminal. It is a container for
|
4
|
-
# the a single character in a {Vedeu::Stream}.
|
5
|
-
#
|
6
|
-
# Though a multi-character String can be passed as a value, only the first
|
7
|
-
# character is returned in the escape sequence.
|
8
|
-
#
|
9
|
-
class Char
|
10
|
-
|
11
|
-
include Comparable
|
12
|
-
include Vedeu::Presentation
|
13
|
-
|
14
|
-
# @!attribute [rw] border
|
15
|
-
# @return [NilClass|Symbol]
|
16
|
-
attr_accessor :border
|
17
|
-
|
18
|
-
# @!attribute [rw] parent
|
19
|
-
# @return [Vedeu::Line]
|
20
|
-
attr_accessor :parent
|
21
|
-
|
22
|
-
# @!attribute [r] attributes
|
23
|
-
# @return [Hash]
|
24
|
-
attr_reader :attributes
|
25
|
-
|
26
|
-
# @!attribute [r] position
|
27
|
-
# @return [Vedeu::Position]
|
28
|
-
attr_reader :position
|
29
|
-
|
30
|
-
# @!attribute [w] value
|
31
|
-
# @return [String]
|
32
|
-
attr_writer :value
|
33
|
-
|
34
|
-
# Returns a new instance of Vedeu::Char.
|
35
|
-
#
|
36
|
-
# @param attributes [Hash]
|
37
|
-
# @option attributes value [String]
|
38
|
-
# @option attributes parent [Vedeu::Line]
|
39
|
-
# @option attributes colour [Vedeu::Colour]
|
40
|
-
# @option attributes style [Vedeu::Style]
|
41
|
-
# @option attributes position [Vedeu::Position]
|
42
|
-
# @option attributes border [NilClass|Symbol] A symbol representing the
|
43
|
-
# border 'piece' this Char represents.
|
44
|
-
# @return [Vedeu::Char]
|
45
|
-
def initialize(attributes = {})
|
46
|
-
@attributes = attributes
|
47
|
-
@border = @attributes[:border]
|
48
|
-
@parent = @attributes[:parent]
|
49
|
-
@value = @attributes[:value]
|
50
|
-
end
|
51
|
-
|
52
|
-
# When {Vedeu::Viewport#padded_lines} has less lines that required to fill
|
53
|
-
# the visible area of the interface, it creates a line that contains a
|
54
|
-
# single {Vedeu::Char} containing a space (0x20); later,
|
55
|
-
# {Vedeu::Viewport#padded_columns} will attempts to call `#chars` on an
|
56
|
-
# expected {Vedeu::Line} and fail; this method fixes that.
|
57
|
-
#
|
58
|
-
# @return [Array]
|
59
|
-
def chars
|
60
|
-
[]
|
61
|
-
end
|
62
|
-
|
63
|
-
# An object is equal when its values are the same.
|
64
|
-
#
|
65
|
-
# @param other [Vedeu::Char]
|
66
|
-
# @return [Boolean]
|
67
|
-
def eql?(other)
|
68
|
-
self.class == other.class && value == other.value &&
|
69
|
-
position == other.position
|
70
|
-
end
|
71
|
-
alias_method :==, :eql?
|
72
|
-
|
73
|
-
# Override Ruby's Object#inspect method to provide a more helpful output.
|
74
|
-
#
|
75
|
-
# @return [String]
|
76
|
-
def inspect
|
77
|
-
"<Vedeu::Char '#{Vedeu::Esc.escape(to_s)}'>"
|
78
|
-
end
|
79
|
-
|
80
|
-
# @return [Vedeu::Position]
|
81
|
-
def position
|
82
|
-
@position = Vedeu::Position.coerce(@attributes[:position])
|
83
|
-
end
|
84
|
-
|
85
|
-
# Sets the position of the Char.
|
86
|
-
#
|
87
|
-
# @param value [Vedeu::Position]
|
88
|
-
# @return [Vedeu::Position]
|
89
|
-
def position=(value)
|
90
|
-
@position = @attributes[:position] = Vedeu::Position.coerce(value)
|
91
|
-
end
|
92
|
-
|
93
|
-
# @return [String]
|
94
|
-
def value
|
95
|
-
if border
|
96
|
-
Vedeu::Esc.border { @value }
|
97
|
-
|
98
|
-
else
|
99
|
-
@value
|
100
|
-
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
|
-
# Returns the x position for the Char when set.
|
105
|
-
#
|
106
|
-
# @return [Fixnum|NilClass]
|
107
|
-
def x
|
108
|
-
position.x if position
|
109
|
-
end
|
110
|
-
|
111
|
-
# Returns the y position for the Char when set.
|
112
|
-
#
|
113
|
-
# @return [Fixnum|NilClass]
|
114
|
-
def y
|
115
|
-
position.y if position
|
116
|
-
end
|
117
|
-
|
118
|
-
# Returns a Hash of all the values before coercion.
|
119
|
-
#
|
120
|
-
# @note
|
121
|
-
# From this hash we should be able to construct a new instance of
|
122
|
-
# Vedeu::Char, however, at the moment, `:parent` cannot be coerced.
|
123
|
-
#
|
124
|
-
# @return [Hash]
|
125
|
-
def to_hash
|
126
|
-
{
|
127
|
-
border: border.to_s,
|
128
|
-
colour: colour_to_hash,
|
129
|
-
parent: parent_to_hash,
|
130
|
-
position: position_to_hash,
|
131
|
-
style: style.to_s,
|
132
|
-
value: value,
|
133
|
-
}
|
134
|
-
end
|
135
|
-
|
136
|
-
# @return [String]
|
137
|
-
def to_html
|
138
|
-
@to_html ||= Vedeu::HTMLChar.render(self)
|
139
|
-
end
|
140
|
-
|
141
|
-
private
|
142
|
-
|
143
|
-
# @return [Hash]
|
144
|
-
def colour_to_hash
|
145
|
-
{
|
146
|
-
background: background.to_s,
|
147
|
-
foreground: foreground.to_s,
|
148
|
-
}
|
149
|
-
end
|
150
|
-
|
151
|
-
# @return [Hash]
|
152
|
-
def parent_to_hash
|
153
|
-
{
|
154
|
-
background: parent_background.to_s,
|
155
|
-
foreground: parent_foreground.to_s,
|
156
|
-
style: parent_style.to_s,
|
157
|
-
}
|
158
|
-
end
|
159
|
-
|
160
|
-
# @return [Hash]
|
161
|
-
def position_to_hash
|
162
|
-
{
|
163
|
-
y: y,
|
164
|
-
x: x,
|
165
|
-
}
|
166
|
-
end
|
167
|
-
|
168
|
-
end # Char
|
169
|
-
|
170
|
-
end # Vedeu
|
data/lib/vedeu/models/chars.rb
DELETED
@@ -1,66 +0,0 @@
|
|
1
|
-
module Vedeu
|
2
|
-
|
3
|
-
# A composition is a collection of interfaces.
|
4
|
-
#
|
5
|
-
class Composition
|
6
|
-
|
7
|
-
include Vedeu::Model
|
8
|
-
include Vedeu::Presentation
|
9
|
-
|
10
|
-
collection Vedeu::InterfaceCollection
|
11
|
-
member Vedeu::Interface
|
12
|
-
|
13
|
-
# @!attribute [r] attributes
|
14
|
-
# @return [Hash]
|
15
|
-
attr_reader :attributes
|
16
|
-
|
17
|
-
# Returns a new instance of Vedeu::Composition.
|
18
|
-
#
|
19
|
-
# @param attributes [Hash]
|
20
|
-
# @option attributes colour [Vedeu::Colour]
|
21
|
-
# @option attributes interfaces [void]
|
22
|
-
# @option attributes style [Vedeu::Style]
|
23
|
-
# @return [Vedeu::Composition]
|
24
|
-
def initialize(attributes = {})
|
25
|
-
@attributes = defaults.merge!(attributes)
|
26
|
-
|
27
|
-
@interfaces = @attributes[:interfaces]
|
28
|
-
end
|
29
|
-
|
30
|
-
# @param child [Vedeu::Interface]
|
31
|
-
# @return [Vedeu::InterfaceCollection]
|
32
|
-
def add(child)
|
33
|
-
@interfaces = interfaces.add(child)
|
34
|
-
end
|
35
|
-
|
36
|
-
# @return [Vedeu::InterfaceCollection]
|
37
|
-
def interfaces
|
38
|
-
collection.coerce(@interfaces, self)
|
39
|
-
end
|
40
|
-
alias_method :value, :interfaces
|
41
|
-
|
42
|
-
# Composition objects do not have a parent.
|
43
|
-
#
|
44
|
-
# @return [NilClass]
|
45
|
-
def parent
|
46
|
-
nil
|
47
|
-
end
|
48
|
-
|
49
|
-
private
|
50
|
-
|
51
|
-
# The default values for a new instance of this class.
|
52
|
-
#
|
53
|
-
# @return [Hash]
|
54
|
-
def defaults
|
55
|
-
{
|
56
|
-
client: nil,
|
57
|
-
colour: nil,
|
58
|
-
interfaces: [],
|
59
|
-
repository: Vedeu.interfaces,
|
60
|
-
style: nil,
|
61
|
-
}
|
62
|
-
end
|
63
|
-
|
64
|
-
end # Composition
|
65
|
-
|
66
|
-
end # Vedeu
|