vedeu 0.0.39 → 0.0.40

Sign up to get free protection for your applications and to get access to all the features.
Files changed (91) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +0 -30
  3. data/Rakefile +8 -9
  4. data/bin/log +13 -0
  5. data/deps.md +11 -95
  6. data/lib/vedeu.rb +14 -46
  7. data/lib/vedeu/application.rb +4 -8
  8. data/lib/vedeu/instrumentation.rb +111 -0
  9. data/lib/vedeu/launcher.rb +2 -2
  10. data/lib/vedeu/models/attributes/interface_collection.rb +2 -2
  11. data/lib/vedeu/models/attributes/line_collection.rb +2 -2
  12. data/lib/vedeu/models/attributes/stream_collection.rb +2 -2
  13. data/lib/vedeu/models/colour.rb +1 -1
  14. data/lib/vedeu/models/composition.rb +1 -1
  15. data/lib/vedeu/models/interface.rb +18 -10
  16. data/lib/vedeu/models/line.rb +3 -3
  17. data/lib/vedeu/models/presentation.rb +1 -1
  18. data/lib/vedeu/models/stream.rb +2 -2
  19. data/lib/vedeu/models/style.rb +1 -1
  20. data/lib/vedeu/output/render_interface.rb +1 -1
  21. data/lib/vedeu/{support → parsing}/compositor.rb +1 -1
  22. data/lib/vedeu/parsing/hash_parser.rb +1 -1
  23. data/lib/vedeu/parsing/parser.rb +6 -10
  24. data/lib/vedeu/{models/builders → support}/builder.rb +19 -9
  25. data/lib/vedeu/support/esc.rb +1 -1
  26. data/lib/vedeu/support/events.rb +15 -19
  27. data/lib/vedeu/support/geometry.rb +3 -3
  28. data/lib/vedeu/{input → support}/input.rb +6 -9
  29. data/lib/vedeu/support/menu.rb +3 -3
  30. data/lib/vedeu/support/persistence.rb +41 -0
  31. data/lib/vedeu/support/terminal.rb +1 -1
  32. data/test/example_app/lib/app.rb +85 -5
  33. data/test/lib/vedeu/application_test.rb +2 -2
  34. data/test/lib/vedeu/configuration_test.rb +2 -2
  35. data/test/lib/vedeu/launcher_test.rb +2 -2
  36. data/test/lib/vedeu/models/attributes/collection_test.rb +2 -2
  37. data/test/lib/vedeu/models/attributes/interface_collection_test.rb +4 -4
  38. data/test/lib/vedeu/models/attributes/line_collection_test.rb +3 -3
  39. data/test/lib/vedeu/models/attributes/stream_collection_test.rb +3 -3
  40. data/test/lib/vedeu/models/colour_test.rb +2 -2
  41. data/test/lib/vedeu/models/composition_test.rb +19 -19
  42. data/test/lib/vedeu/models/interface_test.rb +46 -34
  43. data/test/lib/vedeu/models/line_test.rb +2 -2
  44. data/test/lib/vedeu/models/presentation_test.rb +2 -2
  45. data/test/lib/vedeu/models/stream_test.rb +2 -2
  46. data/test/lib/vedeu/models/style_test.rb +31 -31
  47. data/test/lib/vedeu/output/clear_interface_test.rb +5 -5
  48. data/test/lib/vedeu/output/render_interface_test.rb +5 -6
  49. data/test/lib/vedeu/output/template.rb +2 -1
  50. data/test/lib/vedeu/{support → parsing}/compositor_test.rb +6 -4
  51. data/test/lib/vedeu/parsing/hash_parser_test.rb +2 -2
  52. data/test/lib/vedeu/parsing/json_parser_test.rb +2 -2
  53. data/test/lib/vedeu/parsing/parser_test.rb +6 -5
  54. data/test/lib/vedeu/parsing/text_adaptor_test.rb +2 -2
  55. data/test/lib/vedeu/{models/builders/interface_builder_test.rb → support/builder_test.rb} +10 -10
  56. data/test/lib/vedeu/support/esc_test.rb +2 -2
  57. data/test/lib/vedeu/support/events_test.rb +2 -2
  58. data/test/lib/vedeu/support/geometry_test.rb +2 -2
  59. data/test/lib/vedeu/{input → support}/input_test.rb +6 -7
  60. data/test/lib/vedeu/support/menu_test.rb +2 -2
  61. data/test/lib/vedeu/support/persistence_test.rb +55 -0
  62. data/test/lib/vedeu/support/queue_test.rb +2 -2
  63. data/test/lib/vedeu/support/terminal_test.rb +2 -2
  64. data/test/lib/vedeu/support/translator_test.rb +2 -2
  65. data/test/lib/vedeu/support/wordwrap_test.rb +2 -2
  66. data/test/lib/vedeu_test.rb +17 -2
  67. data/test/support/bench.rb +34 -0
  68. data/test/test_helper.rb +3 -11
  69. data/vedeu.gemspec +2 -2
  70. metadata +20 -44
  71. data/lib/vedeu/models/builders/command_builder.rb +0 -10
  72. data/lib/vedeu/models/builders/interface_builder.rb +0 -32
  73. data/lib/vedeu/models/command.rb +0 -23
  74. data/lib/vedeu/output/output.rb +0 -14
  75. data/lib/vedeu/process/process.rb +0 -51
  76. data/lib/vedeu/repository/command_repository.rb +0 -31
  77. data/lib/vedeu/repository/interface_repository.rb +0 -31
  78. data/lib/vedeu/repository/repository.rb +0 -41
  79. data/lib/vedeu/repository/storage.rb +0 -40
  80. data/lib/vedeu/support/exit.rb +0 -9
  81. data/test/lib/vedeu/models/builders/builder_test.rb +0 -11
  82. data/test/lib/vedeu/models/builders/command_builder_test.rb +0 -16
  83. data/test/lib/vedeu/models/command_test.rb +0 -40
  84. data/test/lib/vedeu/output/output_test.rb +0 -19
  85. data/test/lib/vedeu/process/process_test.rb +0 -71
  86. data/test/lib/vedeu/repository/command_repository_test.rb +0 -55
  87. data/test/lib/vedeu/repository/interface_repository_test.rb +0 -67
  88. data/test/lib/vedeu/repository/repository_test.rb +0 -81
  89. data/test/lib/vedeu/repository/storage_test.rb +0 -70
  90. data/test/lib/vedeu/support/exit_test.rb +0 -12
  91. data/test/support/dummy_command.rb +0 -9
