vedeu 0.0.32 → 0.0.33

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/lib/vedeu/application.rb +2 -0
  3. data/lib/vedeu/launcher.rb +1 -1
  4. data/lib/vedeu/models/colour.rb +7 -7
  5. data/lib/vedeu/models/command.rb +2 -0
  6. data/lib/vedeu/models/composition.rb +2 -2
  7. data/lib/vedeu/models/interface.rb +15 -6
  8. data/lib/vedeu/models/line.rb +5 -3
  9. data/lib/vedeu/models/presentation.rb +3 -3
  10. data/lib/vedeu/models/stream.rb +6 -3
  11. data/lib/vedeu/models/style.rb +31 -0
  12. data/lib/vedeu/output/interface_renderer.rb +1 -3
  13. data/lib/vedeu/support/coordinate.rb +21 -7
  14. data/lib/vedeu/support/parsing/json_parser.rb +3 -3
  15. data/test/lib/vedeu/application_test.rb +0 -11
  16. data/test/lib/vedeu/launcher_test.rb +0 -8
  17. data/test/lib/vedeu/models/collection_test.rb +3 -3
  18. data/test/lib/vedeu/models/colour_test.rb +7 -2
  19. data/test/lib/vedeu/models/command_test.rb +0 -6
  20. data/test/lib/vedeu/models/composition_test.rb +127 -37
  21. data/test/lib/vedeu/models/interface_collection_test.rb +8 -9
  22. data/test/lib/vedeu/models/interface_test.rb +64 -18
  23. data/test/lib/vedeu/models/line_test.rb +3 -7
  24. data/test/lib/vedeu/models/presentation_test.rb +7 -5
  25. data/test/lib/vedeu/models/stream_test.rb +21 -11
  26. data/test/lib/vedeu/models/style_test.rb +86 -0
  27. data/test/lib/vedeu/output/interface_renderer_test.rb +32 -5
  28. data/test/lib/vedeu/output/output_test.rb +8 -1
  29. data/test/lib/vedeu/repository/command_repository_test.rb +14 -10
  30. data/test/lib/vedeu/repository/interface_repository_test.rb +9 -9
  31. data/test/lib/vedeu/support/coordinate_test.rb +72 -19
  32. data/test/lib/vedeu/support/menu_test.rb +16 -16
  33. data/test/lib/vedeu/support/parsing/hash_parser_test.rb +7 -7
  34. data/test/lib/vedeu/support/parsing/json_parser_test.rb +1 -1
  35. data/test/lib/vedeu/support/terminal_test.rb +0 -7
  36. data/test/lib/vedeu_test.rb +0 -5
  37. data/test/test_helper.rb +1 -0
  38. data/vedeu.gemspec +2 -3
  39. metadata +7 -25
  40. data/lib/vedeu/models/style_collection.rb +0 -19
  41. data/lib/vedeu/support/geometry.rb +0 -62
  42. data/test/lib/vedeu/models/style_collection_test.rb +0 -13
  43. data/test/lib/vedeu/support/geometry_test.rb +0 -107
@@ -60,10 +60,10 @@ module Vedeu
60
60
  it 'returns a tuple when the current has changed' do
61
61
  menu.next.items.must_equal(
62
62
  [
63
- [false, false, "hydrogen"],
64
- [false, true, "carbon"],
65
- [false, false, "nitrogen"],
66
- [false, false, "oxygen"]
63
+ [false, false, 'hydrogen'],
64
+ [false, true, 'carbon'],
65
+ [false, false, 'nitrogen'],
66
+ [false, false, 'oxygen']
67
67
  ]
68
68
  )
69
69
  end
@@ -72,10 +72,10 @@ module Vedeu
72
72
  menu.next.select
