vedeu 0.4.50 → 0.4.51

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/Guardfile +0 -5
  3. data/examples/material_colours_app.rb +1 -1
  4. data/examples/panel_app.rb +1 -1
  5. data/lib/vedeu/cli/generator/templates/application/config/configuration.erb +7 -2
  6. data/lib/vedeu/configuration/configuration.rb +1 -1
  7. data/lib/vedeu/output/border.rb +0 -6
  8. data/lib/vedeu/output/clear/named_interface.rb +2 -2
  9. data/lib/vedeu/output/output.rb +12 -12
  10. data/lib/vedeu/output/render_border.rb +1 -1
  11. data/lib/vedeu/output/renderers/all.rb +10 -5
  12. data/lib/vedeu/output/renderers/escape_sequence.rb +21 -23
  13. data/lib/vedeu/output/renderers/file.rb +16 -27
  14. data/lib/vedeu/output/renderers/html.rb +36 -42
  15. data/lib/vedeu/output/renderers/json.rb +22 -5
  16. data/lib/vedeu/output/renderers/null.rb +28 -3
  17. data/lib/vedeu/output/renderers/terminal.rb +23 -19
  18. data/lib/vedeu/output/renderers/text.rb +18 -20
  19. data/lib/vedeu/output/virtual_terminal.rb +1 -1
  20. data/lib/vedeu/support/template.rb +1 -1
  21. data/lib/vedeu/version.rb +1 -1
  22. data/test/lib/vedeu/application/application_controller_test.rb +2 -0
  23. data/test/lib/vedeu/application/application_helper_test.rb +2 -0
  24. data/test/lib/vedeu/application/controller_test.rb +1 -1
  25. data/test/lib/vedeu/application/helper_test.rb +2 -0
  26. data/test/lib/vedeu/application/view_test.rb +2 -0
  27. data/test/lib/vedeu/buffers/buffer_test.rb +1 -1
  28. data/test/lib/vedeu/buffers/display_buffer_test.rb +2 -0
  29. data/test/lib/vedeu/cli/generator/application_test.rb +2 -0
  30. data/test/lib/vedeu/cli/generator/helpers_test.rb +1 -0
  31. data/test/lib/vedeu/configuration/api_test.rb +3 -0
  32. data/test/lib/vedeu/cursor/move_test.rb +5 -0
  33. data/test/lib/vedeu/distributed/client_test.rb +4 -0
  34. data/test/lib/vedeu/distributed/server_test.rb +9 -0
  35. data/test/lib/vedeu/dsl/use_test.rb +4 -0
  36. data/test/lib/vedeu/launcher_test.rb +2 -0
  37. data/test/lib/vedeu/main_loop_test.rb +2 -0
  38. data/test/lib/vedeu/null/interface_test.rb +1 -0
  39. data/test/lib/vedeu/output/border_test.rb +0 -8
  40. data/test/lib/vedeu/output/output_test.rb +12 -11
  41. data/test/lib/vedeu/output/refresh_test.rb +1 -0
  42. data/test/lib/vedeu/output/render_border_test.rb +1 -0
  43. data/test/lib/vedeu/output/renderers/all_test.rb +4 -8
  44. data/test/lib/vedeu/output/renderers/escape_sequence_test.rb +5 -4
  45. data/test/lib/vedeu/output/renderers/file_test.rb +14 -19
  46. data/test/lib/vedeu/output/renderers/html_test.rb +55 -56
  47. data/test/lib/vedeu/output/renderers/json_test.rb +4 -5
  48. data/test/lib/vedeu/output/renderers/null_test.rb +9 -3
  49. data/test/lib/vedeu/output/renderers/terminal_test.rb +5 -4
  50. data/test/lib/vedeu/output/renderers/text_test.rb +5 -4
  51. data/test/lib/vedeu/output/text_test.rb +2 -0
  52. data/test/lib/vedeu/output/virtual_terminal_test.rb +10 -28
  53. data/test/lib/vedeu/repositories/collection_test.rb +1 -0
  54. data/test/lib/vedeu/repositories/model_test.rb +3 -0
  55. data/test/lib/vedeu/repositories/repository_test.rb +1 -0
  56. data/test/lib/vedeu/support/visibility_test.rb +1 -0
  57. data/test/lib/vedeu/traps_test.rb +1 -0
  58. data/test/lib/vedeu_test.rb +1 -0
  59. data/vedeu.gemspec +0 -2
  60. metadata +2 -30
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a09d46830938e1cc8b738499f0473e18c03cfb9c
4
- data.tar.gz: 391122a3f279aded058f010e67eefeb382385dff
3
+ metadata.gz: 51f8100764995bff505583f3dc874821dcb56fc9
4
+ data.tar.gz: 9064e5dfd73320ad37281d8cb112d77439ebc641
5
5
  SHA512:
