vedeu 0.5.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (93) hide show
  1. checksums.yaml +4 -4
  2. data/lib/vedeu/all.rb +1 -1
  3. data/lib/vedeu/application/controller.rb +2 -2
  4. data/lib/vedeu/bindings.rb +1 -1
  5. data/lib/vedeu/bindings/application.rb +2 -2
  6. data/lib/vedeu/bindings/drb.rb +8 -8
  7. data/lib/vedeu/bindings/menus.rb +11 -11
  8. data/lib/vedeu/bindings/movement.rb +12 -12
  9. data/lib/vedeu/bindings/system.rb +18 -18
  10. data/lib/vedeu/bindings/visibility.rb +9 -9
  11. data/lib/vedeu/colours/colour.rb +1 -1
  12. data/lib/vedeu/common.rb +1 -1
  13. data/lib/vedeu/dsl/composition.rb +8 -3
  14. data/lib/vedeu/dsl/interface.rb +41 -17
  15. data/lib/vedeu/log/debug.rb +5 -1
  16. data/lib/vedeu/log/log.rb +1 -0
  17. data/lib/vedeu/models/interface.rb +3 -2
  18. data/lib/vedeu/plugins.rb +1 -1
  19. data/lib/vedeu/runtime/bootstrap.rb +0 -3
  20. data/lib/vedeu/runtime/launcher.rb +3 -2
  21. data/lib/vedeu/runtime/router.rb +49 -47
  22. data/lib/vedeu/{traps.rb → runtime/traps.rb} +0 -0
  23. data/lib/vedeu/templating/decoder.rb +4 -2
  24. data/lib/vedeu/templating/encoder.rb +4 -2
  25. data/lib/vedeu/templating/view_template.rb +35 -2
  26. data/lib/vedeu/version.rb +1 -1
  27. data/test/lib/vedeu/application/application_view_test.rb +1 -1
  28. data/test/lib/vedeu/application/controller_test.rb +4 -0
  29. data/test/lib/vedeu/bindings_test.rb +2 -0
  30. data/test/lib/vedeu/borders/border_test.rb +28 -40
  31. data/test/lib/vedeu/borders/borders_test.rb +0 -2
  32. data/test/lib/vedeu/borders/render_border_test.rb +11 -13
  33. data/test/lib/vedeu/buffers/buffer_test.rb +12 -5
  34. data/test/lib/vedeu/buffers/display_buffer_test.rb +2 -2
  35. data/test/lib/vedeu/cli/generator/application_test.rb +9 -9
  36. data/test/lib/vedeu/cli/generator/view_test.rb +10 -7
  37. data/test/lib/vedeu/cli/main_test.rb +4 -4
  38. data/test/lib/vedeu/colours/colour_translator_test.rb +2 -4
  39. data/test/lib/vedeu/common_test.rb +8 -0
  40. data/test/lib/vedeu/configuration/configuration_test.rb +4 -4
  41. data/test/lib/vedeu/cursor/cursors_test.rb +4 -4
  42. data/test/lib/vedeu/cursor/move_test.rb +11 -8
  43. data/test/lib/vedeu/cursor/refresh_cursor_test.rb +12 -12
  44. data/test/lib/vedeu/cursor/reposition_test.rb +7 -11
  45. data/test/lib/vedeu/distributed/client_test.rb +4 -4
  46. data/test/lib/vedeu/distributed/server_test.rb +4 -5
  47. data/test/lib/vedeu/dsl/border_test.rb +2 -2
  48. data/test/lib/vedeu/dsl/composition_test.rb +5 -4
  49. data/test/lib/vedeu/dsl/geometry_test.rb +6 -4
  50. data/test/lib/vedeu/dsl/interface_test.rb +9 -27
  51. data/test/lib/vedeu/dsl/use_test.rb +2 -2
  52. data/test/lib/vedeu/events/trigger_test.rb +2 -2
  53. data/test/lib/vedeu/geometry/coordinate_test.rb +9 -9
  54. data/test/lib/vedeu/geometry/geometry_test.rb +8 -2
  55. data/test/lib/vedeu/geometry/position_validator_test.rb +11 -14
  56. data/test/lib/vedeu/input/input_test.rb +5 -5
  57. data/test/lib/vedeu/input/keymap_test.rb +2 -2
  58. data/test/lib/vedeu/log/timer_test.rb +2 -2
  59. data/test/lib/vedeu/models/focus_test.rb +20 -25
  60. data/test/lib/vedeu/models/interface_test.rb +2 -2
  61. data/test/lib/vedeu/models/interfaces_test.rb +7 -5
  62. data/test/lib/vedeu/models/line_test.rb +0 -5
  63. data/test/lib/vedeu/models/menu_test.rb +0 -2
  64. data/test/lib/vedeu/null/geometry_test.rb +1 -4
  65. data/test/lib/vedeu/output/clear/named_interface_test.rb +2 -2
  66. data/test/lib/vedeu/output/esc_test.rb +7 -4
  67. data/test/lib/vedeu/output/output_test.rb +3 -6
  68. data/test/lib/vedeu/output/refresh_test.rb +2 -2
  69. data/test/lib/vedeu/output/renderers/file_test.rb +1 -3
  70. data/test/lib/vedeu/output/renderers/html_test.rb +1 -3
  71. data/test/lib/vedeu/output/renderers/json_test.rb +1 -3
  72. data/test/lib/vedeu/output/renderers_test.rb +2 -2
  73. data/test/lib/vedeu/output/viewport_test.rb +70 -71
  74. data/test/lib/vedeu/repositories/model_test.rb +0 -19
  75. data/test/lib/vedeu/repositories/repository_test.rb +8 -8
  76. data/test/lib/vedeu/runtime/application_test.rb +2 -2
  77. data/test/lib/vedeu/runtime/launcher_test.rb +7 -7
  78. data/test/lib/vedeu/runtime/router_test.rb +33 -33
  79. data/test/lib/vedeu/{traps_test.rb → runtime/traps_test.rb} +2 -2
  80. data/test/lib/vedeu/templating/decoder_test.rb +1 -0
  81. data/test/lib/vedeu/templating/encoder_test.rb +1 -0
  82. data/test/lib/vedeu/templating/template_test.rb +8 -1
  83. data/test/lib/vedeu/templating/view_template_test.rb +108 -22
  84. data/test/lib/vedeu/terminal_mode_test.rb +2 -2
  85. data/test/lib/vedeu/terminal_test.rb +6 -6
  86. data/test/support/helpers/model_test_class.rb +19 -0
  87. metadata +5 -17
  88. data/test/support/templates/background.erb +0 -1
  89. data/test/support/templates/colour.erb +0 -1
  90. data/test/support/templates/foreground.erb +0 -1
  91. data/test/support/templates/multiple.erb +0 -2
  92. data/test/support/templates/plain.erb +0 -1
  93. data/test/support/templates/style.erb +0 -1
