vedeu 0.4.16 → 0.4.17

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. checksums.yaml +4 -4
  2. data/lib/vedeu/api.rb +7 -21
  3. data/lib/vedeu/bindings.rb +2 -6
  4. data/lib/vedeu/buffers/buffer.rb +29 -34
  5. data/lib/vedeu/cursor/cursor.rb +5 -2
  6. data/lib/vedeu/distributed/all.rb +5 -5
  7. data/lib/vedeu/distributed/server.rb +1 -1
  8. data/lib/vedeu/dsl/components/border.rb +1 -2
  9. data/lib/vedeu/dsl/components/geometry.rb +0 -47
  10. data/lib/vedeu/dsl/interface.rb +4 -11
  11. data/lib/vedeu/dsl/line.rb +1 -2
  12. data/lib/vedeu/dsl/shared/all.rb +1 -2
  13. data/lib/vedeu/dsl/shared/{colour.rb → presentation.rb} +27 -4
  14. data/lib/vedeu/dsl/shared/use.rb +50 -29
  15. data/lib/vedeu/dsl/stream.rb +1 -2
  16. data/lib/vedeu/geometry/geometry.rb +22 -11
  17. data/lib/vedeu/geometry/index_position.rb +0 -19
  18. data/lib/vedeu/geometry/position_validator.rb +8 -8
  19. data/lib/vedeu/models/interface.rb +34 -76
  20. data/lib/vedeu/models/null_interface.rb +5 -0
  21. data/lib/vedeu/models/stream.rb +1 -1
  22. data/lib/vedeu/output/border.rb +25 -41
  23. data/lib/vedeu/output/clear.rb +1 -7
  24. data/lib/vedeu/output/esc.rb +10 -10
  25. data/lib/vedeu/output/presentation.rb +2 -0
  26. data/lib/vedeu/output/renderers/escape_sequence_renderer.rb +3 -0
  27. data/lib/vedeu/repositories/model.rb +6 -0
  28. data/lib/vedeu/repositories/repositories/groups.rb +12 -0
  29. data/lib/vedeu/repositories/repository.rb +11 -8
  30. data/lib/vedeu/storage/all.rb +4 -4
  31. data/lib/vedeu/support/visibility.rb +8 -0
  32. data/test/lib/vedeu/buffers/buffer_test.rb +0 -2
  33. data/test/lib/vedeu/cursor/cursor_test.rb +14 -0
  34. data/test/lib/vedeu/dsl/components/border_test.rb +2 -2
  35. data/test/lib/vedeu/dsl/components/geometry_test.rb +63 -82
  36. data/test/lib/vedeu/dsl/components/keymap_test.rb +3 -3
  37. data/test/lib/vedeu/dsl/components/menu_test.rb +8 -8
  38. data/test/lib/vedeu/dsl/interface_test.rb +14 -22
  39. data/test/lib/vedeu/dsl/line_test.rb +4 -4
  40. data/test/lib/vedeu/dsl/shared/{colour_test.rb → presentation_test.rb} +19 -11
  41. data/test/lib/vedeu/dsl/shared/text_test.rb +15 -15
  42. data/test/lib/vedeu/dsl/shared/use_test.rb +24 -7
  43. data/test/lib/vedeu/geometry/geometry_test.rb +22 -19
  44. data/test/lib/vedeu/geometry/grid_test.rb +3 -3
  45. data/test/lib/vedeu/geometry/index_position_test.rb +0 -45
  46. data/test/lib/vedeu/geometry/position_test.rb +5 -5
  47. data/test/lib/vedeu/models/cell_test.rb +3 -3
  48. data/test/lib/vedeu/models/char_test.rb +5 -5
  49. data/test/lib/vedeu/models/interface_test.rb +7 -53
  50. data/test/lib/vedeu/models/null_test.rb +2 -2
  51. data/test/lib/vedeu/models/stream_test.rb +5 -5
  52. data/test/lib/vedeu/output/border_test.rb +1 -0
  53. data/test/lib/vedeu/output/colour_test.rb +16 -16
  54. data/test/lib/vedeu/output/esc_test.rb +15 -1
  55. data/test/lib/vedeu/output/html_char_test.rb +4 -4
  56. data/test/lib/vedeu/output/style_test.rb +15 -13
  57. data/test/lib/vedeu/output/text_test.rb +3 -3
  58. data/test/lib/vedeu/repositories/collection_test.rb +2 -2
  59. data/test/lib/vedeu/repositories/model_test.rb +19 -0
  60. data/test/lib/vedeu/repositories/repositories/groups_test.rb +22 -0
  61. data/test/lib/vedeu/repositories/repository_test.rb +50 -16
  62. data/test/lib/vedeu/support/common_test.rb +5 -5
  63. data/test/lib/vedeu/support/terminal_test.rb +3 -3
  64. data/test/lib/vedeu/support/visibility_test.rb +8 -0
  65. data/test/support/helpers/model_test_class.rb +18 -0
  66. data/test/test_helper.rb +1 -1
  67. data/vedeu.gemspec +2 -2
  68. metadata +7 -20
  69. data/lib/vedeu/dsl/shared/style.rb +0 -39
  70. data/test/lib/vedeu/dsl/shared/style_test.rb +0 -25
  71. data/test/support/helpers/all.rb +0 -5
  72. data/test/support/helpers/dsl_model_test_class.rb +0 -25
  73. data/test/support/helpers/helpers.rb +0 -17
  74. data/test/support/helpers/repositories.rb +0 -26
  75. data/test/support/helpers/repository_test_module.rb +0 -21
