vedeu 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Guardfile +1 -1
- data/README.md +13 -0
- data/deps.md +13 -4
- data/lib/vedeu.rb +1 -1
- data/lib/vedeu/models/interface.rb +5 -1
- data/lib/vedeu/output/render_interface.rb +1 -3
- data/lib/vedeu/parsing/erb_parser.rb +43 -0
- data/lib/vedeu/parsing/json_parser.rb +13 -3
- data/lib/vedeu/parsing/menu_parser.rb +7 -12
- data/lib/vedeu/parsing/raw_parser.rb +34 -0
- data/lib/vedeu/parsing/text_adaptor.rb +0 -6
- data/lib/vedeu/parsing/view.rb +46 -0
- data/lib/vedeu/support/events.rb +0 -19
- data/lib/vedeu/support/geometry.rb +66 -46
- data/lib/vedeu/support/helpers.rb +43 -0
- data/lib/vedeu/support/input.rb +2 -0
- data/lib/vedeu/support/queue.rb +0 -12
- data/test/lib/vedeu/parsing/erb_parser_test.rb +154 -0
- data/test/lib/vedeu/parsing/menu_parser_test.rb +9 -0
- data/test/lib/vedeu/parsing/{hash_parser_test.rb → raw_parser_test.rb} +5 -5
- data/test/lib/vedeu/parsing/view_test.rb +38 -0
- data/test/lib/vedeu/support/geometry_test.rb +8 -8
- data/test/lib/vedeu/support/helpers_test.rb +68 -0
- data/test/lib/vedeu/support/queue_test.rb +3 -35
- data/test/lib/vedeu_test.rb +39 -0
- data/test/support/erb/colour.erb +3 -0
- data/test/support/erb/colour_style.erb +1 -0
- data/test/support/erb/style.erb +3 -0
- data/test/support/template.erb +6 -1
- data/vedeu.gemspec +2 -2
- metadata +24 -13
- data/lib/vedeu/output/template.rb +0 -23
- data/lib/vedeu/parsing/hash_parser.rb +0 -68
- data/lib/vedeu/parsing/parser.rb +0 -52
- data/test/lib/vedeu/output/template.rb +0 -21
- data/test/lib/vedeu/parsing/parser_test.rb +0 -31
data/test/lib/vedeu_test.rb
CHANGED
@@ -11,10 +11,49 @@ module Vedeu
|
|
11
11
|
|
12
12
|
describe '.run' do
|
13
13
|
end
|
14
|
+
|
15
|
+
describe '.view' do
|
16
|
+
it 'returns the interface referenced by name' do
|
17
|
+
skip
|
18
|
+
[].must_be_instance_of(Interface)
|
19
|
+
[].name.must_equal([])
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'returns false with no name' do
|
23
|
+
skip
|
24
|
+
[].must_equal(false)
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'raises an exception if the interface does not exist' do
|
28
|
+
skip
|
29
|
+
proc { }.must_raise(EntityNotFound)
|
30
|
+
end
|
31
|
+
end
|
14
32
|
end
|
15
33
|
end
|
16
34
|
|
17
35
|
describe Vedeu do
|
36
|
+
describe '.debug?' do
|
37
|
+
it 'allows me to quickly enable/disable debugging' do
|
38
|
+
skip
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
18
42
|
describe '.events' do
|
43
|
+
it 'creates some system events for the client application' do
|
44
|
+
skip
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe '.log' do
|
49
|
+
it 'returns a logger instance for writing debug messages to' do
|
50
|
+
skip
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
describe '.error' do
|
55
|
+
it 'writes an error to the log' do
|
56
|
+
skip
|
57
|
+
end
|
19
58
|
end
|
20
59
|
end
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= foreground('#0000ff') -%><%= style('underline') -%><%= background('#00005a') -%>Blue underline text on dark blue background.
|
data/test/support/template.erb
CHANGED
@@ -1,3 +1,8 @@
|
|
1
1
|
This is the test template.
|
2
2
|
|
3
|
-
<%=
|
3
|
+
<%= foreground('#5f00af') %><%= object.value %>
|
4
|
+
<%= background('#ffff00') %><%= object.value %>
|
5
|
+
<%= foreground('#ff8700') %><%= background('#ffff00') %><%= object.value %>
|
6
|
+
<%= style('underline') %><%= object.value %>
|
7
|
+
|
8
|
+
Some more content...
|
data/vedeu.gemspec
CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = 'vedeu'
|
7
|
-
spec.version = '0.1.
|
7
|
+
spec.version = '0.1.1'
|
8
8
|
spec.authors = ['Gavin Laking']
|
9
9
|
spec.email = ['gavinlaking@gmail.com']
|
10
10
|
spec.summary = %q{A terminal case of wonderland.}
|
@@ -26,5 +26,5 @@ Gem::Specification.new do |spec|
|
|
26
26
|
spec.add_development_dependency 'ruby-prof', '0.15.1'
|
27
27
|
spec.add_development_dependency 'simplecov', '0.9.0'
|
28
28
|
|
29
|
-
spec.add_dependency 'virtus', '1.0.
|
29
|
+
spec.add_dependency 'virtus', '1.0.3'
|
30
30
|
end
|
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.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gavin Laking
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-07-
|
11
|
+
date: 2014-07-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -142,14 +142,14 @@ dependencies:
|
|
142
142
|
requirements:
|
143
143
|
- - '='
|
144
144
|
- !ruby/object:Gem::Version
|
145
|
-
version: 1.0.
|
145
|
+
version: 1.0.3
|
146
146
|
type: :runtime
|
147
147
|
prerelease: false
|
148
148
|
version_requirements: !ruby/object:Gem::Requirement
|
149
149
|
requirements:
|
150
150
|
- - '='
|
151
151
|
- !ruby/object:Gem::Version
|
152
|
-
version: 1.0.
|
152
|
+
version: 1.0.3
|
153
153
|
description:
|
154
154
|
email:
|
155
155
|
- gavinlaking@gmail.com
|
@@ -188,16 +188,17 @@ files:
|
|
188
188
|
- lib/vedeu/models/style.rb
|
189
189
|
- lib/vedeu/output/clear_interface.rb
|
190
190
|
- lib/vedeu/output/render_interface.rb
|
191
|
-
- lib/vedeu/
|
192
|
-
- lib/vedeu/parsing/hash_parser.rb
|
191
|
+
- lib/vedeu/parsing/erb_parser.rb
|
193
192
|
- lib/vedeu/parsing/json_parser.rb
|
194
193
|
- lib/vedeu/parsing/menu_parser.rb
|
195
|
-
- lib/vedeu/parsing/
|
194
|
+
- lib/vedeu/parsing/raw_parser.rb
|
196
195
|
- lib/vedeu/parsing/text_adaptor.rb
|
196
|
+
- lib/vedeu/parsing/view.rb
|
197
197
|
- lib/vedeu/support/builder.rb
|
198
198
|
- lib/vedeu/support/esc.rb
|
199
199
|
- lib/vedeu/support/events.rb
|
200
200
|
- lib/vedeu/support/geometry.rb
|
201
|
+
- lib/vedeu/support/helpers.rb
|
201
202
|
- lib/vedeu/support/input.rb
|
202
203
|
- lib/vedeu/support/menu.rb
|
203
204
|
- lib/vedeu/support/persistence.rb
|
@@ -222,15 +223,17 @@ files:
|
|
222
223
|
- test/lib/vedeu/models/style_test.rb
|
223
224
|
- test/lib/vedeu/output/clear_interface_test.rb
|
224
225
|
- test/lib/vedeu/output/render_interface_test.rb
|
225
|
-
- test/lib/vedeu/
|
226
|
-
- test/lib/vedeu/parsing/hash_parser_test.rb
|
226
|
+
- test/lib/vedeu/parsing/erb_parser_test.rb
|
227
227
|
- test/lib/vedeu/parsing/json_parser_test.rb
|
228
|
-
- test/lib/vedeu/parsing/
|
228
|
+
- test/lib/vedeu/parsing/menu_parser_test.rb
|
229
|
+
- test/lib/vedeu/parsing/raw_parser_test.rb
|
229
230
|
- test/lib/vedeu/parsing/text_adaptor_test.rb
|
231
|
+
- test/lib/vedeu/parsing/view_test.rb
|
230
232
|
- test/lib/vedeu/support/builder_test.rb
|
231
233
|
- test/lib/vedeu/support/esc_test.rb
|
232
234
|
- test/lib/vedeu/support/events_test.rb
|
233
235
|
- test/lib/vedeu/support/geometry_test.rb
|
236
|
+
- test/lib/vedeu/support/helpers_test.rb
|
234
237
|
- test/lib/vedeu/support/input_test.rb
|
235
238
|
- test/lib/vedeu/support/menu_test.rb
|
236
239
|
- test/lib/vedeu/support/persistence_test.rb
|
@@ -243,6 +246,9 @@ files:
|
|
243
246
|
- test/support/bench.rb
|
244
247
|
- test/support/colours.rb
|
245
248
|
- test/support/dummy_interface.rb
|
249
|
+
- test/support/erb/colour.erb
|
250
|
+
- test/support/erb/colour_style.erb
|
251
|
+
- test/support/erb/style.erb
|
246
252
|
- test/support/json/int1_lin1_str1.json
|
247
253
|
- test/support/json/int1_lin1_str3.json
|
248
254
|
- test/support/json/int1_lin2_str1.json
|
@@ -297,15 +303,17 @@ test_files:
|
|
297
303
|
- test/lib/vedeu/models/style_test.rb
|
298
304
|
- test/lib/vedeu/output/clear_interface_test.rb
|
299
305
|
- test/lib/vedeu/output/render_interface_test.rb
|
300
|
-
- test/lib/vedeu/
|
301
|
-
- test/lib/vedeu/parsing/hash_parser_test.rb
|
306
|
+
- test/lib/vedeu/parsing/erb_parser_test.rb
|
302
307
|
- test/lib/vedeu/parsing/json_parser_test.rb
|
303
|
-
- test/lib/vedeu/parsing/
|
308
|
+
- test/lib/vedeu/parsing/menu_parser_test.rb
|
309
|
+
- test/lib/vedeu/parsing/raw_parser_test.rb
|
304
310
|
- test/lib/vedeu/parsing/text_adaptor_test.rb
|
311
|
+
- test/lib/vedeu/parsing/view_test.rb
|
305
312
|
- test/lib/vedeu/support/builder_test.rb
|
306
313
|
- test/lib/vedeu/support/esc_test.rb
|
307
314
|
- test/lib/vedeu/support/events_test.rb
|
308
315
|
- test/lib/vedeu/support/geometry_test.rb
|
316
|
+
- test/lib/vedeu/support/helpers_test.rb
|
309
317
|
- test/lib/vedeu/support/input_test.rb
|
310
318
|
- test/lib/vedeu/support/menu_test.rb
|
311
319
|
- test/lib/vedeu/support/persistence_test.rb
|
@@ -318,6 +326,9 @@ test_files:
|
|
318
326
|
- test/support/bench.rb
|
319
327
|
- test/support/colours.rb
|
320
328
|
- test/support/dummy_interface.rb
|
329
|
+
- test/support/erb/colour.erb
|
330
|
+
- test/support/erb/colour_style.erb
|
331
|
+
- test/support/erb/style.erb
|
321
332
|
- test/support/json/int1_lin1_str1.json
|
322
333
|
- test/support/json/int1_lin1_str3.json
|
323
334
|
- test/support/json/int1_lin2_str1.json
|
@@ -1,23 +0,0 @@
|
|
1
|
-
module Vedeu
|
2
|
-
class Template
|
3
|
-
def self.parse(object, path)
|
4
|
-
new(object, path).parse
|
5
|
-
end
|
6
|
-
|
7
|
-
def initialize(object, path)
|
8
|
-
@object, @path = object, path
|
9
|
-
end
|
10
|
-
|
11
|
-
def parse
|
12
|
-
ERB.new(load, nil, '-').result(binding)
|
13
|
-
end
|
14
|
-
|
15
|
-
private
|
16
|
-
|
17
|
-
attr_reader :object, :path
|
18
|
-
|
19
|
-
def load
|
20
|
-
File.read(File.dirname(__FILE__) + path)
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
@@ -1,68 +0,0 @@
|
|
1
|
-
require 'vedeu/parsing/text_adaptor'
|
2
|
-
|
3
|
-
module Vedeu
|
4
|
-
class HashParser
|
5
|
-
# Convert a hash into a collection of interfaces.
|
6
|
-
#
|
7
|
-
# @param output [Hash] a collection of interface pairs of the
|
8
|
-
# format:
|
9
|
-
#
|
10
|
-
# {
|
11
|
-
# interface_1: "A block of text containing\n" \
|
12
|
-
# "new line characters.\n",
|
13
|
-
# interface_2: "Some content destined for the " \
|
14
|
-
# "other interface.\n"
|
15
|
-
# }
|
16
|
-
#
|
17
|
-
# becomes:
|
18
|
-
#
|
19
|
-
# {
|
20
|
-
# interfaces: [
|
21
|
-
# {
|
22
|
-
# name: 'interface_1',
|
23
|
-
# lines: [{
|
24
|
-
# streams: { text: "A block of text containing" }
|
25
|
-
# }, {
|
26
|
-
# streams: { text: "new line characters." }
|
27
|
-
# }]
|
28
|
-
# }, {
|
29
|
-
# name: 'interface_2',
|
30
|
-
# lines: [{
|
31
|
-
# streams: { text: "Some content destined for the " \
|
32
|
-
# "other interface." }
|
33
|
-
# }]
|
34
|
-
# }
|
35
|
-
# ]
|
36
|
-
# }
|
37
|
-
#
|
38
|
-
# @return [Hash]
|
39
|
-
def self.parse(output = {})
|
40
|
-
new(output).parse
|
41
|
-
end
|
42
|
-
|
43
|
-
def initialize(output = {})
|
44
|
-
@output = output
|
45
|
-
end
|
46
|
-
|
47
|
-
def parse
|
48
|
-
{ interfaces: interfaces }
|
49
|
-
end
|
50
|
-
|
51
|
-
private
|
52
|
-
|
53
|
-
attr_reader :output
|
54
|
-
|
55
|
-
def interfaces
|
56
|
-
stringified_keys.map do |name, content|
|
57
|
-
{
|
58
|
-
name: name,
|
59
|
-
lines: TextAdaptor.adapt(content)
|
60
|
-
}
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
def stringified_keys
|
65
|
-
output.inject({}) { |a, (k, v)| a[k.to_s] = v; a }
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
data/lib/vedeu/parsing/parser.rb
DELETED
@@ -1,52 +0,0 @@
|
|
1
|
-
require 'vedeu/models/composition'
|
2
|
-
require 'vedeu/parsing/hash_parser'
|
3
|
-
require 'vedeu/parsing/json_parser'
|
4
|
-
require 'vedeu/parsing/menu_parser'
|
5
|
-
|
6
|
-
module Vedeu
|
7
|
-
ParseError = Class.new(StandardError)
|
8
|
-
|
9
|
-
class Parser
|
10
|
-
def self.parse(output = {})
|
11
|
-
return nil if output.nil? || output.empty?
|
12
|
-
|
13
|
-
new(output).parse
|
14
|
-
end
|
15
|
-
|
16
|
-
def initialize(output = {})
|
17
|
-
@output = output
|
18
|
-
end
|
19
|
-
|
20
|
-
def parse
|
21
|
-
Composition.enqueue(parsed_output)
|
22
|
-
end
|
23
|
-
|
24
|
-
private
|
25
|
-
|
26
|
-
attr_reader :output
|
27
|
-
|
28
|
-
def parsed_output
|
29
|
-
@parsed ||= parser.parse(output)
|
30
|
-
end
|
31
|
-
|
32
|
-
def parser
|
33
|
-
return JSONParser if json?
|
34
|
-
return HashParser if hash?
|
35
|
-
return MenuParser if menu?
|
36
|
-
|
37
|
-
fail ParseError, 'Cannot process output from command.'
|
38
|
-
end
|
39
|
-
|
40
|
-
def menu?
|
41
|
-
output.is_a?(Array)
|
42
|
-
end
|
43
|
-
|
44
|
-
def hash?
|
45
|
-
output.is_a?(Hash)
|
46
|
-
end
|
47
|
-
|
48
|
-
def json?
|
49
|
-
output.is_a?(String)
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
require 'vedeu/output/template'
|
3
|
-
|
4
|
-
module Vedeu
|
5
|
-
describe Template do
|
6
|
-
describe '#parse' do
|
7
|
-
object = OpenStruct.new(value: 'Hello from variable!')
|
8
|
-
|
9
|
-
it 'parses the template when the template file was found' do
|
10
|
-
path = '/../../../test/support/template.erb'
|
11
|
-
Template.new(object, path).parse.must_match(/This is the test template/)
|
12
|
-
Template.new(object, path).parse.must_match(/Hello from variable!/)
|
13
|
-
end
|
14
|
-
|
15
|
-
it 'raises an exception when the template file cannot be found' do
|
16
|
-
path = '/some/wrong/path/template.erb'
|
17
|
-
proc { Template.new(object, path).parse }.must_raise(Errno::ENOENT)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
require 'vedeu/parsing/parser'
|
3
|
-
|
4
|
-
module Vedeu
|
5
|
-
describe Parser do
|
6
|
-
describe '#parse' do
|
7
|
-
it 'returns a NilClass when the output is empty' do
|
8
|
-
Parser.parse.must_be_instance_of(NilClass)
|
9
|
-
end
|
10
|
-
|
11
|
-
it 'returns a Composition when the output is JSON' do
|
12
|
-
file = File.read('test/support/json/int1_lin1_str1.json')
|
13
|
-
parser = Parser.parse(file)
|
14
|
-
|
15
|
-
parser.must_be_instance_of(Array)
|
16
|
-
parser.size.must_equal(1)
|
17
|
-
end
|
18
|
-
|
19
|
-
it 'returns a collection of interfaces when the output is a Hash' do
|
20
|
-
parser = Parser.parse({ parser_parse: 'Parser#parse' })
|
21
|
-
|
22
|
-
parser.must_be_instance_of(Array)
|
23
|
-
parser.size.must_equal(1)
|
24
|
-
end
|
25
|
-
|
26
|
-
it 'raises an exception when the output is anything else' do
|
27
|
-
proc { Parser.parse(:invalid) }.must_raise(ParseError)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|