6
- metadata.gz: bebff5ce0ae54c6880aeb8f6f229661007521a4a029b585f1a6bc0a3b027e548ba93136a5ab60e0570cf0075711c0689e52b263bb8e602ad06bda0e4e726c1fe
7
- data.tar.gz: 4dc322f36187484f76665de2eab79f50d2b0ea14b32ca6eba943d6d12c7c87f7593ad37b0a34b014c3188a9a648c21985b7491ad5a6ff69d78427041e195a9e2
6
+ metadata.gz: ae6180723fb6977e5da0efd16ae9a0250feaa89a1ff5e0d813ae8a24d0c399b9086aaa49ab33940fb9fc5ea9652fadf87fb21933c96af17f201cfdc403d51cf5
7
+ data.tar.gz: 9aafcd3c738dde584d38ae6dc0a5e26b552c18f2c498d00dca86cf755dfe76b60d3b518e93343304646cb02d856916774c9400ca23c393cd20c8cc10fb16778a
data/Guardfile CHANGED
@@ -6,8 +6,3 @@ guard :minitest, all_after_pass: true,
6
6
  watch(%r{^test/test_helper\.rb}) { 'test' }
7
7
  watch(%r{^lib/(.+)all\.rb}) { 'test' }
8
8
  end
9
-
10
- guard :bundler do
11
- watch('Gemfile')
12
- watch(/^.+\.gemspec/)
13
- end
@@ -21,7 +21,7 @@ class VedeuMaterialColoursApp
21
21
  configure do
22
22
  # debug!
23
23
  log '/tmp/vedeu_material_colours_app.log'
24
- # renderers Vedeu::Renderers::File
24
+ # renderers Vedeu::Renderers::File.new
25
25
  end
26
26
 
27
27
  interface 'main_interface' do
@@ -21,7 +21,7 @@ class VedeuPanelApp
21
21
  configure do
22
22
  # debug!
23
23
  log '/tmp/vedeu_panel_app.log'
24
- # renderers Vedeu::Renderers::File
24
+ # renderers Vedeu::Renderers::File.new
25
25
  end
26
26
 
27
27
  # line { centre 'Blue', width: 20, background: '#2196f3' }
@@ -1,7 +1,8 @@
1
1
  Vedeu.configure do
2
- log "/tmp/<%= object.name %>.log"
2
+ # base_path
3
3
 
4
- colour_mode 16_777_216
4
+ # colour_mode 16_777_216 # Some terminals don't render colour at all if this
5
+ # value is not one of 8, 16, 256 or 16777216.
5
6
 
6
7
  # debug! # Add "gem 'ruby-prof'" to your Gemfile if uncommenting this line.
7
8
  # drb!
@@ -13,6 +14,10 @@ Vedeu.configure do
13
14
  # cooked!
14
15
  # raw!
15
16
 
17
+ log "/tmp/<%= object.name %>.log"
18
+
19
+ # renderers
20
+
16
21
  # run_once!
17
22
 
18
23
  # interactive!
@@ -266,7 +266,7 @@ module Vedeu
266
266
  interactive: true,
267
267
  log: nil,
268
268
  once: false,
269
- renderers: [Vedeu::Renderers::Terminal],
269
+ renderers: [Vedeu::Renderers::Terminal.new],
270
270
  stdin: nil,
271
271
  stdout: nil,
272
272
  stderr: nil,
@@ -161,12 +161,6 @@ module Vedeu
161
161
  Vedeu::RenderBorder.with(self)
162
162
  end
163
163
 
