vedeu 0.6.31 → 0.6.32

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e129ccc6fe63f7b1f7b48ab9030683d79fe8544c
4
- data.tar.gz: fab4cf9d158706ff5670b11c59bfaf1f03710683
3
+ metadata.gz: 2fc9f2ae69352f9b6c21d8d8607082bb988cff48
4
+ data.tar.gz: 9a0d1207af8e078b58cccadab420b3465e00b816
5
5
  SHA512:
6
- metadata.gz: f76de0943d7be6e18efc10e248acac5232be21608228f45766a4815dd9e6bda0488dc7d304793fa6dea38aceadbf8bbcbba2694fe9763aff645db8d7b8f37b58
7
- data.tar.gz: 8e9ef60497f7132a022a87d8223dddb9b3e486f3887ada7ffc276143dab0dc4c35341a141104eb2c8e5b4621ced3d1de2d00517bfa1aa315b75da4ae9b355f42
6
+ metadata.gz: 2a17c83991be48b4ccbee939f304a72e3e4f2401c2793782b469403ae9386020bb2e36b0afdec9b5c42471045b9262a1c9e23a6ee50c3d6812506ee638480c3e
7
+ data.tar.gz: c7149fbd4b90a7d5eb4e2fecabcafca828cb4805b76c86b369441f37db3b91b3e7077988c7cda7bcde08ef5f5f9ec4c9baf0afdb3c4968a8e257b0a490dda6aa
@@ -72,7 +72,7 @@ class HelloWorldsApp
72
72
  line
73
73
  line { centre "Press 'q' to exit,", width: 24 }
74
74
  line { centre " 'w' to switch worlds.", width: 24 }
75
- line { centre "#{Vedeu.trigger(:_cursor_position_, Vedeu.focus)" }
75
+ line { centre "#{Vedeu.trigger(:_cursor_position_, Vedeu.focus)}" }
76
76
  end
77
77
  end
78
78
  end
@@ -109,9 +109,12 @@ module Vedeu
109
109
  #
110
110
  # @return [Array<Array<Array<Vedeu::Views::Char>>>]
111
111
  def render
112
- swap if back?
112
+ if back?
113
+ swap
113
114
 
114
- if front?
115
+ Vedeu::Output::Viewport.render(front)
116
+
117
+ elsif front?
115
118
  Vedeu::Output::Viewport.render(front)
116
119
 
117
120
  elsif previous?
@@ -11,7 +11,7 @@ module Vedeu
11
11
  null Vedeu::Buffers::Null
12
12
  real Vedeu::Buffers::Buffer
13
13
 
14
- end # Buffers
14
+ end # Repository
15
15
 
16
16
  class Buffer
17
17
 
@@ -127,7 +127,7 @@ module Vedeu
127
127
  # @param name [String|Symbol] The name of the interface.
128
128
  # @return [Hash]
129
129
  def new_attributes(name)
130
- attributes.merge!(existing_attributes(name))
130
+ existing_attributes(name).merge!(attributes)
131
131
  end
132
132
 
133
133
  # Retrieve the attributes of the interface by name.
@@ -9,6 +9,51 @@ module Vedeu
9
9
 
10
10
  include Vedeu::DSL
11
11
 
12
+ class << self
13
+
14
+ # Register a menu by name which will display a collection of
15
+ # items for your users to select; and provide interactivity
16
+ # within your application.
17
+ #
18
+ # @param name [String|Symbol]
19
+ # @param block [Proc] A set of attributes which define the
20
+ # features of the menu. See {Vedeu::Menus::DSL#items} and
21
+ # {Vedeu::Menus::DSL#name}.
22
+ #
23
+ # @example
24
+ # Vedeu.menu :my_interface do
25
+ # items [:item_1, :item_2, :item_3]
26
+ # # ...
27
+ # end
28
+ #
29
+ # Vedeu.menu do
30
+ # name :menus_must_have_a_name
31
+ # items Track.all_my_favourites
32
+ # # ...
33
+ # end
34
+ #
35
+ # @raise [Vedeu::Error::RequiresBlock]
36
+ # @return [API::Menu]
37
+ def menu(name = '', &block)
38
+ fail Vedeu::Error::RequiresBlock unless block_given?
39
+
40
+ attributes = { client: client(&block), name: name }
41
+
42
+ Vedeu::Menus::Menu.build(attributes, &block).store
43
+ end
44
+
45
+ private
46
+
47
+ # Returns the client object which called the DSL method.
48
+ #
49
+ # @param block [Proc]
50
+ # @return [Object]
51
+ def client(&block)
52
+ eval('self', block.binding)
53
+ end
54
+
55
+ end # Eigenclass
56
+
12
57
  # Add an individual item to the menu.
