vedeu 0.6.6 → 0.6.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (81) hide show
  1. checksums.yaml +4 -4
  2. data/.codeclimate.yml +0 -30
  3. data/lib/vedeu/all.rb +0 -1
  4. data/lib/vedeu/api.rb +5 -139
  5. data/lib/vedeu/application/application_controller.rb +12 -10
  6. data/lib/vedeu/application/application_helper.rb +3 -3
  7. data/lib/vedeu/application/application_view.rb +7 -6
  8. data/lib/vedeu/application/controller.rb +16 -10
  9. data/lib/vedeu/bindings/application.rb +6 -3
  10. data/lib/vedeu/bindings/bindings.rb +7 -6
  11. data/lib/vedeu/bindings/document.rb +18 -18
  12. data/lib/vedeu/bindings/drb.rb +12 -8
  13. data/lib/vedeu/bindings/focus.rb +12 -9
  14. data/lib/vedeu/bindings/menus.rb +12 -11
  15. data/lib/vedeu/bindings/movement.rb +23 -22
  16. data/lib/vedeu/bindings/refresh.rb +13 -10
  17. data/lib/vedeu/bindings/visibility.rb +10 -8
  18. data/lib/vedeu/borders/all.rb +26 -0
  19. data/lib/vedeu/borders/dsl.rb +1 -23
  20. data/lib/vedeu/buffers/all.rb +12 -0
  21. data/lib/vedeu/buffers/buffer.rb +1 -10
  22. data/lib/vedeu/buffers/refresh.rb +57 -0
  23. data/lib/vedeu/buffers/virtual_buffer.rb +1 -1
  24. data/lib/vedeu/cursors/all.rb +9 -0
  25. data/lib/vedeu/cursors/cursor.rb +16 -0
  26. data/lib/vedeu/dsl/interface.rb +4 -4
  27. data/lib/vedeu/events/aliases.rb +28 -9
  28. data/lib/vedeu/events/collection.rb +1 -0
  29. data/lib/vedeu/events/trigger.rb +5 -3
  30. data/lib/vedeu/geometry/all.rb +7 -0
  31. data/lib/vedeu/geometry/position.rb +2 -2
  32. data/lib/vedeu/input/editor/editor.rb +1 -1
  33. data/lib/vedeu/log/log.rb +6 -0
  34. data/lib/vedeu/log/timer.rb +2 -2
  35. data/lib/vedeu/models/focus.rb +3 -0
  36. data/lib/vedeu/models/group.rb +13 -0
  37. data/lib/vedeu/models/interface.rb +17 -1
  38. data/lib/vedeu/models/toggleable.rb +2 -1
  39. data/lib/vedeu/models/views/collections/chars.rb +1 -0
  40. data/lib/vedeu/models/views/collections/lines.rb +1 -0
  41. data/lib/vedeu/models/views/collections/streams.rb +1 -0
  42. data/lib/vedeu/models/views/collections/view_collection.rb +1 -0
  43. data/lib/vedeu/models/views/line.rb +2 -2
  44. data/lib/vedeu/null/generic.rb +27 -4
  45. data/lib/vedeu/null/interface.rb +1 -32
  46. data/lib/vedeu/null/menu.rb +1 -16
  47. data/lib/vedeu/null/view.rb +1 -33
  48. data/lib/vedeu/options.rb +3 -0
  49. data/lib/vedeu/output/clear/named_group.rb +5 -0
  50. data/lib/vedeu/output/clear/named_interface.rb +5 -0
  51. data/lib/vedeu/output/direct.rb +2 -2
  52. data/lib/vedeu/output/viewport.rb +1 -1
  53. data/lib/vedeu/refresh/refresh_group.rb +1 -1
  54. data/lib/vedeu/runtime/application.rb +3 -0
  55. data/lib/vedeu/terminal/terminal.rb +3 -0
  56. data/lib/vedeu/version.rb +1 -1
  57. data/test/lib/vedeu/buffers/refresh_test.rb +54 -0
  58. data/test/lib/vedeu/null/generic_test.rb +18 -0
  59. data/test/lib/vedeu/null/interface_test.rb +4 -30
  60. data/test/lib/vedeu/null/menu_test.rb +1 -18
  61. data/test/lib/vedeu/null/view_test.rb +6 -31
  62. data/{examples → test/support}/colour_support.sh +0 -0
  63. data/{examples → test/support/examples}/borders_app.rb +0 -0
  64. data/{examples → test/support/examples}/configuration_app.rb +0 -0
  65. data/{examples → test/support/examples}/drb_app.rb +0 -0
  66. data/{examples → test/support/examples}/editor_app.rb +0 -0
  67. data/{examples → test/support/examples}/focus_app.rb +0 -0
  68. data/{examples → test/support/examples}/hello_world.rb +0 -0
  69. data/{examples → test/support/examples}/material_colours_app.rb +0 -0
  70. data/{examples → test/support/examples}/material_colours_app_20150721.svg +0 -0
  71. data/{examples → test/support/examples}/typed_commands/command.erb +0 -0
  72. data/{examples → test/support/examples}/typed_commands/output.erb +0 -0
  73. data/{examples → test/support/examples}/typed_commands/status.erb +0 -0
  74. data/{examples → test/support/examples}/typed_commands/typed_commands_app.rb +0 -0
  75. data/{examples → test/support/examples}/view_templates_app/default.erb +0 -0
  76. data/{examples → test/support/examples}/view_templates_app/prune.erb +0 -0
  77. data/{examples → test/support/examples}/view_templates_app/view_templates_app.rb +0 -0
  78. data/{examples → test/support/examples}/view_templates_app/wrap.erb +0 -0
  79. metadata +38 -21
  80. data/lib/vedeu/refresh/refresh_buffer.rb +0 -53
  81. data/test/lib/vedeu/refresh/refresh_buffer_test.rb +0 -50