164
- # @return [String]
165
- def to_s
166
- Vedeu::Renderers::Text.render(render)
167
- end
168
- alias_method :to_str, :to_s
169
-
170
164
  private
171
165
 
172
166
  # @return [Vedeu::Geometry]
@@ -66,8 +66,8 @@ module Vedeu
66
66
  @height = geometry.height
67
67
  @colour = interface.colour
68
68
 
69
- @clear ||= Array.new(@width) do |iy|
70
- Array.new(@height) do |ix|
69
+ @clear ||= Array.new(@height) do |iy|
70
+ Array.new(@width) do |ix|
71
71
  Vedeu::Char.new(value: ' ',
72
72
  colour: @colour,
73
73
  position: [@y + iy, @x + ix])
@@ -1,24 +1,24 @@
1
1
  module Vedeu
2
2
 
3
- # Sends the content to the renderers.
3
+ # Sends the output to the renderers.
4
4
  #
5
5
  # @api private
6
6
  class Output
7
7
 
8
- # Writes content to the defined renderers.
8
+ # Writes output to the defined renderers.
9
9
  #
10
10
  # @return [Array|String]
11
11
  # @see #initialize
12
- def self.render(content)
13
- new(content).render
12
+ def self.render(output)
13
+ new(output).render
14
14
  end
15
15
 
16
16
  # Return a new instance of Vedeu::Output.
17
17
  #
18
- # @param content [Array<Array<Vedeu::Char>>]
18
+ # @param output [Array<Array<Vedeu::Char>>]
19
19
  # @return [Output]
20
- def initialize(content)
21
- @content = content
20
+ def initialize(output)
21
+ @output = output
22
22
  end
23
23
 
24
24
  # Send the view to the renderers.
@@ -26,19 +26,19 @@ module Vedeu
26
26
  # @return [Array]
27
27
  def render
28
28
  if Vedeu::Configuration.drb?
29
- Vedeu.trigger(:_drb_store_output_, content)
29
+ Vedeu.trigger(:_drb_store_output_, output)
30
30
 
31
- Vedeu::Renderers::HTML.to_file(Vedeu::VirtualBuffer.retrieve)
31
+ # Vedeu::Renderers::HTML.to_file(Vedeu::VirtualBuffer.retrieve)
32
32
  end
33
33
 
34
- Vedeu.renderers.render(content)
34
+ Vedeu.renderers.render(output)
35
35
  end
36
36
 
37
37
  protected
38
38
 
39
- # @!attribute [r] content
39
+ # @!attribute [r] output
40
40
  # @return [Array<Array<Vedeu::Char>>]
41
- attr_reader :content
41
+ attr_reader :output
42
42
 
43
43
  end # Output
44
44
 
@@ -46,7 +46,7 @@ module Vedeu
46
46
  # Returns a new instance of Vedeu::RenderBorder.
47
47
  #
48
48
  # @param border [Vedeu::Border]
49
- # @return [Vedeu::Renderers::Border]
49
+ # @return [Vedeu::RenderBorder]
50
50
  def initialize(border)
51
51
  @border = border
52
52
  end
@@ -28,15 +28,18 @@ module Vedeu
28
28
  end
29
29
 
30
30
  # @example
31
- # Vedeu.renderers.render(*args)
31
+ # Vedeu.renderers.render(output)
32
32
  #
33
+ # @api public
34
+ # @param output [void]
33
35
  # @return [Array<void>]
34
- def render(*args)
36
+ def render(output)
35
37
  threads = storage.map do |renderer|
36
38
  Thread.new(renderer) do
37
39
  mutex.synchronize do
38
40
  Vedeu.log(type: :debug, message: "Rendering with: '#{renderer}'")
39
- renderer.render(*args)
41
+
42
+ renderer.render(output)
40
43
  end
41
44
  end
42
45
  end
@@ -51,6 +54,7 @@ module Vedeu
51
54
  # @note
52
55
  # A renderer class must respond to the '.render' class method.
53
56
  #
57
+ # @api public
54
58
  # @param renderers [Class]
55
59
  # @return [Set]
56
60
  def renderer(*renderers)
@@ -62,18 +66,19 @@ module Vedeu
62
66
  # @example