@@ -12,14 +12,14 @@ module Vedeu
12
12
  border: border,
13
13
  colour: colour,
14
14
  parent: parent,
15
- value: value
15
+ value: _value
16
16
  }
17
17
  }
18
18
  let(:border) {}
19
19
  let(:colour) {}
20
20
  let(:parent) { Vedeu::Line.new(colour: parent_colour) }
21
21
  let(:parent_colour) {}
22
- let(:value) {}
22
+ let(:_value) {}
23
23
 
24
24
  describe '#initialize' do
25
25
  it { instance.must_be_instance_of(Vedeu::HTMLChar) }
@@ -99,13 +99,13 @@ module Vedeu
99
99
  end
100
100
 
101
101
  context 'when the value is empty' do
102
- let(:value) { '' }
102
+ let(:_value) { '' }
103
103
 
104
104
  it { subject.must_equal('<td>&nbsp;</td>') }
105
105
  end
106
106
 
107
107
  context 'when there is a value' do
108
- let(:value) { 'a' }
108
+ let(:_value) { 'a' }
109
109
 
110
110
  it { subject.must_equal(
111
111
  "<td style='background:#000;color:#222;" \
@@ -5,8 +5,8 @@ module Vedeu
5
5
  describe Style do
6
6
 
7
7
  let(:described) { Vedeu::Style }
8
- let(:instance) { described.new(value) }
9
- let(:value) { 'bold' }
8
+ let(:instance) { described.new(_value) }
9
+ let(:_value) { 'bold' }
10
10
 
11
11
  describe 'alias methods' do
12
12
  it { instance.must_respond_to(:escape_sequences) }
@@ -18,26 +18,28 @@ module Vedeu
18
18
  end
19
19
 
20
20
  describe '.coerce' do
21
- let(:value) { 'bold' }
21
+ let(:_value) { 'bold' }
22
22
 
23
- subject { described.coerce(value) }
23
+ subject { described.coerce(_value) }
24
24
 
25
25
  it { subject.must_be_instance_of(described) }
26
26
 
27
27
  context 'when the value is nil' do
28
- let(:value) { nil }
28
+ let(:_value) { nil }
29
29
 
30
30
  it { subject.must_be_instance_of(described) }
31
31
  end
32
32
 
33
33
  context 'when the value is a Style already' do
34
- let(:value) { Vedeu::Style.new('bold') }
34
+ let(:_value) { Vedeu::Style.new('bold') }
35
35
 
36
- it { subject.must_equal(value) }
36
+ it 'returns the value' do
37
+ subject.must_equal(_value)
38
+ end
37
39
  end
38
40
 
39
41
  context 'when the value is an Array' do
40
- let(:value) { [:bold, :blink] }
42
+ let(:_value) { [:bold, :blink] }
41
43
 
42
44
  it { subject.value.must_equal([:bold, :blink]) }
43
45
  end
@@ -68,7 +70,7 @@ module Vedeu
68
70
  end
69
71
 
70
72
  describe '#to_s' do
71
- let(:value) {}
73
+ let(:_value) {}
72
74
 
73
75
  subject { instance.to_s }
74
76
 
@@ -76,7 +78,7 @@ module Vedeu
76
78
  it { subject.must_equal('') }
77
79
 
78
80
  describe 'for a single style' do
79
- let(:value) { 'normal' }
81
+ let(:_value) { 'normal' }
80
82
 
81
83
  it 'returns an escape sequence' do
82
84
  subject.must_equal("\e[24m\e[22m\e[27m")
@@ -84,7 +86,7 @@ module Vedeu
84
86
  end
85
87
 
86
88
  describe 'for multiple styles' do
87
- let(:value) { ['normal', 'underline'] }
89
+ let(:_value) { ['normal', 'underline'] }
88
90
 
89
91
  it 'returns an escape sequence for multiple styles' do
90
92
  subject.must_equal("\e[24m\e[22m\e[27m\e[4m")
@@ -92,7 +94,7 @@ module Vedeu
92
94
  end
93
95
 
94
96
  describe 'for an unknown style' do
95
- let(:value) { 'unknown' }
97
+ let(:_value) { 'unknown' }
96
98
 
97
99
  it 'returns an empty string for an unknown style' do
98
100
  subject.must_equal('')
@@ -100,7 +102,7 @@ module Vedeu
100
102
  end
101
103
 
102
104
  describe 'for an empty or nil' do
103
- let(:value) { '' }
105
+ let(:_value) { '' }
104
106
 
105
107
  it 'returns an empty string for empty or nil' do
106
108
  subject.must_equal('')
@@ -5,7 +5,7 @@ module Vedeu
5
5
  describe Text do
6
6
 
7
7
  let(:described) { Vedeu::Text }
8
- let(:value) { 'Testing the Text class with various options' }
8
+ let(:_value) { 'Testing the Text class with various options' }
9
9
  let(:options) {
10
10
  {
11
11
  anchor: anchor,
@@ -22,7 +22,7 @@ module Vedeu
22
22
  let(:width) { nil }
23
23
 
24
24
  describe '.with' do
25
- subject { described.with(value, options) }
25
+ subject { described.with(_value, options) }
26
26
 
27
27
  context 'when a width is provided' do
28
28
  context 'when value longer than the width' do
@@ -90,7 +90,7 @@ module Vedeu
90
90
 
91
91
  context 'when a width is not provided' do
92
92
  let(:width) {}
93
- let(:value) { 'some value' }
93
+ let(:_value) { 'some value' }
94
94
 
95
95
  it 'returns the value as a string' do
96
96
  subject.must_equal('some value')
@@ -19,9 +19,9 @@ module Vedeu
19
19
 
20
20
  describe '#[]' do
21
21
  let(:collection) { [:hydrogen, :helium, :lithium, :beryllium] }
22
- let(:value) { 1..2 }
22
+ let(:_value) { 1..2 }
23
23
 
24
- subject { instance[value] }
24
+ subject { instance[_value] }
25
25
 
26
26
  it { subject.must_be_instance_of(Array) }
27
27
  it { subject.must_equal([:helium, :lithium]) }
@@ -2,6 +2,25 @@ require 'test_helper'
2
2
 
3
3
  module Vedeu
4
4
 
5
+ module DSL
6
+
7
+ class ModelTestClass
8
+
9
+ include Vedeu::DSL::Presentation
10
+
11
+ def initialize(model, client = nil)
12
+ @model = model
13
+ @client = client
14
+ end
15
+
16
+ private
17
+
18
+ attr_reader :model
19
+
20
+ end # ModelTestClass
21
+
22
+ end # DSL
23
+
5
24
  describe Model do
6
25
  let(:model_instance) { ModelTestClass.new(attributes) }
7
26
  let(:attributes) {
@@ -12,6 +12,28 @@ module Vedeu
12
12
  it { subject.must_be_instance_of(described) }
13
13
  end
14
14
 
15
+ describe '#by_name' do
16
+ let(:_name) { 'carbon' }
17
+
18
+ subject { described.groups.by_name(_name) }
19
+
20
+ context 'when the group exists' do
21
+ before do
22
+ Vedeu.group 'carbon' do
23
+ end
24
+ end
25
+ after { Vedeu.groups.reset }
26
+
27
+ it { subject.must_be_instance_of(Vedeu::Group) }
28
+ end
29
+
30
+ context 'when the group does not exist' do
31
+ let(:_name) { 'nitrogen' }
32
+
33
+ it { subject.must_be_instance_of(Vedeu::Group) }
34
+ end
35
+ end
36
+
15
37
  end # Groups
16
38
 
17
39
  end # Vedeu
@@ -2,6 +2,27 @@ require 'test_helper'
2
2
 
3
3
  module Vedeu
4
4
 
5
+ class RepositoriesTestClass < Repository
6
+
7
+ attr_accessor :storage
8
+ alias_method :in_memory, :storage
9
+
10
+ def initialize(storage = {})
11
+ @storage = storage
12
+ end
13
+
14
+ def add(model)
15
+ if storage.is_a?(Hash)
16
+ @storage = in_memory.merge!(model)
17
+
18
+ else
19
+ @storage << model
20
+
21
+ end
22
+ end
23
+
24
+ end # RepositoriesTestClass
25
+
5
26
  class TestRepository < Repository
6
27
  end
7
28
 
@@ -101,6 +122,35 @@ module Vedeu
101
122
  end
102
123
  end
103
124
 
125
+ describe '#inspect' do
126
+ subject { instance.inspect }
127
+
128
+ it { subject.must_be_instance_of(String) }
129
+
130
+ context 'when there are no models stored in the repository' do
131
+ before { instance.reset }
132
+
133
+ it { subject.must_equal("<Vedeu::Repository: []>") }
134
+ end
135
+
136
+ context 'when there are models stored in the repository' do
137
+ before do
138
+ Vedeu.interfaces.reset
139
+ Vedeu.interface('hydrogen') {}
140
+ Vedeu.interface('helium') {}
141
+ end
142
+ after do
143
+ Vedeu.interfaces.reset
144
+ end
145
+
146
+ subject { Vedeu.interfaces.inspect }
147
+
148
+ it { subject.must_equal(
149
+ "<Vedeu::InterfacesRepository: [\"hydrogen\", \"helium\"]>"
150
+ ) }
151
+ end
152
+ end
153
+
104
154
  describe '#registered' do
105
155
  it 'returns an Array' do
106
156
  RepositoriesTestClass.new.registered.must_be_instance_of(Array)
@@ -206,22 +256,6 @@ module Vedeu
206
256
  end
207
257
  end
208
258
 
209
- describe '#use' do
210
- subject { instance.use(model_name) }
211
-
212
- context 'when the model exists' do
213
- before { instance.store(model_instance) }
214
-
215
- it { subject.must_equal(model_instance) }
216
- end
217
-
218
- context 'when the model does not exist' do
219
- let(:model_name) { 'not_found' }
220
-
221
- it { subject.must_be_instance_of(NilClass) }
222
- end
223
- end
224
-
225
259
  end # Repository
226
260
 
227
261
  end # Vedeu
@@ -17,29 +17,29 @@ module Vedeu
17
17
  let(:described) { Vedeu::VedeuCommonClass.new }
18
18
 
19
19
  describe '#defined_value?' do
20
- subject { described.defined_value_test(value) }
20
+ subject { described.defined_value_test(_value) }
21
21
 
22
22
  context 'when the variable is a Fixnum' do
23
- let(:value) { 17 }
23
+ let(:_value) { 17 }
24
24
 
25
25
  it { subject.must_equal(true) }
26
26
  end
27
27
 
28
28
  context 'when the variable is not nil or empty' do
29
- let(:value) { 'not empty' }
29
+ let(:_value) { 'not empty' }
30
30
 
31
31
  it { subject.must_equal(true) }
32
32
  end
33
33
 
34
34
  context 'when the variable is nil or empty' do
35
- let(:value) { [] }
35
+ let(:_value) { [] }
36
36
 
37
37
  it { subject.must_equal(false) }
38
38
  end
39
39
 
40
40
  context 'when dealing with keys which may not exist or have a value' do
41
41
  let(:attributes) { {} }
42
- let(:value) { attributes[:not_found] }
42
+ let(:_value) { attributes[:not_found] }
43
43
 
44
44
  it { subject.must_equal(false) }
45
45
  end
@@ -83,15 +83,15 @@ module Vedeu
83
83
  end
84
84
 
85
85
  describe '.output' do
86
- subject { described.output(*value) }
86
+ subject { described.output(*_value) }
87
87
 
88
88
  context 'when the value is a String' do
89
- let(:value) { 'Some output...' }
89
+ let(:_value) { 'Some output...' }
90
90
 
91
91
  it { subject.must_equal(['Some output...']) }
92
92
  end
93
93
  context 'when there are multiple values' do
94
- let(:value) { ['Some output...', 'more output...', 'even more...'] }
94
+ let(:_value) { ['Some output...', 'more output...', 'even more...'] }
95
95
 
96
96
  it { subject.must_equal(['Some output...',
97
97
  'more output...',
@@ -27,6 +27,14 @@ module Vedeu
27
27
  it { instance.instance_variable_get('@model').must_equal(model) }
28
28
  end
29
29
 
30
+ describe '.for_cursor' do
31
+ let(:_name) {}
32
+
33
+ subject { described.for_cursor(_name) }
34
+
35
+ it { subject.must_be_instance_of(Vedeu::Visibility) }
36
+ end
37
+
30
38
  describe '.show' do
31
39
  subject { described.show(model) }
32
40
 
@@ -3,6 +3,24 @@ require 'vedeu/output/presentation'
3
3
 
4
4
  module Vedeu
5
5
 
6
+ module RepositoryTestModule
7
+
8
+ extend self
9
+
10
+ # The real repository stores the model and returns it.
11
+ def store(model)
12
+ model
13
+ end
14
+
15
+ private
16
+
17
+ # A storage solution that uses memory to persist models.
18
+ def in_memory
19
+ {}
20
+ end
21
+
22
+ end # RepositoryTestModule
23
+
6
24
  class ModelTestClass
7
25
 
8
26
  include Vedeu::Model
@@ -36,7 +36,7 @@ end
36
36
 
37
37
  require 'mocha/setup'
38
38
  require 'vedeu'
39
- require 'support/helpers/all'
39
+ require 'support/helpers/model_test_class'
40
40
 
41
41
  # require 'minitest/reporters'
42
42
  # Minitest::Reporters.use!(
@@ -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.16'
7
+ spec.version = '0.4.17'
8
8
  spec.authors = ['Gavin Laking']
9
9
  spec.email = ['gavinlaking@gmail.com']
10
10
  spec.summary = 'A terminal case of wonderland.'
@@ -26,7 +26,7 @@ Gem::Specification.new do |spec|
26
26
  spec.add_development_dependency 'guard-cucumber', '1.6.0'
27
27
  spec.add_development_dependency 'guard-minitest', '2.4.4'
28
28
  spec.add_development_dependency 'inch', '0.5.10'
29
- spec.add_development_dependency 'minitest', '5.5.1'
29
+ spec.add_development_dependency 'minitest', '5.6.0'
30
30
  spec.add_development_dependency 'minitest-reporters', '1.0.11'
31
31
  spec.add_development_dependency 'mocha', '1.1.0'
32
32
  spec.add_development_dependency 'pry', '0.10.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.4.16
4
+ version: 0.4.17
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-04-14 00:00:00.000000000 Z
11
+ date: 2015-04-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aruba
@@ -128,14 +128,14 @@ dependencies:
128
128
  requirements:
129
129
  - - '='
130
130
  - !ruby/object:Gem::Version
131
- version: 5.5.1
131
+ version: 5.6.0
132
132
  type: :development
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
136
  - - '='
137
137
  - !ruby/object:Gem::Version
138
- version: 5.5.1
138
+ version: 5.6.0
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: minitest-reporters
141
141
  requirement: !ruby/object:Gem::Requirement
@@ -358,8 +358,7 @@ files:
358
358
  - lib/vedeu/dsl/interface.rb
359
359
  - lib/vedeu/dsl/line.rb
360
360
  - lib/vedeu/dsl/shared/all.rb
361
- - lib/vedeu/dsl/shared/colour.rb
362
- - lib/vedeu/dsl/shared/style.rb
361
+ - lib/vedeu/dsl/shared/presentation.rb
363
362
  - lib/vedeu/dsl/shared/text.rb
364
363
  - lib/vedeu/dsl/shared/use.rb
365
364
  - lib/vedeu/dsl/stream.rb
@@ -490,8 +489,7 @@ files:
490
489
  - test/lib/vedeu/dsl/group_test.rb
491
490
  - test/lib/vedeu/dsl/interface_test.rb
492
491
  - test/lib/vedeu/dsl/line_test.rb
493
- - test/lib/vedeu/dsl/shared/colour_test.rb
494
- - test/lib/vedeu/dsl/shared/style_test.rb
492
+ - test/lib/vedeu/dsl/shared/presentation_test.rb
495
493
  - test/lib/vedeu/dsl/shared/text_test.rb
496
494
  - test/lib/vedeu/dsl/shared/use_test.rb
497
495
  - test/lib/vedeu/dsl/stream_test.rb
@@ -589,12 +587,7 @@ files:
589
587
  - test/lib/vedeu/traps_test.rb
590
588
  - test/lib/vedeu_test.rb
591
589
  - test/support/colour_test.sh
592
- - test/support/helpers/all.rb
593
- - test/support/helpers/dsl_model_test_class.rb
594
- - test/support/helpers/helpers.rb
595
590
  - test/support/helpers/model_test_class.rb
596
- - test/support/helpers/repositories.rb
597
- - test/support/helpers/repository_test_module.rb
598
591
  - test/support/stats.sh
599
592
  - test/test_helper.rb
600
593
  - vedeu.gemspec
@@ -649,8 +642,7 @@ test_files:
649
642
  - test/lib/vedeu/dsl/group_test.rb
650
643
  - test/lib/vedeu/dsl/interface_test.rb
651
644
  - test/lib/vedeu/dsl/line_test.rb
652
- - test/lib/vedeu/dsl/shared/colour_test.rb
653
- - test/lib/vedeu/dsl/shared/style_test.rb
645
+ - test/lib/vedeu/dsl/shared/presentation_test.rb
654
646
  - test/lib/vedeu/dsl/shared/text_test.rb
655
647
  - test/lib/vedeu/dsl/shared/use_test.rb
656
648
  - test/lib/vedeu/dsl/stream_test.rb
@@ -748,12 +740,7 @@ test_files:
748
740
  - test/lib/vedeu/traps_test.rb
749
741
  - test/lib/vedeu_test.rb
750
742
  - test/support/colour_test.sh
751
- - test/support/helpers/all.rb
752
- - test/support/helpers/dsl_model_test_class.rb
753
- - test/support/helpers/helpers.rb
754
743
  - test/support/helpers/model_test_class.rb
755
- - test/support/helpers/repositories.rb
756
- - test/support/helpers/repository_test_module.rb
757
744
  - test/support/stats.sh
758
745
  - test/test_helper.rb
759
746
  has_rdoc: