vedeu 0.4.21 → 0.4.22

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6d59258ed8c80d1a0edbe50022689de2cdd6b0ae
4
- data.tar.gz: 68f3f7a8bbde59807faa8c9517400f4d43d0c127
3
+ metadata.gz: 0d79ec97271163d2a5714da17bb182a5b10e8364
4
+ data.tar.gz: 8103b05cdd5a5bc0b9936963ac0d4685d0a316ff
5
5
  SHA512:
6
- metadata.gz: 6841e54f8ca0cc71018cf628d0384bc1c250e608505ce55881391130358b9296e1716a3adde7863cf41370c4416e4fe7126b232976a83d8173166cd2c2384d62
7
- data.tar.gz: 50c7fcc0dbd3e42e54dce9367e3fb1af1443a7e853dce4614ed25cbee41f2621a7e4a1624daf3b61285f6c0f8caff7341728f2b7144102feaca8a8b98c01186f
6
+ metadata.gz: 8d6349acfc3ebb738025f2f52604ac2a731a3174ebad8556437110e747c0d6392f976c28d1808b6552edcbfded5316031694d264436f20c4fd1b633cc225166c
7
+ data.tar.gz: 23fe6d51808b2b699632574ab8f4aedd79974ac057ccf59ac85b6e78a7e47fa1df8344ff7b24c5896f259dc7ea8399a9b97bef5eee148de79887f45bb46070d5
@@ -0,0 +1,120 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ lib_dir = File.dirname(__FILE__) + '/../lib'
4
+ $LOAD_PATH.unshift(lib_dir) unless $LOAD_PATH.include?(lib_dir)
5
+
6
+ require 'vedeu'
7
+
8
+ # An example application to demonstrate maximising and unmaximising views.
9
+ #
10
+ class VedeuMaximiseApp
11
+
12
+ include Vedeu
13
+
14
+ configure do
15
+ debug!
16
+ log '/tmp/vedeu_maximise_app.log'
17
+ end
18
+
19
+ interface 'main_interface' do
20
+ colour foreground: '#ff0000', background: '#000000'
21
+ cursor!
22
+
23
+ geometry do
24
+ centred true
25
+ height 10
26
+ width 20
27
+ end
28
+ end
29
+
30
+ keymap('_global_') do
31
+ key(:up, 'k') { Vedeu.trigger(:_cursor_up_) }
32
+ key(:right, 'l') { Vedeu.trigger(:_cursor_right_) }
33
+ key(:down, 'j') { Vedeu.trigger(:_cursor_down_) }
34
+ key(:left, 'h') { Vedeu.trigger(:_cursor_left_) }
35
+ key('m') { Vedeu.trigger(:_maximise_, 'main_interface') }
36
+ key('n') { Vedeu.trigger(:_unmaximise_, 'main_interface') }
37
+ end
38
+
39
+ renders do
40
+ view 'main_interface' do
41
+ border do
42
+ colour foreground: '#aadd00', background: '#000000'
43
+ title 'Move!'
44
+ end
45
+ lines do
46
+ streams do
47
+ text 'A.3 '
48
+ end
49
+ streams do
50
+ background '#550000'
51
+ foreground '#ffff00'
52
+ text 'hydrogen'
53
+ end
54
+ streams do
55
+ text ' helium'
56
+ end
57
+ end
58
+ lines do
59
+ streams do
60
+ text 'B.34 '
61
+ text 'lithium ', colour: { foreground: '#63d48e' }
62
+ text 'beryllium '
63
+ text 'boron', colour: { background: '#770033' }
64
+ text ' nitrogen'
65
+ end
66
+ end
67
+ lines do
68
+ streams do
69
+ text 'C.345'
70
+ text ' carbon oxygen '
71
+ end
72
+ streams do
73
+ background '#aadd00'
74
+ foreground '#00ddaa'
75
+ text 'fluorine'
76
+ end
77
+ end
78
+ lines do
79
+ streams do
80
+ text 'D.3456'
81
+ end
82
+ end
83
+ lines do
84
+ streams do
85
+ text 'E.34567 neon sodium', colour: { foreground: '#ffffff' }
86
+ end
87
+ end
88
+ lines do
89
+ streams do
90
+ text 'F.345678 magnesium '
91
+ end
92
+ streams do
93
+ foreground '#00aaff'
94
+ text 'aluminium'
95
+ end
96
+ end
97
+ lines do
98
+ streams do
99
+ text 'G.3456789 silicon'
100
+ end
101
+ end
102
+ lines do
103
+ streams do
104
+ background '#550000'
105
+ foreground '#ff00ff'
106
+ text 'H.34567890'
107
+ end
108
+ end
109
+ end
110
+ end
111
+
112
+ focus_by_name 'main_interface'
113
+
114
+ def self.start(argv = ARGV)
115
+ Vedeu::Launcher.execute!(argv)
116
+ end
117
+
118
+ end
119
+
120
+ VedeuMaximiseApp.start(ARGV)
@@ -80,7 +80,7 @@ module Vedeu
80
80
 