@@ -2,11 +2,11 @@ require 'test_helper'
2
2
 
3
3
  module Vedeu
4
4
 
5
- describe Traps do
5
+ describe Traps do
6
6
 
7
7
  # @todo Add more tests.
8
8
  # it { skip }
9
9
 
10
- end # Traps
10
+ end # Traps
11
11
 
12
12
  end # Vedeu
@@ -17,6 +17,7 @@ module Vedeu
17
17
  }
18
18
 
19
19
  describe '#initialize' do
20
+ it { instance.must_be_instance_of(described) }
20
21
  it { instance.instance_variable_get('@data').must_equal(data) }
21
22
  end
22
23
 
@@ -17,6 +17,7 @@ module Vedeu
17
17
  }
18
18
 
19
19
  describe '#initialize' do
20
+ it { instance.must_be_instance_of(described) }
20
21
  it { instance.instance_variable_get('@data').must_equal(data) }
21
22
  end
22
23
 
@@ -29,13 +29,20 @@ module Vedeu
29
29
  context 'when the path is does not exist' do
30
30
  let(:path) { '/tmp/vedeu_does_not_exist' }
31
31
 
32
+ before { File.stubs(:exist?).returns(false) }
33
+
32
34
  it { proc { subject }.must_raise(MissingRequired) }