@@ -1,5 +1,5 @@
1
- require_relative '../../../test_helper'
2
- require_relative '../../../../lib/vedeu/support/terminal'
1
+ require 'test_helper'
2
+ require 'vedeu/support/terminal'
3
3
 
4
4
  module Vedeu
5
5
  describe Terminal do
@@ -1,5 +1,5 @@
1
- require_relative '../../../test_helper'
2
- require_relative '../../../../lib/vedeu/support/translator'
1
+ require 'test_helper'
2
+ require 'vedeu/support/translator'
3
3
 
4
4
  module Vedeu
5
5
  describe Translator do
@@ -1,5 +1,5 @@
1
- require_relative '../../../test_helper'
2
- require_relative '../../../../lib/vedeu/support/wordwrap'
1
+ require 'test_helper'
2
+ require 'vedeu/support/wordwrap'
3
3
 
4
4
  module Vedeu
5
5
  describe Wordwrap do
@@ -1,5 +1,20 @@
1
- require_relative '../test_helper'
2
- require_relative '../../lib/vedeu'
1
+ require 'test_helper'
2
+ require 'vedeu'
3
+
4
+ module Vedeu
5
+ describe ClassMethods do
6
+ describe '.interface' do
7
+ end
8
+
9
+ describe '.event' do
10
+ end
11
+
12
+ describe '.run' do
13
+ end
14
+ end
15
+ end
3
16
 
4
17
  describe Vedeu do
18
+ describe '.events' do
19
+ end
5
20
  end