@@ -13,7 +13,7 @@ module Vedeu
13
13
  #
14
14
  # @param message [String]
15
15
  # @param block [Proc]
16
- # @return [void]
16
+ # @return [void] The return value of the executed block.
17
17
  def timer(message = '', &block)
18
18
  new(message).measure(&block)
19
19
  end
@@ -32,7 +32,7 @@ module Vedeu
32
32
  # Write an entry to the log file stating how long a section of code took in
33
33
  # milliseconds. Useful for debugging performance.
34
34
  #
35
- # @return [void]
35
+ # @return [void] The return value of the executed block.
36
36
  def measure
37
37
  work = yield
38
38
 
@@ -46,6 +46,7 @@ module Vedeu
46
46
  # to set the initially focussed interface.
47
47
  #
48
48
  # @example
49
+ # Vedeu.trigger(:_focus_by_name_, name)
49
50
  # Vedeu.focus_by_name('name')
50
51
  #
51
52
  # @param name [String] The interface to focus; must be defined.
@@ -96,6 +97,7 @@ module Vedeu
96
97
  # Put the next interface relative to the current interfaces in focus.
97
98
  #
98
99
  # @example
100
+ # Vedeu.trigger(:_focus_next_)
99
101
  # Vedeu.focus_next
100
102
  #
101
103
  # @return [String]
@@ -125,6 +127,7 @@ module Vedeu
125
127
  # Put the previous interface relative to the current interface in focus.
126
128
  #
127
129
  # @example
130
+ # Vedeu.trigger(:_focus_prev_)
128
131
  # Vedeu.focus_previous
129
132
  #
130
133
  # @return [String]
@@ -124,6 +124,19 @@ module Vedeu
124
124
  self
125
125
  end
126
126
 
127
+ # Toggle the visibility of the group with the given name.
128
+ #
129
+ # @example
130
+ # Vedeu.trigger(:_toggle_group, name)
131
+ # Vedeu.toggle_group(name)
132
+ #
133
+ # @return [Vedeu::Group]
134
+ def toggle
135
+ super
136
+
137
+ self
138
+ end
139
+
127
140
  private
128
141
 
129
142
  # Returns the default options/attributes for this class.
@@ -22,7 +22,7 @@ module Vedeu
22
22
  attr_accessor :delay
23
23
 
24
24
  # @!attribute [rw] group
25
- # @return [void]
25
+ # @return [Symbol|String]
26
26
  attr_accessor :group
27
27
 
28
28
  # @!attribute [rw] name
@@ -83,6 +83,22 @@ module Vedeu
83
83
  Vedeu.buffers.by_name(name).show