33
35
  end
34
36
 
35
37
  context 'when the path exists' do
36
- let(:path) { 'test/support/templates/plain.erb' }
38
+ let(:path) { '/tmp/vedeu_exists' }
37
39
  let(:expected) { "This is a test.\n" }
38
40
 
41
+ before {
42
+ File.stubs(:exist?).returns(true)
43
+ File.stubs(:read).returns(expected)
44
+ }
45
+
39
46
  it { subject.must_equal(expected) }
40
47
  end
41
48
  end
@@ -9,17 +9,27 @@ module Vedeu
9
9
  let(:described) { Vedeu::Templating::ViewTemplate }
10
10
  let(:instance) { described.new(object, path) }
11
11
  let(:object) {}
12
- let(:path) {}
12
+ let(:path) { '/tmp/some_template.erb' }
13
+ let(:content) { '' }
13
14
 
14
15
  describe '.parse' do
16
+ before {
17
+ File.stubs(:exist?).returns(true)
18
+ File.stubs(:read).returns(content)
19
+ }
20
+
15
21
  subject { described.parse(object, path) }
16
22
 
17
23
  context 'with a plain text file' do
18
- let(:path) { 'test/support/templates/plain.erb' }
19
-
24
+ let(:content) { "This is a test.\n" }
20
25
  let(:expected) {
21
26
  Vedeu::Lines.new([
22
- Vedeu::Line.new(streams: Vedeu::Stream.new(value: 'This is a test.'))
27
+ Vedeu::Line.new(streams:
28
+ Vedeu::Stream.new(colour: {
29
+ background: :default,
30
+ foreground: :default },
31
+ style: :normal,
32
+ value: 'This is a test.'))
23
33
  ])
24
34
  }
25
35
 
@@ -27,12 +37,21 @@ module Vedeu
27
37
  end
28
38
 
29
39
  context 'with a plain text file with multiple lines' do
30
- let(:path) { 'test/support/templates/multiple.erb' }
31
-
40
+ let(:content) { "This is a test.\nAnd so is this.\n" }
32
41
  let(:expected) {
33
42
  Vedeu::Lines.new([
34
- Vedeu::Line.new(streams: Vedeu::Stream.new(value: 'This is a test.')),
35
- Vedeu::Line.new(streams: Vedeu::Stream.new(value: 'And so is this.')),
43
+ Vedeu::Line.new(streams:
44
+ Vedeu::Stream.new(colour: {
45
+ background: :default,
46
+ foreground: :default },
47
+ style: :normal,
48
+ value: 'This is a test.')),
49
+ Vedeu::Line.new(streams:
50
+ Vedeu::Stream.new(colour: {
51
+ background: :default,
52
+ foreground: :default },
53
+ style: :normal,
54
+ value: 'And so is this.')),
36
55
  ])
37
56
  }
38
57
 
@@ -40,7 +59,7 @@ module Vedeu
40
59
  end
41
60
 
42
61
  context 'with a background colour directive' do
43
- let(:path) { 'test/support/templates/background.erb' }
62
+ let(:content) { "This is a <%= background('#ff0000') { 'test' } %>.\n" }
44
63
  let(:colour) {
45
64
  Vedeu::Colour.new(background: '#ff0000', foreground: '')
46
65
  }
@@ -48,18 +67,63 @@ module Vedeu
48
67
  let(:expected) {
49
68
  Vedeu::Lines.new([
50
69
  Vedeu::Line.new(streams: [
51
- Vedeu::Stream.new(value: 'This is a '),
70
+ Vedeu::Stream.new(colour: {
71
+ background: :default,
72
+ foreground: :default },
73
+ style: :normal,
74
+ value: 'This is a '),
52
75
  Vedeu::Stream.new(value: 'test', colour: colour),
53
- Vedeu::Stream.new(value: '.'),
76
+ Vedeu::Stream.new(colour: {
77
+ background: :default,
78
+ foreground: :default },
79
+ style: :normal,
80
+ value: '.'),
54
81
  ])
55
82
  ])
56
83
  }