63
67
  # Vedeu.renderers.reset
64
68
  #
69
+ # @api public
65
70
  # @return [Set]
66
71
  def reset
67
72
  @storage = Set.new
68
73
  end
69
74
 
75
+ private
76
+
70
77
  # @return [Set]
71
78
  def storage
72
79
  @storage ||= reset
73
80
  end
74
81
 
75
- private
76
-
77
82
  # @return [Mutex]
78
83
  def mutex
79
84
  @mutex ||= Mutex.new
@@ -7,39 +7,37 @@ module Vedeu
7
7
  # @api private
8
8
  class EscapeSequence
9
9
 
10
- # @param output [Array<Array<Vedeu::Char>>]
11
- # @return [String]
12
- def self.render(output)
13
- new(output).render
14
- end
15
-
16
10
  # Returns a new instance of Vedeu::Renderers::EscapeSequence.
17
11
  #
18
- # @param output [Array<Array<Vedeu::Char>>]
19
- def initialize(output)
20
- @output = output
12
+ # @param options [Hash]
13
+ def initialize(options = {})
14
+ @options = options || {}
21
15
  end
22
16
 
17
+ # Render the output with the escape sequences escaped.
18
+ #
19
+ # @param output [Array<Array<Vedeu::Char>>]
23
20
  # @return [String]
24
- def render
25
- parsed
21
+ def render(output)
22
+ @parsed ||= Array(output).flatten.map do |char|
23
+ Esc.escape(char.to_s) + "\n"
24
+ end.join
26
25
  end
27
26
 
28
- protected
29
-
30
- # @!attribute [r] output
31
- # @return [Array<Array<Vedeu::Char>>]
32
- attr_reader :output
33
-
34
27
  private
35
28
 
36
- # Escapes the escape sequences.
29
+ # Combines the options provided at instantiation with the default values.
37
30
  #
38
- # @return [String]
39
- def parsed
40
- @parsed ||= Array(output).flatten.map do |char|
41
- Esc.escape(char.to_s) + "\n"
42
- end.join
31
+ # @return [Hash<Symbol => void>]
32
+ def options
33
+ defaults.merge!(@options)
34
+ end
35
+
36
+ # The default values for a new instance of this class.
37
+ #
38
+ # @return [Hash<Symbol => void>]
39
+ def defaults
40
+ {}
43
41
  end
44
42
 
45
43
  end # EscapeSequence
@@ -7,46 +7,27 @@ module Vedeu
7
7
  # @api private
8
8
  class File
9
9
 
10
- # @return [String]
11
- # @see Vedeu::Renderers::File#initialize
12
- def self.render(output, options = {})
13
- new(output, options).render
14
- end
15
-
16
10
  # Returns a new instance of Vedeu::Renderers::File.
17
11
  #
18
- # @param output [String]
19
12
  # @param options [Hash]
20
13
  # @option options filename [String] Provide a filename for the output.
21
14
  # Defaults to 'out'.
22
15
  # @option options timestamp [Boolean] Append a timestamp to the filename.
23
16
  # @return [Vedeu::Renderers::File]
24
- def initialize(output, options = {})
25
- @output = output
26
- @options = options
17
+ def initialize(options = {})
18
+ @options = options || {}
27
19
  end
28
20
 
21
+ # @param output [Array<Array<Vedeu::Char>>]
29
22
  # @return [String]
30
- def render
31
- ::File.open(path, 'w') { |f| f.write(parsed) }
23
+ def render(output)
24
+ ::File.write(filename, output) if write_file?
32
25
 
33
- parsed
26
+ output
34
27
  end
35
28
 
36
- protected
37
-
38
- # @!attribute [r] output
39
- # @return [String]
40
- attr_reader :output
41
- alias_method :parsed, :output
42
-
43
29
  private
44
30
 
45
- # @return [String]
46
- def path
47
- "/tmp/#{filename}"
48
- end
49
-
50
31
  # @return [String]
51
32
  def filename
52
33
  if timestamp?
@@ -70,6 +51,13 @@ module Vedeu
70
51
  false
71
52
  end
72
53
 