84
84
  end
85
85
 
86
+ # Toggle the visibility of the interface with the given name.
87
+ #
88
+ # @example
89
+ # Vedeu.toggle_interface(name)
90
+ #
91
+ # @return [void]
92
+ def toggle
93
+ if visible?
94
+ hide
95
+
96
+ else
97
+ show
98
+
99
+ end
100
+ end
101
+
86
102
  private
87
103
 
88
104
  # The default values for a new instance of this class.
@@ -31,7 +31,8 @@ module Vedeu
31
31
  store
32
32
  end
33
33
 
34
- # Toggle the visible state and store the model.
34
+ # Toggle the visible state and store the model. When the model is
35
+ # hidden, then it is shown, and vice versa.
35
36
  #
36
37
  # @return [FalseClass|TrueClass]
37
38
  def toggle
@@ -4,6 +4,7 @@ module Vedeu
4
4
 
5
5
  # A collection of {Vedeu::Views::Char} instances.
6
6
  #
7
+ # @api private
7
8
  class Chars < Vedeu::Collection
8
9
 
9
10
  end # Chars
@@ -4,6 +4,7 @@ module Vedeu
4
4
 
5
5
  # A collection of {Vedeu::Views::Line} instances.
6
6
  #
7
+ # @api private
7
8
  class Lines < Vedeu::Collection
8
9
 
9
10
  end # Lines
@@ -4,6 +4,7 @@ module Vedeu
4
4
 
5
5
  # A collection of {Vedeu::Views::Stream} instances.
6
6
  #
7
+ # @api private
7
8
  class Streams < Vedeu::Collection
8
9
 
9
10
  end # Streams
@@ -4,6 +4,7 @@ module Vedeu
4
4
 
5
5
  # A collection of {Vedeu::Views::View} instances.
6
6
  #
7
+ # @api private
7
8
  class ViewCollection < Vedeu::Collection
8
9
 
9
10
  end # ViewCollection
@@ -38,8 +38,8 @@ module Vedeu
38
38
  end
39
39
  end
40
40
 
41
- # @param child [void]
42
- # @return [void]
41
+ # @param child [Vedeu::Views::Stream]
42
+ # @return [Vedeu::Views::Stream]
43
43
  def add(child)
44
44
  @value = value.add(child)
45
45
  end
@@ -6,6 +6,14 @@ module Vedeu
6
6
  #
7
7
  class Generic
8
8
 
9
+ # @!attribute [r] attributes
10
+ # @return [String]
11
+ attr_reader :attributes
12
+
13
+ # @!attribute [r] name
14
+ # @return [String]
15
+ attr_reader :name
16
+
9
17
  # Returns an instance of the Vedeu::Null::Generic class.
10
18
  #
11
19
  # @param attributes [Hash<Symbol => void>]
@@ -20,10 +28,25 @@ module Vedeu
20
28
  def null(*)
21
29
  nil
22
30
  end
23
- alias_method :add, :null
24
- alias_method :colour, :null
25
- alias_method :parent, :null
26
- alias_method :style, :null
31
+ alias_method :add, :null
32
+ alias_method :bottom_item, :null
33
+ alias_method :colour, :null
34
+ alias_method :current_item, :null
35
+ alias_method :deselect_item, :null
36
+ alias_method :hide, :null
37
+ alias_method :item, :null
38
+ alias_method :items, :null
39
+ alias_method :next_item, :null
40
+ alias_method :parent, :null
41
+ alias_method :prev_item, :null
42
+ alias_method :select_item, :null
43
+ alias_method :selected_item, :null
44
+ alias_method :show, :null
45
+ alias_method :style, :null
46
+ alias_method :toggle, :null
47
+ alias_method :top_item, :null
48
+ alias_method :view, :null
49
+ alias_method :zindex, :null
27
50
 
28
51
  # @return [Boolean]
29
52
  def null?
@@ -6,23 +6,14 @@ module Vedeu
6
6
 
7
7
  # Provides a non-existent model to swallow messages.
8
8
  #
9
- class Interface
9
+ class Interface < Vedeu::Null::Generic
10
10
 
11
11
  include Vedeu::Presentation
12
12
 
13
- # @!attribute [r] name
14
- # @return [String]
15
- attr_reader :name
16
-
17
13
  # @!attribute [r] attributes
