vedeu 0.8.18 → 0.8.19

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: bed6cd0c3c695df9f891c552340787a070f6f54a
4
- data.tar.gz: 8dcad64d499e1cf9dffb5dda7451b050f9a09a12
3
+ metadata.gz: b277bb2a5c69ac52c885232267ee82fdb002277d
4
+ data.tar.gz: edc448e3e5a89a5ad038bae149d9a2adbff9f939
5
5
  SHA512:
6
- metadata.gz: 179414aaacba620522ea4005d8c353609ea5deab9e9ad4d7d0d5431ee31bc634ca32c42df602056a41078f8eb3a8a779758fe2a1d07257c71a037e41d1420460
7
- data.tar.gz: 1ddf063acbd38734c3098c5cc88b4cb1bf0aa9240ec8d9f806be1c82c2107d80890d1b3d9c639b81264ccfcc6e230832a6b7a7e0cdb78fa659b8c7664b863722
6
+ metadata.gz: a615ad7a66fa2d035a9b996cbe45346d5c0d5d649135a4f0dff83d9e407e6e06dedaaacfcb225f8dbfe1beeee7e528054fd659c71f17d510d192f261a803620d
7
+ data.tar.gz: e9e791cb8613bbaaf07d54904dd052254dd5fd4bb7f09f3caa7df79db934ae8a9ae5186d404849665d631661acdff2c911a4f47f066474ff72c7589cb8157f35
@@ -315,7 +315,7 @@ module Vedeu
315
315
  enabled: false,
316
316
  horizontal: Vedeu.esc.horizontal,
317
317
  left_vertical: nil,
318
- name: '',
318
+ name: nil,
319
319
  parent: nil,
320
320
  repository: Vedeu.borders,
321
321
  right_vertical: nil,
@@ -120,6 +120,13 @@ module Vedeu
120
120
  [(bottom_left if left?), captionbar, (bottom_right if right?)].compact
121
121
  end
122
122
 
123
+ # @return [Array<void>]
124
+ def bottom_border
125
+ build_collection(bordered_width) do |ix|
126
+ bottom_horizontal.dup.tap { |cell| cell.position = [yn, bx + ix] }
127
+ end
128
+ end
129
+
123
130
  # @macro geometry_by_name
124
131
  def geometry
125
132
  Vedeu.geometries.by_name(name)
@@ -141,9 +148,7 @@ module Vedeu
141
148
  # @return [Array<void>]
142
149
  def left
143
150
  build_collection(bordered_height) do |iy|
144
- cell = left_vertical.dup
145
- cell.position = [by + iy, x]
146
- cell
151
+ left_vertical.dup.tap { |cell| cell.position = [by + iy, x] }
147
152
  end
148
153
  end
149
154
 
@@ -152,9 +157,7 @@ module Vedeu
152
157
  # @return [Array<void>]
153
158
  def right
154
159
  build_collection(bordered_height) do |iy|
155
- cell = right_vertical.dup
156
- cell.position = [by + iy, xn]
157
- cell
160
+ right_vertical.dup.tap { |cell| cell.position = [by + iy, xn] }
158
161
  end
159
162
  end
160
163
 
@@ -170,34 +173,29 @@ module Vedeu
170
173
  [(top_left if left?), titlebar, (top_right if right?)].compact
171
174
  end
172
175
 
176
+ # @return [Array<void>]
177
+ def top_border
178
+ build_collection(bordered_width) do |ix|
179
+ top_horizontal.dup.tap { |cell| cell.position = [y, bx + ix] }
180
+ end
181
+ end
182
+
173
183
  # An optional caption for when the bottom border is to be shown.
174
184
  #
175
185
  # @return (see Vedeu::Borders::Caption#render)
176
186
  def captionbar
177
- characters = build_collection(bordered_width) do |ix|
178
- cell = bottom_horizontal.dup
179
- cell.position = [yn, bx + ix]
180
- cell
181
- end
187
+ return bottom_border unless present?(caption)
182
188
 
183
- return characters unless present?(caption)
184
-
185
- Vedeu::Borders::Caption.render(name, caption, characters)
189
+ Vedeu::Borders::Caption.render(name, caption, bottom_border)
186
190
  end
187
191
 
188
192
  # An optional title for when the top border is to be shown.
189
193
  #