81
81
  # When triggered will cause Vedeu to trigger the `:_clear_` and `:_refresh_`
82
82
  # events. Please see those events for their behaviour.
83
- Vedeu.bind(:_resize_, delay: 0.25) { Vedeu.resize }
83
+ Vedeu.bind(:_resize_, delay: 0.15) { Vedeu.resize }
84
84
 
85
85
  Vedeu.bind(:tick) do |time|
86
86
  Vedeu.log(type: :debug, message: "Tick: #{time}")
@@ -72,9 +72,9 @@ module Vedeu
72
72
  #
73
73
  # @return [void]
74
74
  def clear
75
- Vedeu::Output.render(clear_buffer) unless clear_buffer.empty?
76
-
77
- clear_buffer
75
+ unless clear_buffer.empty?
76
+ Vedeu::Output.render(clear_buffer)
77
+ end
78
78
  end
79
79
 
80
80
  # Hide this buffer.
@@ -54,6 +54,8 @@ module Vedeu
54
54
  @y, @yn, @x, @xn = y, yn, x, xn
55
55
  end
56
56
 
57
+ # An object is equal when its values are the same.
58
+ #
57
59
  # @param other [Vedeu::Area]
58
60
  # @return [Boolean]
59
61
  def eql?(other)
@@ -63,16 +63,16 @@ module Vedeu
63
63
 
64
64
  # @return [Array<Fixnum>]
65
65
  def dimension
66
- @dimension ||= if maximised?
67
- [1, default]
66
+ @dimension = if maximised?
67
+ [1, default]
68
68
 
69
- elsif centred? && length?
70
- [centred_d, centred_dn]
69
+ elsif centred? && length?
70
+ [centred_d, centred_dn]
71
71
 
72
- else
73
- [_d, _dn]
72
+ else
73
+ [_d, _dn]
74
74
 
75
- end
75
+ end
76
76
  end
77
77
 
78
78
  # @return [Boolean]
@@ -86,6 +86,7 @@ module Vedeu
86
86
  #
87
87
  # @param attributes [Hash]
88
88
  # @option attributes centred [Boolean]
89
+ # @option attributes maximised [Boolean]
89
90
  # @option attributes height [Fixnum]
90
91
  # @option attributes name [String]
91
92
  # @option attributes repository [Vedeu::Geometries]
@@ -101,6 +102,11 @@ module Vedeu
101
102
  @attributes.each { |key, value| instance_variable_set("@#{key}", value) }
102
103
  end
103
104
 
105
+ # @return [String]
106
+ def inspect
107
+ "<Vedeu::Geometry x:#{x} xn:#{xn} y:#{y} yn:#{yn} maximise:#{maximised}>"
108
+ end
109
+
104
110
  # @return [Vedeu::Geometry]
105
111
  def maximise
106
112
  @maximised = true
@@ -119,29 +125,29 @@ module Vedeu
119
125
 
120
126
  # @return [Vedeu::Area]
121
127
  def area