@@ -0,0 +1,34 @@
1
+ require 'benchmark'
2
+
3
+ class Foo
4
+ def bar(a, b)
5
+ a + b
6
+ end
7
+
8
+ def baz
9
+ a + b
10
+ end
11
+
12
+ def a
13
+ rand(1000_000)
14
+ end
15
+
16
+ def b
17
+ rand(1000_000)
18
+ end
19
+ end
20
+
21
+ foo = Foo.new
22
+
23
+ Benchmark.bm 30 do |x|
24
+ x.report 'original method' do
25
+ 1000000.times do |_|
26
+ foo.bar(rand(1_000_000), rand(1_000_000))
27
+ end
28
+ end
29
+ x.report 'shiny new method' do
30
+ 1000000.times do |_|
31
+ foo.baz
32
+ end
33
+ end
34
+ end
data/test/test_helper.rb CHANGED
@@ -18,14 +18,6 @@ GC.disable
18
18
  # Minitest::Reporters::SpecReporter.new
19
19
  # )
20
20
 
21
- # trace method execution with local variables
22
- # my_event = 'call'
23
- # my_class = /^Vedeu/
24
- # set_trace_func proc { |event, file, line, id, binding, classname|
25
- # if event == my_event && classname.to_s.match(my_class)
26
- # printf("\e[38;5;#{rand(22..231)}m%s %s #%s\e[38;2;39m\n", event, classname, id)
27
- # binding.eval('local_variables').each do |var|
28
- # print("#{var.to_s} = #{binding.local_variable_get(var).inspect}\n")
29
- # end
30
- # end
31
- # }
21
+ # trace method execution with (optionally) local variables
22
+ # require 'vedeu/instrumentation'
23
+ # Vedeu::Instrumentation::Trace.call({ watched: 'call', klass: /^Vedeu/ })
data/vedeu.gemspec CHANGED
@@ -4,11 +4,11 @@ $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.39'
7
+ spec.version = '0.0.40'
8
8
  spec.authors = ['Gavin Laking']
9
9
  spec.email = ['gavinlaking@gmail.com']
10
10
  spec.summary = %q{A terminal case of wonderland.}
11
- spec.homepage = 'http://www.gavinlaking.name/'
11
+ spec.homepage = 'https://github.com/gavinlaking/vedeu'
12
12
  spec.license = 'MIT'
13
13
 
14
14
  spec.files = `git ls-files -z`.split("\x0")
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.39
4
+ version: 0.0.40
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-23 00:00:00.000000000 Z
11
+ date: 2014-07-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -154,6 +154,7 @@ description:
154
154
  email:
155
155
  - gavinlaking@gmail.com
156
156
  executables:
157
+ - log
157
158
  - vedeu
158
159
  extensions: []
159
160
  extra_rdoc_files: []
@@ -166,22 +167,19 @@ files:
166
167
  - LICENSE.txt
167
168
  - README.md
168
169
  - Rakefile
170
+ - bin/log
169
171
  - bin/vedeu
170
172
  - deps.md
171
173
  - lib/vedeu.rb
172
174
  - lib/vedeu/application.rb
173
175
  - lib/vedeu/configuration.rb
174
- - lib/vedeu/input/input.rb
176
+ - lib/vedeu/instrumentation.rb
175
177
  - lib/vedeu/launcher.rb
176
178
  - lib/vedeu/models/attributes/collection.rb
177
179
  - lib/vedeu/models/attributes/interface_collection.rb
178
180
  - lib/vedeu/models/attributes/line_collection.rb
179
181
  - lib/vedeu/models/attributes/stream_collection.rb
180
- - lib/vedeu/models/builders/builder.rb
181
- - lib/vedeu/models/builders/command_builder.rb
182
- - lib/vedeu/models/builders/interface_builder.rb
183
182
  - lib/vedeu/models/colour.rb
184
- - lib/vedeu/models/command.rb
185
183
  - lib/vedeu/models/composition.rb
186
184
  - lib/vedeu/models/interface.rb
187
185
  - lib/vedeu/models/line.rb
@@ -189,24 +187,20 @@ files:
189
187
  - lib/vedeu/models/stream.rb