57
84
 
58
85
  it { subject.must_equal(expected) }
86
+
87
+ context 'and multiple' do
88
+ let(:content) {
89
+ "This is a <%= background('#ff0000') { 'test' } %>. And so is " \
90
+ "<%= background('#ff0000') { 'this' } %>.\n"
91
+ }
92
+
93
+ let(:colour) {
94
+ Vedeu::Colour.new(background: '#ff0000', foreground: '')
95
+ }
96
+
97
+ let(:expected) {
98
+ Vedeu::Lines.new([
99
+ Vedeu::Line.new(streams: [
100
+ Vedeu::Stream.new(colour: {
101
+ background: :default,
102
+ foreground: :default },
103
+ style: :normal,
104
+ value: 'This is a '),
105
+ Vedeu::Stream.new(value: 'test', colour: colour),
106
+ Vedeu::Stream.new(colour: {
107
+ background: :default,
108
+ foreground: :default },
109
+ style: :normal,
110
+ value: '. And so is '),
111
+ Vedeu::Stream.new(value: 'this', colour: colour),
112
+ Vedeu::Stream.new(colour: {
113
+ background: :default,
114
+ foreground: :default },
115
+ style: :normal,
116
+ value: '.'),
117
+ ])
118
+ ])
119
+ }
120
+
121
+ it { subject.must_equal(expected) }
122
+ end
59
123
  end
60
124
 
61
125
  context 'with a foreground colour directive' do
62
- let(:path) { 'test/support/templates/foreground.erb' }
126
+ let(:content) { "This is a <%= foreground('#00ff00') { 'test' } %>.\n" }
63
127
  let(:colour) {
64
128
  Vedeu::Colour.new(background: '', foreground: '#00ff00')
65
129
  }
@@ -67,9 +131,17 @@ module Vedeu
67
131
  let(:expected) {
68
132
  Vedeu::Lines.new([
69
133
  Vedeu::Line.new(streams: [
70
- Vedeu::Stream.new(value: 'This is a '),
134
+ Vedeu::Stream.new(colour: {
135
+ background: :default,
136
+ foreground: :default },
137
+ style: :normal,
138
+ value: 'This is a '),
71
139
  Vedeu::Stream.new(value: 'test', colour: colour),
72
- Vedeu::Stream.new(value: '.'),
140
+ Vedeu::Stream.new(colour: {
141
+ background: :default,
142
+ foreground: :default },
143
+ style: :normal,
144
+ value: '.'),
73
145
  ])
74
146
  ])
75
147
  }
@@ -78,8 +150,7 @@ module Vedeu
78
150
  end
79
151
 
80
152
  context 'with a colour directive' do
81
- let(:path) { 'test/support/templates/colour.erb' }
82
-
153
+ let(:content) { "This is a <%= colour(background: '#003300', foreground: '#aadd00') { 'test' } %>.\n" }
83
154
  let(:colour) {
84
155
  Vedeu::Colour.new(background: '#003300', foreground: '#aadd00')
85
156
  }
@@ -87,9 +158,17 @@ module Vedeu
87
158
  let(:expected) {
88
159
  Vedeu::Lines.new([
89
160
  Vedeu::Line.new(streams: [
90
- Vedeu::Stream.new(value: 'This is a '),
161
+ Vedeu::Stream.new(colour: {
162
+ background: :default,
163
+ foreground: :default },
164
+ style: :normal,
165
+ value: 'This is a '),
91
166
  Vedeu::Stream.new(value: 'test', colour: colour),
92
- Vedeu::Stream.new(value: '.'),
167
+ Vedeu::Stream.new(colour: {
168
+ background: :default,
169
+ foreground: :default },
170
+ style: :normal,
171
+ value: '.'),
93
172
  ])
94
173
  ])
95
174
  }