18
14
  # @return [String]
19
15
  attr_reader :attributes
20
16
 
21
- # @!attribute [rw] visible
22
- # @return [String]
23
- attr_accessor :visible
24
- alias_method :visible?, :visible
25
-
26
17
  # Returns a new instance of Vedeu::Null::Interface.
27
18
  #
28
19
  # @param attributes [Hash<Symbol => void>]
@@ -34,28 +25,6 @@ module Vedeu
34
25
  @visible = false
35
26
  end
36
27
 
37
- # @return [NilClass]
38
- def null
39
- nil
40
- end
41
- alias_method :hide, :null
42
- alias_method :parent, :null
43
- alias_method :show, :null
44
- alias_method :toggle, :null
45
- alias_method :zindex, :null
46
-
47
- # @return [Boolean]
48
- def null?
49
- true
50
- end
51
-
52
- # Pretend to store this model in the repository.
53
- #
54
- # @return [Vedeu::Null::Interface]
55
- def store
56
- self
57
- end
58
-
59
28
  end # Interface
60
29
 
61
30
  end # Null
@@ -4,7 +4,7 @@ module Vedeu
4
4
 
5
5
  # Provides a non-existent model to swallow messages.
6
6
  #
7
- class Menu
7
+ class Menu < Vedeu::Null::Generic
8
8
 
9
9
  # Returns an instance of the Vedeu::Null::Menu class.
10
10
  #
@@ -16,21 +16,6 @@ module Vedeu
16
16
  @name = @attributes[:name]
17
17
  end
18
18
 
19
- # @return [NilClass]
20
- def item
21
- nil
22
- end
23
- alias_method :bottom_item, :item
24
- alias_method :current_item, :item
25
- alias_method :deselect_item, :item
26
- alias_method :items, :item
27
- alias_method :next_item, :item
28
- alias_method :prev_item, :item
29
- alias_method :select_item, :item
30
- alias_method :selected_item, :item
31
- alias_method :top_item, :item
32
- alias_method :view, :item
33
-
34
19
  end # Menu
35
20
 
36
21
  end # Null
@@ -6,23 +6,10 @@ module Vedeu
6
6
 
7
7
  # Provides a non-existent model to swallow messages.
8
8
  #
9
- class View
9
+ class View < Vedeu::Null::Generic
10
10
 
11
11
  include Vedeu::Presentation
12
12
 
13
- # @!attribute [r] name,
14
- # @return [String]
15
- attr_reader :name
16
-
17
- # @!attribute [r] attributes
18
- # @return [String]
19
- attr_reader :attributes
20
-
21
- # @!attribute [rw] visible
22
- # @return [String]
23
- attr_accessor :visible
24
- alias_method :visible?, :visible
25
-
26
13
  # Returns a new instance of Vedeu::Null::View.
27
14
  #
28
15
  # @param attributes [Hash<Symbol => void>]
@@ -34,25 +21,6 @@ module Vedeu
34
21
  @visible = false
35
22
  end
36
23
 
37
- # @return [NilClass]
38
- def null
39
- nil
40
- end
41
- alias_method :parent, :null
42
- alias_method :zindex, :null
43
-
44
- # @return [Boolean]
45
- def null?
46
- true
47
- end
48
-
49
- # Pretend to store this model in the repository.
50
- #
51
- # @return [Vedeu::Null::View]
52
- def store
53
- self
54
- end
55
-
56
24
  end # View
57
25
 
58
26
  end # Null
data/lib/vedeu/options.rb CHANGED
@@ -1,5 +1,8 @@
1
1
  module Vedeu
2
2
 
3
+ # An internal class for Vedeu to provide a consistent interface to
4
+ # options used by many classes.
5
+ #
3
6
  class Options
4
7
 
5
8
  # @param options [Hash]
@@ -10,6 +10,11 @@ module Vedeu
10
10
 
11
11
  class << self
12
12
 
13
+ # Clears the group of interfaces belonging to the given name.
14
+ #
15
+ # @example
16
+ # Vedeu.clear_by_group(name)
17
+ #
13
18
  # @param name [String]
14
19
  # @return [void]
15
20
  def render(name)
@@ -10,6 +10,11 @@ module Vedeu
10
10
 