54
+ # @return [Boolean]
55
+ def write_file?
56
+ options[:write_file]
57
+ end
58
+
59
+ # Combines the options provided at instantiation with the default values.
60
+ #
73
61
  # @return [Hash]
74
62
  def options
75
63
  defaults.merge!(@options)
@@ -80,8 +68,9 @@ module Vedeu
80
68
  # @return [Hash]
81
69
  def defaults
82
70
  {
83
- filename: 'out',
84
- timestamp: false,
71
+ filename: 'out',
72
+ timestamp: false,
73
+ write_file: true,
85
74
  }
86
75
  end
87
76
 
@@ -5,51 +5,34 @@ module Vedeu
5
5
  # Renders a {Vedeu::VirtualBuffer} or {Vedeu::Output} as a HTML table.
6
6
  #
7
7
  # @api private
8
- class HTML
9
-
10
- # @param output [Array<Array<Vedeu::Char>>]
11
- # @return [String]
12
- def self.render(output)
13
- new(output).to_file
14
- end
15
-
16
- # @param output [Array<Array<Vedeu::Char>>]
17
- # @param path [String]
18
- # @return [String]
19
- def self.to_file(output, path = nil)
20
- new(output).to_file(path)
21
- end
8
+ class HTML < Vedeu::Renderers::File
22
9
 
23
10
  # Returns a new instance of Vedeu::Renderers::HTML.
24
11
  #
25
- # @param output [Array<Array<Vedeu::Char>>]
12
+ # @param options [Hash]
26
13
  # @return [Vedeu::Renderers::HTML]
27
- def initialize(output)
28
- @output = output
14
+ def initialize(options = {})
15
+ @options = options || {}
29
16
  end
30
17
 
18
+ # @param output [Array<Array<Vedeu::Char>>]
31
19
  # @return [String]
32
- def render
33
- Vedeu::Template.parse(self, template)
34
- end
20
+ def render(output)
21
+ @options[:content] = output
35
22
 
36
- # Writes the parsed template to a file (at the given path) and returns the
37
- # contents.
38
- #
39
- # @param path [String]
40
- # @return [String]
41
- def to_file(path = file_path)
42
- content = render
23
+ if write_file?
24
+ super(Vedeu::Template.parse(self, template))
43
25
 
44
- ::File.open(path, 'w') { |file| file.write(content) }
26
+ else
27
+ Vedeu::Template.parse(self, template)
45
28
 
46
- content
29
+ end
47
30
  end
48
31
 
49
32
  # @return [String]
50
33
  def html_body
51
34
  out = ''
52
- Array(output).each do |line|
35
+ Array(content).each do |line|
53
36
  out << "<tr>\n"
54
37
  line.each do |char|
55
38
  if char.is_a?(Vedeu::Char)
@@ -62,27 +45,38 @@ module Vedeu
62
45
  out
63
46
  end
64
47
 
65
- protected
48
+ private
66
49
 
67
- # @!attribute [r] output
68
50
  # @return [Array<Array<Vedeu::Char>>]
69
- attr_reader :output
70
-
71
- private
51
+ def content
52
+ options[:content]
53
+ end
72
54
 
73
55
  # @return [String]
74
56
  def template
75
- ::File.dirname(__FILE__) + '/../templates/html_renderer.vedeu'
57
+ options[:template]
76
58
  end
77
59
 
78
- # @return [String]
79
- def file_path
80
- "/tmp/vedeu_html_#{timestamp}.html"
60
+ # Combines the options provided at instantiation with the default values.
61
+ #
62
+ # @return [Hash<Symbol => void>]
63
+ def options
64
+ defaults.merge!(@options)
65
+ end
66
+
67
+ # The default values for a new instance of this class.
68
+ #
69
+ # @return [Hash<Symbol => void>]
70
+ def defaults
71
+ {
72
+ content: '',
73
+ template: default_template,
74
+ }
81
75
  end
82
76
 
83
- # return [Fixnum]
84
- def timestamp
85
- @timestamp ||= Time.now.to_i
77
+ # @return [String]
78
+ def default_template
79
+ ::File.dirname(__FILE__) + '/../templates/html_renderer.vedeu'
86
80
  end
87
81
 
88
82
  end # HTML