@@ -98,8 +177,7 @@ module Vedeu
98
177
  end
99
178
 
100
179
  context 'with a style directive' do
101
- let(:path) { 'test/support/templates/style.erb' }
102
-
180
+ let(:content) { "This is a <%= style(:bold) { 'test' } %>." }
103
181
  let(:style) {
104
182
  Vedeu::Style.new(:bold)
105
183
  }
@@ -107,9 +185,17 @@ module Vedeu
107
185
  let(:expected) {
108
186
  Vedeu::Lines.new([
109
187
  Vedeu::Line.new(streams: [
110
- Vedeu::Stream.new(value: 'This is a '),
188
+ Vedeu::Stream.new(colour: {
189
+ background: :default,
190
+ foreground: :default },
191
+ style: :normal,
192
+ value: 'This is a '),
111
193
  Vedeu::Stream.new(value: 'test', style: style),
112
- Vedeu::Stream.new(value: '.'),
194
+ Vedeu::Stream.new(colour: {
195
+ background: :default,
196
+ foreground: :default },
197
+ style: :normal,
198
+ value: '.'),
113
199
  ])
114
200
  ])
115
201
  }
@@ -55,10 +55,10 @@ module Vedeu
55
55
  describe '.mode' do
56
56
  subject { described.mode }
57
57
 
58
- before do
58
+ before {
59
59
  described.raw_mode!
60
60
  Configuration.stubs(:terminal_mode).returns(:raw)
61
- end
61
+ }
62
62
 
63
63
  it { subject.must_be_instance_of(Symbol) }
64
64
 
@@ -7,10 +7,10 @@ module Vedeu
7
7
  let(:described) { Vedeu::Terminal }
8
8
  let(:console) { IO.console }
9
9
 
10
- before do
10
+ before {
11
11
  console.stubs(:winsize).returns([25, 80])
12
12
  console.stubs(:print)
13
- end
13
+ }
14
14
 
15
15
  describe '.open' do
16
16
  context 'when a block was not given' do
@@ -47,10 +47,10 @@ module Vedeu
47
47
  let(:mode) { :cooked }
48
48
  let(:input) { "Some input\r\n" }
49
49
 
50
- before do
50
+ before {
51
51
  Terminal.stubs(:mode).returns(mode)
52
52
  console.stubs(:gets).returns(input)
53
- end
53
+ }
54
54
 
55
55
  it { subject.must_equal('Some input') }
56
56
  end
@@ -59,12 +59,12 @@ module Vedeu
59
59
  let(:mode) { :raw }
60
60
  let(:input) { "\e" }
61
61
 
62
- before do
62
+ before {
63
63
  Terminal.stubs(:mode).returns(mode)
64
64
  console.stubs(:getch).returns(input)
65
65
  input.stubs(:ord).returns(27)
66
66
  console.stubs(:read_nonblock)
67
- end
67
+ }
68
68
 
69
69
  it { subject.must_be_instance_of(String) }
70
70
  end
@@ -22,6 +22,25 @@ module Vedeu
22
22
 
23
23
  end # RepositoryTestModule
24
24
 
25
+ module DSL
26
+
27
+ class ModelTestClass
28
+
29
+ include Vedeu::DSL::Presentation
30
+
31
+ def initialize(model, client = nil)
32
+ @model = model
33
+ @client = client
34
+ end
35
+
36
+ protected
37
+
38
+ attr_reader :model
39
+
40
+ end # ModelTestClass
41
+
42
+ end # DSL
43
+
25
44
  class ModelTestClass
26
45
 
27
46
  include Vedeu::Model
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.5.0
4
+ version: 0.5.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-07-28 00:00:00.000000000 Z
11
+ date: 2015-07-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: guard
@@ -438,6 +438,7 @@ files:
438
438
  - lib/vedeu/runtime/launcher.rb
439
439
  - lib/vedeu/runtime/main_loop.rb
440
440
  - lib/vedeu/runtime/router.rb
441
+ - lib/vedeu/runtime/traps.rb
441
442
  - lib/vedeu/templating/all.rb