13
58
  #
14
59
  # @param element [Object] An object you wish to add to the
@@ -34,35 +34,6 @@ module Vedeu
34
34
  # @return [Fixnum]
35
35
  attr_accessor :selected
36
36
 
37
- # Register a menu by name which will display a collection of
38
- # items for your users to select; and provide interactivity
39
- # within your application.
40
- #
41
- # @param name [String|Symbol]
42
- # @param block [Proc] A set of attributes which define the
43
- # features of the menu. See {Vedeu::Menus::DSL#items} and
44
- # {Vedeu::Menus::DSL#name}.
45
- #
46
- # @example
47
- # Vedeu.menu :my_interface do
48
- # items [:item_1, :item_2, :item_3]
49
- # # ...
50
- # end
51
- #
52
- # Vedeu.menu do
53
- # name :menus_must_have_a_name
54
- # items Track.all_my_favourites
55
- # # ...
56
- # end
57
- #
58
- # @raise [Vedeu::Error::RequiresBlock]
59
- # @return [API::Menu]
60
- def self.menu(name = '', &block)
61
- fail Vedeu::Error::RequiresBlock unless block_given?
62
-
63
- build(name: name, &block).store
64
- end
65
-
66
37
  # Returns a new instance of Vedeu::Menus::Menu.
67
38
  #
68
39
  # @param attributes [Hash]
@@ -229,7 +200,7 @@ module Vedeu
229
200
  end # Menus
230
201
 
231
202
  # @!method menu
232
- # @see Vedeu::Menus::Menu.menu
233
- def_delegators Vedeu::Menus::Menu, :menu
203
+ # @see Vedeu::Menus::DSL.menu
204
+ def_delegators Vedeu::Menus::DSL, :menu
234
205
 
235
206
  end # Vedeu
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.31'.freeze
4
+ VERSION = '0.6.32'.freeze
5
5
 
6
6
  end
@@ -110,6 +110,43 @@ module Vedeu
110
110
  }
111
111
 
112
112
  subject { instance.render }
113
+
114
+ context 'when there is new content on the back buffer' do
115
+ let(:back) {
116
+ Vedeu::Views::View.new(value: [Vedeu::Views::Line.new])
117
+ }
118
+
119
+ it {
120
+ Vedeu::Output::Viewport.expects(:render)
121
+ subject
122
+ }
123
+ end
124
+
125
+ context 'when there is existing content on the front buffer' do
126
+ let(:front) {
127
+ Vedeu::Views::View.new(value: [Vedeu::Views::Line.new])
128
+ }
129
+
130
+ it {
131
+ Vedeu::Output::Viewport.expects(:render)
132
+ subject
133
+ }
134
+ end
135
+
136
+ context 'when there is content on the previous buffer' do
137
+ let(:previous) {
138
+ Vedeu::Views::View.new(value: [Vedeu::Views::Line.new])
139
+ }
140
+
141
+ it {
142
+ Vedeu::Output::Viewport.expects(:render)
143
+ subject
144
+ }
145
+ end
146
+
147
+ context 'when there is no content on any buffer' do
148
+ it { subject.must_equal(nil) }
149
+ end
113
150
  end
114
151
 
115
152
  end # Buffer
@@ -5,6 +5,26 @@ module Vedeu
5
5
  module DSL
6
6
 
7
7
  describe Shared do
8
+
9
+ let(:described) { Vedeu::DSL::Shared }
10
+ let(:instance) { Class.include(described).new }
11
+
12
+ describe '#border' do
13
+ context 'when the block is not given' do
14
+ subject { instance.border }
15
+
16
+ it { proc { subject }.must_raise(Vedeu::Error::RequiresBlock) }
17
+ end
18
+ end
19
+
20
+ describe '#geometry' do
21
+ context 'when the required block is not given' do
22
+ subject { instance.geometry }
23
+
24
+ it { proc { subject }.must_raise(Vedeu::Error::RequiresBlock) }
25
+ end
26
+ end
27
+
8
28
  end # Shared
9
29
 
10
30
  end # DSL
@@ -63,7 +63,7 @@ module Vedeu
63
63
 
64
64
  it { subject.must_be_instance_of(Vedeu::Views::Lines) }
65
65
 
66
- context 'when the required block is not provided' do
66
+ context 'when the required block is not given' do
67
67
  subject { instance.lines }
68
68
 
69
69
  it { proc { subject }.must_raise(Vedeu::Error::RequiresBlock) }
@@ -47,8 +47,6 @@ module Vedeu
47
47
  subject { instance.to_a }
48
48
 
49
49
  context 'when there are no lines' do
