vedeu 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/examples/borders_app.rb +60 -56
  3. data/lib/vedeu/buffers/all.rb +1 -0
  4. data/lib/vedeu/configuration/configuration.rb +2 -4
  5. data/lib/vedeu/cursor/all.rb +3 -6
  6. data/lib/vedeu/cursor/cursor.rb +4 -3
  7. data/lib/vedeu/cursor/move_cursor.rb +7 -4
  8. data/lib/vedeu/cursor/toggle_cursor.rb +0 -1
  9. data/lib/vedeu/dsl/components/border.rb +99 -0
  10. data/lib/vedeu/dsl/components/geometry.rb +1 -0
  11. data/lib/vedeu/dsl/components/keymap.rb +1 -1
  12. data/lib/vedeu/dsl/composition.rb +7 -12
  13. data/lib/vedeu/dsl/interface.rb +7 -8
  14. data/lib/vedeu/dsl/line.rb +1 -10
  15. data/lib/vedeu/dsl/stream.rb +0 -2
  16. data/lib/vedeu/input/key.rb +10 -6
  17. data/lib/vedeu/input/keymap.rb +10 -8
  18. data/lib/vedeu/models/menu.rb +0 -2
  19. data/lib/vedeu/models/model.rb +20 -0
  20. data/lib/vedeu/models/view/composition.rb +4 -17
  21. data/lib/vedeu/models/view/interface.rb +9 -21
  22. data/lib/vedeu/models/view/line.rb +4 -17
  23. data/lib/vedeu/models/view/stream.rb +4 -17
  24. data/lib/vedeu/output/all.rb +1 -0
  25. data/lib/vedeu/output/border.rb +2 -2
  26. data/lib/vedeu/output/compositor.rb +0 -4
  27. data/lib/vedeu/output/wordwrap.rb +146 -0
  28. data/lib/vedeu/repositories/repository.rb +3 -2
  29. data/lib/vedeu/support/console.rb +29 -6
  30. data/lib/vedeu/support/content_geometry.rb +2 -0
  31. data/lib/vedeu/support/coordinate.rb +9 -4
  32. data/lib/vedeu/support/position_validator.rb +28 -7
  33. data/lib/vedeu/support/sentence.rb +21 -1
  34. data/lib/vedeu/support/terminal.rb +0 -2
  35. data/lib/vedeu/support/trace.rb +48 -2
  36. data/lib/vedeu/support/visible.rb +2 -0
  37. data/test/lib/vedeu/cursor/all_test.rb +1 -1
  38. data/test/lib/vedeu/events/event_test.rb +7 -29
  39. data/test/lib/vedeu/input/key_test.rb +3 -3
  40. data/test/lib/vedeu/input/keymap_test.rb +3 -3
  41. data/test/lib/vedeu/output/wordwrap_test.rb +266 -0
  42. data/test/lib/vedeu/presentation/colour_test.rb +68 -33
  43. data/test/lib/vedeu/support/common_test.rb +10 -0
  44. data/test/lib/vedeu/support/console_test.rb +82 -0
  45. data/test/lib/vedeu/support/position_validator_test.rb +13 -0
  46. data/test/support/helpers/all.rb +0 -1
  47. data/vedeu.gemspec +8 -8
  48. metadata +19 -18
  49. data/test/support/helpers/misc.rb +0 -15
@@ -4,7 +4,8 @@ module Vedeu
4
4
 
5
5
  describe Colour do
6
6
 
