vedeu 0.4.3 → 0.4.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/vedeu/api.rb +3 -1
- data/lib/vedeu/application.rb +1 -1
- data/lib/vedeu/bindings.rb +68 -101
- data/lib/vedeu/cursor/cursor.rb +1 -1
- data/lib/vedeu/cursor/move_cursor.rb +77 -1
- data/lib/vedeu/cursor/toggle_cursor.rb +2 -0
- data/lib/vedeu/distributed/all.rb +7 -0
- data/lib/vedeu/distributed/client.rb +23 -11
- data/lib/vedeu/distributed/server.rb +8 -0
- data/lib/vedeu/distributed/subprocess.rb +0 -24
- data/lib/vedeu/distributed/uri.rb +1 -8
- data/lib/vedeu/dsl/all.rb +3 -0
- data/lib/vedeu/dsl/components/all.rb +4 -4
- data/lib/vedeu/dsl/components/geometry.rb +2 -0
- data/lib/vedeu/dsl/components/keymap.rb +14 -3
- data/lib/vedeu/dsl/group.rb +69 -0
- data/lib/vedeu/dsl/interface.rb +9 -8
- data/lib/vedeu/dsl/shared/text.rb +3 -1
- data/lib/vedeu/events/event.rb +2 -2
- data/lib/vedeu/input/keymap.rb +1 -1
- data/lib/vedeu/models/geometry.rb +1 -1
- data/lib/vedeu/models/group.rb +24 -10
- data/lib/vedeu/models/view/lines.rb +1 -0
- data/lib/vedeu/output/all.rb +6 -1
- data/lib/vedeu/output/border.rb +1 -1
- data/lib/vedeu/{support → output}/esc.rb +0 -0
- data/lib/vedeu/output/foreground.rb +1 -1
- data/lib/vedeu/output/html_char.rb +2 -0
- data/lib/vedeu/output/html_renderer.rb +6 -0
- data/lib/vedeu/output/output.rb +21 -0
- data/lib/vedeu/{support → output}/refresh.rb +1 -1
- data/lib/vedeu/output/renderer.rb +3 -0
- data/lib/vedeu/{support → output}/text.rb +0 -0
- data/lib/vedeu/output/virtual_terminal.rb +2 -0
- data/lib/vedeu/support/all.rb +0 -7
- data/lib/vedeu/support/coercions.rb +7 -4
- data/lib/vedeu/support/terminal.rb +1 -1
- data/lib/vedeu/support/trace.rb +1 -1
- data/lib/vedeu/support/visible.rb +1 -1
- data/test/lib/vedeu/cursor/move_cursor_test.rb +60 -1
- data/test/lib/vedeu/distributed/client_test.rb +21 -2
- data/test/lib/vedeu/dsl/group_test.rb +52 -0
- data/test/lib/vedeu/models/group_test.rb +11 -4
- data/test/lib/vedeu/{support → output}/esc_test.rb +0 -0
- data/test/lib/vedeu/{support → output}/refresh_test.rb +0 -0
- data/test/lib/vedeu/{support → output}/text_test.rb +0 -0
- data/test/test_helper.rb +2 -0
- data/vedeu.gemspec +2 -1
- metadata +28 -24
- data/lib/vedeu/output/writer.rb +0 -44
- data/lib/vedeu/support/console.rb +0 -90
- data/lib/vedeu/support/node.rb +0 -51
- data/lib/vedeu/support/read.rb +0 -66
- data/lib/vedeu/support/write.rb +0 -86
- data/test/lib/vedeu/output/writer_test.rb +0 -32
- data/test/lib/vedeu/support/console_test.rb +0 -138
- data/test/lib/vedeu/support/read_test.rb +0 -86
- data/test/lib/vedeu/support/write_test.rb +0 -158
@@ -19,7 +19,7 @@ module Vedeu
|
|
19
19
|
new(uri).connect
|
20
20
|
end
|
21
21
|
|
22
|
-
# @param uri [String]
|
22
|
+
# @param uri [Vedeu::Distributed::Uri|String]
|
23
23
|
# @return [Client]
|
24
24
|
def initialize(uri)
|
25
25
|
@uri = uri.to_s
|
@@ -31,35 +31,37 @@ module Vedeu
|
|
31
31
|
def connect
|
32
32
|
server.status
|
33
33
|
|
34
|
+
rescue DRb::DRbConnError
|
35
|
+
drb_connection_error
|
36
|
+
|
34
37
|
rescue DRb::DRbBadURI
|
35
|
-
puts
|
38
|
+
puts 'Could not connect to DRb server, URI may be bad.'
|
36
39
|
|
37
|
-
|
38
|
-
puts "Could not connect to DRb server."
|
40
|
+
:drb_bad_uri
|
39
41
|
|
40
42
|
end
|
41
43
|
|
42
44
|
# Send input to the DRb server.
|
43
45
|
#
|
44
46
|
# @param data [String|Symbol]
|
45
|
-
# @return [void]
|
47
|
+
# @return [void|Symbol]
|
46
48
|
def input(data)
|
47
49
|
server.input(data)
|
48
50
|
|
49
51
|
rescue DRb::DRbConnError
|
50
|
-
|
52
|
+
drb_connection_error
|
51
53
|
|
52
54
|
end
|
53
55
|
alias_method :read, :input
|
54
56
|
|
55
57
|
# Fetch output from the DRb server.
|
56
58
|
#
|
57
|
-
# @return [void]
|
59
|
+
# @return [void|Symbol]
|
58
60
|
def output
|
59
61
|
server.output
|
60
62
|
|
61
63
|
rescue DRb::DRbConnError
|
62
|
-
|
64
|
+
drb_connection_error
|
63
65
|
|
64
66
|
end
|
65
67
|
alias_method :write, :output
|
@@ -70,17 +72,20 @@ module Vedeu
|
|
70
72
|
# {Vedeu::Application} will raise StopIteration when its `.stop` method
|
71
73
|
# is called. Here we rescue that to give a clean client exit.
|
72
74
|
#
|
73
|
-
# @return [void]
|
75
|
+
# @return [void|Symbol]
|
74
76
|
def shutdown
|
75
77
|
server.shutdown
|
76
78
|
|
77
79
|
Process.kill("KILL", server.pid)
|
78
80
|
|
79
81
|
rescue DRb::DRbConnError
|
80
|
-
|
82
|
+
drb_connection_error
|
81
83
|
|
82
84
|
rescue Interrupt
|
83
|
-
puts
|
85
|
+
puts 'Client application exited.'
|
86
|
+
|
87
|
+
ensure
|
88
|
+
:shutdown
|
84
89
|
|
85
90
|
end
|
86
91
|
|
@@ -93,6 +98,13 @@ module Vedeu
|
|
93
98
|
@server ||= DRbObject.new_with_uri(uri)
|
94
99
|
end
|
95
100
|
|
101
|
+
# @return [Symbol]
|
102
|
+
def drb_connection_error
|
103
|
+
puts 'Could not connect to DRb server.'
|
104
|
+
|
105
|
+
:drb_connection_error
|
106
|
+
end
|
107
|
+
|
96
108
|
end # Client
|
97
109
|
|
98
110
|
end # Distributed
|
@@ -69,6 +69,8 @@ module Vedeu
|
|
69
69
|
|
70
70
|
# @return [void]
|
71
71
|
def restart
|
72
|
+
Vedeu.log(type: :drb, message: 'Attempting to restart')
|
73
|
+
|
72
74
|
return not_enabled unless drb?
|
73
75
|
|
74
76
|
log('Not running') unless drb_running?
|
@@ -100,6 +102,8 @@ module Vedeu
|
|
100
102
|
|
101
103
|
# @return [Vedeu::Distributed::Server]
|
102
104
|
def start
|
105
|
+
Vedeu.log(type: :drb, message: 'Attempting to start')
|
106
|
+
|
103
107
|
return not_enabled unless drb?
|
104
108
|
|
105
109
|
if drb_running?
|
@@ -116,6 +120,8 @@ module Vedeu
|
|
116
120
|
|
117
121
|
# @return [Symbol]
|
118
122
|
def status
|
123
|
+
Vedeu.log(type: :drb, message: 'Fetching status')
|
124
|
+
|
119
125
|
return not_enabled unless drb?
|
120
126
|
|
121
127
|
if drb_running?
|
@@ -133,6 +139,8 @@ module Vedeu
|
|
133
139
|
|
134
140
|
# @return [void]
|
135
141
|
def stop
|
142
|
+
Vedeu.log(type: :drb, message: 'Attempting to stop')
|
143
|
+
|
136
144
|
return not_enabled unless drb?
|
137
145
|
|
138
146
|
if drb_running?
|
@@ -1,29 +1,5 @@
|
|
1
|
-
require 'pty'
|
2
1
|
require 'vedeu/distributed/test_application'
|
3
2
|
|
4
|
-
# app_config = Vedeu::TestApplication.build
|
5
|
-
# timestamp = Time.now.to_i
|
6
|
-
# file = File.new("/tmp/foo_#{timestamp}", "w")
|
7
|
-
# file.write(app_config)
|
8
|
-
# file.close
|
9
|
-
|
10
|
-
# cmd = "ruby #{file.path}"
|
11
|
-
# begin
|
12
|
-
# PTY.spawn(cmd) do |stdin, stdout, pid|
|
13
|
-
# begin
|
14
|
-
# # Do stuff with the output here. Just printing to show it works
|
15
|
-
# stdin.each { |line| print line }
|
16
|
-
# rescue Errno::EIO
|
17
|
-
# puts "Errno:EIO error, but this probably just means " +
|
18
|
-
# "that the process has finished giving output"
|
19
|
-
# end
|
20
|
-
# end
|
21
|
-
# rescue PTY::ChildExited
|
22
|
-
# puts "The child process exited!"
|
23
|
-
# ensure
|
24
|
-
# File.unlink("/tmp/foo_#{timestamp}")
|
25
|
-
# end
|
26
|
-
|
27
3
|
module Vedeu
|
28
4
|
|
29
5
|
# @example
|
@@ -22,14 +22,7 @@ module Vedeu
|
|
22
22
|
#
|
23
23
|
# @return [String] The host and port as a single value.
|
24
24
|
def to_s
|
25
|
-
[
|
26
|
-
end
|
27
|
-
|
28
|
-
private
|
29
|
-
|
30
|
-
# @return [String]
|
31
|
-
def scheme
|
32
|
-
'druby://'
|
25
|
+
['druby://', host, ':', port].join
|
33
26
|
end
|
34
27
|
|
35
28
|
end # Uri
|
data/lib/vedeu/dsl/all.rb
CHANGED
@@ -2,6 +2,7 @@ require 'vedeu/dsl/components/all'
|
|
2
2
|
require 'vedeu/dsl/shared/all'
|
3
3
|
|
4
4
|
require 'vedeu/dsl/composition'
|
5
|
+
require 'vedeu/dsl/group'
|
5
6
|
require 'vedeu/dsl/interface'
|
6
7
|
require 'vedeu/dsl/line'
|
7
8
|
require 'vedeu/dsl/stream'
|
@@ -13,6 +14,8 @@ module Vedeu
|
|
13
14
|
#
|
14
15
|
module DSL
|
15
16
|
|
17
|
+
private
|
18
|
+
|
16
19
|
# Attempts to find the missing method on the client object.
|
17
20
|
#
|
18
21
|
# @param method [Symbol] The name of the method sought.
|
@@ -1,7 +1,7 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
require_relative 'border'
|
2
|
+
require_relative 'geometry'
|
3
|
+
require_relative 'keymap'
|
4
|
+
require_relative 'menu'
|
5
5
|
|
6
6
|
module Vedeu
|
7
7
|
end # Vedeu
|
@@ -25,15 +25,26 @@ module Vedeu
|
|
25
25
|
#
|
26
26
|
# Vedeu.interface 'my_interface' do
|
27
27
|
# keymap do
|
28
|
-
# ...
|
28
|
+
# # ...
|
29
29
|
#
|
30
30
|
# @param name [String] The name of the interface which this keymap relates
|
31
31
|
# to.
|
32
32
|
# @param block [Proc]
|
33
33
|
#
|
34
34
|
# @example
|
35
|
-
# keymap 'my_interface' do
|
36
|
-
# ...
|
35
|
+
# Vedeu.keymap 'my_interface' do
|
36
|
+
# # ...
|
37
|
+
#
|
38
|
+
# Vedeu.keys 'my_interface' do
|
39
|
+
# # ...
|
40
|
+
#
|
41
|
+
# Vedeu.interface 'my_interface' do
|
42
|
+
# keymap do
|
43
|
+
# # ...
|
44
|
+
#
|
45
|
+
# Vedeu.interface 'my_interface' do
|
46
|
+
# keys do
|
47
|
+
# # ...
|
37
48
|
#
|
38
49
|
# @raise [InvalidSyntax] The required block was not given.
|
39
50
|
# @return [Keymap]
|
@@ -0,0 +1,69 @@
|
|
1
|
+
require 'vedeu/models/group'
|
2
|
+
|
3
|
+
module Vedeu
|
4
|
+
|
5
|
+
module DSL
|
6
|
+
|
7
|
+
# DSL for adding interfaces to a group.
|
8
|
+
#
|
9
|
+
class Group
|
10
|
+
|
11
|
+
include Vedeu::DSL
|
12
|
+
|
13
|
+
# Specify a new group of interfaces with a simple DSL.
|
14
|
+
#
|
15
|
+
# The example below resembles 'vim' (the popular terminal-based text
|
16
|
+
# editor):
|
17
|
+
#
|
18
|
+
# @example
|
19
|
+
# Vedeu.group 'title_screen' do
|
20
|
+
# add 'welcome_interface'
|
21
|
+
# # ...
|
22
|
+
#
|
23
|
+
# Vedeu.group 'main_screen' do
|
24
|
+
# add 'editor_interface'
|
25
|
+
# add 'status_interface'
|
26
|
+
# add 'command_interface'
|
27
|
+
# # ...
|
28
|
+
#
|
29
|
+
# @note
|
30
|
+
# Creating a group with the same name as an existing group overwrites
|
31
|
+
# the existing group.
|
32
|
+
#
|
33
|
+
# @param name [String] The name of this group.
|
34
|
+
# @param block [Proc]
|
35
|
+
# @raise [InvalidSyntax] The required block was not given.
|
36
|
+
# @return [Vedeu::Group]
|
37
|
+
def self.group(name, &block)
|
38
|
+
fail InvalidSyntax, 'block not given' unless block_given?
|
39
|
+
|
40
|
+
Vedeu::Group.build({ name: name }, &block).store
|
41
|
+
end
|
42
|
+
|
43
|
+
# Returns an instance of DSL::Group.
|
44
|
+
#
|
45
|
+
# @param model [Group]
|
46
|
+
# @param client [Object]
|
47
|
+
# @return [Vedeu::DSL::Group]
|
48
|
+
def initialize(model, client = nil)
|
49
|
+
@model = model
|
50
|
+
@client = client
|
51
|
+
end
|
52
|
+
|
53
|
+
# Add the named interface to this group.
|
54
|
+
#
|
55
|
+
# @param interface_name [String]
|
56
|
+
# @return [void]
|
57
|
+
def add(interface_name)
|
58
|
+
model.add(interface_name)
|
59
|
+
end
|
60
|
+
|
61
|
+
private
|
62
|
+
|
63
|
+
attr_reader :client, :model
|
64
|
+
|
65
|
+
end # Group
|
66
|
+
|
67
|
+
end # DSL
|
68
|
+
|
69
|
+
end # Vedeu
|
data/lib/vedeu/dsl/interface.rb
CHANGED
@@ -135,28 +135,29 @@ module Vedeu
|
|
135
135
|
# targetted together; for example you may want to refresh multiple
|
136
136
|
# interfaces at once.
|
137
137
|
#
|
138
|
-
# @param value [String] The name for the group of interfaces.
|
139
|
-
#
|
140
138
|
# @example
|
141
139
|
# interface 'my_interface' do
|
142
140
|
# group 'main_screen'
|
143
141
|
# # ...
|
144
142
|
#
|
143
|
+
# @param name [String] The name of the group to which this interface
|
144
|
+
# should belong.
|
145
145
|
# @return [String]
|
146
|
-
def group(
|
147
|
-
return false unless defined_value?(
|
146
|
+
def group(name)
|
147
|
+
return false unless defined_value?(name)
|
148
148
|
|
149
149
|
if defined_value?(model.name)
|
150
|
-
if Vedeu.groups.registered?(
|
151
|
-
Vedeu.groups.find(
|
150
|
+
if Vedeu.groups.registered?(name)
|
151
|
+
Vedeu.groups.find(name).add(model.name)
|
152
152
|
|
153
153
|
else
|
154
|
-
Vedeu::Group.new(
|
154
|
+
new_group = Vedeu::Group.new({ name: name })
|
155
|
+
new_group.add(model.name)
|
155
156
|
|
156
157
|
end
|
157
158
|
end
|
158
159
|
|
159
|
-
model.group =
|
160
|
+
model.group = name
|
160
161
|
end
|
161
162
|
|
162
163
|
# @see Vedeu::DSL::Keymap.keymap
|
data/lib/vedeu/events/event.rb
CHANGED
@@ -41,8 +41,8 @@ module Vedeu
|
|
41
41
|
# Register an event by name with optional delay (throttling) which when
|
42
42
|
# triggered will execute the code contained within the passed block.
|
43
43
|
#
|
44
|
-
# @param name
|
45
|
-
# @param [Hash]
|
44
|
+
# @param name [Symbol] The name of the event which will be triggered later.
|
45
|
+
# @param options [Hash] The options to register the event with.
|
46
46
|
# @option options :delay [Fixnum|Float] Limits the execution of the
|
47
47
|
# triggered event to only execute when first triggered, with subsequent
|
48
48
|
# triggering being ignored until the delay has expired.
|
data/lib/vedeu/input/keymap.rb
CHANGED
data/lib/vedeu/models/group.rb
CHANGED
@@ -7,17 +7,23 @@ module Vedeu
|
|
7
7
|
|
8
8
|
include Vedeu::Model
|
9
9
|
|
10
|
-
|
10
|
+
attr_accessor :name
|
11
11
|
|
12
12
|
# Return a new instance of Group.
|
13
13
|
#
|
14
|
-
# @param
|
15
|
-
# @
|
14
|
+
# @param attributes [Hash]
|
15
|
+
# @option attributes members [Array] A collection of names of interfaces
|
16
|
+
# belonging to this group.
|
17
|
+
# @option attributes name [String] The name of the group.
|
18
|
+
# @option attributes repository [Vedeu::Repository] The storage for all
|
19
|
+
# Group models.
|
16
20
|
# @return [Group]
|
17
|
-
def initialize(
|
18
|
-
@
|
19
|
-
|
20
|
-
@
|
21
|
+
def initialize(attributes = {})
|
22
|
+
@attributes = defaults.merge!(attributes)
|
23
|
+
|
24
|
+
@members = Array(@attributes[:members])
|
25
|
+
@name = @attributes[:name]
|
26
|
+
@repository = @attributes[:repository]
|
21
27
|
end
|
22
28
|
|
23
29
|
# Add a member to the group by name.
|
@@ -25,7 +31,7 @@ module Vedeu
|
|
25
31
|
# @param member [String]
|
26
32
|
# @return [Group]
|
27
33
|
def add(member)
|
28
|
-
Group.new(name, members.add(member)).store
|
34
|
+
Group.new({ name: name, members: members.add(member) }).store
|
29
35
|
end
|
30
36
|
|
31
37
|
# Return the members as a Set.
|
@@ -40,18 +46,26 @@ module Vedeu
|
|
40
46
|
# @param member [String]
|
41
47
|
# @return [Group]
|
42
48
|
def remove(member)
|
43
|
-
Group.new(name, members.delete(member)).store
|
49
|
+
Group.new({ name: name, members: members.delete(member) }).store
|
44
50
|
end
|
45
51
|
|
46
52
|
# Remove all members from the group.
|
47
53
|
#
|
48
54
|
# @return [Group]
|
49
55
|
def reset
|
50
|
-
Group.new(name).store
|
56
|
+
Group.new(defaults.merge!({ name: name })).store
|
51
57
|
end
|
52
58
|
|
53
59
|
private
|
54
60
|
|
61
|
+
def defaults
|
62
|
+
{
|
63
|
+
members: [],
|
64
|
+
name: '',
|
65
|
+
repository: Vedeu.groups,
|
66
|
+
}
|
67
|
+
end
|
68
|
+
|
55
69
|
end # Group
|
56
70
|
|
57
71
|
end # Vedeu
|