50
- let(:lines) { Vedeu::Editor::Lines.new }
51
-
52
50
  it { subject.must_equal([]) }
53
51
  end
54
52
 
@@ -67,51 +65,47 @@ module Vedeu
67
65
  end
68
66
  end
69
67
 
70
- # describe '#viewport' do
71
- # subject { instance.viewport }
72
-
73
- # context 'when there are no lines' do
74
- # let(:lines) { Vedeu::Editor::Lines.new }
75
-
76
- # it { subject.must_equal([]) }
77
- # end
78
-
79
- # context 'when there are lines' do
80
- # let(:lines) {
81
- # Vedeu::Editor::Lines.new([
82
- # Vedeu::Editor::Line.new('Hydrogen'),
83
- # Vedeu::Editor::Line.new('Helium'),
84
- # Vedeu::Editor::Line.new('Lithium'),
85
- # Vedeu::Editor::Line.new('Beryllium'),
86
- # Vedeu::Editor::Line.new('Boron'),
87
- # ])
88
- # }
89
-
90
- # it { subject.must_equal(['elium', 'ithiu', 'eryll']) }
91
-
92
- # context 'when oy is near the bottom' do
93
- # let(:oy) { 6 }
68
+ describe '#viewport' do
69
+ subject { instance.viewport }
94
70
 
95
- # it { subject.must_equal([]) }
96
- # end
97
-
98
- # context 'when ox is nearly past the content width' do
99
- # let(:oy) { 5 }
100
- # let(:ox) { 10 }
101
-
102
- # it 'returns only that which is visible, discarding empty lines' do
103
- # subject.must_equal([])
104
- # end
105
- # end
71
+ context 'when there are no lines' do
72
+ it { subject.must_equal([]) }
73
+ end
106
74
 
107
- # context 'when both oy and ox are effectively out of range' do
108
- # let(:oy) { 10 }
109
- # let(:ox) { 20 }
75
+ context 'when there are lines' do
76
+ let(:lines) {
77
+ Vedeu::Editor::Lines.new([
78
+ Vedeu::Editor::Line.new('Hydrogen'),
79
+ Vedeu::Editor::Line.new('Helium'),
80
+ Vedeu::Editor::Line.new('Lithium'),
81
+ Vedeu::Editor::Line.new('Beryllium'),
82
+ Vedeu::Editor::Line.new('Boron'),
83
+ ])
84
+ }
85
+ let(:expected) {
86
+ [
87
+ "\e[1;1H\e[39m\e[49m\e[24m\e[22m\e[27me",
88
+ "\e[1;2H\e[39m\e[49m\e[24m\e[22m\e[27ml",
89
+ "\e[1;3H\e[39m\e[49m\e[24m\e[22m\e[27mi",
90
+ "\e[1;4H\e[39m\e[49m\e[24m\e[22m\e[27mu",
91
+ "\e[1;5H\e[39m\e[49m\e[24m\e[22m\e[27mm",
92
+ "\e[2;1H\e[39m\e[49m\e[24m\e[22m\e[27mi",
93
+ "\e[2;2H\e[39m\e[49m\e[24m\e[22m\e[27mt",
94
+ "\e[2;3H\e[39m\e[49m\e[24m\e[22m\e[27mh",
95
+ "\e[2;4H\e[39m\e[49m\e[24m\e[22m\e[27mi",
96
+ "\e[2;5H\e[39m\e[49m\e[24m\e[22m\e[27mu",
97
+ "\e[3;1H\e[39m\e[49m\e[24m\e[22m\e[27me",
98
+ "\e[3;2H\e[39m\e[49m\e[24m\e[22m\e[27mr",
99
+ "\e[3;3H\e[39m\e[49m\e[24m\e[22m\e[27my",
100
+ "\e[3;4H\e[39m\e[49m\e[24m\e[22m\e[27ml",
101
+ "\e[3;5H\e[39m\e[49m\e[24m\e[22m\e[27ml"
102
+ ]
103
+ }
110
104
 
111
- # it { subject.must_equal([]) }
112
- # end
113
- # end
114
- # end
105
+ it { subject.size.must_equal(15) }
106
+ it { subject.map(&:to_s).must_equal(expected) }
107
+ end
108
+ end
115
109
 
116
110
  end # Cropper
117
111
 
@@ -4,6 +4,33 @@ module Vedeu
4
4
 
5
5
  module Error
6
6
 
7
+ describe ActionNotFound do
8
+ end
9
+
10
+ describe ControllerNotFound do
11
+ end
12
+
13
+ describe Fatal do
14
+ end
15
+
16
+ describe Interrupt do
17
+ end
18
+
19
+ describe InvalidSyntax do
20
+ end
21
+
22
+ describe MissingRequired do
23
+ end
24
+
25
+ describe ModelNotFound do
26
+ end
27
+
28
+ describe ModeSwitch do
29
+ end
30
+
31
+ describe NotImplemented do
32
+ end
33
+
7
34
  describe OutOfRange do