122
- Vedeu::Area.from_dimensions(y_yn: y_yn, x_xn: x_xn)
128
+ @area = Vedeu::Area.from_dimensions(y_yn: y_yn, x_xn: x_xn)
123
129
  end
124
130
 
125
131
  # @return [Array<Fixnum>]
126
132
  def x_xn
127
- Vedeu::Dimension.pair(d: _x,
128
- dn: _xn,
129
- d_dn: @width,
130
- default: Vedeu::Terminal.width,
131
- options: {
132
- centred: centred,
133
- maximised: maximised })
133
+ @x_xn = Vedeu::Dimension.pair(d: _x,
134
+ dn: _xn,
135
+ d_dn: @width,
136
+ default: Vedeu::Terminal.width,
137
+ options: {
138
+ centred: centred,
139
+ maximised: maximised })
134
140
  end
135
141
 
136
142
  # @return [Array<Fixnum>]
137
143
  def y_yn
138
- Vedeu::Dimension.pair(d: _y,
139
- dn: _yn,
140
- d_dn: @height,
141
- default: Vedeu::Terminal.height,
142
- options: {
143
- centred: centred,
144
- maximised: maximised })
144
+ @y_yn = Vedeu::Dimension.pair(d: _y,
145
+ dn: _yn,
146
+ d_dn: @height,
147
+ default: Vedeu::Terminal.height,
148
+ options: {
149
+ centred: centred,
150
+ maximised: maximised })
145
151
  end
146
152
 
147
153
  # Returns the row/line start position for the interface.
@@ -31,6 +31,8 @@ module Vedeu
31
31
  Vedeu::Position.new(y, x)
32
32
  end
33
33
 
34
+ # An object is equal when its values are the same.
35
+ #
34
36
  # @param other [Vedeu::IndexPosition]
35
37
  # @return [Boolean]
36
38
  def eql?(other)
@@ -46,6 +46,8 @@ module Vedeu
46
46
  @x = (x.nil? || x < 1) ? 1 : x
47
47
  end
48
48
 
49
+ # An object is equal when its values are the same.
50
+ #
49
51
  # @param other [Vedeu::Position]
50
52
  # @return [Boolean]
51
53
  def eql?(other)
@@ -1,6 +1,7 @@
1
1
  module Vedeu
2
2
 
3
- # Converts a position into an index for the terminal.
3
+ # Converts a position into an index for the terminal. An index is the position
4
+ # minus 1.
4
5
  class PositionIndex
5
6
 
6
7
  # Convenience constructor for Vedeu::Position.
@@ -27,6 +28,8 @@ module Vedeu
27
28
  [y, x]
28
29
  end
29
30
 
31
+ # An object is equal when its values are the same.
32
+ #
30
33
  # @param other [Vedeu::PositionIndex]
31
34
  # @return [Boolean]
32
35
  def eql?(other)
@@ -34,17 +37,25 @@ module Vedeu
34
37
  end
35
38
  alias_method :==, :eql?
36
39
 
40
+ # Converts the index values into a Vedeu::Position.
41
+ #
37
42
  # @return [Vedeu::Position]
38
43
  def to_position
39
44
  Vedeu::Position.new(y, x)
40
45
  end
41
46
 
47
+ # Returns the x index.
48
+ # If the position for x is less than 1, then the index is 0.
49
+ #
42
50
  # @return [Fixnum]
43
51
  def x
44
52
  @_x ||= ((@x - 1) <= 1) ? 0 : (@x - 1)
45
53
  end
46
54
  alias_method :last, :x
47
55
 
56
+ # Returns the y index.
57
+ # If the position for y is less than 1, then the index is 0.
58
+ #
48
59
  # @return [Fixnum]
49
60
  def y
50
61
  @_y ||= ((@y - 1) <= 1) ? 0 : (@y - 1)
@@ -41,6 +41,8 @@ module Vedeu
41
41
  @y = attributes[:y]
42
42
  end
43
43
 
44
+ # An object is equal when its values are the same.
45
+ #
44
46
  # @param other [Vedeu::Cell]