190
188
  - lib/vedeu/models/style.rb
191
189
  - lib/vedeu/output/clear_interface.rb
192
- - lib/vedeu/output/output.rb
193
190
  - lib/vedeu/output/render_interface.rb
194
191
  - lib/vedeu/output/template.rb
192
+ - lib/vedeu/parsing/compositor.rb
195
193
  - lib/vedeu/parsing/hash_parser.rb
196
194
  - lib/vedeu/parsing/json_parser.rb
197
195
  - lib/vedeu/parsing/parser.rb
198
196
  - lib/vedeu/parsing/text_adaptor.rb
199
- - lib/vedeu/process/process.rb
200
- - lib/vedeu/repository/command_repository.rb
201
- - lib/vedeu/repository/interface_repository.rb
202
- - lib/vedeu/repository/repository.rb
203
- - lib/vedeu/repository/storage.rb
204
- - lib/vedeu/support/compositor.rb
197
+ - lib/vedeu/support/builder.rb
205
198
  - lib/vedeu/support/esc.rb
206
199
  - lib/vedeu/support/events.rb
207
- - lib/vedeu/support/exit.rb
208
200
  - lib/vedeu/support/geometry.rb
201
+ - lib/vedeu/support/input.rb
209
202
  - lib/vedeu/support/menu.rb
203
+ - lib/vedeu/support/persistence.rb
210
204
  - lib/vedeu/support/queue.rb
211
205
  - lib/vedeu/support/terminal.rb
212
206
  - lib/vedeu/support/translator.rb
@@ -216,17 +210,12 @@ files:
216
210
  - test/example_app/lib/app.rb
217
211
  - test/lib/vedeu/application_test.rb
218
212
  - test/lib/vedeu/configuration_test.rb
219
- - test/lib/vedeu/input/input_test.rb
220
213
  - test/lib/vedeu/launcher_test.rb
221
214
  - test/lib/vedeu/models/attributes/collection_test.rb
222
215
  - test/lib/vedeu/models/attributes/interface_collection_test.rb
223
216
  - test/lib/vedeu/models/attributes/line_collection_test.rb
224
217
  - test/lib/vedeu/models/attributes/stream_collection_test.rb
225
- - test/lib/vedeu/models/builders/builder_test.rb
226
- - test/lib/vedeu/models/builders/command_builder_test.rb
227
- - test/lib/vedeu/models/builders/interface_builder_test.rb
228
218
  - test/lib/vedeu/models/colour_test.rb
229
- - test/lib/vedeu/models/command_test.rb
230
219
  - test/lib/vedeu/models/composition_test.rb
231
220
  - test/lib/vedeu/models/interface_test.rb
232
221
  - test/lib/vedeu/models/line_test.rb
@@ -234,32 +223,28 @@ files:
234
223
  - test/lib/vedeu/models/stream_test.rb
235
224
  - test/lib/vedeu/models/style_test.rb
236
225
  - test/lib/vedeu/output/clear_interface_test.rb
237
- - test/lib/vedeu/output/output_test.rb
238
226
  - test/lib/vedeu/output/render_interface_test.rb
239
227
  - test/lib/vedeu/output/template.rb
228
+ - test/lib/vedeu/parsing/compositor_test.rb
240
229
  - test/lib/vedeu/parsing/hash_parser_test.rb
241
230
  - test/lib/vedeu/parsing/json_parser_test.rb
242
231
  - test/lib/vedeu/parsing/parser_test.rb
243
232
  - test/lib/vedeu/parsing/text_adaptor_test.rb
244
- - test/lib/vedeu/process/process_test.rb
245
- - test/lib/vedeu/repository/command_repository_test.rb
246
- - test/lib/vedeu/repository/interface_repository_test.rb
247
- - test/lib/vedeu/repository/repository_test.rb
248
- - test/lib/vedeu/repository/storage_test.rb
249
- - test/lib/vedeu/support/compositor_test.rb
233
+ - test/lib/vedeu/support/builder_test.rb
250
234
  - test/lib/vedeu/support/esc_test.rb
251
235
  - test/lib/vedeu/support/events_test.rb
252
- - test/lib/vedeu/support/exit_test.rb
253
236
  - test/lib/vedeu/support/geometry_test.rb
237
+ - test/lib/vedeu/support/input_test.rb
254
238
  - test/lib/vedeu/support/menu_test.rb
239
+ - test/lib/vedeu/support/persistence_test.rb
255
240
  - test/lib/vedeu/support/queue_test.rb
256
241
  - test/lib/vedeu/support/terminal_test.rb
257
242
  - test/lib/vedeu/support/translator_test.rb
258
243
  - test/lib/vedeu/support/wordwrap_test.rb
259
244
  - test/lib/vedeu_test.rb
260
245
  - test/stats.sh
246
+ - test/support/bench.rb
261
247
  - test/support/colours.rb
262
- - test/support/dummy_command.rb
263
248
  - test/support/dummy_interface.rb
264
249
  - test/support/json/int1_lin1_str1.json
265
250
  - test/support/json/int1_lin1_str3.json
@@ -274,7 +259,7 @@ files:
274
259
  - test/support/template.erb
275
260
  - test/test_helper.rb
276
261
  - vedeu.gemspec
277
- homepage: http://www.gavinlaking.name/
262
+ homepage: https://github.com/gavinlaking/vedeu
278
263
  licenses:
279
264
  - MIT
280
265
  metadata: {}
@@ -303,17 +288,12 @@ test_files:
303
288
  - test/example_app/lib/app.rb
304
289
  - test/lib/vedeu/application_test.rb
305
290
  - test/lib/vedeu/configuration_test.rb
306
- - test/lib/vedeu/input/input_test.rb
307
291
  - test/lib/vedeu/launcher_test.rb
308
292
  - test/lib/vedeu/models/attributes/collection_test.rb
309
293
  - test/lib/vedeu/models/attributes/interface_collection_test.rb
310
294
  - test/lib/vedeu/models/attributes/line_collection_test.rb
311
295
  - test/lib/vedeu/models/attributes/stream_collection_test.rb
312
- - test/lib/vedeu/models/builders/builder_test.rb
313
- - test/lib/vedeu/models/builders/command_builder_test.rb
314
- - test/lib/vedeu/models/builders/interface_builder_test.rb
315
296
  - test/lib/vedeu/models/colour_test.rb
316
- - test/lib/vedeu/models/command_test.rb
317
297
  - test/lib/vedeu/models/composition_test.rb
318
298
  - test/lib/vedeu/models/interface_test.rb
319
299
  - test/lib/vedeu/models/line_test.rb
@@ -321,32 +301,28 @@ test_files:
321
301
  - test/lib/vedeu/models/stream_test.rb
322
302
  - test/lib/vedeu/models/style_test.rb
323
303
  - test/lib/vedeu/output/clear_interface_test.rb
324
- - test/lib/vedeu/output/output_test.rb
325
304
  - test/lib/vedeu/output/render_interface_test.rb
326
305
  - test/lib/vedeu/output/template.rb
306
+ - test/lib/vedeu/parsing/compositor_test.rb
327
307
  - test/lib/vedeu/parsing/hash_parser_test.rb
328
308
  - test/lib/vedeu/parsing/json_parser_test.rb
329
309
  - test/lib/vedeu/parsing/parser_test.rb
330
310
  - test/lib/vedeu/parsing/text_adaptor_test.rb
331
- - test/lib/vedeu/process/process_test.rb
332
- - test/lib/vedeu/repository/command_repository_test.rb
333
- - test/lib/vedeu/repository/interface_repository_test.rb
334
- - test/lib/vedeu/repository/repository_test.rb
335
- - test/lib/vedeu/repository/storage_test.rb
336
- - test/lib/vedeu/support/compositor_test.rb
311
+ - test/lib/vedeu/support/builder_test.rb
337
312
  - test/lib/vedeu/support/esc_test.rb
338
313
  - test/lib/vedeu/support/events_test.rb
339
- - test/lib/vedeu/support/exit_test.rb
340
314
  - test/lib/vedeu/support/geometry_test.rb