73
73
  menu.items.must_equal(
74
74
  [
75
- [false, false, "hydrogen"],
76
- [true, true, "carbon"],
77
- [false, false, "nitrogen"],
78
- [false, false, "oxygen"]
75
+ [false, false, 'hydrogen'],
76
+ [true, true, 'carbon'],
77
+ [false, false, 'nitrogen'],
78
+ [false, false, 'oxygen']
79
79
  ]
80
80
  )
81
81
  end
@@ -86,10 +86,10 @@ module Vedeu
86
86
  menu.next.next
87
87
  menu.items.must_equal(
88
88
  [
89
- [false, false, "hydrogen"],
90
- [true, false, "carbon"],
91
- [false, false, "nitrogen"],
92
- [false, true, "oxygen"]
89
+ [false, false, 'hydrogen'],
90
+ [true, false, 'carbon'],
91
+ [false, false, 'nitrogen'],
92
+ [false, true, 'oxygen']
93
93
  ]
94
94
  )
95
95
  end
@@ -98,20 +98,20 @@ module Vedeu
98
98
  describe '#render' do
99
99
  it 'returns a tuple' do
100
100
  menu.render.must_equal(
101
- [" > hydrogen", " carbon", " nitrogen", " oxygen"]
101
+ [' > hydrogen', ' carbon', ' nitrogen', ' oxygen']
102
102
  )
103
103
  end
104
104
 
105
105
  it 'returns a tuple when the current has changed' do
106
106
  menu.next.render.must_equal(
107
- [" hydrogen", " > carbon", " nitrogen", " oxygen"]
107
+ [' hydrogen', ' > carbon', ' nitrogen', ' oxygen']
108
108
  )
109
109
  end
110
110
 
111
111
  it 'returns a tuple when an item is selected' do
112
112
  menu.next.select
113
113
  menu.render.must_equal(
114
- [" hydrogen", "*> carbon", " nitrogen", " oxygen"]
114
+ [' hydrogen', '*> carbon', ' nitrogen', ' oxygen']
115
115
  )
116
116
  end
117
117
 
@@ -120,7 +120,7 @@ module Vedeu
120
120
  menu.next.select
121
121
  menu.next.next
122
122
  menu.render.must_equal(
123
- [" hydrogen", "* carbon", " nitrogen", " > oxygen"]
123
+ [' hydrogen', '* carbon', ' nitrogen', ' > oxygen']
124
124
  )
125
125
  end
126
126
  end
@@ -6,14 +6,14 @@ module Vedeu
6
6
  describe '.parse' do
7
7
  it 'returns a Hash when the output is content for multiple interfaces' do
8
8
  HashParser.parse({
9
- test: 'Some content...',
9
+ test: 'Some content...',
10
10
  dummy: 'More content...'
11
11
  }).must_equal({
12
12
  interfaces: [
13
- { name: "test", lines: [
14
- { streams: { text: "Some content..." } }] },
15
- { name: "dummy", lines: [
16
- { streams: { text: "More content..." } }] }
13
+ { name: 'test', lines: [
14
+ { streams: { text: 'Some content...' } }] },
15
+ { name: 'dummy', lines: [
16
+ { streams: { text: 'More content...' } }] }
17
17
  ]
18
18
  })
19
19
  end
@@ -23,8 +23,8 @@ module Vedeu
23
23
  dummy: 'Some content...'
24
24
  }).must_equal({
25
25
  interfaces: [
26
- { name: "dummy", lines: [
27
- { streams: { text: "Some content..." } }] }
26
+ { name: 'dummy', lines: [
27
+ { streams: { text: 'Some content...' } }] }
28
28
  ]
29
29
  })
30
30
  end
@@ -10,7 +10,7 @@ module Vedeu
10
10
  end
11
11
 
12
12
  it 'returns an empty hash when the JSON is invalid' do
13
- JSONParser.parse("{ invalid JSON }").must_be_instance_of(Hash)
13
+ JSONParser.parse('{ invalid JSON }').must_be_instance_of(Hash)
14
14
  end
15
15
  end
16
16
  end
@@ -54,13 +54,6 @@ module Vedeu
54
54
  end
55
55
  end
56
56
 
57
- describe '.open' do
58
- it 'returns a NilClass' do
59
- skip
60
- Terminal.open.must_be_instance_of(NilClass)
61
- end
62
- end
63
-
64
57
  describe '.console' do
65
58
  it 'returns the console' do
66
59
  console = IO.console
@@ -2,9 +2,4 @@ require_relative '../test_helper'
2
2
  require_relative '../../lib/vedeu'
3
3
 
4
4
  describe Vedeu do
5
- describe '.logger' do
6
- it 'needs a spec, please write one.' do
7
- skip
8
- end
9
- end
10
5
  end
data/test/test_helper.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require 'simplecov'
2
+ require 'pry'
2
3
  require 'minitest/autorun'
3
4
  require 'minitest/pride'
4
5
  require 'minitest/hell'
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.0.32'
7
+ spec.version = '0.0.33'
8
8
  spec.authors = ['Gavin Laking']
9
9
  spec.email = ['gavinlaking@gmail.com']
10
10
  spec.summary = %q{A terminal case of wonderland.}
@@ -24,8 +24,7 @@ Gem::Specification.new do |spec|
24
24
  spec.add_development_dependency 'pry', '0.10.0'
25
25
  spec.add_development_dependency 'rake', '10.3.2'
26
26
  spec.add_development_dependency 'ruby-prof', '0.15.1'
27
- spec.add_development_dependency 'simplecov', '0.8.2'
27
+ spec.add_development_dependency 'simplecov', '0.9.0'
28
28
 
29
- spec.add_dependency 'oj', '2.9.9'
30
29
  spec.add_dependency 'virtus', '1.0.2'
31
30
  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.0.32
4
+ version: 0.0.33
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-07-17 00:00:00.000000000 Z
11
+ date: 2014-07-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -128,28 +128,14 @@ dependencies:
128
128
  requirements:
129
129
  - - '='
130
130
  - !ruby/object:Gem::Version
131
- version: 0.8.2
131
+ version: 0.9.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: 0.8.2
139
- - !ruby/object:Gem::Dependency
140
- name: oj
141
- requirement: !ruby/object:Gem::Requirement
142
- requirements:
143
- - - '='
144
- - !ruby/object:Gem::Version
145
- version: 2.9.9
146
- type: :runtime
147
- prerelease: false
148
- version_requirements: !ruby/object:Gem::Requirement
149
- requirements:
150
- - - '='
151
- - !ruby/object:Gem::Version
152
- version: 2.9.9
138
+ version: 0.9.0
153
139
  - !ruby/object:Gem::Dependency
154
140
  name: virtus
155
141
  requirement: !ruby/object:Gem::Requirement
@@ -197,7 +183,7 @@ files:
197
183
  - lib/vedeu/models/presentation.rb
198
184
  - lib/vedeu/models/stream.rb
199
185
  - lib/vedeu/models/stream_collection.rb
200
- - lib/vedeu/models/style_collection.rb
186
+ - lib/vedeu/models/style.rb
201
187
  - lib/vedeu/output/interface_renderer.rb
202
188
  - lib/vedeu/output/output.rb
203
189
  - lib/vedeu/output/template.rb
@@ -211,7 +197,6 @@ files:
211
197
  - lib/vedeu/support/coordinate.rb
212
198
  - lib/vedeu/support/esc.rb
213
199
  - lib/vedeu/support/exit.rb
214
- - lib/vedeu/support/geometry.rb
215
200
  - lib/vedeu/support/menu.rb
216
201
  - lib/vedeu/support/parser.rb
217
202
  - lib/vedeu/support/parsing/hash_parser.rb
@@ -238,7 +223,7 @@ files:
238
223
  - test/lib/vedeu/models/presentation_test.rb
239
224
  - test/lib/vedeu/models/stream_collection_test.rb
240
225
  - test/lib/vedeu/models/stream_test.rb
241
- - test/lib/vedeu/models/style_collection_test.rb
226
+ - test/lib/vedeu/models/style_test.rb
242
227
  - test/lib/vedeu/output/interface_renderer_test.rb
243
228
  - test/lib/vedeu/output/output_test.rb
244
229
  - test/lib/vedeu/output/template.rb
@@ -252,7 +237,6 @@ files:
252
237
  - test/lib/vedeu/support/esc_test.rb
253
238
  - test/lib/vedeu/support/event_repository_test.rb
254
239
  - test/lib/vedeu/support/exit_test.rb
255
- - test/lib/vedeu/support/geometry_test.rb
256
240
  - test/lib/vedeu/support/menu_test.rb
257
241
  - test/lib/vedeu/support/parser_test.rb
258
242
  - test/lib/vedeu/support/parsing/hash_parser_test.rb
@@ -320,7 +304,7 @@ test_files:
320
304
  - test/lib/vedeu/models/presentation_test.rb
321
305
  - test/lib/vedeu/models/stream_collection_test.rb
322
306
  - test/lib/vedeu/models/stream_test.rb
323
- - test/lib/vedeu/models/style_collection_test.rb
307
+ - test/lib/vedeu/models/style_test.rb
324
308
  - test/lib/vedeu/output/interface_renderer_test.rb
325
309
  - test/lib/vedeu/output/output_test.rb
326
310
  - test/lib/vedeu/output/template.rb
@@ -334,7 +318,6 @@ test_files:
334
318
  - test/lib/vedeu/support/esc_test.rb
335
319
  - test/lib/vedeu/support/event_repository_test.rb
336
320
  - test/lib/vedeu/support/exit_test.rb
337
- - test/lib/vedeu/support/geometry_test.rb
338
321
  - test/lib/vedeu/support/menu_test.rb
339
322
  - test/lib/vedeu/support/parser_test.rb
340
323
  - test/lib/vedeu/support/parsing/hash_parser_test.rb
@@ -359,4 +342,3 @@ test_files:
359
342
  - test/support/json/int2_lin2_str3_styles.json
360
343
  - test/support/template.erb
361
344
  - test/test_helper.rb
362
- has_rdoc:
@@ -1,19 +0,0 @@
1
- require 'virtus'
2
-
3
- require_relative '../support/esc'
4
-
5
- module Vedeu
6
- class StyleCollection < Virtus::Attribute
7
- def coerce(values)
8
- return '' if values.nil? || values.empty?
9
-
10
- if values.is_a?(::Array)
11
- values.map { |value| Esc.string(value) }.join
12
-
13
- elsif values.is_a?(::String)
14
- Esc.string(values)
15
-
16
- end
17
- end
18
- end
19
- end
@@ -1,62 +0,0 @@
1
- require_relative 'esc'
2
- require_relative 'terminal'
3
-
4
- module Vedeu
5
- class Geometry
6
- def initialize(interface)
7
- @interface = interface
8
- end
9
-
10
- def origin(index = 0)
11
- Esc.set_position(virtual_y(index), virtual_x)
12
- end
13
-
14
- private
15
-
16
- attr_reader :interface
17
-
18
- def virtual_x(index = 0)
19
- ((x..max_x).to_a)[index]
20
- end
21
-
22
- def virtual_y(index = 0)
23
- ((y..max_y).to_a)[index]
24
- end
25
-
26
- def max_y
27
- if (y + height) > Terminal.height
28
- Terminal.height
29
-
30
- else
31
- (y + height)
32
-
33
- end
34
- end
35
-
36
- def max_x
37
- if (x + width) > Terminal.width
38
- Terminal.width
39
-
40
- else
41
- (x + width)
42
-
43
- end
44
- end
45
-
46
- def height
47
- interface.height
48
- end
49
-
50
- def width
51
- interface.width
52
- end
53
-
54
- def x
55
- interface.x
56
- end
57
-
58
- def y
59
- interface.y
60
- end
61
- end
62
- end
@@ -1,13 +0,0 @@
1
- require_relative '../../../test_helper'
2
- require_relative '../../../../lib/vedeu/models/style_collection'
3
- require_relative '../../../../lib/vedeu/models/stream'
4
-
5
- module Vedeu
6
- describe StyleCollection do
7
- describe '#coerce' do
8
- it 'returns an empty string' do
9
- Stream.new({ style: {} }).style.must_equal('')
10
- end
11
- end
12
- end
13
- end
@@ -1,107 +0,0 @@
1
- require_relative '../../../test_helper'
2
- require_relative '../../../../lib/vedeu/support/geometry'
3
- require_relative '../../../../lib/vedeu/models/interface'
4
-
5
- module Vedeu
6
- describe Geometry do
7
- describe '#origin' do
8
- it 'returns the origin for the interface' do
9
- interface = Interface.new({
10
- name: 'dummy',
11
- width: 5,
12
- height: 5,
13
- x: 1,
14
- y: 1,
15
- z: 1
16
- })
17
- Geometry.new(interface).origin.must_equal("\e[1;1H")
18
- end
19
-
20
- it 'returns the line position relative to the origin' do
21
- interface = Interface.new({
22
- name: 'dummy',
23
- width: 5,
24
- height: 5,
25
- x: 1,
26
- y: 1,
27
- z: 1
28
- })
29
- Geometry.new(interface).origin(3).must_equal("\e[4;1H")
30
- end
31
-
32
- it 'returns the origin for the interface when the interface is at a custom position' do
33
- interface = Interface.new({
34
- name: 'dummy',
35
- width: 5,
36
- height: 5,
37
- x: 3,
38
- y: 6,
39
- z: 1
40
- })
41
- Geometry.new(interface).origin.must_equal("\e[6;3H")
42
- end
43
-
44
- it 'returns the line position relative to the origin when the interface is at a custom position' do
45
- interface = Interface.new({
46
- name: 'dummy',
47
- width: 5,
48
- height: 5,
49
- x: 3,
50
- y: 6,
51
- z: 1
52
- })
53
- Geometry.new(interface).origin(3).must_equal("\e[9;3H")
54
- end
55
-
56
- it 'clips the maximum height to the terminal height when the height is more than the terminal height' do
57
- skip
58
- interface = Interface.new({
59
- name: 'dummy',
60
- width: 5,
61
- height: 6,
62
- x: 1,
63
- y: 20,
64
- z: 1
65
- })
66
- Geometry.new(interface).origin.must_equal("\e[1;1H")
67
- end
68
-
69
- it 'returns the value when the height is less than the terminal height' do
70
- skip
71
- interface = Interface.new({
72
- name: 'dummy',
73
- width: 5,
74
- height: 2,
75
- x: 1,
76
- y: 20,
77
- z: 1
78
- })
79
- Geometry.new(interface).origin.must_equal("\e[1;1H")
80
- end
81
-
82
- it 'clips the maximum width to the terminal width when the width is more than the terminal width' do
83
- interface = Interface.new({
84
- name: 'dummy',
85
- width: 20,
86
- height: 5,
87
- x: 30,
88
- y: 1,
89
- z: 1
90
- })
91
- Geometry.new(interface).origin.must_equal("\e[1;30H")
92
- end
93
-
94
- it 'returns the value when the width is less than the terminal width' do
95
- interface = Interface.new({
96
- name: 'dummy',
97
- width: 20,
98
- height: 5,
99
- x: 15,
100
- y: 1,
101
- z: 1
102
- })
103
- Geometry.new(interface).origin.must_equal("\e[1;15H")
104
- end
105
- end
106
- end
107
- end