vedeu 0.1.9 → 0.1.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/vedeu.rb +43 -17
- data/lib/vedeu/api/api.rb +21 -0
- data/lib/vedeu/api/base.rb +7 -15
- data/lib/vedeu/api/events.rb +5 -10
- data/lib/vedeu/api/grid.rb +0 -2
- data/lib/vedeu/api/interface.rb +15 -37
- data/lib/vedeu/api/line.rb +0 -3
- data/lib/vedeu/{instrumentation.rb → api/log.rb} +2 -5
- data/lib/vedeu/api/store.rb +3 -9
- data/lib/vedeu/api/stream.rb +0 -2
- data/lib/vedeu/api/view.rb +4 -15
- data/lib/vedeu/application.rb +1 -5
- data/lib/vedeu/configuration.rb +0 -2
- data/lib/vedeu/launcher.rb +0 -3
- data/lib/vedeu/models/attributes/background.rb +0 -4
- data/lib/vedeu/models/attributes/foreground.rb +0 -4
- data/lib/vedeu/models/attributes/interface_collection.rb +3 -8
- data/lib/vedeu/models/attributes/line_collection.rb +0 -5
- data/lib/vedeu/models/attributes/stream_collection.rb +0 -5
- data/lib/vedeu/models/colour.rb +0 -5
- data/lib/vedeu/models/composition.rb +0 -15
- data/lib/vedeu/models/geometry.rb +0 -5
- data/lib/vedeu/models/interface.rb +0 -14
- data/lib/vedeu/models/line.rb +0 -6
- data/lib/vedeu/models/stream.rb +0 -5
- data/lib/vedeu/models/style.rb +0 -4
- data/lib/vedeu/output/buffers.rb +13 -4
- data/lib/vedeu/output/render.rb +1 -4
- data/lib/vedeu/output/view.rb +7 -3
- data/lib/vedeu/support/input.rb +0 -3
- data/lib/vedeu/support/menu.rb +0 -5
- data/lib/vedeu/support/terminal.rb +0 -4
- data/test/lib/vedeu/api/events_test.rb +0 -1
- data/test/lib/vedeu/api/grid_test.rb +0 -2
- data/test/lib/vedeu/api/interface_test.rb +0 -1
- data/test/lib/vedeu/api/store_test.rb +0 -1
- data/test/lib/vedeu/api/view_test.rb +1 -4
- data/test/lib/vedeu/configuration_test.rb +0 -1
- data/test/lib/vedeu/models/attributes/collection_test.rb +0 -1
- data/test/lib/vedeu/models/attributes/interface_collection_test.rb +0 -5
- data/test/lib/vedeu/models/attributes/line_collection_test.rb +0 -2
- data/test/lib/vedeu/models/attributes/stream_collection_test.rb +0 -2
- data/test/lib/vedeu/models/colour_test.rb +0 -1
- data/test/lib/vedeu/models/composition_test.rb +14 -34
- data/test/lib/vedeu/models/geometry_test.rb +0 -1
- data/test/lib/vedeu/models/interface_test.rb +0 -1
- data/test/lib/vedeu/models/line_test.rb +0 -1
- data/test/lib/vedeu/models/stream_test.rb +0 -1
- data/test/lib/vedeu/models/style_test.rb +0 -1
- data/test/lib/vedeu/output/buffers_test.rb +0 -2
- data/test/lib/vedeu/output/clear_test.rb +0 -3
- data/test/lib/vedeu/output/render_test.rb +0 -3
- data/test/lib/vedeu/support/esc_test.rb +0 -1
- data/test/lib/vedeu/support/input_test.rb +0 -1
- data/test/lib/vedeu/support/menu_test.rb +0 -1
- data/test/lib/vedeu/support/terminal_test.rb +0 -1
- data/test/support/model_test_data.json +437 -0
- data/test/test_helper.rb +4 -2
- data/vedeu.gemspec +1 -1
- metadata +6 -44
- data/lib/vedeu/support/wordwrap.rb +0 -88
- data/test/lib/vedeu/api/base_test.rb +0 -12
- data/test/lib/vedeu/api/line_test.rb +0 -10
- data/test/lib/vedeu/api/stream_test.rb +0 -12
- data/test/lib/vedeu/application_test.rb +0 -10
- data/test/lib/vedeu/launcher_test.rb +0 -7
- data/test/lib/vedeu/models/attributes/background_test.rb +0 -8
- data/test/lib/vedeu/models/attributes/foreground_test.rb +0 -8
- data/test/lib/vedeu/output/view_test.rb +0 -9
- data/test/lib/vedeu/support/wordwrap_test.rb +0 -56
- data/test/lib/vedeu_test.rb +0 -10
- data/test/support/json/int1_lin1_str1.json +0 -10
- data/test/support/json/int1_lin1_str3.json +0 -18
- data/test/support/json/int1_lin2_str1.json +0 -17
- data/test/support/json/int1_lin2_str3.json +0 -33
- data/test/support/json/int1_lin2_str3_styles.json +0 -43
- data/test/support/json/int2_lin1_str1.json +0 -20
- data/test/support/json/int2_lin1_str3.json +0 -36
- data/test/support/json/int2_lin2_str1.json +0 -34
- data/test/support/json/int2_lin2_str3.json +0 -66
- data/test/support/json/int2_lin2_str3_styles.json +0 -158
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8aeb09ef744842c704e9bdf1e1fb5b4aedc8f130
|
4
|
+
data.tar.gz: 84c802a8a7d76a20896f2062dc150f2a02294acb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ad4a0e07634064d86fc758f62a6bdba2d17366e5295e890bac15024991149a0910c1a90ce125ea227cf740ca871def5b3bd88547a12ac2f9f9c84ce713e06613
|
7
|
+
data.tar.gz: 269d83fef585811e1b3ea07b261809b405f7753827a2a24f8f0a2e964be7c44e5438bce495954d1551da4ca261dc2fb79de1680cf970577cdf70688d3cfdbfb5
|
data/lib/vedeu.rb
CHANGED
@@ -1,30 +1,56 @@
|
|
1
|
-
|
1
|
+
module Vedeu
|
2
|
+
|
3
|
+
def self.included(receiver)
|
4
|
+
receiver.send(:include, API)
|
5
|
+
receiver.extend(API)
|
6
|
+
end
|
2
7
|
|
8
|
+
end
|
9
|
+
|
10
|
+
require 'date'
|
11
|
+
require 'forwardable'
|
12
|
+
require 'io/console'
|
13
|
+
require 'logger'
|
14
|
+
require 'optparse'
|
15
|
+
|
16
|
+
require 'virtus'
|
17
|
+
|
18
|
+
require 'vedeu/api/api'
|
19
|
+
require 'vedeu/api/base'
|
3
20
|
require 'vedeu/api/events'
|
4
21
|
require 'vedeu/api/grid'
|
5
22
|
require 'vedeu/api/interface'
|
6
23
|
require 'vedeu/api/line'
|
24
|
+
require 'vedeu/api/log'
|
7
25
|
require 'vedeu/api/store'
|
8
26
|
require 'vedeu/api/stream'
|
9
27
|
require 'vedeu/api/view'
|
10
|
-
require 'vedeu/output/view'
|
11
28
|
|
12
|
-
require 'vedeu/
|
29
|
+
require 'vedeu/application'
|
30
|
+
require 'vedeu/configuration'
|
13
31
|
require 'vedeu/launcher'
|
14
32
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
33
|
+
require 'vedeu/models/attributes/background'
|
34
|
+
require 'vedeu/models/attributes/collection'
|
35
|
+
require 'vedeu/models/attributes/colour_translator'
|
36
|
+
require 'vedeu/models/attributes/foreground'
|
37
|
+
require 'vedeu/models/attributes/interface_collection'
|
38
|
+
require 'vedeu/models/attributes/line_collection'
|
39
|
+
require 'vedeu/models/attributes/stream_collection'
|
40
|
+
require 'vedeu/models/composition'
|
41
|
+
require 'vedeu/support/terminal'
|
42
|
+
require 'vedeu/models/geometry'
|
43
|
+
require 'vedeu/models/colour'
|
44
|
+
require 'vedeu/models/style'
|
45
|
+
require 'vedeu/models/interface'
|
46
|
+
require 'vedeu/models/line'
|
47
|
+
require 'vedeu/models/stream'
|
21
48
|
|
22
|
-
|
23
|
-
|
24
|
-
|
49
|
+
require 'vedeu/output/buffers'
|
50
|
+
require 'vedeu/output/clear'
|
51
|
+
require 'vedeu/output/render'
|
52
|
+
require 'vedeu/output/view'
|
25
53
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
end
|
30
|
-
end
|
54
|
+
require 'vedeu/support/esc'
|
55
|
+
require 'vedeu/support/input'
|
56
|
+
require 'vedeu/support/menu'
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Vedeu
|
2
|
+
module API
|
3
|
+
def interface(name, &block)
|
4
|
+
API::Interface.save(name, &block)
|
5
|
+
end
|
6
|
+
|
7
|
+
def log(message)
|
8
|
+
API::Log.logger.debug(message)
|
9
|
+
end
|
10
|
+
|
11
|
+
# def render(object = nil)
|
12
|
+
# Vedeu::View.render(object)
|
13
|
+
# end
|
14
|
+
|
15
|
+
def view(name, &block)
|
16
|
+
API::View.build(name, &block)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
extend API
|
21
|
+
end
|
data/lib/vedeu/api/base.rb
CHANGED
@@ -6,25 +6,17 @@ module Vedeu
|
|
6
6
|
end
|
7
7
|
|
8
8
|
def initialize(attributes = {}, &block)
|
9
|
-
@attributes
|
9
|
+
@attributes = attributes
|
10
|
+
@self_before_instance_eval = eval('self', block.binding)
|
10
11
|
|
11
|
-
|
12
|
-
|
13
|
-
self.instance_eval(&block)
|
12
|
+
instance_eval(&block)
|
14
13
|
end
|
15
14
|
|
16
|
-
def colour(
|
17
|
-
|
18
|
-
|
19
|
-
foreground: args.last }
|
20
|
-
|
21
|
-
elsif args.is_a?(Array) && args.size == 1 && args.first.is_a?(Hash)
|
22
|
-
attributes[:colour] = args.first
|
15
|
+
def colour(values = {})
|
16
|
+
fail InvalidArgument, '#colour expects a Hash containing :foreground,' \
|
17
|
+
' :background or both.' unless values.is_a?(Hash)
|
23
18
|
|
24
|
-
|
25
|
-
attributes[:colour] = {}
|
26
|
-
|
27
|
-
end
|
19
|
+
attributes[:colour] = values
|
28
20
|
end
|
29
21
|
|
30
22
|
def style(values = [], &block)
|
data/lib/vedeu/api/events.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
# Todo: mutation (events)
|
2
|
-
|
3
1
|
module Vedeu
|
4
2
|
module API
|
5
3
|
def on(name, delay = 0, &block)
|
@@ -36,14 +34,13 @@ module Vedeu
|
|
36
34
|
last_exec: 0,
|
37
35
|
}
|
38
36
|
end
|
39
|
-
|
40
|
-
self
|
37
|
+
instance_eval(&block) if block_given?
|
41
38
|
end
|
42
39
|
|
43
40
|
def add(object, &block)
|
44
|
-
@self_before_instance_eval = eval
|
41
|
+
@self_before_instance_eval = eval('self', block.binding)
|
45
42
|
|
46
|
-
|
43
|
+
instance_eval(&block)
|
47
44
|
end
|
48
45
|
|
49
46
|
def on(event, delay = 0, &block)
|
@@ -58,15 +55,13 @@ module Vedeu
|
|
58
55
|
if elapsed > handlers[event][:delay]
|
59
56
|
handlers[event][:last_exec] = Time.now.to_f
|
60
57
|
|
61
|
-
handlers[event][:events].each
|
62
|
-
handler.call(*args)
|
63
|
-
end
|
58
|
+
handlers[event][:events].each { |handler| handler.call(*args) }
|
64
59
|
end
|
65
60
|
end
|
66
61
|
|
67
62
|
private
|
68
63
|
|
69
|
-
attr_reader :handlers
|
64
|
+
attr_reader :handlers
|
70
65
|
|
71
66
|
def method_missing(method, *args, &block)
|
72
67
|
@self_before_instance_eval.send method, *args, &block
|
data/lib/vedeu/api/grid.rb
CHANGED
data/lib/vedeu/api/interface.rb
CHANGED
@@ -1,20 +1,10 @@
|
|
1
|
-
require 'vedeu/models/geometry'
|
2
|
-
require 'vedeu/models/composition'
|
3
|
-
require 'vedeu/api/grid'
|
4
|
-
require 'vedeu/api/store'
|
5
|
-
require 'vedeu/support/terminal'
|
6
|
-
|
7
1
|
module Vedeu
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
YOutOfBounds = Class.new(StandardError)
|
13
|
-
|
14
|
-
def interface(name, &block)
|
15
|
-
Interface.save(name, &block)
|
16
|
-
end
|
2
|
+
InvalidHeight = Class.new(StandardError)
|
3
|
+
InvalidWidth = Class.new(StandardError)
|
4
|
+
XOutOfBounds = Class.new(StandardError)
|
5
|
+
YOutOfBounds = Class.new(StandardError)
|
17
6
|
|
7
|
+
module API
|
18
8
|
class Interface
|
19
9
|
def self.save(name, &block)
|
20
10
|
new(name).save(&block)
|
@@ -25,24 +15,12 @@ module Vedeu
|
|
25
15
|
end
|
26
16
|
|
27
17
|
def save(&block)
|
28
|
-
|
18
|
+
instance_eval(&block) if block_given?
|
29
19
|
|
30
20
|
stored_attributes = Store.create(attributes)
|
31
21
|
interface = Vedeu::Interface.new(stored_attributes)
|
32
22
|
|
33
|
-
Vedeu::Buffers.create(interface
|
34
|
-
|
35
|
-
Vedeu.events.on("_refresh_#{interface.name}_".to_sym, interface.delay) do
|
36
|
-
Vedeu::Buffers.refresh(interface.name)
|
37
|
-
end
|
38
|
-
|
39
|
-
# TODO:
|
40
|
-
# cannot do group at this time
|
41
|
-
# unless interface.group.nil? || interface.group.empty?
|
42
|
-
# Vedeu.events.on("_refresh_group_#{interface.group}_".to_sym, interface.delay) do
|
43
|
-
# buffer.refresh_group(interface.group)
|
44
|
-
# end
|
45
|
-
# end
|
23
|
+
Vedeu::Buffers.create(interface)
|
46
24
|
|
47
25
|
interface
|
48
26
|
end
|
@@ -83,14 +61,6 @@ module Vedeu
|
|
83
61
|
attributes[:geometry][:centred] = value
|
84
62
|
end
|
85
63
|
|
86
|
-
def attributes
|
87
|
-
@attributes ||= { name: name, geometry: {} }
|
88
|
-
end
|
89
|
-
|
90
|
-
def method_missing(method_name, arg, &block)
|
91
|
-
attributes[method_name] = arg
|
92
|
-
end
|
93
|
-
|
94
64
|
def y_out_of_bounds?(value)
|
95
65
|
value < 1 || value > Terminal.height
|
96
66
|
end
|
@@ -98,6 +68,14 @@ module Vedeu
|
|
98
68
|
def x_out_of_bounds?(value)
|
99
69
|
value < 1 || value > Terminal.width
|
100
70
|
end
|
71
|
+
|
72
|
+
def method_missing(method_name, arg, &block)
|
73
|
+
attributes[method_name] = arg
|
74
|
+
end
|
75
|
+
|
76
|
+
def attributes
|
77
|
+
@attributes ||= { name: name, geometry: {} }
|
78
|
+
end
|
101
79
|
end
|
102
80
|
end
|
103
81
|
end
|
data/lib/vedeu/api/line.rb
CHANGED
@@ -1,8 +1,5 @@
|
|
1
|
-
require 'date'
|
2
|
-
require 'logger'
|
3
|
-
|
4
1
|
module Vedeu
|
5
|
-
module
|
2
|
+
module API
|
6
3
|
class Log
|
7
4
|
def self.logger
|
8
5
|
@logger ||= Logger.new(filename).tap do |log|
|
@@ -63,7 +60,7 @@ module Vedeu
|
|
63
60
|
def defaults
|
64
61
|
{
|
65
62
|
event: 'call',
|
66
|
-
klass: /^Vedeu::(?!.*
|
63
|
+
klass: /^Vedeu::(?!.*Log|Interface|Line|Stream|Style|Colour|Geometry|Terminal|Esc|ColourTranslator).*/
|
67
64
|
}
|
68
65
|
end
|
69
66
|
|
data/lib/vedeu/api/store.rb
CHANGED
@@ -1,11 +1,7 @@
|
|
1
|
-
require 'vedeu/models/interface'
|
2
|
-
|
3
|
-
# Todo: mutation (persistence)
|
4
|
-
|
5
1
|
module Vedeu
|
6
|
-
|
7
|
-
EntityNotFound = Class.new(StandardError)
|
2
|
+
EntityNotFound = Class.new(StandardError)
|
8
3
|
|
4
|
+
module API
|
9
5
|
def use(name)
|
10
6
|
Vedeu::Interface.new(Store.query(name))
|
11
7
|
end
|
@@ -18,9 +14,7 @@ module Vedeu
|
|
18
14
|
end
|
19
15
|
|
20
16
|
def query(name)
|
21
|
-
|
22
|
-
fail EntityNotFound, 'Interface was not found.'
|
23
|
-
end
|
17
|
+
storage.fetch(name) { fail EntityNotFound, 'Interface was not found.' }
|
24
18
|
end
|
25
19
|
|
26
20
|
def reset
|
data/lib/vedeu/api/stream.rb
CHANGED
data/lib/vedeu/api/view.rb
CHANGED
@@ -1,33 +1,22 @@
|
|
1
|
-
require 'vedeu/api/line'
|
2
|
-
require 'vedeu/api/store'
|
3
|
-
|
4
1
|
module Vedeu
|
5
2
|
module API
|
6
3
|
InterfaceNotSpecified = Class.new(StandardError)
|
7
4
|
|
8
|
-
def render(object = nil)
|
9
|
-
Vedeu::View.render(object)
|
10
|
-
end
|
11
|
-
|
12
|
-
def view(name = '', &block)
|
13
|
-
Vedeu::API::View.build(name, &block)
|
14
|
-
end
|
15
|
-
|
16
5
|
class View
|
17
|
-
def self.build(name
|
6
|
+
def self.build(name, &block)
|
18
7
|
new(name).build(&block)
|
19
8
|
end
|
20
9
|
|
21
|
-
def initialize(name
|
10
|
+
def initialize(name)
|
22
11
|
fail InterfaceNotSpecified if name.nil? || name.empty?
|
23
12
|
|
24
13
|
@name = name.to_s
|
25
14
|
end
|
26
15
|
|
27
16
|
def build(&block)
|
28
|
-
@self_before_instance_eval = eval
|
17
|
+
@self_before_instance_eval = eval('self', block.binding)
|
29
18
|
|
30
|
-
|
19
|
+
instance_eval(&block) if block_given?
|
31
20
|
|
32
21
|
attributes
|
33
22
|
end
|
data/lib/vedeu/application.rb
CHANGED
@@ -1,7 +1,3 @@
|
|
1
|
-
require 'vedeu/instrumentation'
|
2
|
-
require 'vedeu/support/input'
|
3
|
-
require 'vedeu/support/terminal'
|
4
|
-
|
5
1
|
module Vedeu
|
6
2
|
ModeSwitch = Class.new(StandardError)
|
7
3
|
|
@@ -68,7 +64,7 @@ module Vedeu
|
|
68
64
|
end
|
69
65
|
|
70
66
|
def debug
|
71
|
-
Vedeu::
|
67
|
+
Vedeu::API::Trace.call if options.fetch(:debug)
|
72
68
|
end
|
73
69
|
|
74
70
|
def options
|
data/lib/vedeu/configuration.rb
CHANGED
data/lib/vedeu/launcher.rb
CHANGED
@@ -1,17 +1,12 @@
|
|
1
|
-
require 'virtus'
|
2
|
-
|
3
|
-
require 'vedeu/models/interface'
|
4
|
-
require 'vedeu/api/store'
|
5
|
-
|
6
1
|
module Vedeu
|
7
2
|
class InterfaceCollection < Virtus::Attribute
|
8
3
|
def coerce(values)
|
9
4
|
return [] if values.nil? || values.empty?
|
10
5
|
|
11
|
-
[values].flatten.map do |
|
12
|
-
|
6
|
+
[values].flatten.map do |view_attributes|
|
7
|
+
stored_attributes = API::Store.query(view_attributes[:name])
|
13
8
|
|
14
|
-
Interface.new(
|
9
|
+
Interface.new(stored_attributes.merge!(view_attributes))
|
15
10
|
end
|
16
11
|
end
|
17
12
|
end
|