8
35
 
9
36
  let(:described) { Vedeu::Error::OutOfRange }
@@ -29,10 +29,10 @@ module Vedeu
29
29
  end
30
30
 
31
31
  context 'when the name is present' do
32
- it {
33
- Vedeu::Groups::Refresh.expects(:by_name).with(_name)
34
- subject
35
- }
32
+ # it {
33
+ # Vedeu.expects(:trigger).with(:_refresh_view_)
34
+ # subject
35
+ # }
36
36
  end
37
37
  end
38
38
 
@@ -42,44 +42,6 @@ module Vedeu
42
42
  end
43
43
  end
44
44
 
45
- describe '#border' do
46
- after { Vedeu.borders.reset }
47
-
48
- context 'when the block is not given' do
49
- subject { instance.border }
50
-
51
- it { proc { subject }.must_raise(Vedeu::Error::RequiresBlock) }
52
- end
53
-
54
- context 'when the block is given' do
55
- subject { instance.border { } }
56
-
57
- it { subject.must_be_instance_of(Vedeu::Borders::Border) }
58
-
59
- context 'when the name is not given' do
60
- it 'uses the interface name for storing the border' do
61
- subject.name.must_equal('actinium')
62
- end
63
- end
64
-
65
- context 'when the name is given' do
66
- subject { instance.border('magnesium') { } }
67
-
68
- it 'uses the name for storing the border' do
69
- subject.name.must_equal('magnesium')
70
- end
71
- end
72
- end
73
- end
74
-
75
- describe '#border!' do
76
- after { Vedeu.borders.reset }
77
-
78
- subject { instance.border! }
79
-
80
- it { subject.must_be_instance_of(Vedeu::Borders::Border) }
81
- end
82
-
83
45
  describe '#cursor' do
84
46
  let(:_value) {}
85
47
 
@@ -172,34 +134,6 @@ module Vedeu
172
134
  end
173
135
  end
174
136
 
175
- describe '#geometry' do
176
- context 'when the required block is not provided' do
177
- subject { instance.geometry }
178
-
179
- it { proc { subject }.must_raise(Vedeu::Error::RequiresBlock) }
180
- end
181
-
182
- context 'when the block is given' do
183
- subject { instance.geometry { } }
184
-
185
- it { subject.must_be_instance_of(Vedeu::Geometry::Geometry) }
186
-
187
- context 'when the name is not given' do
188
- it 'uses the interface name for storing the geometry' do
189
- subject.name.must_equal('actinium')
190
- end
191
- end
192
-
193
- context 'when the name is given' do
194
- subject { instance.geometry('magnesium') { } }
195
-
196
- it 'uses the name for storing the geometry' do
197
- subject.name.must_equal('magnesium')
198
- end
199
- end
200
- end
201
- end
202
-
203
137
  describe '#group' do
204
138
  let(:_value) { 'elements' }
205
139
 
@@ -18,6 +18,22 @@ module Vedeu
18
18
  let(:collection) { [:sodium, :magnesium, :aluminium, :silicon] }
19
19
  let(:menu_name) { 'elements' }
20
20
 
21
+ describe '.menu' do
22
+ subject {
23
+ described.menu('elements') do
24
+ # ...
25
+ end
26
+ }
27
+
28
+ it { subject.must_be_instance_of(Vedeu::Menus::Menu) }
29
+
30
+ context 'when the block is not given' do
31
+ subject { described.menu }
32
+
33
+ it { proc { subject }.must_raise(Vedeu::Error::RequiresBlock) }
34
+ end
35
+ end
36
+
21
37
  describe '#item' do
22
38
  let(:_value) { :platinum }
23
39
 
@@ -21,22 +21,6 @@ module Vedeu
21
21
  let(:current) { 0 }
22
22
  let(:selected) {}
23
23
 
24
- describe '.menu' do
25
- subject {
26
- described.menu('elements') do
27
- # ...
28
- end
29
- }
30
-
31
- it { subject.must_be_instance_of(described) }
32
-
33
- context 'when the block is not given' do
34
- subject { described.menu }
35
-
36
- it { proc { subject }.must_raise(Vedeu::Error::RequiresBlock) }
37
- end
38
- end
39
-
40
24
  describe '#initialize' do
41
25
  it { instance.must_be_instance_of(described) }
42
26
  it {
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.6.31
4
+ version: 0.6.32
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-10-11 00:00:00.000000000 Z
11
+ date: 2015-10-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: guard