7
- let(:described) { Colour.new(attributes) }
7
+ let(:described) { Vedeu::Colour }
8
+ let(:instance) { described.new(attributes) }
8
9
  let(:attributes) {
9
10
  {
10
11
  background: '',
@@ -13,62 +14,96 @@ module Vedeu
13
14
  }
14
15
 
15
16
  describe '#initialize' do
16
- it { described.must_be_instance_of(Colour) }
17
- it { described.instance_variable_get('@attributes').must_equal(attributes) }
17
+ subject { instance }
18
+
19
+ it { instance.must_be_instance_of(described) }
20
+ it { instance.instance_variable_get('@attributes').must_equal(attributes) }
18
21
  end
19
22
 
20
23
  describe '#background' do
21
- it { described.background.must_be_instance_of(String) }
24
+ subject { instance.background }
25
+
26
+ it { subject.must_be_instance_of(String) }
27
+
28
+ context 'with a background' do
29
+ let(:attributes) {
30
+ {
31
+ background: '#000000'
32
+ }
33
+ }
22
34
 
23
- it 'returns an escape sequence' do
24
- Colour.new({
25
- background: '#000000'
26
- }).background.must_equal("\e[48;2;0;0;0m")
35
+ it { subject.must_equal("\e[48;2;0;0;0m") }
27
36
  end
28
37
 
29
- it 'returns an empty string when the value is empty' do
30
- Colour.new.background.must_equal('')
38
+ context 'without a background' do
39
+ let(:attributes) { {} }
40
+
41
+ it { subject.must_equal('') }
31
42
  end
32
43
  end
33
44
 
34
45
  describe '#foreground' do
35
- it { described.foreground.must_be_instance_of(String) }
46
+ subject { instance.foreground }
47
+
48
+ it { subject.must_be_instance_of(String) }
49
+
50
+ context 'with a foreground' do
51
+ let(:attributes) {
52
+ {
53
+ foreground: '#ff0000'
54
+ }
55
+ }
36
56
 
37
- it 'returns an escape sequence' do
38
- Colour.new({
39
- foreground: '#ff0000'
40
- }).foreground.must_equal("\e[38;2;255;0;0m")
57
+ it { subject.must_equal("\e[38;2;255;0;0m") }
41
58
  end
42
59
 
43
- it 'returns an empty string when the value is empty' do
44
- Colour.new.foreground.must_equal('')
60
+ context 'without a foreground' do
61
+ let(:attributes) { {} }
62
+
63
+ it { subject.must_equal('') }
45
64
  end
46
65
  end
47
66
 
48
67
  describe '#to_s' do
49
- it { described.to_s.must_be_instance_of(String) }
68
+ subject { instance.to_s }
69
+
70
+ it { subject.must_be_instance_of(String) }
71
+
72
+ context 'with both background and foreground' do
73
+ let(:attributes) {
74
+ {
75
+ foreground: '#ff0000',
76
+ background: '#000000'
77
+ }
78
+ }
50
79
 
51
- it 'returns an escape sequence' do
52
- Colour.new({
53
- foreground: '#ff0000',
54
- background: '#000000'
55
- }).to_s.must_equal("\e[38;2;255;0;0m\e[48;2;0;0;0m")
80
+ it { subject.must_equal("\e[38;2;255;0;0m\e[48;2;0;0;0m") }
56
81
  end
57
82
 
58
- it 'returns an escape sequence when the foreground is missing' do
59
- Colour.new({
60
- background: '#000000'
61
- }).to_s.must_equal("\e[48;2;0;0;0m")
83
+ context 'when the foreground is missing' do
84
+ let(:attributes) {
85
+ {
86
+ background: '#000000'
87
+ }
88
+ }
89
+
90
+ it { subject.must_equal("\e[48;2;0;0;0m") }
62
91
  end
63
92
 
64
- it 'returns an escape sequence when the background is missing' do
65
- Colour.new({
66
- foreground: '#ff0000',
67
- }).to_s.must_equal("\e[38;2;255;0;0m")
93
+ context 'when the background is missing' do
94
+ let(:attributes) {
95
+ {
96
+ foreground: '#ff0000',
97
+ }
98
+ }
99
+
100
+ it { subject.must_equal("\e[38;2;255;0;0m") }
68
101
  end
69
102
 
70
- it 'returns an empty string when both are missing' do
71
- Colour.new.to_s.must_equal('')
103
+ context 'when both are missing' do
104
+ let(:attributes) { {} }
105
+
106
+ it { subject.must_equal('') }
72
107
  end
73
108
  end
74
109
 
@@ -2,6 +2,16 @@ require 'test_helper'
2
2
 
3
3
  module Vedeu
4
4
 
5
+ class VedeuCommonClass
6
+
7
+ include Vedeu::Common
8
+
9
+ def defined_value_test(variable)
10
+ defined_value?(variable)
11
+ end
12
+
13
+ end # VedeuCommonClass
14
+
5
15
  describe Common do
6
16
 
7
17
  let(:described) { Vedeu::VedeuCommonClass.new }
@@ -66,11 +66,69 @@ module Vedeu
66
66
  it { subject.must_equal(16) }
67
67
  end
68
68
 
69
+ describe '#cooked' do
70
+ subject { instance.cooked }
71
+
72
+ context 'when the block is not given' do
73
+ it { proc { subject }.must_raise(LocalJumpError) }
74
+ end
75
+ end
76
+
77
+ describe '#height' do
78
+ subject { instance.height }
79
+
80
+ it { subject.must_be_instance_of(Fixnum) }
81
+
82
+ context 'alias method #tyn' do
83
+ subject { instance.tyn }
84
+
85
+ it { subject.must_be_instance_of(Fixnum) }
86
+ end
87
+
88
+ context 'alias method #yn' do
89
+ subject { instance.yn }
90
+
91
+ it { subject.must_be_instance_of(Fixnum) }
92
+ end
93
+ end
94
+
69
95
  describe '#origin' do
70
96
  subject { instance.origin }
71
97
 
72
98
  it { subject.must_be_instance_of(Fixnum) }
73
99
  it { subject.must_equal(1) }
100
+
101
+ context 'alias method #x' do
102
+ subject { instance.x }
103
+
104
+ it { subject.must_be_instance_of(Fixnum) }
105
+ end
106
+
107
+ context 'alias method #y' do
108
+ subject { instance.y }
109
+
110
+ it { subject.must_be_instance_of(Fixnum) }
111
+ end
112
+
113
+ context 'alias method #tx' do
114
+ subject { instance.tx }
115
+
116
+ it { subject.must_be_instance_of(Fixnum) }
117
+ end
118
+
119
+ context 'alias method #ty' do
120
+ subject { instance.ty }
121
+
122
+ it { subject.must_be_instance_of(Fixnum) }
123
+ end
124
+ end
125
+
126
+ describe '#raw' do
127
+ subject { instance.raw }
128
+
129
+ context 'when the block is not given' do
130
+ it { proc { subject }.must_raise(LocalJumpError) }
131
+ end
74
132
  end
75
133
 
76
134
  describe '#size' do
@@ -78,6 +136,30 @@ module Vedeu
78
136
 
79
137
  it { subject.must_be_instance_of(Array) }
80
138
  it { subject.must_equal([24, 32]) }
139
+
140
+ context 'alias method #winsize' do
141
+ subject { instance.winsize }
142
+
143
+ it { subject.must_be_instance_of(Array) }
144
+ end
145
+ end
146
+
147
+ describe '#width' do
148
+ subject { instance.width }
149
+
150
+ it { subject.must_be_instance_of(Fixnum) }
151
+
152
+ context 'alias method #txn' do
153
+ subject { instance.txn }
154
+
155
+ it { subject.must_be_instance_of(Fixnum) }
156
+ end
157
+
158
+ context 'alias method #xn' do
159
+ subject { instance.xn }
160
+
161
+ it { subject.must_be_instance_of(Fixnum) }
162
+ end
81
163
  end
82
164
 
83
165
  end # Console
@@ -4,7 +4,20 @@ module Vedeu
4
4
 
5
5
  describe PositionValidator do
6
6
 
7
+ let(:described) { Vedeu::PositionValidator }
8
+ let(:instance) { described.new(interface, x, y) }
9
+ let(:interface) {}
10
+ let(:x) {}
11
+ let(:y) {}
7
12
 
13
+ describe '#initialize' do
14
+ subject { instance }
15
+
16
+ it { subject.must_be_instance_of(described) }
17
+ it { subject.instance_variable_get('@interface').must_equal(interface) }
18
+ it { subject.instance_variable_get('@x').must_equal(x) }
19
+ it { subject.instance_variable_get('@y').must_equal(y) }
20
+ end
8
21
 
9
22
  end # PositionValidator
10
23
 
@@ -1,6 +1,5 @@
1
1
  require 'support/helpers/dsl_model_test_class'
2
2
  require 'support/helpers/helpers'
3
- require 'support/helpers/misc'
4
3
  require 'support/helpers/model_test_class'
5
4
  require 'support/helpers/presentation'
6
5
  require 'support/helpers/repositories'
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.3.0'
7
+ spec.version = '0.3.1'
8
8
  spec.authors = ['Gavin Laking']
9
9
  spec.email = ['gavinlaking@gmail.com']
10
10
  spec.summary = %q{A terminal case of wonderland.}
@@ -18,19 +18,19 @@ Gem::Specification.new do |spec|
18
18
  spec.require_paths = ['lib']
19
19
 
20
20
  spec.add_development_dependency 'aruba', '0.6.2'
21
- spec.add_development_dependency 'bundler', '~> 1.6'
22
- spec.add_development_dependency 'cucumber', '1.3.18'
23
- spec.add_development_dependency 'guard', '2.11.1'
21
+ spec.add_development_dependency 'bundler', '~> 1.7'
22
+ spec.add_development_dependency 'cucumber', '1.3.19'
23
+ spec.add_development_dependency 'guard', '2.12.1'
24
24
  spec.add_development_dependency 'guard-bundler', '2.1.0'
25
25
  spec.add_development_dependency 'guard-cucumber', '1.5.3'
26
- spec.add_development_dependency 'guard-minitest', '2.4.2'
26
+ spec.add_development_dependency 'guard-minitest', '2.4.3'
27
27
  spec.add_development_dependency 'guard-yard', '2.1.4'
28
28
  spec.add_development_dependency 'minitest', '5.5.1'
29
- spec.add_development_dependency 'minitest-reporters', '1.0.8'
29
+ spec.add_development_dependency 'minitest-reporters', '1.0.10'
30
30
  spec.add_development_dependency 'mocha', '1.1.0'
31
31
  spec.add_development_dependency 'pry', '0.10.1'
32
- spec.add_development_dependency 'pry-byebug', '2.0.0'
33
- spec.add_development_dependency 'rake', '10.3.2'
32
+ spec.add_development_dependency 'pry-byebug', '3.0.1'
33
+ spec.add_development_dependency 'rake', '10.4.2'
34
34
  spec.add_development_dependency 'simplecov', '0.9.1'
35
35
  spec.add_development_dependency 'yard', '0.8.7.6'
36
36
  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.3.0
4
+ version: 0.3.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: 2015-02-10 00:00:00.000000000 Z
11
+ date: 2015-02-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aruba
@@ -30,42 +30,42 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '1.6'
33
+ version: '1.7'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '1.6'
40
+ version: '1.7'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: cucumber
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - '='
46
46
  - !ruby/object:Gem::Version
47
- version: 1.3.18
47
+ version: 1.3.19
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - '='
53
53
  - !ruby/object:Gem::Version
54
- version: 1.3.18
54
+ version: 1.3.19
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: guard
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - '='
60
60
  - !ruby/object:Gem::Version
61
- version: 2.11.1
61
+ version: 2.12.1
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - '='
67
67
  - !ruby/object:Gem::Version
68
- version: 2.11.1
68
+ version: 2.12.1
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: guard-bundler
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -100,14 +100,14 @@ dependencies:
100
100
  requirements:
101
101
  - - '='
102
102
  - !ruby/object:Gem::Version
103
- version: 2.4.2
103
+ version: 2.4.3
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - '='
109
109
  - !ruby/object:Gem::Version
110
- version: 2.4.2
110
+ version: 2.4.3
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: guard-yard
113
113
  requirement: !ruby/object:Gem::Requirement
@@ -142,14 +142,14 @@ dependencies:
142
142
  requirements:
143
143
  - - '='
144
144
  - !ruby/object:Gem::Version
145
- version: 1.0.8
145
+ version: 1.0.10
146
146
  type: :development
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.8
152
+ version: 1.0.10
153
153
  - !ruby/object:Gem::Dependency
154
154
  name: mocha
155
155
  requirement: !ruby/object:Gem::Requirement
@@ -184,28 +184,28 @@ dependencies:
184
184
  requirements:
185
185
  - - '='
186
186
  - !ruby/object:Gem::Version
187
- version: 2.0.0
187
+ version: 3.0.1
188
188
  type: :development
189
189
  prerelease: false
190
190
  version_requirements: !ruby/object:Gem::Requirement
191
191
  requirements:
192
192
  - - '='
193
193
  - !ruby/object:Gem::Version
194
- version: 2.0.0
194
+ version: 3.0.1
195
195
  - !ruby/object:Gem::Dependency
196
196
  name: rake
197
197
  requirement: !ruby/object:Gem::Requirement
198
198
  requirements:
199
199
  - - '='
200
200
  - !ruby/object:Gem::Version
201
- version: 10.3.2
201
+ version: 10.4.2
202
202
  type: :development
203
203
  prerelease: false
204
204
  version_requirements: !ruby/object:Gem::Requirement
205
205
  requirements:
206
206
  - - '='
207
207
  - !ruby/object:Gem::Version
208
- version: 10.3.2
208
+ version: 10.4.2
209
209
  - !ruby/object:Gem::Dependency
210
210
  name: simplecov
211
211
  requirement: !ruby/object:Gem::Requirement
@@ -335,6 +335,7 @@ files:
335
335
  - lib/vedeu/output/compositor.rb
336
336
  - lib/vedeu/output/output.rb
337
337
  - lib/vedeu/output/viewport.rb
338
+ - lib/vedeu/output/wordwrap.rb
338
339
  - lib/vedeu/output/writer.rb
339
340
  - lib/vedeu/presentation/all.rb
340
341
  - lib/vedeu/presentation/background.rb
@@ -430,6 +431,7 @@ files:
430
431
  - test/lib/vedeu/output/compositor_test.rb
431
432
  - test/lib/vedeu/output/output_test.rb
432
433
  - test/lib/vedeu/output/viewport_test.rb
434
+ - test/lib/vedeu/output/wordwrap_test.rb
433
435
  - test/lib/vedeu/output/writer_test.rb
434
436
  - test/lib/vedeu/presentation/background_test.rb
435
437
  - test/lib/vedeu/presentation/colour_test.rb
@@ -465,7 +467,6 @@ files:
465
467
  - test/support/helpers/all.rb
466
468
  - test/support/helpers/dsl_model_test_class.rb
467
469
  - test/support/helpers/helpers.rb
468
- - test/support/helpers/misc.rb
469
470
  - test/support/helpers/model_test_class.rb
470
471
  - test/support/helpers/presentation.rb
471
472
  - test/support/helpers/repositories.rb
@@ -561,6 +562,7 @@ test_files:
561
562
  - test/lib/vedeu/output/compositor_test.rb
562
563
  - test/lib/vedeu/output/output_test.rb
563
564
  - test/lib/vedeu/output/viewport_test.rb
565
+ - test/lib/vedeu/output/wordwrap_test.rb
564
566
  - test/lib/vedeu/output/writer_test.rb
565
567
  - test/lib/vedeu/presentation/background_test.rb
566
568
  - test/lib/vedeu/presentation/colour_test.rb
@@ -596,7 +598,6 @@ test_files:
596
598
  - test/support/helpers/all.rb
597
599
  - test/support/helpers/dsl_model_test_class.rb
598
600
  - test/support/helpers/helpers.rb
599
- - test/support/helpers/misc.rb
600
601
  - test/support/helpers/model_test_class.rb
601
602
  - test/support/helpers/presentation.rb
602
603
  - test/support/helpers/repositories.rb
@@ -1,15 +0,0 @@
1
- require 'vedeu/support/common'
2
-
3
- module Vedeu
4
-
5
- class VedeuCommonClass
6
-
7
- include Vedeu::Common
8
-
9
- def defined_value_test(variable)
10
- defined_value?(variable)
11
- end
12
-
13
- end # VedeuCommonClass
14
-
15
- end # Vedeu