45
47
  # @return [Boolean]
46
48
  def eql?(other)
@@ -60,6 +60,8 @@ module Vedeu
60
60
  []
61
61
  end
62
62
 
63
+ # An object is equal when its values are the same.
64
+ #
63
65
  # @param other [Vedeu::Char]
64
66
  # @return [Boolean]
65
67
  def eql?(other)
@@ -44,11 +44,21 @@ module Vedeu
44
44
  false
45
45
  end
46
46
 
47
+ # @return [FalseClass]
48
+ def maximise
49
+ false
50
+ end
51
+
47
52
  # @return [Vedeu::Null::Geometry]
48
53
  def store
49
54
  self
50
55
  end
51
56
 
57
+ # @return [FalseClass]
58
+ def unmaximise
59
+ false
60
+ end
61
+
52
62
  private
53
63
 
54
64
  # @return [Vedeu::Area]
@@ -82,6 +82,8 @@ module Vedeu
82
82
  @background = @attributes[:background] = Vedeu::Background.coerce(value)
83
83
  end
84
84
 
85
+ # An object is equal when its values are the same.
86
+ #
85
87
  # @param other [Vedeu::Char]
86
88
  # @return [Boolean]
87
89
  def eql?(other)
@@ -53,6 +53,8 @@ module Vedeu
53
53
  }
54
54
  end
55
55
 
56
+ # An object is equal when its values are the same.
57
+ #
56
58
  # @param other [Vedeu::Char]
57
59
  # @return [Boolean]
58
60
  def eql?(other)
@@ -60,6 +60,8 @@ module Vedeu
60
60
  @colour = colour
61
61
  end
62
62
 
63
+ # An object is equal when its values are the same.
64
+ #
63
65
  # @param other [Vedeu::Char]
64
66
  # @return [Boolean]
65
67
  def eql?(other)
@@ -69,9 +69,11 @@ module Vedeu
69
69
  subject { instance.clear }
70
70
 
71
71
  context 'when the clear buffer is empty' do
72
+ it { subject.must_be_instance_of(NilClass) }
72
73
  end
73
74
 
74
75
  context 'when the clear buffer is not empty' do
76
+ # it { subject.must_be_instance_of(Array) }
75
77
  end
76
78
  end
77
79
 
@@ -90,6 +92,7 @@ module Vedeu
90
92
  subject { instance.show }
91
93
 
92
94
  context 'when the interface is visible' do
95
+ # it { subject.must_be_instance_of(NilClass) }
93
96
  end
94
97
 
95
98
  context 'when the interface is not visible' do
@@ -22,7 +22,7 @@ module Vedeu
22
22
  }
23
23
  let(:centred) {}
24
24
  let(:height) {}
25
- let(:maximised) {}
25
+ let(:maximised) { false }
26
26
  let(:_name) {}
27
27
  let(:width) {}
28
28
  let(:x) {}
@@ -39,6 +39,7 @@ module Vedeu
39
39
  it { subject.instance_variable_get('@attributes').must_equal(attributes) }
40
40
  it { subject.instance_variable_get('@centred').must_equal(centred) }
41
41
  it { subject.instance_variable_get('@height').must_equal(height) }
42
+ it { subject.instance_variable_get('@maximised').must_equal(maximised) }
42
43
  it { subject.instance_variable_get('@name').must_equal(_name) }
43
44
  it { subject.instance_variable_get('@width').must_equal(width) }
44
45
  it { subject.instance_variable_get('@x').must_equal(x) }
@@ -147,6 +148,37 @@ module Vedeu
147
148
  it { instance.bottom.must_equal(6) }
148
149
  it { instance.left.must_equal(4) }
149
150
  end
