vedeu 0.4.60 → 0.4.61
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/vedeu.rb +2 -0
- data/lib/vedeu/all.rb +8 -4
- data/lib/vedeu/{output → borders}/border.rb +0 -0
- data/lib/vedeu/{output → borders}/borders.rb +0 -0
- data/lib/vedeu/{output → borders}/render_border.rb +24 -18
- data/lib/vedeu/cursor/move.rb +5 -16
- data/lib/vedeu/cursor/reposition.rb +3 -17
- data/lib/vedeu/dsl/view.rb +1 -1
- data/lib/vedeu/geometry/coordinate.rb +21 -11
- data/lib/vedeu/geometry/geometry.rb +1 -1
- data/lib/vedeu/geometry/position.rb +2 -2
- data/lib/vedeu/output/compressor.rb +3 -7
- data/lib/vedeu/output/style.rb +1 -1
- data/lib/vedeu/plugins.rb +12 -13
- data/lib/vedeu/plugins/plugin.rb +4 -2
- data/lib/vedeu/repositories/collection.rb +9 -0
- data/lib/vedeu/templating/all.rb +9 -0
- data/lib/vedeu/templating/decoder.rb +62 -0
- data/lib/vedeu/templating/directive.rb +0 -1
- data/lib/vedeu/templating/encoder.rb +62 -0
- data/lib/vedeu/templating/helpers.rb +10 -22
- data/lib/vedeu/templating/post_processor.rb +81 -0
- data/lib/vedeu/templating/template.rb +1 -7
- data/lib/vedeu/terminal_mode.rb +2 -0
- data/lib/vedeu/version.rb +1 -1
- data/test/lib/vedeu/{output → borders}/border_test.rb +0 -0
- data/test/lib/vedeu/{output → borders}/borders_test.rb +0 -0
- data/test/lib/vedeu/{output → borders}/render_border_test.rb +0 -0
- data/test/lib/vedeu/geometry/coordinate_test.rb +20 -17
- data/test/lib/vedeu/geometry/position_test.rb +1 -1
- data/test/lib/vedeu/models/char_test.rb +17 -18
- data/test/lib/vedeu/output/compressor_test.rb +5 -5
- data/test/lib/vedeu/output/{renderers/all_test.rb → renderers_test.rb} +0 -0
- data/test/lib/vedeu/output/viewport_test.rb +63 -63
- data/test/lib/vedeu/plugins_test.rb +12 -6
- data/test/lib/vedeu/repositories/collection_test.rb +14 -0
- data/test/lib/vedeu/templating/decoder_test.rb +37 -0
- data/test/lib/vedeu/templating/encoder_test.rb +38 -0
- data/test/lib/vedeu/templating/helpers_test.rb +11 -0
- data/test/lib/vedeu/templating/{preprocessor_test.rb → post_processor_test.rb} +14 -18
- data/test/lib/vedeu/templating/template_test.rb +3 -2
- data/test/support/templates/{inline.erb → plain.erb} +0 -0
- metadata +25 -18
- data/lib/vedeu/templating/preprocessor.rb +0 -81
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6ceb6ac3ef4df98a7535ceeb37ae65a39d5a6645
|
|
4
|
+
data.tar.gz: 21bc34bf6d44e123fe9895603bef26832738b892
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 879388bbd80aff90f21b262568bda67262c509efaccda7570968bf3080a1951c2be6452fb46ef4f5fb7e36ab63e15c4e56c440effd6bea59775dfcf0e020c13d
|
|
7
|
+
data.tar.gz: 4b2e7aefea725739b77497a3133ae74efa074add21b67ee0c4591c1d646b9764fe15e13a74b8f697f620883ae0ab0168023b3d0612ada31c740192828bf64297
|
data/lib/vedeu.rb
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
$LIB_DIR = File.dirname(__FILE__) + '/../lib'
|
|
2
2
|
$LOAD_PATH.unshift($LIB_DIR) unless $LOAD_PATH.include?($LIB_DIR)
|
|
3
3
|
|
|
4
|
+
require 'base64'
|
|
4
5
|
require 'date'
|
|
5
6
|
require 'drb'
|
|
6
7
|
require 'erb'
|
|
@@ -14,6 +15,7 @@ require 'set'
|
|
|
14
15
|
require 'singleton'
|
|
15
16
|
require 'thread'
|
|
16
17
|
require 'time'
|
|
18
|
+
require 'zlib'
|
|
17
19
|
|
|
18
20
|
require 'thor'
|
|
19
21
|
|
data/lib/vedeu/all.rb
CHANGED
|
@@ -101,9 +101,12 @@ require 'vedeu/models/groups'
|
|
|
101
101
|
require 'vedeu/models/menu'
|
|
102
102
|
require 'vedeu/models/menus'
|
|
103
103
|
|
|
104
|
+
require 'vedeu/templating/all'
|
|
105
|
+
require 'vedeu/templating/encoder'
|
|
106
|
+
require 'vedeu/templating/decoder'
|
|
104
107
|
require 'vedeu/templating/helpers'
|
|
105
108
|
require 'vedeu/templating/directive'
|
|
106
|
-
require 'vedeu/templating/
|
|
109
|
+
require 'vedeu/templating/post_processor'
|
|
107
110
|
require 'vedeu/templating/template'
|
|
108
111
|
|
|
109
112
|
require 'vedeu/application/controller'
|
|
@@ -147,13 +150,14 @@ require 'vedeu/input/input'
|
|
|
147
150
|
require 'vedeu/input/keymap'
|
|
148
151
|
require 'vedeu/input/keymaps'
|
|
149
152
|
|
|
153
|
+
require 'vedeu/borders/render_border'
|
|
154
|
+
require 'vedeu/borders/border'
|
|
155
|
+
require 'vedeu/borders/borders'
|
|
156
|
+
|
|
150
157
|
require 'vedeu/output/clear/named_group'
|
|
151
158
|
require 'vedeu/output/clear/named_interface'
|
|
152
159
|
require 'vedeu/output/esc'
|
|
153
160
|
require 'vedeu/output/presentation'
|
|
154
|
-
require 'vedeu/output/render_border'
|
|
155
|
-
require 'vedeu/output/border'
|
|
156
|
-
require 'vedeu/output/borders'
|
|
157
161
|
require 'vedeu/output/compressor'
|
|
158
162
|
require 'vedeu/output/style'
|
|
159
163
|
require 'vedeu/output/text'
|
|
File without changes
|
|
File without changes
|
|
@@ -87,22 +87,32 @@ module Vedeu
|
|
|
87
87
|
|
|
88
88
|
# @return [Vedeu::Char]
|
|
89
89
|
def build_bottom_left
|
|
90
|
-
build(bottom_left, :bottom_left,
|
|
90
|
+
build(bottom_left, :bottom_left, yn, x) if left?
|
|
91
91
|
end
|
|
92
92
|
|
|
93
93
|
# @return [Vedeu::Char]
|
|
94
94
|
def build_bottom_right
|
|
95
|
-
build(bottom_right, :bottom_right,
|
|
95
|
+
build(bottom_right, :bottom_right, yn, xn) if right?
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
# @return [Array<Vedeu::Char>]
|
|
99
|
+
def build_top
|
|
100
|
+
build_horizontal(:bottom_horizontal, y)
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
# @return [Array<Vedeu::Char>]
|
|
104
|
+
def build_bottom
|
|
105
|
+
build_horizontal(:bottom_horizontal, yn)
|
|
96
106
|
end
|
|
97
107
|
|
|
98
108
|
# @return [Vedeu::Char]
|
|
99
109
|
def build_top_left
|
|
100
|
-
build(top_left, :top_left,
|
|
110
|
+
build(top_left, :top_left, y, x) if left?
|
|
101
111
|
end
|
|
102
112
|
|
|
103
113
|
# @return [Vedeu::Char]
|
|
104
114
|
def build_top_right
|
|
105
|
-
build(top_right, :top_right,
|
|
115
|
+
build(top_right, :top_right, y, xn) if right?
|
|
106
116
|
end
|
|
107
117
|
|
|
108
118
|
# Renders the bottom border for the interface.
|
|
@@ -111,11 +121,7 @@ module Vedeu
|
|
|
111
121
|
def bottom
|
|
112
122
|
return [] unless bottom?
|
|
113
123
|
|
|
114
|
-
[
|
|
115
|
-
build_bottom_left,
|
|
116
|
-
build_horizontal(:bottom_horizontal, yn),
|
|
117
|
-
build_bottom_right,
|
|
118
|
-
].compact
|
|
124
|
+
[build_bottom_left, build_bottom, build_bottom_right].compact
|
|
119
125
|
end
|
|
120
126
|
|
|
121
127
|
# @return [Vedeu::Geometry]
|
|
@@ -128,7 +134,7 @@ module Vedeu
|
|
|
128
134
|
# @return [Array<Vedeu::Char>]
|
|
129
135
|
def build_horizontal(position, y_coordinate)
|
|
130
136
|
Array.new(width) do |ix|
|
|
131
|
-
build(horizontal, position,
|
|
137
|
+
build(horizontal, position, y_coordinate, (bx + ix))
|
|
132
138
|
end
|
|
133
139
|
end
|
|
134
140
|
|
|
@@ -147,7 +153,7 @@ module Vedeu
|
|
|
147
153
|
def left(iy = 0)
|
|
148
154
|
return [] unless left?
|
|
149
155
|
|
|
150
|
-
build(vertical, :left_vertical,
|
|
156
|
+
build(vertical, :left_vertical, (by + iy), x)
|
|
151
157
|
end
|
|
152
158
|
|
|
153
159
|
# Renders the right border for the interface.
|
|
@@ -157,7 +163,7 @@ module Vedeu
|
|
|
157
163
|
def right(iy = 0)
|
|
158
164
|
return [] unless right?
|
|
159
165
|
|
|
160
|
-
build(vertical, :right_vertical,
|
|
166
|
+
build(vertical, :right_vertical, (by + iy), xn)
|
|
161
167
|
end
|
|
162
168
|
|
|
163
169
|
# Renders the top border for the interface.
|
|
@@ -179,13 +185,13 @@ module Vedeu
|
|
|
179
185
|
#
|
|
180
186
|
# @return [Array<Vedeu::Char>]
|
|
181
187
|
def titlebar
|
|
182
|
-
return
|
|
188
|
+
return build_top unless title? && title_fits?
|
|
189
|
+
|
|
190
|
+
build_top.each_with_index do |char, index|
|
|
191
|
+
next if index == 0 || index > title_characters.size
|
|
183
192
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
char.border = nil
|
|
187
|
-
char.value = title_characters[(index - 1)]
|
|
188
|
-
end
|
|
193
|
+
char.border = nil
|
|
194
|
+
char.value = title_characters[(index - 1)]
|
|
189
195
|
end
|
|
190
196
|
end
|
|
191
197
|
|
data/lib/vedeu/cursor/move.rb
CHANGED
|
@@ -177,23 +177,9 @@ module Vedeu
|
|
|
177
177
|
|
|
178
178
|
private
|
|
179
179
|
|
|
180
|
-
# Returns the cursors x position based on its current offset.
|
|
181
|
-
#
|
|
182
|
-
# @return [Fixnum]
|
|
183
|
-
def x_position
|
|
184
|
-
coordinate.x_position(ox)
|
|
185
|
-
end
|
|
186
|
-
|
|
187
|
-
# Returns the cursors y position based on its current offset.
|
|
188
|
-
#
|
|
189
|
-
# @return [Fixnum]
|
|
190
|
-
def y_position
|
|
191
|
-
coordinate.y_position(oy)
|
|
192
|
-
end
|
|
193
|
-
|
|
194
180
|
# @return [Vedeu::Coordinate]
|
|
195
181
|
def coordinate
|
|
196
|
-
@coordinate ||= Vedeu::Coordinate.new(name)
|
|
182
|
+
@coordinate ||= Vedeu::Coordinate.new(name, oy, ox)
|
|
197
183
|
end
|
|
198
184
|
|
|
199
185
|
# @see Vedeu::Cursors#by_name
|
|
@@ -203,7 +189,10 @@ module Vedeu
|
|
|
203
189
|
|
|
204
190
|
# @return [Hash<Symbol => void>]
|
|
205
191
|
def cursor_attributes
|
|
206
|
-
cursor.attributes.merge!(x:
|
|
192
|
+
cursor.attributes.merge!(x: coordinate.x_position,
|
|
193
|
+
y: coordinate.y_position,
|
|
194
|
+
ox: ox,
|
|
195
|
+
oy: oy)
|
|
207
196
|
end
|
|
208
197
|
|
|
209
198
|
# @see Vedeu::Geometries#by_name
|
|
@@ -27,8 +27,8 @@ module Vedeu
|
|
|
27
27
|
# @return [Vedeu::Cursor]
|
|
28
28
|
def to
|
|
29
29
|
result = entity.new(name: name,
|
|
30
|
-
y: y_position,
|
|
31
|
-
x: x_position,
|
|
30
|
+
y: coordinate.y_position,
|
|
31
|
+
x: coordinate.x_position,
|
|
32
32
|
oy: y,
|
|
33
33
|
ox: x).store
|
|
34
34
|
|
|
@@ -61,21 +61,7 @@ module Vedeu
|
|
|
61
61
|
|
|
62
62
|
# @return [Vedeu::Coordinate]
|
|
63
63
|
def coordinate
|
|
64
|
-
@coordinate ||= Vedeu::Coordinate.new(name)
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
# Returns the cursors x position based on the desired x position.
|
|
68
|
-
#
|
|
69
|
-
# @return [Fixnum]
|
|
70
|
-
def x_position
|
|
71
|
-
coordinate.x_position(x)
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
# Returns the cursors y position based on the desired y position.
|
|
75
|
-
#
|
|
76
|
-
# @return [Fixnum]
|
|
77
|
-
def y_position
|
|
78
|
-
coordinate.y_position(y)
|
|
64
|
+
@coordinate ||= Vedeu::Coordinate.new(name, y, x)
|
|
79
65
|
end
|
|
80
66
|
|
|
81
67
|
end # Reposition
|
data/lib/vedeu/dsl/view.rb
CHANGED
|
@@ -163,7 +163,7 @@ module Vedeu
|
|
|
163
163
|
# interface back buffers until a refresh event occurs. When the refresh
|
|
164
164
|
# event is triggered, the back buffers are swapped into the front
|
|
165
165
|
# buffers and the content here will be rendered to
|
|
166
|
-
# {Vedeu::Terminal
|
|
166
|
+
# {Vedeu::Terminal#output}.
|
|
167
167
|
#
|
|
168
168
|
# Vedeu.views do
|
|
169
169
|
# view 'some_interface' do
|
|
@@ -19,9 +19,13 @@ module Vedeu
|
|
|
19
19
|
# Returns a new instance of Vedeu::Coordinate.
|
|
20
20
|
#
|
|
21
21
|
# @param name [String]
|
|
22
|
+
# @param oy [Fixnum]
|
|
23
|
+
# @param ox [Fixnum]
|
|
22
24
|
# @return [Vedeu::Coordinate]
|
|
23
|
-
def initialize(name)
|
|
25
|
+
def initialize(name, oy, ox)
|
|
24
26
|
@name = name
|
|
27
|
+
@ox = ox
|
|
28
|
+
@oy = oy
|
|
25
29
|
end
|
|
26
30
|
|
|
27
31
|
# Returns the maximum y coordinate for an area.
|
|
@@ -69,17 +73,16 @@ module Vedeu
|
|
|
69
73
|
# y_position(2) # => 9
|
|
70
74
|
# y_position(7) # => 11
|
|
71
75
|
#
|
|
72
|
-
# @param index [Fixnum]
|
|
73
76
|
# @return [Fixnum]
|
|
74
|
-
def y_position
|
|
75
|
-
value = if
|
|
77
|
+
def y_position
|
|
78
|
+
value = if oy <= 0
|
|
76
79
|
y
|
|
77
80
|
|
|
78
|
-
elsif
|
|
81
|
+
elsif oy > yn_index
|
|
79
82
|
yn
|
|
80
83
|
|
|
81
84
|
else
|
|
82
|
-
y_range[
|
|
85
|
+
y_range[oy]
|
|
83
86
|
|
|
84
87
|
end
|
|
85
88
|
|
|
@@ -95,17 +98,16 @@ module Vedeu
|
|
|
95
98
|
# x_position(2) # => 6
|
|
96
99
|
# x_position(15) # => 13
|
|
97
100
|
#
|
|
98
|
-
# @param index [Fixnum]
|
|
99
101
|
# @return [Fixnum]
|
|
100
|
-
def x_position
|
|
101
|
-
value = if
|
|
102
|
+
def x_position
|
|
103
|
+
value = if ox <= 0
|
|
102
104
|
x
|
|
103
105
|
|
|
104
|
-
elsif
|
|
106
|
+
elsif ox > xn_index
|
|
105
107
|
xn
|
|
106
108
|
|
|
107
109
|
else
|
|
108
|
-
x_range[
|
|
110
|
+
x_range[ox]
|
|
109
111
|
|
|
110
112
|
end
|
|
111
113
|
|
|
@@ -118,6 +120,14 @@ module Vedeu
|
|
|
118
120
|
# @return [String]
|
|
119
121
|
attr_reader :name
|
|
120
122
|
|
|
123
|
+
# @!attribute [r] oy
|
|
124
|
+
# @return [Fixnum]
|
|
125
|
+
attr_reader :oy
|
|
126
|
+
|
|
127
|
+
# @!attribute [r] ox
|
|
128
|
+
# @return [Fixnum]
|
|
129
|
+
attr_reader :ox
|
|
130
|
+
|
|
121
131
|
private
|
|
122
132
|
|
|
123
133
|
# @see Vedeu::Borders#by_name
|
|
@@ -87,9 +87,9 @@ module Vedeu
|
|
|
87
87
|
# @yieldreturn [void] Returns the block wrapped in position escape
|
|
88
88
|
# sequences.
|
|
89
89
|
def to_s
|
|
90
|
-
return sequence
|
|
90
|
+
return [sequence, yield].join if block_given?
|
|
91
91
|
|
|
92
|
-
|
|
92
|
+
sequence
|
|
93
93
|
end
|
|
94
94
|
alias_method :to_str, :to_s
|
|
95
95
|
|
|
@@ -22,7 +22,8 @@ module Vedeu
|
|
|
22
22
|
@style = ''
|
|
23
23
|
end
|
|
24
24
|
|
|
25
|
-
# @note
|
|
25
|
+
# @note
|
|
26
|
+
# Takes approximately ~25ms for 2100 chars. (2015-07-25)
|
|
26
27
|
# @return [String]
|
|
27
28
|
def render
|
|
28
29
|
if Vedeu::Configuration.compression?
|
|
@@ -57,12 +58,7 @@ module Vedeu
|
|
|
57
58
|
# @return [String]
|
|
58
59
|
def uncompress
|
|
59
60
|
out = ''
|
|
60
|
-
Array(output).flatten.each
|
|
61
|
-
out << char.position.to_s
|
|
62
|
-
out << char.colour.to_s
|
|
63
|
-
out << char.style.to_s
|
|
64
|
-
out << char.value
|
|
65
|
-
end
|
|
61
|
+
Array(output).flatten.each { |char| out << char.to_s }
|
|
66
62
|
out
|
|
67
63
|
end
|
|
68
64
|
|
data/lib/vedeu/output/style.rb
CHANGED
data/lib/vedeu/plugins.rb
CHANGED
|
@@ -13,11 +13,9 @@ module Vedeu
|
|
|
13
13
|
|
|
14
14
|
# Loads all plugins that are not enabled.
|
|
15
15
|
#
|
|
16
|
-
# @return [void]
|
|
16
|
+
# @return [Array<void>]
|
|
17
17
|
def load
|
|
18
|
-
plugins.each
|
|
19
|
-
plugin.load! unless plugin.enabled?
|
|
20
|
-
end
|
|
18
|
+
plugins.each { |plugin| plugin.load! unless plugin.enabled? }
|
|
21
19
|
end
|
|
22
20
|
|
|
23
21
|
# Register plugin with name in an internal array.
|
|
@@ -26,21 +24,21 @@ module Vedeu
|
|
|
26
24
|
# @param plugin [Vedeu::Plugin]
|
|
27
25
|
# @return [void]
|
|
28
26
|
def register(name, plugin = false)
|
|
29
|
-
if plugin &&
|
|
30
|
-
plugins << plugin
|
|
31
|
-
end
|
|
27
|
+
plugins << plugin if plugin && not_loaded?(name)
|
|
32
28
|
end
|
|
33
29
|
|
|
34
30
|
# Find all installed plugins and store them.
|
|
35
31
|
#
|
|
36
|
-
# @return [void]
|
|
32
|
+
# @return [Array<void>]
|
|
37
33
|
def find
|
|
38
34
|
Gem.refresh
|
|
39
35
|
|
|
40
36
|
Gem::Specification.each do |gem|
|
|
41
37
|
next unless gem.name =~ /^#{prefix}/
|
|
38
|
+
|
|
42
39
|
plugin_name = gem.name[/^#{prefix}-(.*)/, 1]
|
|
43
|
-
|
|
40
|
+
|
|
41
|
+
register(plugin_name, Vedeu::Plugin.new(plugin_name, gem))
|
|
44
42
|
end
|
|
45
43
|
|
|
46
44
|
plugins
|
|
@@ -48,9 +46,10 @@ module Vedeu
|
|
|
48
46
|
|
|
49
47
|
# Return a list of all plugin names as strings.
|
|
50
48
|
#
|
|
51
|
-
# @return [
|
|
49
|
+
# @return [Hash]
|
|
52
50
|
def names
|
|
53
|
-
|
|
51
|
+
collection = {}
|
|
52
|
+
plugins.each_with_object(collection) do |hash, plugin|
|
|
54
53
|
hash[plugin.name] = plugin
|
|
55
54
|
hash
|
|
56
55
|
end
|
|
@@ -68,8 +67,8 @@ module Vedeu
|
|
|
68
67
|
#
|
|
69
68
|
# @param name [String]
|
|
70
69
|
# @return [Boolean]
|
|
71
|
-
def
|
|
72
|
-
plugins.any? { |plugin| plugin.gem_name
|
|
70
|
+
def not_loaded?(name)
|
|
71
|
+
plugins.empty? || plugins.any? { |plugin| plugin.gem_name != name }
|
|
73
72
|
end
|
|
74
73
|
|
|
75
74
|
# @return [String]
|
data/lib/vedeu/plugins/plugin.rb
CHANGED
|
@@ -40,9 +40,11 @@ module Vedeu
|
|
|
40
40
|
begin
|
|
41
41
|
require gem_name unless enabled?
|
|
42
42
|
rescue LoadError => error
|
|
43
|
-
|
|
43
|
+
raise Vedeu::VedeuError,
|
|
44
|
+
"Unable to load plugin #{gem_name} due to #{error}."
|
|
44
45
|
rescue => error
|
|
45
|
-
|
|
46
|
+
raise Vedeu::VedeuError,
|
|
47
|
+
"require '#{gem_name}' failed with #{error}."
|
|
46
48
|
end
|
|
47
49
|
|
|
48
50
|
@enabled = true
|