vedeu 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/deps.md +2 -2
- data/lib/vedeu.rb +8 -4
- data/lib/vedeu/api/base.rb +36 -0
- data/lib/vedeu/api/interface.rb +76 -0
- data/lib/vedeu/api/line.rb +41 -0
- data/lib/vedeu/api/stream.rb +19 -0
- data/lib/vedeu/api/view.rb +39 -0
- data/lib/vedeu/output/menu_parser.rb +7 -7
- data/test/lib/vedeu/api/base_test.rb +23 -0
- data/test/lib/vedeu/api/interface_test.rb +77 -0
- data/test/lib/vedeu/api/line_test.rb +23 -0
- data/test/lib/vedeu/api/stream_test.rb +23 -0
- data/test/lib/vedeu/api/view_test.rb +478 -0
- data/test/lib/vedeu/output/menu_parser_test.rb +37 -0
- data/test/lib/vedeu/output/raw_parser_test.rb +20 -0
- data/test/lib/vedeu_test.rb +15 -15
- data/vedeu.gemspec +1 -1
- metadata +17 -5
- data/lib/vedeu/support/interface_template.rb +0 -74
- data/test/lib/vedeu/support/interface_template_test.rb +0 -97
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2ef9364bd8562905d44a580a1f6b9f0acb3820d6
|
4
|
+
data.tar.gz: 30849fc7340fbb1ab220e24834580bd0941e8545
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 461240de809a3abd145c22eaea50bc32b5dfe56f41c16c35c407b6e13493f4d16e431d0fb9f2fdbb5111f847287d771f39fb7a239fe8f6c24f47677b930c4f44
|
7
|
+
data.tar.gz: e823ea6b126ea32dd259fdef8a58c3cd6c59c3a07bcaa8d51cb52bef0847226dbf69890d9b0e4c6ec064c5feffaaee17e48ccd91ea417dff7faf14579c5d2d83
|
data/deps.md
CHANGED
@@ -50,7 +50,7 @@ Interface
|
|
50
50
|
InterfaceCollection
|
51
51
|
InterfaceStore
|
52
52
|
|
53
|
-
|
53
|
+
API::Interface
|
54
54
|
Geometry
|
55
55
|
Interface
|
56
56
|
InterfaceStore
|
@@ -129,7 +129,7 @@ Menu - orphaned
|
|
129
129
|
Grouped
|
130
130
|
----------------------------------------------------------------------
|
131
131
|
|
132
|
-
|
132
|
+
API::Interface
|
133
133
|
Interface
|
134
134
|
Geometry
|
135
135
|
InterfaceStore
|
data/lib/vedeu.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
require 'vedeu/instrumentation'
|
2
|
-
require 'vedeu/
|
2
|
+
require 'vedeu/api/interface'
|
3
3
|
require 'vedeu/support/events'
|
4
4
|
require 'vedeu/support/interface_store'
|
5
|
-
|
5
|
+
require 'vedeu/api/view'
|
6
6
|
require 'vedeu/models/geometry'
|
7
7
|
require 'vedeu/support/menu'
|
8
8
|
require 'vedeu/output/view'
|
@@ -20,7 +20,7 @@ module Vedeu
|
|
20
20
|
|
21
21
|
module API
|
22
22
|
def interface(name, &block)
|
23
|
-
|
23
|
+
Interface.save(name, &block)
|
24
24
|
end
|
25
25
|
|
26
26
|
def on(name, delay = 0, &block)
|
@@ -33,9 +33,13 @@ module Vedeu
|
|
33
33
|
end
|
34
34
|
alias_method :run, :trigger
|
35
35
|
|
36
|
-
def
|
36
|
+
def with(name, &block)
|
37
37
|
InterfaceStore.query(name)
|
38
38
|
end
|
39
|
+
|
40
|
+
def view(name = '', &block)
|
41
|
+
Vedeu::API::View.build(name, &block)
|
42
|
+
end
|
39
43
|
end
|
40
44
|
|
41
45
|
def self.events
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Vedeu
|
2
|
+
module API
|
3
|
+
class Base
|
4
|
+
def self.build(attributes = {}, &block)
|
5
|
+
new(attributes, &block).build
|
6
|
+
end
|
7
|
+
|
8
|
+
def initialize(attributes, &block)
|
9
|
+
@attributes = attributes
|
10
|
+
|
11
|
+
self.instance_eval(&block) if block_given?
|
12
|
+
end
|
13
|
+
|
14
|
+
def colour(*args)
|
15
|
+
if args.is_a?(Array) && args.size == 2
|
16
|
+
attributes[:colour] = { background: args.first, foreground: args.last }
|
17
|
+
|
18
|
+
elsif args.is_a?(Array) && args.size == 1 && args.first.is_a?(Hash)
|
19
|
+
attributes[:colour] = args.first
|
20
|
+
|
21
|
+
else
|
22
|
+
attributes[:colour] = {}
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def style(values = [], &block)
|
28
|
+
if block_given?
|
29
|
+
attributes[:streams] << API::Stream.build({ style: [values] }, &block)
|
30
|
+
else
|
31
|
+
[values].flatten.each { |value| attributes[:style] << value }
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
require 'vedeu/models/geometry'
|
2
|
+
require 'vedeu/support/interface_store'
|
3
|
+
require 'vedeu/support/terminal'
|
4
|
+
|
5
|
+
module Vedeu
|
6
|
+
module API
|
7
|
+
InvalidHeight = Class.new(StandardError)
|
8
|
+
InvalidWidth = Class.new(StandardError)
|
9
|
+
XOutOfBounds = Class.new(StandardError)
|
10
|
+
YOutOfBounds = Class.new(StandardError)
|
11
|
+
|
12
|
+
class Interface
|
13
|
+
def self.save(name, &block)
|
14
|
+
new(name).save(&block)
|
15
|
+
end
|
16
|
+
|
17
|
+
def initialize(name)
|
18
|
+
@name = name.to_s
|
19
|
+
end
|
20
|
+
|
21
|
+
def save(&block)
|
22
|
+
self.instance_eval(&block) if block_given?
|
23
|
+
|
24
|
+
InterfaceStore.create(attributes)
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
attr_reader :name
|
30
|
+
|
31
|
+
def x(value)
|
32
|
+
fail XOutOfBounds if x_out_of_bounds?(value)
|
33
|
+
|
34
|
+
attributes[:geometry][:x] = value
|
35
|
+
end
|
36
|
+
|
37
|
+
def y(value)
|
38
|
+
fail YOutOfBounds if y_out_of_bounds?(value)
|
39
|
+
|
40
|
+
attributes[:geometry][:y] = value
|
41
|
+
end
|
42
|
+
|
43
|
+
def width(value)
|
44
|
+
fail InvalidWidth if x_out_of_bounds?(value)
|
45
|
+
|
46
|
+
attributes[:geometry][:width] = value
|
47
|
+
end
|
48
|
+
|
49
|
+
def height(value)
|
50
|
+
fail InvalidHeight if y_out_of_bounds?(value)
|
51
|
+
|
52
|
+
attributes[:geometry][:height] = value
|
53
|
+
end
|
54
|
+
|
55
|
+
def centred(value)
|
56
|
+
attributes[:geometry][:centred] = value
|
57
|
+
end
|
58
|
+
|
59
|
+
def attributes
|
60
|
+
@attributes ||= { name: name, geometry: {} }
|
61
|
+
end
|
62
|
+
|
63
|
+
def method_missing(method_name, arg, &block)
|
64
|
+
attributes[method_name] = arg
|
65
|
+
end
|
66
|
+
|
67
|
+
def y_out_of_bounds?(value)
|
68
|
+
value < 1 || value > Terminal.height
|
69
|
+
end
|
70
|
+
|
71
|
+
def x_out_of_bounds?(value)
|
72
|
+
value < 1 || value > Terminal.width
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'vedeu/api/base'
|
2
|
+
require 'vedeu/api/stream'
|
3
|
+
|
4
|
+
module Vedeu
|
5
|
+
module API
|
6
|
+
class Line < Base
|
7
|
+
def build
|
8
|
+
attributes
|
9
|
+
end
|
10
|
+
|
11
|
+
def width(value)
|
12
|
+
#attributes[:streams][:width] = value
|
13
|
+
#attributes[:streams] << API::Stream.build({ width: value })
|
14
|
+
end
|
15
|
+
|
16
|
+
def align(value)
|
17
|
+
attributes[:align] = value
|
18
|
+
end
|
19
|
+
|
20
|
+
def stream(&block)
|
21
|
+
attributes[:streams] << API::Stream.build(&block)
|
22
|
+
end
|
23
|
+
|
24
|
+
def text(value)
|
25
|
+
attributes[:streams] << { text: value }
|
26
|
+
end
|
27
|
+
|
28
|
+
def foreground(value = '', &block)
|
29
|
+
attributes[:streams] << API::Stream.build({ colour: { foreground: value } }, &block)
|
30
|
+
end
|
31
|
+
|
32
|
+
def background(value = '', &block)
|
33
|
+
attributes[:streams] << API::Stream.build({ colour: { background: value } }, &block)
|
34
|
+
end
|
35
|
+
|
36
|
+
def attributes
|
37
|
+
@_attributes ||= { colour: {}, style: [], streams: [] }.merge!(@attributes)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'vedeu/api/base'
|
2
|
+
|
3
|
+
module Vedeu
|
4
|
+
module API
|
5
|
+
class Stream < Base
|
6
|
+
def build
|
7
|
+
attributes
|
8
|
+
end
|
9
|
+
|
10
|
+
def text(value)
|
11
|
+
attributes[:text] = value
|
12
|
+
end
|
13
|
+
|
14
|
+
def attributes
|
15
|
+
@_attributes ||= { colour: {}, style: [], text: '' }.merge!(@attributes)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'vedeu/api/base'
|
2
|
+
require 'vedeu/api/line'
|
3
|
+
require 'vedeu/support/interface_store'
|
4
|
+
|
5
|
+
module Vedeu
|
6
|
+
module API
|
7
|
+
InterfaceNotSpecified = Class.new(StandardError)
|
8
|
+
|
9
|
+
class View
|
10
|
+
def self.build(name = '', &block)
|
11
|
+
new(name).build(&block)
|
12
|
+
end
|
13
|
+
|
14
|
+
def initialize(name = '')
|
15
|
+
fail Vedeu::API::InterfaceNotSpecified if name.nil? || name.empty?
|
16
|
+
|
17
|
+
@name = name.to_s
|
18
|
+
end
|
19
|
+
|
20
|
+
def build(&block)
|
21
|
+
self.instance_eval(&block) if block_given?
|
22
|
+
|
23
|
+
attributes
|
24
|
+
end
|
25
|
+
|
26
|
+
def line(&block)
|
27
|
+
attributes[:lines] << API::Line.build(&block)
|
28
|
+
end
|
29
|
+
|
30
|
+
def attributes
|
31
|
+
@_attributes ||= { name: name, lines: [] }
|
32
|
+
end
|
33
|
+
|
34
|
+
def name
|
35
|
+
return @name if InterfaceStore.query(@name)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -1,11 +1,11 @@
|
|
1
1
|
module Vedeu
|
2
2
|
class MenuParser
|
3
|
-
def self.parse(
|
4
|
-
new(
|
3
|
+
def self.parse(args)
|
4
|
+
new(args).parse
|
5
5
|
end
|
6
6
|
|
7
|
-
def initialize(
|
8
|
-
@
|
7
|
+
def initialize(args)
|
8
|
+
@args = args
|
9
9
|
end
|
10
10
|
|
11
11
|
def parse
|
@@ -14,7 +14,7 @@ module Vedeu
|
|
14
14
|
|
15
15
|
private
|
16
16
|
|
17
|
-
attr_reader :
|
17
|
+
attr_reader :args
|
18
18
|
|
19
19
|
def interface
|
20
20
|
{ name: name, lines: lines }
|
@@ -41,11 +41,11 @@ module Vedeu
|
|
41
41
|
end
|
42
42
|
|
43
43
|
def items
|
44
|
-
|
44
|
+
args.last
|
45
45
|
end
|
46
46
|
|
47
47
|
def name
|
48
|
-
|
48
|
+
args.first
|
49
49
|
end
|
50
50
|
end
|
51
51
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
require 'vedeu/api/line'
|
4
|
+
require 'vedeu/api/interface'
|
5
|
+
require 'vedeu/support/interface_store'
|
6
|
+
|
7
|
+
module Vedeu
|
8
|
+
module API
|
9
|
+
describe Base do
|
10
|
+
before do
|
11
|
+
InterfaceStore.reset
|
12
|
+
Interface.save('testing_view') do
|
13
|
+
width 80
|
14
|
+
height 25
|
15
|
+
x 1
|
16
|
+
y 1
|
17
|
+
colour foreground: '#ffffff', background: '#000000'
|
18
|
+
centred false
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'vedeu/api/interface'
|
3
|
+
|
4
|
+
module Vedeu
|
5
|
+
module API
|
6
|
+
describe Interface do
|
7
|
+
interface = Interface.new('widget')
|
8
|
+
|
9
|
+
it 'creates and stores a new interface' do
|
10
|
+
interface.save.must_be_instance_of(Vedeu::Interface)
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'allows interfaces to share behaviour' do
|
14
|
+
IO.console.stub :winsize, [10, 40] do
|
15
|
+
main = Interface.save('main') do
|
16
|
+
colour foreground: '#ff0000', background: '#000000'
|
17
|
+
cursor false
|
18
|
+
centred true
|
19
|
+
width 10
|
20
|
+
height 2
|
21
|
+
end
|
22
|
+
status = Interface.save('status') do
|
23
|
+
colour foreground: 'aadd00', background: '#4040cc'
|
24
|
+
cursor true
|
25
|
+
centred true
|
26
|
+
width 10
|
27
|
+
height 1
|
28
|
+
y main.geometry.bottom
|
29
|
+
x main.geometry.left
|
30
|
+
end
|
31
|
+
|
32
|
+
main.geometry.left.must_equal(15)
|
33
|
+
main.geometry.top.must_equal(4)
|
34
|
+
status.geometry.left.must_equal(15)
|
35
|
+
status.geometry.top.must_equal(5)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'raises an exception when the value is out of bounds' do
|
40
|
+
proc { interface.save { x 0 } }.must_raise(XOutOfBounds)
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'raises an exception when the value is out of bounds' do
|
44
|
+
proc { interface.save { x 999 } }.must_raise(XOutOfBounds)
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'raises an exception when the value is out of bounds' do
|
48
|
+
proc { interface.save { y 0 } }.must_raise(YOutOfBounds)
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'raises an exception when the value is out of bounds' do
|
52
|
+
proc { interface.save { y 999 } }.must_raise(YOutOfBounds)
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'raises an exception when the value is out of bounds' do
|
56
|
+
proc { interface.save { width 0 } }.must_raise(InvalidWidth)
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'raises an exception when the value is out of bounds' do
|
60
|
+
proc { interface.save { width 999 } }.must_raise(InvalidWidth)
|
61
|
+
end
|
62
|
+
|
63
|
+
it 'raises an exception when the value is out of bounds' do
|
64
|
+
proc { interface.save { height 0 } }.must_raise(InvalidHeight)
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'raises an exception when the value is out of bounds' do
|
68
|
+
proc { interface.save { height 999 } }.must_raise(InvalidHeight)
|
69
|
+
end
|
70
|
+
|
71
|
+
it 'should have a valid spec, please write one.' do
|
72
|
+
skip
|
73
|
+
interface = Interface.new('widget')
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
require 'vedeu/api/line'
|
4
|
+
require 'vedeu/api/interface'
|
5
|
+
require 'vedeu/support/interface_store'
|
6
|
+
|
7
|
+
module Vedeu
|
8
|
+
module API
|
9
|
+
describe Line do
|
10
|
+
before do
|
11
|
+
InterfaceStore.reset
|
12
|
+
Interface.save('testing_view') do
|
13
|
+
width 80
|
14
|
+
height 25
|
15
|
+
x 1
|
16
|
+
y 1
|
17
|
+
colour foreground: '#ffffff', background: '#000000'
|
18
|
+
centred false
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
require 'vedeu/api/line'
|
4
|
+
require 'vedeu/api/interface'
|
5
|
+
require 'vedeu/support/interface_store'
|
6
|
+
|
7
|
+
module Vedeu
|
8
|
+
module API
|
9
|
+
describe Stream do
|
10
|
+
before do
|
11
|
+
InterfaceStore.reset
|
12
|
+
Interface.save('testing_view') do
|
13
|
+
width 80
|
14
|
+
height 25
|
15
|
+
x 1
|
16
|
+
y 1
|
17
|
+
colour foreground: '#ffffff', background: '#000000'
|
18
|
+
centred false
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,478 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
require 'vedeu/api/view'
|
4
|
+
require 'vedeu'
|
5
|
+
|
6
|
+
module Vedeu
|
7
|
+
module API
|
8
|
+
describe View do
|
9
|
+
before do
|
10
|
+
InterfaceStore.reset
|
11
|
+
Interface.save('testing_view') do
|
12
|
+
width 80
|
13
|
+
height 25
|
14
|
+
x 1
|
15
|
+
y 1
|
16
|
+
colour foreground: '#ffffff', background: '#000000'
|
17
|
+
centred false
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'builds a basic view' do
|
22
|
+
Vedeu.view 'testing_view' do
|
23
|
+
line do
|
24
|
+
text '1. A line of text.'
|
25
|
+
text '2. Another line of text.'
|
26
|
+
end
|
27
|
+
end.must_equal(
|
28
|
+
{
|
29
|
+
name: 'testing_view',
|
30
|
+
lines: [
|
31
|
+
{
|
32
|
+
colour: {},
|
33
|
+
style: [],
|
34
|
+
streams: [
|
35
|
+
{
|
36
|
+
text: '1. A line of text.',
|
37
|
+
}, {
|
38
|
+
text: '2. Another line of text.',
|
39
|
+
}
|
40
|
+
]
|
41
|
+
}
|
42
|
+
]
|
43
|
+
}
|
44
|
+
)
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'handles coloured lines' do
|
48
|
+
Vedeu.view 'testing_view' do
|
49
|
+
line do
|
50
|
+
text '1. Line without colours.'
|
51
|
+
end
|
52
|
+
end.must_equal(
|
53
|
+
{
|
54
|
+
name: 'testing_view',
|
55
|
+
lines: [
|
56
|
+
{
|
57
|
+
colour: {},
|
58
|
+
style: [],
|
59
|
+
streams: [{ text: '1. Line without colours.' }]
|
60
|
+
}
|
61
|
+
]
|
62
|
+
}
|
63
|
+
)
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'handles coloured lines' do
|
67
|
+
Vedeu.view 'testing_view' do
|
68
|
+
line do
|
69
|
+
colour '#ff0000', '#ffff00'
|
70
|
+
text '2. Line with colours.'
|
71
|
+
end
|
72
|
+
end.must_equal(
|
73
|
+
{
|
74
|
+
name: 'testing_view',
|
75
|
+
lines: [
|
76
|
+
{
|
77
|
+
colour: { background: '#ff0000', foreground: '#ffff00' },
|
78
|
+
style: [],
|
79
|
+
streams: [{ text: '2. Line with colours.' }]
|
80
|
+
}
|
81
|
+
]
|
82
|
+
}
|
83
|
+
)
|
84
|
+
end
|
85
|
+
|
86
|
+
it 'handles coloured lines' do
|
87
|
+
Vedeu.view 'testing_view' do
|
88
|
+
line do
|
89
|
+
colour foreground: '#a7ff00', background: '#005700'
|
90
|
+
text '3. Line with explicit colour declaration.'
|
91
|
+
end
|
92
|
+
end.must_equal(
|
93
|
+
{
|
94
|
+
name: 'testing_view',
|
95
|
+
lines: [
|
96
|
+
{
|
97
|
+
colour: { background: '#005700', foreground: '#a7ff00' },
|
98
|
+
style: [],
|
99
|
+
streams: [{ text: '3. Line with explicit colour declaration.' }]
|
100
|
+
}
|
101
|
+
]
|
102
|
+
}
|
103
|
+
)
|
104
|
+
end
|
105
|
+
|
106
|
+
it 'handles coloured lines' do
|
107
|
+
Vedeu.view 'testing_view' do
|
108
|
+
line do # actually uses streams
|
109
|
+
foreground '#ff00ff' do
|
110
|
+
text '4. Line with only foreground set.'
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end.must_equal(
|
114
|
+
{
|
115
|
+
name: 'testing_view',
|
116
|
+
lines: [
|
117
|
+
{
|
118
|
+
colour: {},
|
119
|
+
style: [],
|
120
|
+
streams: [{
|
121
|
+
colour: { foreground: '#ff00ff' },
|
122
|
+
style: [],
|
123
|
+
text: '4. Line with only foreground set.'
|
124
|
+
}]
|
125
|
+
}
|
126
|
+
]
|
127
|
+
}
|
128
|
+
)
|
129
|
+
end
|
130
|
+
|
131
|
+
it 'handles coloured lines' do
|
132
|
+
Vedeu.view 'testing_view' do
|
133
|
+
line do # actually uses streams
|
134
|
+
background '#00ff00' do
|
135
|
+
text '5. Line with only background set.'
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end.must_equal(
|
139
|
+
{
|
140
|
+
name: 'testing_view',
|
141
|
+
lines: [
|
142
|
+
{
|
143
|
+
colour: {},
|
144
|
+
style: [],
|
145
|
+
streams: [{
|
146
|
+
colour: { background: '#00ff00' },
|
147
|
+
style: [],
|
148
|
+
text: '5. Line with only background set.'
|
149
|
+
}]
|
150
|
+
}
|
151
|
+
]
|
152
|
+
}
|
153
|
+
)
|
154
|
+
end
|
155
|
+
|
156
|
+
it 'handles styles' do
|
157
|
+
Vedeu.view 'testing_view' do
|
158
|
+
line do
|
159
|
+
style 'normal'
|
160
|
+
text '1. Line with a normal style.'
|
161
|
+
end
|
162
|
+
end.must_equal(
|
163
|
+
{
|
164
|
+
name: 'testing_view',
|
165
|
+
lines: [
|
166
|
+
{
|
167
|
+
colour: {},
|
168
|
+
style: ['normal'],
|
169
|
+
streams: [{
|
170
|
+
text: '1. Line with a normal style.'
|
171
|
+
}]
|
172
|
+
}
|
173
|
+
]
|
174
|
+
}
|
175
|
+
)
|
176
|
+
end
|
177
|
+
|
178
|
+
it 'handles styles' do
|
179
|
+
Vedeu.view 'testing_view' do
|
180
|
+
line do
|
181
|
+
style 'underline'
|
182
|
+
text '2. Line with an underline style.'
|
183
|
+
end
|
184
|
+
end.must_equal(
|
185
|
+
{
|
186
|
+
name: 'testing_view',
|
187
|
+
lines: [
|
188
|
+
{
|
189
|
+
colour: {},
|
190
|
+
style: ['underline'],
|
191
|
+
streams: [{
|
192
|
+
text: '2. Line with an underline style.'
|
193
|
+
}]
|
194
|
+
}
|
195
|
+
]
|
196
|
+
}
|
197
|
+
)
|
198
|
+
end
|
199
|
+
|
200
|
+
it 'handles styles' do
|
201
|
+
Vedeu.view 'testing_view' do
|
202
|
+
line do # actually uses streams
|
203
|
+
style 'normal' do
|
204
|
+
text '3. Line with a normal style.'
|
205
|
+
end
|
206
|
+
end
|
207
|
+
end.must_equal(
|
208
|
+
{
|
209
|
+
name: 'testing_view',
|
210
|
+
lines: [
|
211
|
+
{
|
212
|
+
colour: {},
|
213
|
+
style: [],
|
214
|
+
streams: [{
|
215
|
+
colour: {},
|
216
|
+
style: ['normal'],
|
217
|
+
text: '3. Line with a normal style.'
|
218
|
+
}]
|
219
|
+
}
|
220
|
+
]
|
221
|
+
}
|
222
|
+
)
|
223
|
+
end
|
224
|
+
|
225
|
+
it 'handles styles' do
|
226
|
+
Vedeu.view 'testing_view' do
|
227
|
+
line do # actually uses streams
|
228
|
+
style 'underline' do
|
229
|
+
text '4. Line with an underlined style.'
|
230
|
+
end
|
231
|
+
end
|
232
|
+
end.must_equal(
|
233
|
+
{
|
234
|
+
name: 'testing_view',
|
235
|
+
lines: [
|
236
|
+
{
|
237
|
+
colour: {},
|
238
|
+
style: [],
|
239
|
+
streams: [{
|
240
|
+
colour: {},
|
241
|
+
style: ['underline'],
|
242
|
+
text: '4. Line with an underlined style.'
|
243
|
+
}]
|
244
|
+
}
|
245
|
+
]
|
246
|
+
}
|
247
|
+
)
|
248
|
+
end
|
249
|
+
|
250
|
+
it 'handles streams, which means sub-line colours and styles' do
|
251
|
+
Vedeu.view 'testing_view' do
|
252
|
+
line do
|
253
|
+
stream do
|
254
|
+
text 'A stream of text.'
|
255
|
+
end
|
256
|
+
end
|
257
|
+
end.must_equal(
|
258
|
+
{
|
259
|
+
name: 'testing_view',
|
260
|
+
lines: [
|
261
|
+
{
|
262
|
+
colour: {},
|
263
|
+
style: [],
|
264
|
+
streams: [
|
265
|
+
{
|
266
|
+
colour: {},
|
267
|
+
style: [],
|
268
|
+
text: 'A stream of text.'
|
269
|
+
}
|
270
|
+
]
|
271
|
+
}
|
272
|
+
]
|
273
|
+
}
|
274
|
+
)
|
275
|
+
end
|
276
|
+
|
277
|
+
it 'handles streams, which means sub-line colours and styles' do
|
278
|
+
Vedeu.view 'testing_view' do
|
279
|
+
line do
|
280
|
+
stream do # Stream is an 'explicit declaration'.
|
281
|
+
# We don't need it unless we want to add colours and styles.
|
282
|
+
# See below.
|
283
|
+
text '1. Two streams of text, these will be'
|
284
|
+
end
|
285
|
+
|
286
|
+
stream do
|
287
|
+
text ' on the same line- note the space.'
|
288
|
+
end
|
289
|
+
end
|
290
|
+
end.must_equal(
|
291
|
+
{
|
292
|
+
name: 'testing_view',
|
293
|
+
lines: [
|
294
|
+
{
|
295
|
+
colour: {},
|
296
|
+
style: [],
|
297
|
+
streams: [
|
298
|
+
{
|
299
|
+
colour: {},
|
300
|
+
style: [],
|
301
|
+
text: '1. Two streams of text, these will be'
|
302
|
+
}, {
|
303
|
+
colour: {},
|
304
|
+
style: [],
|
305
|
+
text: ' on the same line- note the space.'
|
306
|
+
}
|
307
|
+
]
|
308
|
+
}
|
309
|
+
]
|
310
|
+
}
|
311
|
+
)
|
312
|
+
end
|
313
|
+
|
314
|
+
it 'handles streams, which means sub-line colours and styles' do
|
315
|
+
Vedeu.view 'testing_view' do
|
316
|
+
line do
|
317
|
+
stream do
|
318
|
+
text '2. Streams can have'
|
319
|
+
end
|
320
|
+
|
321
|
+
stream do
|
322
|
+
colour foreground: '#ff0000', background: '#00ff00'
|
323
|
+
text ' colours too.'
|
324
|
+
end
|
325
|
+
end
|
326
|
+
end.must_equal(
|
327
|
+
{
|
328
|
+
name: 'testing_view',
|
329
|
+
lines: [
|
330
|
+
{
|
331
|
+
colour: {},
|
332
|
+
style: [],
|
333
|
+
streams: [
|
334
|
+
{
|
335
|
+
colour: {},
|
336
|
+
style: [],
|
337
|
+
text: '2. Streams can have'
|
338
|
+
}, {
|
339
|
+
colour: {
|
340
|
+
foreground: '#ff0000',
|
341
|
+
background: '#00ff00'
|
342
|
+
},
|
343
|
+
style: [],
|
344
|
+
text: ' colours too.'
|
345
|
+
}
|
346
|
+
]
|
347
|
+
}
|
348
|
+
]
|
349
|
+
}
|
350
|
+
)
|
351
|
+
end
|
352
|
+
|
353
|
+
it 'handles streams, which means sub-line colours and styles' do
|
354
|
+
Vedeu.view 'testing_view' do
|
355
|
+
line do
|
356
|
+
stream do
|
357
|
+
text '3. Streams can have'
|
358
|
+
end
|
359
|
+
|
360
|
+
stream do
|
361
|
+
style 'underline'
|
362
|
+
text ' styles too.'
|
363
|
+
end
|
364
|
+
end
|
365
|
+
end.must_equal(
|
366
|
+
{
|
367
|
+
name: 'testing_view',
|
368
|
+
lines: [
|
369
|
+
{
|
370
|
+
colour: {},
|
371
|
+
style: [],
|
372
|
+
streams: [
|
373
|
+
{
|
374
|
+
colour: {},
|
375
|
+
style: [],
|
376
|
+
text: '3. Streams can have'
|
377
|
+
}, {
|
378
|
+
colour: {},
|
379
|
+
style: ['underline'],
|
380
|
+
text: ' styles too.'
|
381
|
+
}
|
382
|
+
]
|
383
|
+
}
|
384
|
+
]
|
385
|
+
}
|
386
|
+
)
|
387
|
+
end
|
388
|
+
|
389
|
+
it 'handles alignment' do
|
390
|
+
skip
|
391
|
+
Vedeu.view 'testing_view' do
|
392
|
+
line do
|
393
|
+
width 80
|
394
|
+
text 'This is aligned left, and padded with spaces.'
|
395
|
+
end
|
396
|
+
end.must_equal(
|
397
|
+
{
|
398
|
+
name: 'testing_view',
|
399
|
+
lines: [{
|
400
|
+
colour: {},
|
401
|
+
style: [],
|
402
|
+
streams: [{
|
403
|
+
width: 80,
|
404
|
+
text: 'This is aligned left, and padded with spaces.'
|
405
|
+
}]
|
406
|
+
}]
|
407
|
+
}
|
408
|
+
)
|
409
|
+
end
|
410
|
+
|
411
|
+
it 'handles alignment' do
|
412
|
+
skip
|
413
|
+
Vedeu.view 'testing_view' do
|
414
|
+
line do
|
415
|
+
width 80
|
416
|
+
align :left # explicit
|
417
|
+
text 'This is aligned left, and padded with spaces.'
|
418
|
+
end
|
419
|
+
end.must_equal(
|
420
|
+
{
|
421
|
+
name: 'testing_view',
|
422
|
+
lines: [{
|
423
|
+
streams: [{
|
424
|
+
width: 80,
|
425
|
+
align: :left,
|
426
|
+
text: 'This is aligned left, and padded with spaces.'
|
427
|
+
}]
|
428
|
+
}]
|
429
|
+
}
|
430
|
+
)
|
431
|
+
end
|
432
|
+
|
433
|
+
it 'handles alignment' do
|
434
|
+
skip
|
435
|
+
Vedeu.view 'testing_view' do
|
436
|
+
line do
|
437
|
+
width 80
|
438
|
+
align :centre
|
439
|
+
text 'This is aligned centrally, and padded with spaces.'
|
440
|
+
end
|
441
|
+
end.must_equal(
|
442
|
+
{
|
443
|
+
name: 'testing_view',
|
444
|
+
lines: [{
|
445
|
+
streams: [{
|
446
|
+
width: 80,
|
447
|
+
align: :centre,
|
448
|
+
text: 'This is aligned right, and padded with spaces.'
|
449
|
+
}]
|
450
|
+
}]
|
451
|
+
}
|
452
|
+
)
|
453
|
+
end
|
454
|
+
|
455
|
+
it 'handles alignment' do
|
456
|
+
skip
|
457
|
+
Vedeu.view 'testing_view' do
|
458
|
+
line do
|
459
|
+
width 80
|
460
|
+
align :right
|
461
|
+
text 'This is aligned right, and padded with spaces.'
|
462
|
+
end
|
463
|
+
end.must_equal(
|
464
|
+
{
|
465
|
+
name: 'testing_view',
|
466
|
+
lines: [{
|
467
|
+
streams: [{
|
468
|
+
width: 80,
|
469
|
+
align: :right,
|
470
|
+
text: 'This is aligned right, and padded with spaces.'
|
471
|
+
}]
|
472
|
+
}]
|
473
|
+
}
|
474
|
+
)
|
475
|
+
end
|
476
|
+
end
|
477
|
+
end
|
478
|
+
end
|
@@ -1,9 +1,46 @@
|
|
1
1
|
require 'test_helper'
|
2
|
+
require 'vedeu/support/menu'
|
2
3
|
require 'vedeu/output/menu_parser'
|
3
4
|
|
4
5
|
module Vedeu
|
5
6
|
describe MenuParser do
|
6
7
|
describe '.parse' do
|
8
|
+
it 'returns an interface' do
|
9
|
+
items = [
|
10
|
+
[false, true, 'Hydrogen'],
|
11
|
+
[true, false, 'Helium'],
|
12
|
+
[false, false, 'Lithium'],
|
13
|
+
[true, true, 'Beryllium']
|
14
|
+
]
|
15
|
+
args = ['dummy', items]
|
16
|
+
parser = MenuParser.parse(args)
|
17
|
+
parser.must_equal(
|
18
|
+
{
|
19
|
+
interfaces: {
|
20
|
+
name: 'dummy',
|
21
|
+
lines: [
|
22
|
+
{
|
23
|
+
streams: {
|
24
|
+
text: ' > Hydrogen'
|
25
|
+
}
|
26
|
+
}, {
|
27
|
+
streams: {
|
28
|
+
text: '* Helium'
|
29
|
+
}
|
30
|
+
}, {
|
31
|
+
streams: {
|
32
|
+
text: ' Lithium'
|
33
|
+
}
|
34
|
+
}, {
|
35
|
+
streams: {
|
36
|
+
text: '*> Beryllium'
|
37
|
+
}
|
38
|
+
}
|
39
|
+
]
|
40
|
+
}
|
41
|
+
}
|
42
|
+
)
|
43
|
+
end
|
7
44
|
end
|
8
45
|
end
|
9
46
|
end
|
@@ -46,6 +46,26 @@ module Vedeu
|
|
46
46
|
})
|
47
47
|
end
|
48
48
|
|
49
|
+
it 'returns a Hash when the output is content is a Hash' do
|
50
|
+
RawParser.parse({ dummy: [{ streams: { text: 'Some content' } }] })
|
51
|
+
.must_equal(
|
52
|
+
{
|
53
|
+
interfaces: [
|
54
|
+
{
|
55
|
+
name: 'dummy',
|
56
|
+
lines: [
|
57
|
+
{
|
58
|
+
streams: {
|
59
|
+
text: 'Some content'
|
60
|
+
}
|
61
|
+
}
|
62
|
+
]
|
63
|
+
}
|
64
|
+
]
|
65
|
+
}
|
66
|
+
)
|
67
|
+
end
|
68
|
+
|
49
69
|
it 'returns a Hash when the output is empty' do
|
50
70
|
RawParser.parse({}).must_equal({ interfaces: [] })
|
51
71
|
end
|
data/test/lib/vedeu_test.rb
CHANGED
@@ -12,21 +12,21 @@ module Vedeu
|
|
12
12
|
describe '.run' do
|
13
13
|
end
|
14
14
|
|
15
|
-
describe '.view' do
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
end
|
15
|
+
# describe '.view' do
|
16
|
+
# it 'returns the interface referenced by name' do
|
17
|
+
# Vedeu.interface 'Vedeu.view' do
|
18
|
+
# width 5
|
19
|
+
# height 5
|
20
|
+
# end
|
21
|
+
|
22
|
+
# Vedeu.view('Vedeu.view').must_be_instance_of(Interface)
|
23
|
+
# Vedeu.view('Vedeu.view').name.must_equal('Vedeu.view')
|
24
|
+
# end
|
25
|
+
|
26
|
+
# it 'raises an exception if the interface does not exist' do
|
27
|
+
# proc { Vedeu.view('unknown') }.must_raise(EntityNotFound)
|
28
|
+
# end
|
29
|
+
# end
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
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.5'
|
8
8
|
spec.authors = ['Gavin Laking']
|
9
9
|
spec.email = ['gavinlaking@gmail.com']
|
10
10
|
spec.summary = %q{A terminal case of wonderland.}
|
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.5
|
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-08-
|
11
|
+
date: 2014-08-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -185,6 +185,11 @@ files:
|
|
185
185
|
- bin/vedeu
|
186
186
|
- deps.md
|
187
187
|
- lib/vedeu.rb
|
188
|
+
- lib/vedeu/api/base.rb
|
189
|
+
- lib/vedeu/api/interface.rb
|
190
|
+
- lib/vedeu/api/line.rb
|
191
|
+
- lib/vedeu/api/stream.rb
|
192
|
+
- lib/vedeu/api/view.rb
|
188
193
|
- lib/vedeu/application.rb
|
189
194
|
- lib/vedeu/configuration.rb
|
190
195
|
- lib/vedeu/instrumentation.rb
|
@@ -214,12 +219,16 @@ files:
|
|
214
219
|
- lib/vedeu/support/helpers.rb
|
215
220
|
- lib/vedeu/support/input.rb
|
216
221
|
- lib/vedeu/support/interface_store.rb
|
217
|
-
- lib/vedeu/support/interface_template.rb
|
218
222
|
- lib/vedeu/support/menu.rb
|
219
223
|
- lib/vedeu/support/queue.rb
|
220
224
|
- lib/vedeu/support/terminal.rb
|
221
225
|
- lib/vedeu/support/wordwrap.rb
|
222
226
|
- logs/.gitkeep
|
227
|
+
- test/lib/vedeu/api/base_test.rb
|
228
|
+
- test/lib/vedeu/api/interface_test.rb
|
229
|
+
- test/lib/vedeu/api/line_test.rb
|
230
|
+
- test/lib/vedeu/api/stream_test.rb
|
231
|
+
- test/lib/vedeu/api/view_test.rb
|
223
232
|
- test/lib/vedeu/application_test.rb
|
224
233
|
- test/lib/vedeu/configuration_test.rb
|
225
234
|
- test/lib/vedeu/launcher_test.rb
|
@@ -248,7 +257,6 @@ files:
|
|
248
257
|
- test/lib/vedeu/support/helpers_test.rb
|
249
258
|
- test/lib/vedeu/support/input_test.rb
|
250
259
|
- test/lib/vedeu/support/interface_store_test.rb
|
251
|
-
- test/lib/vedeu/support/interface_template_test.rb
|
252
260
|
- test/lib/vedeu/support/menu_test.rb
|
253
261
|
- test/lib/vedeu/support/queue_test.rb
|
254
262
|
- test/lib/vedeu/support/terminal_test.rb
|
@@ -303,6 +311,11 @@ signing_key:
|
|
303
311
|
specification_version: 4
|
304
312
|
summary: A terminal case of wonderland.
|
305
313
|
test_files:
|
314
|
+
- test/lib/vedeu/api/base_test.rb
|
315
|
+
- test/lib/vedeu/api/interface_test.rb
|
316
|
+
- test/lib/vedeu/api/line_test.rb
|
317
|
+
- test/lib/vedeu/api/stream_test.rb
|
318
|
+
- test/lib/vedeu/api/view_test.rb
|
306
319
|
- test/lib/vedeu/application_test.rb
|
307
320
|
- test/lib/vedeu/configuration_test.rb
|
308
321
|
- test/lib/vedeu/launcher_test.rb
|
@@ -331,7 +344,6 @@ test_files:
|
|
331
344
|
- test/lib/vedeu/support/helpers_test.rb
|
332
345
|
- test/lib/vedeu/support/input_test.rb
|
333
346
|
- test/lib/vedeu/support/interface_store_test.rb
|
334
|
-
- test/lib/vedeu/support/interface_template_test.rb
|
335
347
|
- test/lib/vedeu/support/menu_test.rb
|
336
348
|
- test/lib/vedeu/support/queue_test.rb
|
337
349
|
- test/lib/vedeu/support/terminal_test.rb
|
@@ -1,74 +0,0 @@
|
|
1
|
-
require 'vedeu/models/geometry'
|
2
|
-
require 'vedeu/support/interface_store'
|
3
|
-
require 'vedeu/support/terminal'
|
4
|
-
|
5
|
-
module Vedeu
|
6
|
-
InvalidHeight = Class.new(StandardError)
|
7
|
-
InvalidWidth = Class.new(StandardError)
|
8
|
-
XOutOfBounds = Class.new(StandardError)
|
9
|
-
YOutOfBounds = Class.new(StandardError)
|
10
|
-
|
11
|
-
class InterfaceTemplate
|
12
|
-
def self.save(name, &block)
|
13
|
-
new(name).save(&block)
|
14
|
-
end
|
15
|
-
|
16
|
-
def initialize(name)
|
17
|
-
@name = name.to_s
|
18
|
-
end
|
19
|
-
|
20
|
-
def save(&block)
|
21
|
-
self.instance_eval(&block)
|
22
|
-
|
23
|
-
InterfaceStore.create(attributes)
|
24
|
-
end
|
25
|
-
|
26
|
-
def x(value)
|
27
|
-
fail XOutOfBounds if x_out_of_bounds?(value)
|
28
|
-
|
29
|
-
attributes[:geometry][:x] = value
|
30
|
-
end
|
31
|
-
|
32
|
-
def y(value)
|
33
|
-
fail YOutOfBounds if y_out_of_bounds?(value)
|
34
|
-
|
35
|
-
attributes[:geometry][:y] = value
|
36
|
-
end
|
37
|
-
|
38
|
-
def width(value)
|
39
|
-
fail InvalidWidth if x_out_of_bounds?(value)
|
40
|
-
|
41
|
-
attributes[:geometry][:width] = value
|
42
|
-
end
|
43
|
-
|
44
|
-
def height(value)
|
45
|
-
fail InvalidHeight if y_out_of_bounds?(value)
|
46
|
-
|
47
|
-
attributes[:geometry][:height] = value
|
48
|
-
end
|
49
|
-
|
50
|
-
def centred(value)
|
51
|
-
attributes[:geometry][:centred] = value
|
52
|
-
end
|
53
|
-
|
54
|
-
private
|
55
|
-
|
56
|
-
attr_reader :name
|
57
|
-
|
58
|
-
def attributes
|
59
|
-
@attributes ||= { name: name, geometry: {} }
|
60
|
-
end
|
61
|
-
|
62
|
-
def method_missing(method_name, arg, &block)
|
63
|
-
attributes[method_name] = arg
|
64
|
-
end
|
65
|
-
|
66
|
-
def y_out_of_bounds?(value)
|
67
|
-
value < 1 || value > Terminal.height
|
68
|
-
end
|
69
|
-
|
70
|
-
def x_out_of_bounds?(value)
|
71
|
-
value < 1 || value > Terminal.width
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
@@ -1,97 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
require 'vedeu/support/interface_template'
|
3
|
-
|
4
|
-
module Vedeu
|
5
|
-
describe InterfaceTemplate do
|
6
|
-
it 'creates and stores a new interface' do
|
7
|
-
interface = InterfaceTemplate.save('widget') do
|
8
|
-
colour foreground: '#ff0000', background: '#5f0000'
|
9
|
-
cursor false
|
10
|
-
width 10
|
11
|
-
height 2
|
12
|
-
centred true
|
13
|
-
end
|
14
|
-
interface.must_be_instance_of(Interface)
|
15
|
-
end
|
16
|
-
|
17
|
-
it 'allows interfaces to share behaviour' do
|
18
|
-
IO.console.stub :winsize, [10, 40] do
|
19
|
-
main = InterfaceTemplate.save('main') do
|
20
|
-
colour foreground: '#ff0000', background: '#000000'
|
21
|
-
cursor false
|
22
|
-
centred true
|
23
|
-
width 10
|
24
|
-
height 2
|
25
|
-
end
|
26
|
-
status = InterfaceTemplate.save('status') do
|
27
|
-
colour foreground: 'aadd00', background: '#4040cc'
|
28
|
-
cursor true
|
29
|
-
centred true
|
30
|
-
width 10
|
31
|
-
height 1
|
32
|
-
y main.geometry.bottom
|
33
|
-
x main.geometry.left
|
34
|
-
end
|
35
|
-
|
36
|
-
main.geometry.left.must_equal(15)
|
37
|
-
main.geometry.top.must_equal(4)
|
38
|
-
status.geometry.left.must_equal(15)
|
39
|
-
status.geometry.top.must_equal(5)
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
describe '#x' do
|
44
|
-
interface = InterfaceTemplate.new('widget')
|
45
|
-
|
46
|
-
it 'raises an exception when the value is out of bounds' do
|
47
|
-
proc { interface.x(0) }.must_raise(XOutOfBounds)
|
48
|
-
end
|
49
|
-
|
50
|
-
it 'raises an exception when the value is out of bounds' do
|
51
|
-
proc { interface.x(999) }.must_raise(XOutOfBounds)
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
describe '#y' do
|
56
|
-
interface = InterfaceTemplate.new('widget')
|
57
|
-
|
58
|
-
it 'raises an exception when the value is out of bounds' do
|
59
|
-
proc { interface.y(0) }.must_raise(YOutOfBounds)
|
60
|
-
end
|
61
|
-
|
62
|
-
it 'raises an exception when the value is out of bounds' do
|
63
|
-
proc { interface.y(999) }.must_raise(YOutOfBounds)
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
describe '#width' do
|
68
|
-
interface = InterfaceTemplate.new('widget')
|
69
|
-
|
70
|
-
it 'raises an exception when the value is out of bounds' do
|
71
|
-
proc { interface.width(0) }.must_raise(InvalidWidth)
|
72
|
-
end
|
73
|
-
|
74
|
-
it 'raises an exception when the value is out of bounds' do
|
75
|
-
proc { interface.width(999) }.must_raise(InvalidWidth)
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
describe '#height' do
|
80
|
-
interface = InterfaceTemplate.new('widget')
|
81
|
-
|
82
|
-
it 'raises an exception when the value is out of bounds' do
|
83
|
-
proc { interface.height(0) }.must_raise(InvalidHeight)
|
84
|
-
end
|
85
|
-
|
86
|
-
it 'raises an exception when the value is out of bounds' do
|
87
|
-
proc { interface.height(999) }.must_raise(InvalidHeight)
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
describe '#centred' do
|
92
|
-
it 'should hav a valid spec, please write one.' do
|
93
|
-
skip
|
94
|
-
end
|
95
|
-
end
|
96
|
-
end
|
97
|
-
end
|