315
+ - test/lib/vedeu/support/input_test.rb
341
316
  - test/lib/vedeu/support/menu_test.rb
317
+ - test/lib/vedeu/support/persistence_test.rb
342
318
  - test/lib/vedeu/support/queue_test.rb
343
319
  - test/lib/vedeu/support/terminal_test.rb
344
320
  - test/lib/vedeu/support/translator_test.rb
345
321
  - test/lib/vedeu/support/wordwrap_test.rb
346
322
  - test/lib/vedeu_test.rb
347
323
  - test/stats.sh
324
+ - test/support/bench.rb
348
325
  - test/support/colours.rb
349
- - test/support/dummy_command.rb
350
326
  - test/support/dummy_interface.rb
351
327
  - test/support/json/int1_lin1_str1.json
352
328
  - test/support/json/int1_lin1_str3.json
@@ -1,10 +0,0 @@
1
- require_relative 'builder'
2
- require_relative '../../repository/command_repository'
3
-
4
- module Vedeu
5
- class CommandBuilder < Builder
6
- def repository
7
- CommandRepository
8
- end
9
- end
10
- end
@@ -1,32 +0,0 @@
1
- require_relative 'builder'
2
- require_relative '../../support/geometry'
3
- require_relative '../../repository/interface_repository'
4
-
5
- module Vedeu
6
- class InterfaceBuilder < Builder
7
- def repository
8
- InterfaceRepository
9
- end
10
-
11
- private
12
-
13
- def overrides
14
- @overrides = if user_attributes[:centred] == true
15
- { x: geometry.left, y: geometry.top }
16
- else
17
- {}
18
- end
19
- end
20
-
21
- def geometry
22
- @_geometry ||= Geometry.new({
23
- height: user_attributes[:height],
24
- width: user_attributes[:width],
25
- })
26
- end
27
-
28
- def method_missing(method_name, arg, &block)
29
- user_attributes[method_name] = arg
30
- end
31
- end
32
- end
@@ -1,23 +0,0 @@
1
- require 'virtus'
2
-
3
- module Vedeu
4
- class Command
5
- include Virtus.model
6
-
7
- attribute :name, String
8
- attribute :entity, Class
9
- attribute :keyword, String, default: ''
10
- attribute :keypress, String, default: ''
11
- attribute :arguments, Array, default: []
12
-
13
- def execute(*args)
14
- executable.call(*args)
15
- end
16
-
17
- # :nocov:
18
- def executable
19
- proc { |*args| entity.dispatch(*args) }
20
- end
21
- # :nocov:
22
- end
23
- end
@@ -1,14 +0,0 @@
1
- require_relative '../repository/interface_repository'
2
- require_relative '../support/terminal'
3
-
4
- module Vedeu
5
- module Output
6
- extend self
7
-
8
- def render
9
- InterfaceRepository.refresh.each do |interface|
10
- Terminal.output(interface)
11
- end
12
- end
13
- end
14
- end
@@ -1,51 +0,0 @@
1
- require_relative '../repository/command_repository'
2
- require_relative '../support/queue'
3
- require_relative '../parsing/parser'
4
-
5
- module Vedeu
6
- class Process
7
- def self.evaluate
8
- new.evaluate
9
- end
10
-
11
- def initialize; end
12
-
13
- def evaluate
14
- return false if no_input?
15
-
16
- fail StopIteration if stop_requested?
17
-
18
- Parser.parse(result) unless no_result?
19
- end
20
-
21
- private
22
-
23
- def stop_requested?
24
- result == :stop
25
- end
26
-
27
- def no_result?
28
- result.nil? || result.empty?
29
- end
30
-
31
- def no_input?
32
- input.nil? || input.empty?
33
- end
34
-
35
- def result
36
- @result ||= command.execute(*args) if command
37
- end
38
-
39
- def command
40
- @command ||= CommandRepository.by_input(input)
41
- end
42
-
43
- def input
44
- @input ||= Queue.dequeue
45
- end
46
-
47
- def args
48
- []
49
- end
50
- end
51
- end