151
+
152
+ context 'maximised' do
153
+ let(:attributes) { { maximised: true } }
154
+
155
+ it { instance.top.must_equal(1) }
156
+ it { instance.right.must_equal(40) }
157
+ it { instance.bottom.must_equal(12) }
158
+ it { instance.left.must_equal(1) }
159
+ end
160
+ end
161
+
162
+ describe '#maximise' do
163
+ let(:attributes) { { maximised: true } }
164
+
165
+ subject { instance.maximise }
166
+
167
+ it { instance.top.must_equal(1) }
168
+ it { instance.right.must_equal(40) }
169
+ it { instance.bottom.must_equal(12) }
170
+ it { instance.left.must_equal(1) }
171
+ end
172
+
173
+ describe '#unmaximise' do
174
+ let(:attributes) { { maximised: false } }
175
+
176
+ subject { instance.unmaximise }
177
+
178
+ it { instance.top.must_equal(1) }
179
+ it { instance.right.must_equal(40) }
180
+ it { instance.bottom.must_equal(12) }
181
+ it { instance.left.must_equal(1) }
150
182
  end
151
183
 
152
184
  end # Geometry
@@ -23,6 +23,11 @@ module Vedeu
23
23
  subject { described.safe_exit_point! }
24
24
 
25
25
  context 'when the application has started' do
26
+ context 'when the loop is running' do
27
+ end
28
+
29
+ context 'when the loop is not running' do
30
+ end
26
31
  end
27
32
 
28
33
  context 'when the application has not started' do
@@ -26,12 +26,24 @@ module Vedeu
26
26
  it { subject.must_equal(false) }
27
27
  end
28
28
 
29
+ describe '#maximise' do
30
+ subject { instance.maximise }
31
+
32
+ it { subject.must_equal(false) }
33
+ end
34
+
29
35
  describe '#store' do
30
36
  subject { instance.store }
31
37
 
32
38
  it { subject.must_be_instance_of(described) }
33
39
  end
34
40
 
41
+ describe '#unmaximise' do
42
+ subject { instance.unmaximise }
43
+
44
+ it { subject.must_equal(false) }
45
+ end
46
+
35
47
  describe '#height' do
36
48
  it { instance.height.must_equal(25) }
37
49
  end
@@ -33,6 +33,12 @@ module Vedeu
33
33
  it { subject.must_be_instance_of(FalseClass) }
34
34
  end
35
35
 
36
+ describe '#visible=' do
37
+ subject { instance.visible=(:irrelevant) }
38
+
39
+ # it { subject.must_be_instance_of(FalseClass) }
40
+ end
41
+
36
42
  end # Interface
37
43
 
38
44
  end # Null
@@ -531,6 +531,14 @@ module Vedeu
531
531
  end
532
532
  end
533
533
 
534
+ describe '#to_s' do
535
+ subject { instance.to_s }
536
+
537
+ it { subject.must_be_instance_of(String) }
538
+
539
+ it { subject.must_equal('') }
540
+ end
541
+
534
542
  end # Border
535
543
 
536
544
  end # Vedeu
@@ -51,10 +51,11 @@ module Vedeu
51
51
  it { subject.colour.must_equal('#000033') }
52
52
 
53
53
  context 'no background value' do
54
+ let(:attributes) { {} }
54
55
  let(:background) {}
55
56
 
56
57
  it { subject.must_be_instance_of(Vedeu::Background) }
57
- it { subject.colour.must_equal('') }
58
+ # it { subject.colour.must_equal('') }
58
59
  end
59
60
  end
60
61
 
@@ -65,10 +66,11 @@ module Vedeu
65
66
  it { subject.colour.must_equal('#aadd00') }
66
67
 
67
68
  context 'no foreground value' do
69
+ let(:attributes) { {} }
68
70
  let(:foreground) {}
69
71
 
70
72
  it { subject.must_be_instance_of(Vedeu::Foreground) }
71
- it { subject.colour.must_equal('') }
73
+ # it { subject.colour.must_equal('') }
72
74
  end
73
75
  end
74
76
 
@@ -21,6 +21,32 @@ module Vedeu
21
21
  it { instance.instance_variable_get('@colour').must_equal(colour) }
22
22
  end
23
23
 