11
11
  class << self
12
12
 
13
+ # Clear the interface with the given name.
14
+ #
15
+ # @example
16
+ # Vedeu.clear_by_name(name)
17
+ #
13
18
  # @return [Array<Array<Vedeu::Views::Char>>]
14
19
  # @see #initialize
15
20
  def render(name)
@@ -7,7 +7,7 @@ module Vedeu
7
7
  # @param value [String]
8
8
  # @param x [Fixnum]
9
9
  # @param y [Fixnum]
10
- # @return [void]
10
+ # @return [String]
11
11
  def self.write(value:, x:, y:)
12
12
  new(value: value, x: x, y: y).write
13
13
  end
@@ -24,7 +24,7 @@ module Vedeu
24
24
  @y = y || 1
25
25
  end
26
26
 
27
- # @return [void]
27
+ # @return [String]
28
28
  def write
29
29
  Vedeu::Terminal.output(output)
30
30
 
@@ -129,7 +129,7 @@ module Vedeu
129
129
  # @param dimension [Fixnum] Either the height or width.
130
130
  # @return [Fixnum]
131
131
  def content_offset(offset, dimension)
132
- if offset >= dimension && ((offset - dimension) > 0)
132
+ if offset >= dimension
133
133
  offset - dimension
134
134
 
135
135
  else
@@ -32,7 +32,7 @@ module Vedeu
32
32
  def by_name
33
33
  Vedeu.timer("Refresh Group: '#{group_name}'") do
34
34
  Vedeu.groups.by_name(group_name).by_zindex.each do |name|
35
- Vedeu::RefreshBuffer.by_name(name)
35
+ Vedeu::Buffers::Refresh.by_name(name)
36
36
  end
37
37
  end
38
38
  end
@@ -23,6 +23,9 @@ module Vedeu
23
23
  # encouraged to use this event to close any open buffers, save files,
24
24
  # empty trash, etc.
25
25
  #
26
+ # @example
27
+ # Vedeu.exit
28
+ #
26
29
  # @return [void]
27
30
  def stop
28
31
  Vedeu.trigger(:_cleanup_)
@@ -81,6 +81,9 @@ module Vedeu
81
81
 
82
82
  # Clears the entire terminal space.
83
83
  #
84
+ # @example
85
+ # Vedeu.clear
86
+ #
84
87
  # @return [String]
85
88
  def clear
86
89
  virtual.clear if Vedeu::Configuration.drb?
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.6.6'
4
+ VERSION = '0.6.7'
5
5
 
6
6
  end
@@ -0,0 +1,54 @@
1
+ require 'test_helper'
2
+
3
+ module Vedeu
4
+
5
+ module Buffers
6
+
7
+ describe Refresh do
8
+
9
+ let(:described) { Vedeu::Buffers::Refresh }
10
+ let(:instance) { described.new(_name) }
11
+ let(:_name) { 'Vedeu::Buffers::Refresh' }
12
+
13
+ describe '#initialize' do
14
+ it { instance.must_be_instance_of(described) }
15
+ it { instance.instance_variable_get('@name').must_equal(_name) }
16
+ end
17
+
18
+ describe '.by_name' do
19
+ subject { described.by_name(_name) }
20
+
21
+ context 'when the name is not present' do
22
+ let(:_name) { '' }
23
+
24
+ it { proc { subject }.must_raise(Vedeu::Error::MissingRequired) }
25
+ end
26
+
27
+ # describe '.by_name' do
28
+ # let(:_name) { 'aluminium' }
29
+ # let(:buffer) { Vedeu::Buffers::Null.new(name: _name) }
30
+ #
31
+ # subject { described.by_name(_name) }
32
+ #
33
+ # it {
34
+ # Vedeu.buffers.expects(:by_name).with(_name).returns(buffer)
35
+ # buffer.expects(:render)
36
+ # subject
37
+ # }
38
+ # end
39
+
40
+ context 'when the name is present' do
41
+ # @todo Add more tests.
42
+ # it { skip }
43
+ end
44
+ end
45
+
46
+ describe '#by_name' do
47
+ it { instance.must_respond_to(:by_name) }
48
+ end
49
+
50
+ end # Refresh
51
+
52
+ end # Buffers
53
+
54
+ end # Vedeu