190
194
  # @return (see Vedeu::Borders::Title#render)
191
195
  def titlebar
192
- characters = build_collection(bordered_width) do |ix|
193
- cell = top_horizontal.dup
194
- cell.position = [y, bx + ix]
195
- cell
196
- end
197
-
198
- return characters unless present?(title)
196
+ return top_border unless present?(title)
199
197
 
200
- Vedeu::Borders::Title.render(name, title, characters)
198
+ Vedeu::Borders::Title.render(name, title, top_border)
201
199
  end
202
200
 
203
201
  # Build a collection with the given size of objects given within
@@ -136,20 +136,7 @@ module Vedeu
136
136
  #
137
137
  # @return [Array<Array<Array<Vedeu::Cells::Char>>>]
138
138
  def render
139
- current = if back?
140
- swap
141
-
142
- front
143
-
144
- elsif front?
145
- front
146
-
147
- elsif previous?
148
- previous
149
-
150
- end
151
-
152
- Vedeu::Output::Viewport.render(current) unless current.nil?
139
+ Vedeu::Output::Viewport.render(current)
153
140
  end
154
141
 
155
142
  # Returns the number of lines of content for the buffer or 0 if
@@ -174,12 +161,28 @@ module Vedeu
174
161
 
175
162
  private
176
163
 
164
+ # @return [Vedeu::Views::View|NilClass]
165
+ def current
166
+ if back?
167
+ swap
168
+
169
+ front
170
+
171
+ elsif front?
172
+ front
173
+
174
+ elsif previous?
175
+ previous
176
+
177
+ end
178
+ end
179
+
177
180
  # @macro defaults_method
178
181
  def defaults
179
182
  {
180
183
  back: nil,
181
184
  front: nil,
182
- name: '',
185
+ name: nil,
183
186
  previous: nil,
184
187
  repository: Vedeu.buffers,
185
188
  }
@@ -20,6 +20,11 @@ module Vedeu
20
20
  alias foreground null
21
21
  alias style null
22
22
 
23
+ # @return [String]
24
+ def to_ast
25
+ ''
26
+ end
27
+
23
28
  # Return an empty hash as most escape sequences won't make
24
29
  # sense as JSON.
25
30
  #
@@ -44,6 +49,11 @@ module Vedeu
44
49
  end
45
50
  alias to_str to_s
46
51
 
52
+ # @return [String]
53
+ def text
54
+ ''
55
+ end
56
+
47
57
  # @return [Symbol]
48
58
  def type
49
59
  :cursor
@@ -91,7 +91,7 @@ module Vedeu
91
91
  def defaults