24
+ describe '.coerce' do
25
+ let(:_value) {}
26
+
27
+ subject { described.coerce(value) }
28
+
29
+ # context 'when the value is nil' do
30
+ # it { subject.must_equal(nil) }
31
+ # end
32
+
33
+ # context 'when the value is a Vedeu::Colour' do
34
+ # it { subject.must_be_instance_of(Vedeu::Colour) }
35
+ # end
36
+
37
+ # context 'when the value is a Vedeu::Background' do
38
+ # it { subject.must_be_instance_of(Vedeu::Background) }
39
+ # end
40
+
41
+ # context 'when the value is a Vedeu::Foreground' do
42
+ # it { subject.must_be_instance_of(Vedeu::Foreground) }
43
+ # end
44
+
45
+ # context 'when the value is not a polymorphic Colour' do
46
+ # it { subject.must_be_instance_of(Vedeu::Colour) }
47
+ # end
48
+ end
49
+
24
50
  describe '#eql?' do
25
51
  let(:other) { instance }
26
52
 
@@ -9,6 +9,54 @@ module Vedeu
9
9
 
10
10
  describe '#initialize' do
11
11
  it { instance.must_be_instance_of(described) }
12
+ it { instance.instance_variable_get('@storage').must_equal({}) }
13
+ end
14
+
15
+ describe '#register' do
16
+ let(:colour) {}
17
+ let(:escape_sequence) {}
18
+
19
+ subject { instance.register(colour, escape_sequence) }
20
+ end
21
+
22
+ describe '#registered?' do
23
+ let(:colour) {}
24
+
25
+ subject { instance.registered?(colour) }
26
+ end
27
+
28
+ describe '#reset!' do
29
+ subject { instance.reset! }
30
+
31
+ it { subject.must_be_instance_of(Hash) }
32
+
33
+ it { subject.must_equal({}) }
34
+ end
35
+
36
+ describe '#retrieve' do
37
+ let(:colour) {}
38
+
39
+ subject { instance.retrieve(colour) }
40
+
41
+ context 'when the colour can be found' do
42
+ end
43
+
44
+ context 'when the colour cannot be found' do
45
+ it { subject.must_equal('') }
46
+ end
47
+ end
48
+
49
+ describe '#retrieve_or_register' do
50
+ let(:colour) {}
51
+ let(:escape_sequence) {}
52
+
53
+ subject { instance.retrieve_or_register(colour, escape_sequence) }
54
+
55
+ context 'when the colour is registered' do
56
+ end
57
+
58
+ context 'when the colour is not registered' do
59
+ end
12
60
  end
13
61
 
14
62
  end # Colours
@@ -4,7 +4,29 @@ module Vedeu
4
4
 
5
5
  describe Log do
6
6
 
7
- # it { skip }
7
+ let(:described) { Vedeu::Log }
8
+ let(:_message) {}
9
+ let(:force) {}
10
+ let(:type) {}
11
+
12
+ describe '.log' do
13
+ subject { described.log(message: _message, force: force, type: type) }
14
+
15
+ context 'when logging has been forced' do
16
+ end
17
+
18
+ context 'when logging has not been forced' do
19
+ context 'when the configuration requests logging' do
20
+ end
21
+
22
+ context 'when the configuration does not request logging' do
23
+ end
24
+ end
25
+ end
26
+
27
+ describe '.logger' do
28
+ subject { described.logger }
29
+ end
8
30
 
9
31
  end # Log
10
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.4.21'
7
+ spec.version = '0.4.22'
8
8
  spec.authors = ['Gavin Laking']
9
9
  spec.email = ['gavinlaking@gmail.com']
10
10
  spec.summary = '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.4.21
4
+ version: 0.4.22
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gavin Laking
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-21 00:00:00.000000000 Z
11
+ date: 2015-05-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aruba
@@ -321,6 +321,7 @@ files:
321
321
  - examples/hello_world.rb
322
322
  - examples/lines_app.rb
323
323
  - examples/material_colours_app.rb
324
+ - examples/maximise_unmaximise_app.rb
324
325
  - examples/typed_commands/command.erb
325
326
  - examples/typed_commands/output.erb
326
327
  - examples/typed_commands/status.erb