vedeu 0.1.1 → 0.1.2
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 +17 -11
- data/lib/vedeu/configuration.rb +3 -3
- data/lib/vedeu/instrumentation.rb +1 -2
- data/lib/vedeu/launcher.rb +3 -0
- data/lib/vedeu/models/interface.rb +2 -1
- data/lib/vedeu/{parsing → output}/erb_parser.rb +1 -1
- data/lib/vedeu/output/json_parser.rb +23 -0
- data/lib/vedeu/{parsing → output}/menu_parser.rb +0 -0
- data/lib/vedeu/{parsing → output}/raw_parser.rb +1 -1
- data/lib/vedeu/output/render_interface.rb +11 -5
- data/lib/vedeu/{parsing → output}/text_adaptor.rb +0 -0
- data/lib/vedeu/{parsing → output}/view.rb +6 -6
- data/lib/vedeu/support/events.rb +20 -6
- data/lib/vedeu/support/persistence.rb +1 -3
- data/test/lib/vedeu/{parsing → output}/erb_parser_test.rb +1 -1
- data/test/lib/vedeu/{parsing → output}/json_parser_test.rb +1 -1
- data/test/lib/vedeu/{parsing → output}/menu_parser_test.rb +1 -1
- data/test/lib/vedeu/{parsing → output}/raw_parser_test.rb +1 -1
- data/test/lib/vedeu/{parsing → output}/text_adaptor_test.rb +1 -1
- data/test/lib/vedeu/output/view_test.rb +36 -0
- data/test/lib/vedeu/support/events_test.rb +10 -3
- data/test/lib/vedeu/support/menu_test.rb +1 -1
- data/test/lib/vedeu/support/persistence_test.rb +0 -4
- data/test/lib/vedeu_test.rb +8 -16
- data/test/test_helper.rb +2 -0
- data/vedeu.gemspec +2 -1
- metadata +34 -20
- data/lib/vedeu/parsing/json_parser.rb +0 -23
- data/test/lib/vedeu/parsing/view_test.rb +0 -38
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d4ccb72c3982e068887e6d1ac1e7dab94bfd25a9
|
4
|
+
data.tar.gz: a92614c47e5b02740ed486f0ea76bf3c3bbb8b67
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 056459bd4d73d522448bb43214420a255edf99dd58e3c5fc11d9b85da885a63badc6cc66e9cc5965e8815979f8d8e2cac846cef39154399dc4917e77bf93b375
|
7
|
+
data.tar.gz: e503cbc2ef1e1714c1993b37490c0d8d2ebc1fef012ed707018051ec7dc1927f9f8d71bea4882d89484d67a0bbb85a3889cb0d5f0328952bb5dffcd91a26adbc
|
data/lib/vedeu.rb
CHANGED
@@ -1,33 +1,39 @@
|
|
1
1
|
require 'vedeu/instrumentation'
|
2
2
|
require 'vedeu/support/builder'
|
3
3
|
require 'vedeu/support/events'
|
4
|
+
require 'vedeu/support/persistence'
|
5
|
+
|
4
6
|
require 'vedeu/support/geometry'
|
5
7
|
require 'vedeu/support/menu'
|
6
|
-
require 'vedeu/
|
8
|
+
require 'vedeu/output/view'
|
7
9
|
require 'vedeu/launcher'
|
8
10
|
|
9
11
|
module Vedeu
|
12
|
+
# :nocov:
|
10
13
|
def self.debug?
|
11
14
|
false
|
12
15
|
end
|
13
16
|
|
14
17
|
Vedeu::Instrumentation::Trace.call if debug?
|
15
18
|
|
16
|
-
|
17
|
-
module ClassMethods
|
19
|
+
module API
|
18
20
|
def interface(name, &block)
|
19
21
|
Builder.build(name, &block)
|
20
22
|
end
|
21
23
|
|
22
|
-
def
|
23
|
-
Vedeu.events.on(name, &block)
|
24
|
+
def on(name, delay = 0, &block)
|
25
|
+
Vedeu.events.on(name, delay, &block)
|
24
26
|
end
|
25
|
-
alias_method :
|
27
|
+
alias_method :event, :on
|
26
28
|
|
27
|
-
def
|
29
|
+
def trigger(name, *args)
|
28
30
|
Vedeu.events.trigger(name, *args)
|
29
31
|
end
|
30
|
-
alias_method :
|
32
|
+
alias_method :run, :trigger
|
33
|
+
|
34
|
+
def view(name)
|
35
|
+
Persistence.query(name)
|
36
|
+
end
|
31
37
|
end
|
32
38
|
|
33
39
|
def self.events
|
@@ -53,11 +59,11 @@ module Vedeu
|
|
53
59
|
end
|
54
60
|
|
55
61
|
def self.included(receiver)
|
56
|
-
receiver.send(:include,
|
57
|
-
receiver.extend(
|
62
|
+
receiver.send(:include, API)
|
63
|
+
receiver.extend(API)
|
58
64
|
end
|
59
65
|
|
60
|
-
extend
|
66
|
+
extend API
|
61
67
|
|
62
68
|
private
|
63
69
|
|
data/lib/vedeu/configuration.rb
CHANGED
@@ -16,15 +16,15 @@ module Vedeu
|
|
16
16
|
opts.banner = "Usage: #{$PROGRAM_NAME} [options]"
|
17
17
|
|
18
18
|
opts.on('-1', '--run-once', 'Run application once.') do
|
19
|
-
|
19
|
+
options[:interactive] = false
|
20
20
|
end
|
21
21
|
|
22
22
|
opts.on('-c', '--cooked', 'Run application in cooked mode.') do
|
23
|
-
|
23
|
+
options[:mode] = :cooked
|
24
24
|
end
|
25
25
|
|
26
26
|
opts.on('-r', '--raw', 'Run application in raw mode (default).') do
|
27
|
-
|
27
|
+
options[:mode] = :raw
|
28
28
|
end
|
29
29
|
end
|
30
30
|
parser.parse!(args)
|
@@ -83,7 +83,6 @@ module Vedeu
|
|
83
83
|
|
84
84
|
def pretty!(&block)
|
85
85
|
["\e[38;5;#{rand(22..231)}m", yield, "\e[38;2;39m"].join
|
86
|
-
|
87
86
|
end
|
88
87
|
|
89
88
|
def watched
|
@@ -101,7 +100,7 @@ module Vedeu
|
|
101
100
|
def defaults
|
102
101
|
{
|
103
102
|
event: 'call',
|
104
|
-
klass: /^Vedeu::(?!.*Instrumentation|Line|Stream|Style|Colour|Geometry|Terminal|Esc|Translator).*/
|
103
|
+
klass: /^Vedeu::(?!.*Instrumentation|Interface|Line|Stream|Style|Colour|Geometry|Terminal|Esc|Translator).*/
|
105
104
|
}
|
106
105
|
end
|
107
106
|
|
data/lib/vedeu/launcher.rb
CHANGED
@@ -22,11 +22,14 @@ module Vedeu
|
|
22
22
|
Application.start(configuration)
|
23
23
|
|
24
24
|
@exit_code = 0
|
25
|
+
|
25
26
|
rescue StandardError => uncaught_exception
|
26
27
|
Vedeu.error(uncaught_exception)
|
28
|
+
|
27
29
|
ensure
|
28
30
|
$stdin, $stdout, $stderr = STDIN, STDOUT, STDERR
|
29
31
|
@kernel.exit(@exit_code)
|
32
|
+
|
30
33
|
end
|
31
34
|
|
32
35
|
private
|
@@ -27,9 +27,10 @@ module Vedeu
|
|
27
27
|
attribute :current, String, default: ''
|
28
28
|
attribute :cursor, Boolean, default: true
|
29
29
|
attribute :centred, Boolean, default: false
|
30
|
+
attribute :delay, Float, default: 0.0
|
30
31
|
|
31
32
|
def initialize(attributes = {})
|
32
|
-
Vedeu.events.on(:refresh) { refresh }
|
33
|
+
Vedeu.events.on(:refresh, attributes[:delay]) { refresh }
|
33
34
|
|
34
35
|
super
|
35
36
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
3
|
+
module Vedeu
|
4
|
+
class JSONParser
|
5
|
+
def self.parse(json)
|
6
|
+
new(json).parse
|
7
|
+
end
|
8
|
+
|
9
|
+
def initialize(json)
|
10
|
+
@json = json
|
11
|
+
end
|
12
|
+
|
13
|
+
def parse
|
14
|
+
JSON.load(json, nil, symbolize_names: true)
|
15
|
+
rescue JSON::ParserError
|
16
|
+
{}
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
attr_reader :json
|
22
|
+
end
|
23
|
+
end
|
File without changes
|
@@ -24,7 +24,7 @@ module Vedeu
|
|
24
24
|
attr_reader :interface
|
25
25
|
|
26
26
|
def processed_lines
|
27
|
-
lines.
|
27
|
+
processed_lines = lines.map do |line|
|
28
28
|
if line.streams.any?
|
29
29
|
processed_streams = []
|
30
30
|
line_length = 0
|
@@ -33,13 +33,19 @@ module Vedeu
|
|
33
33
|
|
34
34
|
if (line_length += stream.text.size) >= width
|
35
35
|
remainder = width - line_length
|
36
|
-
stream.text = truncate(stream.text, remainder)
|
37
|
-
end
|
38
36
|
|
39
|
-
|
37
|
+
new_stream = Stream.new(text: truncate(stream.text, remainder),
|
38
|
+
style: stream.style,
|
39
|
+
colour: stream.colour)
|
40
|
+
processed_streams << new_stream
|
41
|
+
else
|
42
|
+
processed_streams << stream
|
43
|
+
end
|
40
44
|
end
|
41
45
|
|
42
|
-
|
46
|
+
new_line = Line.new(streams: processed_streams,
|
47
|
+
style: line.style,
|
48
|
+
colour: line.colour)
|
43
49
|
end
|
44
50
|
end
|
45
51
|
end
|
File without changes
|
@@ -1,9 +1,9 @@
|
|
1
1
|
require 'vedeu/models/composition'
|
2
|
-
require 'vedeu/
|
3
|
-
require 'vedeu/
|
4
|
-
require 'vedeu/
|
5
|
-
require 'vedeu/
|
6
|
-
require 'vedeu/
|
2
|
+
require 'vedeu/output/erb_parser'
|
3
|
+
require 'vedeu/output/raw_parser'
|
4
|
+
require 'vedeu/output/json_parser'
|
5
|
+
require 'vedeu/output/menu_parser'
|
6
|
+
require 'vedeu/output/raw_parser'
|
7
7
|
|
8
8
|
module Vedeu
|
9
9
|
class View
|
@@ -33,7 +33,7 @@ module Vedeu
|
|
33
33
|
json: JSONParser,
|
34
34
|
hash: RawParser,
|
35
35
|
menu: MenuParser,
|
36
|
-
raw:
|
36
|
+
raw: RawParser,
|
37
37
|
}.fetch(type)
|
38
38
|
end
|
39
39
|
end
|
data/lib/vedeu/support/events.rb
CHANGED
@@ -1,7 +1,13 @@
|
|
1
1
|
module Vedeu
|
2
2
|
class Events
|
3
3
|
def initialize(&block)
|
4
|
-
@handlers = Hash.new
|
4
|
+
@handlers = Hash.new do |hash, key|
|
5
|
+
hash[key] = {
|
6
|
+
delay: 0,
|
7
|
+
events: [],
|
8
|
+
last_exec: 0,
|
9
|
+
}
|
10
|
+
end
|
5
11
|
self.instance_eval(&block) if block_given?
|
6
12
|
self
|
7
13
|
end
|
@@ -12,13 +18,21 @@ module Vedeu
|
|
12
18
|
self.instance_eval(&block)
|
13
19
|
end
|
14
20
|
|
15
|
-
def on(event, &block)
|
16
|
-
handlers[event] << block
|
21
|
+
def on(event, delay = 0, &block)
|
22
|
+
handlers[event][:events] << block
|
23
|
+
handlers[event][:delay] = delay
|
24
|
+
handlers[event]
|
17
25
|
end
|
18
26
|
|
19
27
|
def trigger(event, *args)
|
20
|
-
handlers[event]
|
21
|
-
|
28
|
+
elapsed = Time.now.to_f - handlers[event][:last_exec]
|
29
|
+
|
30
|
+
if elapsed > handlers[event][:delay]
|
31
|
+
handlers[event][:last_exec] = Time.now.to_f
|
32
|
+
|
33
|
+
handlers[event][:events].each do |handler|
|
34
|
+
handler.call(*args)
|
35
|
+
end
|
22
36
|
end
|
23
37
|
end
|
24
38
|
|
@@ -30,6 +44,6 @@ module Vedeu
|
|
30
44
|
|
31
45
|
private
|
32
46
|
|
33
|
-
attr_reader :handlers
|
47
|
+
attr_reader :handlers, :throttles
|
34
48
|
end
|
35
49
|
end
|
@@ -19,11 +19,9 @@ module Vedeu
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def query(value)
|
22
|
-
return false if value.nil? || value.empty?
|
23
|
-
|
24
22
|
storage.select do |name, result|
|
25
23
|
return result if name == value
|
26
|
-
end
|
24
|
+
end unless value.nil? || value.empty?
|
27
25
|
|
28
26
|
fail EntityNotFound, "Interface could not be found."
|
29
27
|
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'vedeu/output/view'
|
3
|
+
|
4
|
+
module Vedeu
|
5
|
+
describe View do
|
6
|
+
describe '.render' do
|
7
|
+
it 'returns when the type is :erb' do
|
8
|
+
skip
|
9
|
+
View.render(:erb, '').must_equal('')
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'returns when the type is :json' do
|
13
|
+
skip
|
14
|
+
View.render(:json, '').must_equal('')
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'returns when the type is :raw' do
|
18
|
+
skip
|
19
|
+
View.render(:raw, '').must_equal('')
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'returns when the type is :menu' do
|
23
|
+
skip
|
24
|
+
View.render(:menu, '').must_equal('')
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'returns when the type is not set' do
|
28
|
+
proc { View.render(nil, '') }.must_raise(KeyError)
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'returns when the type is not recognised' do
|
32
|
+
proc { View.render(:unknown, '') }.must_raise(KeyError)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -4,15 +4,22 @@ require 'vedeu/support/events'
|
|
4
4
|
module Vedeu
|
5
5
|
describe Events do
|
6
6
|
describe '#on' do
|
7
|
-
it '
|
7
|
+
it 'adds the event block to the handlers' do
|
8
|
+
skip
|
8
9
|
events = Events.new
|
9
10
|
events.on(:some_event) { proc { |x| x } }
|
10
|
-
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'adds the specified throttle to the throttles' do
|
14
|
+
skip
|
15
|
+
events = Events.new
|
16
|
+
events.on(:some_event, 250) { proc { |x| x } }
|
11
17
|
end
|
12
18
|
end
|
13
19
|
|
14
20
|
describe '#trigger' do
|
15
|
-
it 'returns a collection containing the event when the event is
|
21
|
+
it 'returns a collection containing the event when the event is ' \
|
22
|
+
'pre-registered' do
|
16
23
|
events = Events.new do
|
17
24
|
on(:_exit_) { fail StopIteration }
|
18
25
|
end
|
data/test/lib/vedeu_test.rb
CHANGED
@@ -2,7 +2,7 @@ require 'test_helper'
|
|
2
2
|
require 'vedeu'
|
3
3
|
|
4
4
|
module Vedeu
|
5
|
-
describe
|
5
|
+
describe API do
|
6
6
|
describe '.interface' do
|
7
7
|
end
|
8
8
|
|
@@ -14,31 +14,23 @@ module Vedeu
|
|
14
14
|
|
15
15
|
describe '.view' do
|
16
16
|
it 'returns the interface referenced by name' do
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
17
|
+
Vedeu.interface 'Vedeu.view' do
|
18
|
+
width 5
|
19
|
+
height 5
|
20
|
+
end
|
21
21
|
|
22
|
-
|
23
|
-
|
24
|
-
[].must_equal(false)
|
22
|
+
Vedeu.view('Vedeu.view').must_be_instance_of(Interface)
|
23
|
+
Vedeu.view('Vedeu.view').name.must_equal('Vedeu.view')
|
25
24
|
end
|
26
25
|
|
27
26
|
it 'raises an exception if the interface does not exist' do
|
28
|
-
|
29
|
-
proc { }.must_raise(EntityNotFound)
|
27
|
+
proc { Vedeu.view('unknown') }.must_raise(EntityNotFound)
|
30
28
|
end
|
31
29
|
end
|
32
30
|
end
|
33
31
|
end
|
34
32
|
|
35
33
|
describe Vedeu do
|
36
|
-
describe '.debug?' do
|
37
|
-
it 'allows me to quickly enable/disable debugging' do
|
38
|
-
skip
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
34
|
describe '.events' do
|
43
35
|
it 'creates some system events for the client application' do
|
44
36
|
skip
|
data/test/test_helper.rb
CHANGED
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.2'
|
8
8
|
spec.authors = ['Gavin Laking']
|
9
9
|
spec.email = ['gavinlaking@gmail.com']
|
10
10
|
spec.summary = %q{A terminal case of wonderland.}
|
@@ -21,6 +21,7 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.add_development_dependency 'guard-minitest', '2.3.1'
|
22
22
|
spec.add_development_dependency 'minitest', '5.4.0'
|
23
23
|
spec.add_development_dependency 'minitest-reporters', '1.0.5'
|
24
|
+
spec.add_development_dependency 'mocha', '1.1.0'
|
24
25
|
spec.add_development_dependency 'pry', '0.10.0'
|
25
26
|
spec.add_development_dependency 'rake', '10.3.2'
|
26
27
|
spec.add_development_dependency 'ruby-prof', '0.15.1'
|
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.2
|
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-
|
11
|
+
date: 2014-08-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -80,6 +80,20 @@ dependencies:
|
|
80
80
|
- - '='
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: 1.0.5
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: mocha
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 1.1.0
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 1.1.0
|
83
97
|
- !ruby/object:Gem::Dependency
|
84
98
|
name: pry
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -187,13 +201,13 @@ files:
|
|
187
201
|
- lib/vedeu/models/stream.rb
|
188
202
|
- lib/vedeu/models/style.rb
|
189
203
|
- lib/vedeu/output/clear_interface.rb
|
204
|
+
- lib/vedeu/output/erb_parser.rb
|
205
|
+
- lib/vedeu/output/json_parser.rb
|
206
|
+
- lib/vedeu/output/menu_parser.rb
|
207
|
+
- lib/vedeu/output/raw_parser.rb
|
190
208
|
- lib/vedeu/output/render_interface.rb
|
191
|
-
- lib/vedeu/
|
192
|
-
- lib/vedeu/
|
193
|
-
- lib/vedeu/parsing/menu_parser.rb
|
194
|
-
- lib/vedeu/parsing/raw_parser.rb
|
195
|
-
- lib/vedeu/parsing/text_adaptor.rb
|
196
|
-
- lib/vedeu/parsing/view.rb
|
209
|
+
- lib/vedeu/output/text_adaptor.rb
|
210
|
+
- lib/vedeu/output/view.rb
|
197
211
|
- lib/vedeu/support/builder.rb
|
198
212
|
- lib/vedeu/support/esc.rb
|
199
213
|
- lib/vedeu/support/events.rb
|
@@ -222,13 +236,13 @@ files:
|
|
222
236
|
- test/lib/vedeu/models/stream_test.rb
|
223
237
|
- test/lib/vedeu/models/style_test.rb
|
224
238
|
- test/lib/vedeu/output/clear_interface_test.rb
|
239
|
+
- test/lib/vedeu/output/erb_parser_test.rb
|
240
|
+
- test/lib/vedeu/output/json_parser_test.rb
|
241
|
+
- test/lib/vedeu/output/menu_parser_test.rb
|
242
|
+
- test/lib/vedeu/output/raw_parser_test.rb
|
225
243
|
- test/lib/vedeu/output/render_interface_test.rb
|
226
|
-
- test/lib/vedeu/
|
227
|
-
- test/lib/vedeu/
|
228
|
-
- test/lib/vedeu/parsing/menu_parser_test.rb
|
229
|
-
- test/lib/vedeu/parsing/raw_parser_test.rb
|
230
|
-
- test/lib/vedeu/parsing/text_adaptor_test.rb
|
231
|
-
- test/lib/vedeu/parsing/view_test.rb
|
244
|
+
- test/lib/vedeu/output/text_adaptor_test.rb
|
245
|
+
- test/lib/vedeu/output/view_test.rb
|
232
246
|
- test/lib/vedeu/support/builder_test.rb
|
233
247
|
- test/lib/vedeu/support/esc_test.rb
|
234
248
|
- test/lib/vedeu/support/events_test.rb
|
@@ -302,13 +316,13 @@ test_files:
|
|
302
316
|
- test/lib/vedeu/models/stream_test.rb
|
303
317
|
- test/lib/vedeu/models/style_test.rb
|
304
318
|
- test/lib/vedeu/output/clear_interface_test.rb
|
319
|
+
- test/lib/vedeu/output/erb_parser_test.rb
|
320
|
+
- test/lib/vedeu/output/json_parser_test.rb
|
321
|
+
- test/lib/vedeu/output/menu_parser_test.rb
|
322
|
+
- test/lib/vedeu/output/raw_parser_test.rb
|
305
323
|
- test/lib/vedeu/output/render_interface_test.rb
|
306
|
-
- test/lib/vedeu/
|
307
|
-
- test/lib/vedeu/
|
308
|
-
- test/lib/vedeu/parsing/menu_parser_test.rb
|
309
|
-
- test/lib/vedeu/parsing/raw_parser_test.rb
|
310
|
-
- test/lib/vedeu/parsing/text_adaptor_test.rb
|
311
|
-
- test/lib/vedeu/parsing/view_test.rb
|
324
|
+
- test/lib/vedeu/output/text_adaptor_test.rb
|
325
|
+
- test/lib/vedeu/output/view_test.rb
|
312
326
|
- test/lib/vedeu/support/builder_test.rb
|
313
327
|
- test/lib/vedeu/support/esc_test.rb
|
314
328
|
- test/lib/vedeu/support/events_test.rb
|
@@ -1,23 +0,0 @@
|
|
1
|
-
require 'json'
|
2
|
-
|
3
|
-
module Vedeu
|
4
|
-
class JSONParser
|
5
|
-
def self.parse(output)
|
6
|
-
new(output).parse
|
7
|
-
end
|
8
|
-
|
9
|
-
def initialize(output)
|
10
|
-
@output = output
|
11
|
-
end
|
12
|
-
|
13
|
-
def parse
|
14
|
-
JSON.load(output, nil, symbolize_names: true)
|
15
|
-
rescue JSON::ParserError
|
16
|
-
{}
|
17
|
-
end
|
18
|
-
|
19
|
-
private
|
20
|
-
|
21
|
-
attr_reader :output
|
22
|
-
end
|
23
|
-
end
|
@@ -1,38 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
require 'vedeu/parsing/view'
|
3
|
-
|
4
|
-
module Vedeu
|
5
|
-
describe View do
|
6
|
-
describe '.render' do
|
7
|
-
# it 'returns when the type is :erb' do
|
8
|
-
# output = ''
|
9
|
-
# View.render(:erb, output).must_equal('')
|
10
|
-
# end
|
11
|
-
|
12
|
-
# it 'returns when the type is :json' do
|
13
|
-
# output = ''
|
14
|
-
# View.render(:json, output).must_equal('')
|
15
|
-
# end
|
16
|
-
|
17
|
-
# it 'returns when the type is :hash' do
|
18
|
-
# output = ''
|
19
|
-
# View.render(:hash, output).must_equal('')
|
20
|
-
# end
|
21
|
-
|
22
|
-
# it 'returns when the type is :menu' do
|
23
|
-
# output = ''
|
24
|
-
# View.render(:menu, output).must_equal('')
|
25
|
-
# end
|
26
|
-
|
27
|
-
# it 'returns when the type is not set' do
|
28
|
-
# output = ''
|
29
|
-
# View.render(nil, output).must_equal('')
|
30
|
-
# end
|
31
|
-
|
32
|
-
# it 'returns when the type is not recognised' do
|
33
|
-
# output = ''
|
34
|
-
# View.render(:unknown, output).must_equal('')
|
35
|
-
# end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|