442
443
  - lib/vedeu/templating/decoder.rb
443
444
  - lib/vedeu/templating/encoder.rb
@@ -446,7 +447,6 @@ files:
446
447
  - lib/vedeu/templating/view_template.rb
447
448
  - lib/vedeu/terminal.rb
448
449
  - lib/vedeu/terminal_mode.rb
449
- - lib/vedeu/traps.rb
450
450
  - lib/vedeu/version.rb
451
451
  - test/lib/vedeu/api_test.rb
452
452
  - test/lib/vedeu/application/application_controller_test.rb
@@ -593,6 +593,7 @@ files:
593
593
  - test/lib/vedeu/runtime/launcher_test.rb
594
594
  - test/lib/vedeu/runtime/main_loop_test.rb
595
595
  - test/lib/vedeu/runtime/router_test.rb
596
+ - test/lib/vedeu/runtime/traps_test.rb
596
597
  - test/lib/vedeu/templating/decoder_test.rb
597
598
  - test/lib/vedeu/templating/encoder_test.rb
598
599
  - test/lib/vedeu/templating/helpers_test.rb
@@ -600,18 +601,11 @@ files:
600
601
  - test/lib/vedeu/templating/view_template_test.rb
601
602
  - test/lib/vedeu/terminal_mode_test.rb
602
603
  - test/lib/vedeu/terminal_test.rb
603
- - test/lib/vedeu/traps_test.rb
604
604
  - test/lib/vedeu_test.rb
605
605
  - test/support/all_seeds.sh
606
606
  - test/support/coverage.rb
607
607
  - test/support/helpers/model_test_class.rb
608
608
  - test/support/stats.sh
609
- - test/support/templates/background.erb
610
- - test/support/templates/colour.erb
611
- - test/support/templates/foreground.erb
612
- - test/support/templates/multiple.erb
613
- - test/support/templates/plain.erb
614
- - test/support/templates/style.erb
615
609
  - test/test_helper.rb
616
610
  - vedeu.gemspec
617
611
  homepage: https://github.com/gavinlaking/vedeu
@@ -784,6 +778,7 @@ test_files:
784
778
  - test/lib/vedeu/runtime/launcher_test.rb
785
779
  - test/lib/vedeu/runtime/main_loop_test.rb
786
780
  - test/lib/vedeu/runtime/router_test.rb
781
+ - test/lib/vedeu/runtime/traps_test.rb
787
782
  - test/lib/vedeu/templating/decoder_test.rb
788
783
  - test/lib/vedeu/templating/encoder_test.rb
789
784
  - test/lib/vedeu/templating/helpers_test.rb
@@ -791,17 +786,10 @@ test_files:
791
786
  - test/lib/vedeu/templating/view_template_test.rb
792
787
  - test/lib/vedeu/terminal_mode_test.rb
793
788
  - test/lib/vedeu/terminal_test.rb
794
- - test/lib/vedeu/traps_test.rb
795
789
  - test/lib/vedeu_test.rb
796
790
  - test/support/all_seeds.sh
797
791
  - test/support/coverage.rb
798
792
  - test/support/helpers/model_test_class.rb
799
793
  - test/support/stats.sh
800
- - test/support/templates/background.erb
801
- - test/support/templates/colour.erb
802
- - test/support/templates/foreground.erb
803
- - test/support/templates/multiple.erb
804
- - test/support/templates/plain.erb
805
- - test/support/templates/style.erb
806
794
  - test/test_helper.rb
807
795
  has_rdoc:
@@ -1 +0,0 @@
1
- This is a <%= background('#ff0000') { 'test' } %>.
@@ -1 +0,0 @@
1
- This is a <%= colour(background: '#003300', foreground: '#aadd00') { 'test' } %>.
@@ -1 +0,0 @@
1
- This is a <%= foreground('#00ff00') { 'test' } %>.
@@ -1,2 +0,0 @@
1
- This is a test.
2
- And so is this.
@@ -1 +0,0 @@
1
- This is a test.