92
92
  {
93
93
  colour: {},
94
- name: '',
94
+ name: nil,
95
95
  position: nil,
96
96
  style: '',
97
97
  value: '',
@@ -28,6 +28,11 @@ module Vedeu
28
28
  alias foreground null
29
29
  alias style null
30
30
 
31
+ # @return [String]
32
+ def text
33
+ ''
34
+ end
35
+
31
36
  # Return an empty hash as most escape sequences won't make
32
37
  # sense as JSON.
33
38
  #
@@ -30,6 +30,7 @@ module Vedeu
30
30
  info: [:white, :light_grey],
31
31
  input: [:light_yellow, :yellow],
32
32
  magenta: [:light_magenta, :magenta],
33
+ nonevent: [:magenta, :light_magenta],
33
34
  output: [:light_yellow, :yellow],
34
35
  red: [:light_red, :red],
35
36
  render: [:light_green, :green],
@@ -231,7 +231,7 @@ module Vedeu
231
231
  # @macro defaults_method
232
232
  def defaults
233
233
  {
234
- name: '',
234
+ name: nil,
235
235
  ox: 1,
236
236
  oy: 1,
237
237
  repository: Vedeu.cursors,
@@ -246,11 +246,6 @@ module Vedeu
246
246
  Vedeu::Cells::Cursor.new(position: position, value: visibility)
247
247
  end
248
248
 
249
- # @return [Hash<Symbol => Fixnum>]
250
- def new_attributes(new_y = y, new_x = x, new_oy = oy, new_ox = ox)
251
- attributes.merge!(x: new_x, y: new_y, ox: new_ox, oy: new_oy)
252
- end
253
-
254
249
  # Returns the escape sequence for setting the visibility of the
255
250
  # cursor.
256
251
  #
@@ -19,10 +19,7 @@ module Vedeu
19
19
  :ox,
20
20
  :oy,
21
21
  :render,
22
- :visible,
23
- :visible?,
24
- :x,
25
- :y
22
+ :visible?
26
23
 
27
24
  def_delegators :geometry,
28
25
  :bordered_height,
@@ -52,13 +49,12 @@ module Vedeu
52
49
  #
53
50
  # @return [Array]
54
51
  def by_name
55
- Vedeu.trigger(:_refresh_view_content_, name) if refresh_view?
56
-
57
52
  Vedeu.log(type: :cursor,
58
- message: "Refreshing cursor: '#{name}' (x:#{x}, y:#{y}, " \
59
- "ox:#{ox}, oy:#{oy}, visible:#{visible})")
53
+ message: "Refreshing cursor: (#{cursor.inspect})")
60
54
 
61
55
  render
56
+
57
+ Vedeu.trigger(:_refresh_view_content_, name) if refresh_view?
62
58
  end
63
59
 
64
60
  private
@@ -171,12 +171,9 @@ module Vedeu
171
171
 
172
172
  end
173
173
 
174
- if view_model?
174
+ if view_model? || line_model? || stream_model?
175
175
  model.add(l)
176
176
 
177
- elsif line_model? || stream_model?
178
- model.add([l])
179
-
180
177
  else
181
178
  raise Vedeu::Error::Fatal,
182
179
  "Cannot add stream to '#{model.class.name}' model."
@@ -173,7 +173,7 @@ module Vedeu
173
173
  # @macro defaults_method
174
174
  def defaults
175
175
  {
176
- name: '',
176
+ name: nil,
177
177
  ox: 0,
178
178
  oy: 0,
179
179
  x: 0,
@@ -42,7 +42,7 @@ module Vedeu
42
42
  # @return [Array]
43
43
  def trigger
44
44
  if Vedeu.config.debug? && results.empty?
45
- Vedeu.log(type: :event,
45
+ Vedeu.log(type: :nonevent,
46
46
  message: "No action for: '#{name.inspect}'")
47
47
  end
48
48
 
@@ -66,7 +66,7 @@ module Vedeu
66
66
  def defaults
67
67
  {
68
68
  direction: :none,
69
- name: '',
69
+ name: nil,
70
70
  offset: 1,
71
71
  }
72
72
  end
@@ -162,7 +162,7 @@ module Vedeu
162
162
  def defaults
163
163
  {
164
164
  members: Set.new,
165
- name: '',
165
+ name: nil,
166
166
  repository: Vedeu.groups,
167
167
  visible: true,
168
168
  }
@@ -88,7 +88,7 @@ module Vedeu
88
88
  # @macro defaults_method
89
89
  def defaults
90
90
  {
91
- name: '',
91
+ name: nil,
92
92
  keys: [],
93
93
  repository: Vedeu.keymaps,
94
94
  }
@@ -155,7 +155,7 @@ module Vedeu
155
155
  delay: 0.0,
156
156
  editable: false,
157
157
  group: '',
158
- name: '',
158
+ name: nil,
159
159
  parent: nil,
160
160
  repository: Vedeu.interfaces,
161
161
  style: :normal,
@@ -206,7 +206,7 @@ module Vedeu
206
206
  client: nil,
207
207
  collection: [],
208
208
  current: 0,
209
- name: '',
209
+ name: nil,
210
210
  repository: Vedeu.menus,
211
211
  selected: nil,
212
212
  }
@@ -61,8 +61,10 @@ module Vedeu
61
61
  #
62
62
  # @return [Array]
63
63
  def content
64
- @_content ||= output.content.reject do |cell|
65
- cell.class == Vedeu::Cells::Empty
64
+ @_content ||= Vedeu.timer('Removing empty cells...') do
65
+ output.content.reject do |cell|
66
+ cell.class == Vedeu::Cells::Empty
67
+ end
66
68
  end
67
69
  end
68
70
 
@@ -35,7 +35,7 @@ module Vedeu
35
35
  # @param (see #initialize)
36
36
  # @return (see #render)
37
37
  def self.render(view)
38
- new(view).render
38
+ new(view).render if view
39
39
  end
40
40
 
41
41
  # Returns a new instance of Vedeu::Output::Viewport.
@@ -39,9 +39,7 @@ module Vedeu
39
39
 
40
40
  output.each do |row|
41
41
  row.each do |char|
42
- next unless renderable?(char) &&
43
- positionable?(char) &&
44
- escapable?(char)
42
+ next unless positionable?(char)
45
43
 
46
44
  empty[char.position.y - 1][char.position.x - 1] = char.to_ast
47
45
  end
@@ -50,39 +48,6 @@ module Vedeu
50
48
  empty
51
49
  end
52
50
 
53
- # @return [Array<Class>]
54
- def renderables
55
- [
56
- Vedeu::Cells::Border,
57
- Vedeu::Cells::BottomHorizontal,
58
- Vedeu::Cells::BottomLeft,
59
- Vedeu::Cells::BottomRight,
60
- Vedeu::Cells::Corner,
61
- Vedeu::Cells::Char,
62
- Vedeu::Cells::Clear,
63
- Vedeu::Cells::Cursor,
64
- Vedeu::Cells::Empty,
65
- Vedeu::Cells::Escape,
66
- Vedeu::Cells::Horizontal,
67
- Vedeu::Cells::LeftVertical,
68
- Vedeu::Cells::RightVertical,
69
- Vedeu::Cells::TopHorizontal,
70
- Vedeu::Cells::TopLeft,
71
- Vedeu::Cells::TopRight,
72
- Vedeu::Cells::Vertical,
73
- ]
74
- end
75
-
76
- # @return [Boolean]
77
- def renderable?(char)
78
- renderables.include?(char.class)
79
- end
80
-
81
- # @return [Boolean]
82
- def escapable?(char)
83
- char.respond_to?(:to_ast)
84
- end
85
-
86
51
  end # Escape
87
52
 
88
53
  end # Renderers
@@ -34,9 +34,7 @@ module Vedeu
34
34
 
35
35
  output.each do |row|
36
36
  row.each do |char|
37
- next unless renderable?(char) &&
38
- positionable?(char) &&
39
- textual?(char)
37
+ next unless positionable?(char)
40
38
 
41
39
  empty[char.position.y - 1][char.position.x - 1] = char.text
42
40
  end
@@ -45,37 +43,6 @@ module Vedeu
45
43
  empty
46
44
  end
47
45
 
48
- # @return [Array<Class>]
49
- def renderables
50
- [
51
- Vedeu::Cells::Border,
52
- Vedeu::Cells::BottomHorizontal,
53
- Vedeu::Cells::BottomLeft,
54
- Vedeu::Cells::BottomRight,
55
- Vedeu::Cells::Corner,
56
- Vedeu::Cells::Char,
57
- Vedeu::Cells::Clear,
58
- Vedeu::Cells::Empty,
59
- Vedeu::Cells::Horizontal,
60
- Vedeu::Cells::LeftVertical,
61
- Vedeu::Cells::RightVertical,
62
- Vedeu::Cells::TopHorizontal,
63
- Vedeu::Cells::TopLeft,
64
- Vedeu::Cells::TopRight,
65
- Vedeu::Cells::Vertical,
66
- ]
67
- end
68
-
69
- # @return [Boolean]
70
- def renderable?(char)
71
- renderables.include?(char.class)
72
- end
73
-
74
- # @return [Boolean]
75
- def textual?(char)
76
- char.respond_to?(:text)
77
- end
78
-
79
46
  end # Text
80
47
 
81
48
  end # Renderers
@@ -5,7 +5,8 @@ module Vedeu
5
5
  module Repositories
6
6
 
7
7
  # Convert an Array into an object which has some meaning in the
8
- # context it is being used.
8
+ # context it is being used. Various classes throughout Vedeu
9
+ # subclass this class.
9
10
  #
10
11
  # @api private
11
12
  #
@@ -60,10 +61,10 @@ module Vedeu
60
61
  # @return [Vedeu::Repositories::Collection]
61
62
  def add(other)
62
63
  if other.is_a?(Vedeu::Repositories::Collection)
63
- return self.class.coerce(other, parent, name) if empty?
64
+ return klass.coerce(other, parent, name) if empty?
64
65
 
65
66
  else
66
- self.class.new(@collection += Array(other), parent, name)
67
+ klass.new(@collection += Array(other), parent, name)
67
68
 
68
69
  end
69
70
  end
@@ -77,6 +78,15 @@ module Vedeu
77
78
  end
78
79
  alias to_str to_s
79
80
 
81
+ private
82
+
83
+ # Return the inheriting class.
84
+ #
85
+ # @return [void]
86
+ def klass
87
+ self.class
88
+ end
89
+
80
90
  end # Collection
81
91
 
82
92
  end # Repositories
data/lib/vedeu/version.rb CHANGED
@@ -3,6 +3,6 @@
3
3
  module Vedeu
4
4
 
5
5
  # The current version of Vedeu.
6
- VERSION = '0.8.18'
6
+ VERSION = '0.8.19'
7
7
 
8
8
  end
@@ -125,14 +125,10 @@ module Vedeu
125
125
  # @macro raise_missing_required
126
126
  # @return [Vedeu::Views::View]
127
127
  def update_buffer(refresh = false)
128
- if present?(name)
129
- buffer.add(self, refresh)
128
+ raise Vedeu::Error::MissingRequired,
129
+ 'Cannot store a view without a name.' unless present?(name)
130
130
 
131
- else
132
- raise Vedeu::Error::MissingRequired,
133
- 'Cannot store a view without a name.'
134
-
135
- end
131
+ buffer.add(self, refresh)
136
132
 
137
133
  self
138
134
  end
@@ -58,6 +58,12 @@ module Vedeu
58
58
  it { subject.must_equal("\e[?25h") }
59
59
  end
60
60
 
61
+ describe '#to_ast' do
62
+ subject { instance.to_ast }
63
+
64
+ it { subject.must_equal('') }
65
+ end
66
+
61
67
  describe '#to_h' do
62
68
  let(:expected) {
63
69
  {
@@ -96,6 +102,12 @@ module Vedeu
96
102
  it { instance.must_respond_to(:to_str) }
97
103
  end
98
104
 
105
+ describe '#text' do
106
+ subject { instance.text }
107
+
108
+ it { subject.must_equal('') }
109
+ end
110
+
99
111
  describe '#type' do
100
112
  subject { instance.type }
101
113
 
@@ -20,7 +20,7 @@ module Vedeu
20
20
  }
21
21
  }
22
22
  let(:colour) { {} }
23
- let(:_name) { '' }
23
+ let(:_name) { nil }
24
24
  let(:position) { Vedeu::Geometries::Position.new(1, 1) }
25
25
  let(:style) { '' }
26
26
  let(:_value) { '' }
@@ -58,6 +58,12 @@ module Vedeu
58
58
  it { subject.must_equal("\e[?25h") }
59
59
  end
60
60
 
61
+ describe '#text' do
62
+ subject { instance.text }
63
+
64
+ it { subject.must_equal('') }
65
+ end
66
+
61
67
  describe '#to_h' do
62
68
  let(:expected) {
63
69
  {
@@ -48,7 +48,7 @@ module Vedeu
48
48
  context 'when a name is not given' do
49
49
  let(:_name) {}
50
50
 
51
- it { instance.instance_variable_get('@name').must_equal('') }
51
+ it { instance.instance_variable_get('@name').must_equal(nil) }
52
52
  end
53
53
 
54
54
  context 'when an offset is given' do
@@ -55,7 +55,13 @@ module Vedeu
55
55
 
56
56
  subject { described.render(view) }
57
57
 
58
- context 'when the interface is visible' do
58
+ context 'when the view is empty or nil' do
59
+ let(:view) {}
60
+
61
+ it { subject.must_equal(nil) }
62
+ end
63
+
64
+ context 'when the view is visible' do
59
65
  context 'and Vedeu is ready' do
60
66
  it do
61
67
  Vedeu.expects(:render_output)
@@ -62,7 +62,7 @@ module Vedeu
62
62
  # Vedeu::Views::Stream.new(
63
63
  # client: nil,
64
64
  # colour: Vedeu::Colours::Colour.coerce(attributes),
65
- # name: '',
65
+ # name: nil,
66
66
  # parent: nil,
67
67
  # style: Vedeu::Presentation::Style.new,
68
68
  # value: 'colour text')
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.8.18
4
+ version: 0.8.19
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gavin Laking
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-02 00:00:00.000000000 Z
11
+ date: 2016-03-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: guard