vedeu 0.4.51 → 0.4.52

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/examples/colour_support.sh +7 -2
  3. data/lib/vedeu/bootstrap.rb +2 -0
  4. data/lib/vedeu/cli/generator/application.rb +6 -0
  5. data/lib/vedeu/cli/generator/templates/application/.gitignore +1 -0
  6. data/lib/vedeu/cli/generator/templates/application/app/views/interfaces/name.erb +7 -0
  7. data/lib/vedeu/cli/generator/templates/application/config/configuration.erb +2 -0
  8. data/lib/vedeu/configuration/api.rb +31 -0
  9. data/lib/vedeu/configuration/configuration.rb +10 -1
  10. data/lib/vedeu/distributed/templates/default_configuration.vedeu +1 -0
  11. data/lib/vedeu/dsl/composition.rb +3 -9
  12. data/lib/vedeu/dsl/interface.rb +1 -1
  13. data/lib/vedeu/geometry/grid.rb +27 -38
  14. data/lib/vedeu/models/interface.rb +12 -0
  15. data/lib/vedeu/null/interface.rb +4 -6
  16. data/lib/vedeu/output/all.rb +1 -0
  17. data/lib/vedeu/output/clear/named_interface.rb +1 -1
  18. data/lib/vedeu/output/compressor.rb +28 -7
  19. data/lib/vedeu/output/refresh.rb +6 -7
  20. data/lib/vedeu/output/refresh_group.rb +52 -0
  21. data/lib/vedeu/output/render_border.rb +1 -1
  22. data/lib/vedeu/output/renderers/all.rb +2 -1
  23. data/lib/vedeu/output/viewport.rb +1 -1
  24. data/lib/vedeu/support/terminal.rb +20 -1
  25. data/lib/vedeu/version.rb +1 -1
  26. data/test/lib/vedeu/configuration/api_test.rb +19 -0
  27. data/test/lib/vedeu/configuration/configuration_test.rb +8 -0
  28. data/test/lib/vedeu/geometry/grid_test.rb +0 -12
  29. data/test/lib/vedeu/models/interface_test.rb +18 -0
  30. data/test/lib/vedeu/null/interface_test.rb +4 -0
  31. data/test/lib/vedeu/output/compressor_test.rb +40 -33
  32. data/test/lib/vedeu/output/refresh_group_test.rb +29 -0
  33. data/test/lib/vedeu/output/renderers/file_test.rb +6 -2
  34. data/test/lib/vedeu/output/renderers/html_test.rb +4 -0
  35. data/test/lib/vedeu/output/renderers/json_test.rb +4 -0
  36. data/test/lib/vedeu/support/terminal_test.rb +3 -3
  37. metadata +5 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 51f8100764995bff505583f3dc874821dcb56fc9
4
- data.tar.gz: 9064e5dfd73320ad37281d8cb112d77439ebc641
3
+ metadata.gz: 2cd921c8f76dab6e9fb3b972420e1bc86dcfb33c
4
+ data.tar.gz: f01800caf43bfcc0a9a50ae8825f3c96acd257ae
5
5
  SHA512:
6
- metadata.gz: ae6180723fb6977e5da0efd16ae9a0250feaa89a1ff5e0d813ae8a24d0c399b9086aaa49ab33940fb9fc5ea9652fadf87fb21933c96af17f201cfdc403d51cf5
7
- data.tar.gz: 9aafcd3c738dde584d38ae6dc0a5e26b552c18f2c498d00dca86cf755dfe76b60d3b518e93343304646cb02d856916774c9400ca23c393cd20c8cc10fb16778a
6
+ metadata.gz: 33e373ad6fddc14a6ecbdf27645890dc4598b542b258b6a0f1d623fdf129c1afb10e1ba8056ba7aed4fb2d734687b8ab2539c5dd588f3e78e7a18779d1f9d708
7
+ data.tar.gz: 647940089d7ade5c1ef030898561eb542e08265b8d4c7975712780fcdc4fe7a44afa954f5a5d8830fb02db9bf57a134c02857f50847f7d121b215ac13f9a653b
@@ -1,5 +1,10 @@
1
1
  #!/bin/bash
2
2
  #
3
+ # Vedeu can use 24-bit color codes. To test whether your terminal supports
4
+ # this colour mode, running this file should output lots of beautiful colours.
5
+ # If the output is 'patchy' and not many colours show, then it is unlikely
6
+ # your terminal supports 24-bit colour mode, which is disappointing.
7
+ #
3
8
  # This file echoes a bunch of 24-bit color codes
4
9
  # to the terminal to demonstrate its functionality.
5
10
  # The foreground escape sequence is ^[38;2;<r>;<g>;<b>m
@@ -9,12 +14,12 @@
9
14
 
10
15
  setBackgroundColor()
11
16
  {
12
- echo -en "\x1b[48;2;$1;$2;$3""m"
17
+ echo -en "\e[48;2;$1;$2;$3""m"
13
18
  }
14
19
 
15
20
  resetOutput()
16
21
  {
17
- echo -en "\x1b[0m\n"
22
+ echo -en "\e[0m\n"
18
23
  }
19
24
 
20
25
  # Gives a color $1/255 % along HSV
@@ -42,6 +42,8 @@ module Vedeu
42
42
  end
43
43
 
44
44
  [
45
+ 'app/views/templates/**/*',
46
+ 'app/views/interfaces/**/*',
45
47
  'app/controllers/**/*',
46
48
  'app/helpers/**/*',
47
49
  'app/views/**/*',
@@ -34,6 +34,7 @@ module Vedeu
34
34
  make_directory_structure
35
35
 
36
36
  copy_gemfile
37
+ copy_gitignore
37
38
  copy_license
38
39
  copy_readme
39
40
  copy_application_bootstrapper
@@ -92,6 +93,11 @@ module Vedeu
92
93
  copy_file(source + '/Gemfile', "#{name}/Gemfile")
93
94
  end
94
95
 
96
+ # @return [void]
97
+ def copy_gitignore
98
+ copy_file(source + '/.gitignore', "#{name}/.gitignore")
99
+ end
100
+
95
101
  # @return [void]
96
102
  def copy_license
97
103
  copy_file(source + '/LICENSE.txt', "#{name}/LICENSE.txt")
@@ -11,6 +11,10 @@ Vedeu.interface '<%= object.name %>' do
11
11
  # disable!
12
12
  #
13
13
  # Individually control each border:
14
+ # hide_bottom!
15
+ # hide_left!
16
+ # hide_right!
17
+ # hide_top!
14
18
  # show_bottom!
15
19
  # show_left!
16
20
  # show_right!
@@ -34,6 +38,9 @@ Vedeu.interface '<%= object.name %>' do
34
38
 
35
39
  # cursor!
36
40
 
41
+ # See Vedeu::DSL::Interface#delay
42
+ # delay 1.0
43
+
37
44
  # focus!
38
45
 
39
46
  # foreground
@@ -4,6 +4,8 @@ Vedeu.configure do
4
4
  # colour_mode 16_777_216 # Some terminals don't render colour at all if this
5
5
  # value is not one of 8, 16, 256 or 16777216.
6
6
 
7
+ # compression false
8
+
7
9
  # debug! # Add "gem 'ruby-prof'" to your Gemfile if uncommenting this line.
8
10
  # drb!
9
11
  # drb_host 'localhost'
@@ -329,6 +329,37 @@ module Vedeu
329
329
  options[:stderr] = io
330
330
  end
331
331
 
332
+ # Compression reduces the number of escape sequences being sent to the
333
+ # terminal which improves redraw/render/refresh rate. By default it is
334
+ # enabled.
335
+ #
336
+ # Sets boolean to enable/disable compression. Vedeu's default setting is
337
+ # for compression to be enabled. Setting `compression` to false will
338
+ # disable compression.
339
+ #
340
+ # @note
341
+ # - Be aware that running an application without compression will
342
+ # affect performance.
343
+ # - Compression cannot yet be configured using a CLI option flag.
344
+ #
345
+ # @example
346
+ # Vedeu.configure do
347
+ # compression! # enabled (default)
348
+ # # ...
349
+ # end
350
+ #
351
+ # Vedeu.configure do
352
+ # compression false
353
+ # # ...
354
+ # end
355
+ #
356
+ # @param value [Boolean]
357
+ # @return [Boolean]
358
+ def compression(value = true)
359
+ options[:compression] = value
360
+ end
361
+ alias_method :compression!, :compression
362
+
332
363
  private
333
364
 
334
365
  # Returns the options set via the configuration API DSL or an empty Hash
@@ -34,13 +34,21 @@ module Vedeu
34
34
 
35
35
  class << self
36
36
 
37
- # Returns the base_path value
37
+ # Returns the base_path value.
38
38
  #
39
39
  # @return [String]
40
40
  def base_path
41
41
  instance.options[:base_path]
42
42
  end
43
43
 
44
+ # Returns the compression value.
45
+ #
46
+ # @return [Boolean]
47
+ def compression
48
+ instance.options[:compression]
49
+ end
50
+ alias_method :compression?, :compression
51
+
44
52
  # Configure Vedeu with sensible defaults. If the client application sets
45
53
  # options, override the defaults with those, and if command-line arguments
46
54
  # are provided at application invocation, override any options with the
@@ -257,6 +265,7 @@ module Vedeu
257
265
  {
258
266
  base_path: base_path,
259
267
  colour_mode: detect_colour_mode,
268
+ compression: true,
260
269
  debug: false,
261
270
  drb: false,
262
271
  drb_host: nil,
@@ -1,4 +1,5 @@
1
1
  Vedeu.configure do
2
+ # compression false
2
3
  # log '/tmp/your_app.log'
3
4
  # debug!
4
5
  # drb!
@@ -113,15 +113,6 @@ module Vedeu
113
113
  model.add(new_model)
114
114
  end
115
115
 
116
- # def content_for(name, filename, object = nil, options = {})
117
- # lines = Vedeu::Template.parse(object, filename)
118
-
119
- # _model = model.member.build(new_attributes(name).
120
- # merge!({ lines: lines }))
121
-
122
- # model.add(_model)
123
- # end
124
-
125
116
  protected
126
117
 
127
118
  # @!attribute [r] client
@@ -141,6 +132,9 @@ module Vedeu
141
132
  new_attributes(name).merge!(lines: lines)
142
133
  end
143
134
 
135
+ # Return the current attributes combined with the existing interface
136
+ # attributes defined by the interface.
137
+ #
144
138
  # @param name [String] The name of the interface.
145
139
  # @return [Hash]
146
140
  def new_attributes(name)
@@ -101,7 +101,7 @@ module Vedeu
101
101
  # often, the reduces artefacts particularly when resizing the terminal
102
102
  # screen.
103
103
  #
104
- # @param value [Fixnum|Float]
104
+ # @param value [Fixnum|Float] Time in seconds. (0.5 = 500ms).
105
105
  #
106
106
  # @example
107
107
  # interface 'my_interface' do
@@ -1,25 +1,10 @@
1
1
  module Vedeu
2
2
 
3
- # Augment Fixnum to calculate column width or row height in a grid-based
4
- # layout.
5
- #
6
3
  # The grid system splits the terminal height and width into 12 equal parts, by
7
4
  # dividing the available height and width by 12. If the terminal height or
8
5
  # width is not a multiple of 12, then Grid chooses the maximum value which
9
6
  # will fit.
10
7
  #
11
- # Used primarily whilst defining geometry:
12
- #
13
- # width: columns(9) # (Terminal width / 12) * 9 characters wide; e.g.
14
- # # Terminal is 92 characters wide, maximum value is
15
- # # therefore 84, meaning a column is 7 characters wide.
16
- # # (And width is therefore 63 characters wide.)
17
- #
18
- # height: rows(3) # (Terminal height / 12) * 3 rows high; e.g.
19
- # # Terminal is 38 characters wide, maximum value is
20
- # # therefore 36, meaning a row is 3 characters tall.
21
- # # (And height is therefore 9 characters tall.)
22
- #
23
8
  # @api public
24
9
  class Grid
25
10
 
@@ -45,6 +30,13 @@ module Vedeu
45
30
 
46
31
  # Returns the width in characters for the number of columns specified.
47
32
  #
33
+ # @example
34
+ # Vedeu.geometry 'main_interface' do
35
+ # width: columns(9) # Vedeu.width # => 92 (for example)
36
+ # # 92 / 12 = 7
37
+ # # 7 * 9 = 63
38
+ # # Therefore, width is 63 characters.
39
+ #
48
40
  # @raise [OutOfRange] When the value parameter is not between 1 and 12
49
41
  # inclusive.
50
42
  # @return [Fixnum|OutOfRange]
@@ -55,16 +47,15 @@ module Vedeu
55
47
  column * value
56
48
  end
57
49
 
58
- # Returns the height of a single row in characters.
59
- #
60
- # @return [Fixnum]
61
- def height
62
- actual_height / 12
63
- end
64
- alias_method :row, :height
65
-
66
50
  # Returns the height in characters for the number of rows specified.
67
51
  #
52
+ # @example
53
+ # Vedeu.geometry 'main_interface' do
54
+ # height: rows(3) # Vedeu.height # => 38 (for example)
55
+ # # 38 / 12 = 3
56
+ # # 3 * 3 = 9
57
+ # # Therefore, height is 9 characters.
58
+ #
68
59
  # @raise [OutOfRange] When the value parameter is not between 1 and 12
69
60
  # inclusive.
70
61
  # @return [Fixnum|OutOfRange]
@@ -75,14 +66,6 @@ module Vedeu
75
66
  row * value
76
67
  end
77
68
 
78
- # Returns the width of a single column in characters.
79
- #
80
- # @return [Fixnum]
81
- def width
82
- actual_width / 12
83
- end
84
- alias_method :column, :width
85
-
86
69
  protected
87
70
 
88
71
  # @!attribute [r] value
@@ -91,21 +74,27 @@ module Vedeu
91
74
 
92
75
  private
93
76
 
77
+ # Returns the height of a single row in characters.
78
+ #
94
79
  # @return [Fixnum]
95
- def actual_height
96
- Vedeu.height
97
- end
98
-
99
- # @return [Fixnum]
100
- def actual_width
101
- Vedeu.width
80
+ def row
81
+ Vedeu.height / 12
102
82
  end
103
83
 
84
+ # Returns a boolean indicating whether the value is out of range.
85
+ #
104
86
  # @return [Boolean]
105
87
  def out_of_range?
106
88
  value < 1 || value > 12
107
89
  end
108
90
 
91
+ # Returns the width of a single column in characters.
92
+ #
93
+ # @return [Fixnum]
94
+ def column
95
+ Vedeu.width / 12
96
+ end
97
+
109
98
  end # Grid
110
99
 
111
100
  end # Vedeu
@@ -83,6 +83,18 @@ module Vedeu
83
83
  @lines = lines.add(child)
84
84
  end
85
85
 
86
+ # Override Ruby's Object#inspect method to provide a more helpful output.
87
+ #
88
+ # @return [String]
89
+ def inspect
90
+ '<Vedeu::Interface ' \
91
+ "name: '#{name}', " \
92
+ "group: '#{group}', " \
93
+ "visible: '#{visible}', " \
94
+ "zindex: '#{zindex}'" \
95
+ '>'
96
+ end
97
+
86
98
  # @return [Vedeu::Lines]
87
99
  def lines
88
100
  collection.coerce(@lines, self)
@@ -11,6 +11,10 @@ module Vedeu
11
11
 
12
12
  include Vedeu::Presentation
13
13
 
14
+ # @!attribute [r] name
15
+ # @return [String]
16
+ attr_reader :name
17
+
14
18
  # Returns a new instance of Vedeu::Null::Interface.
15
19
  #
16
20
  # @param name [String]
@@ -59,12 +63,6 @@ module Vedeu
59
63
  false
60
64
  end
61
65
 
62
- protected
63
-
64
- # @!attribute [r] name
65
- # @return [String]
66
- attr_reader :name
67
-
68
66
  end # Interface
69
67
 
70
68
  end # Null
@@ -11,6 +11,7 @@ require_relative 'style'
11
11
  require_relative 'text'
12
12
  require_relative 'virtual_buffer'
13
13
  require_relative 'html_char'
14
+ require_relative 'refresh_group'
14
15
  require_relative 'refresh'
15
16
  require_relative 'renderers/all'
16
17
  require_relative 'output'
@@ -59,7 +59,7 @@ module Vedeu
59
59
  #
60
60
  # @return [Array<Array<Vedeu::Char>>]
61
61
  def output
62
- Vedeu.timer("Clearing: #{name}") do
62
+ Vedeu.timer("Clearing: '#{name}'") do
63
63
  @y = geometry.y
64
64
  @x = geometry.x
65
65
  @width = geometry.width
@@ -26,14 +26,13 @@ module Vedeu
26
26
  # @note Takes approximately ~70ms for 2100 chars. (2015-05-24)
27
27
  # @return [String]
28
28
  def render
29
- out = ''
30
- Array(output).flatten.each do |char|
31
- out << char.position.to_s
32
- out << colour_for(char)
33
- out << style_for(char)
34
- out << char.value
29
+ if Vedeu::Configuration.compression?
30
+ compress
31
+
32
+ else
33
+ uncompress
34
+
35
35
  end
36
- out
37
36
  end
38
37
 
39
38
  protected
@@ -44,6 +43,28 @@ module Vedeu
44
43
 
45
44
  private
46
45
 
46
+ def compress
47
+ out = ''
48
+ Array(output).flatten.each do |char|
49
+ out << char.position.to_s
50
+ out << colour_for(char)
51
+ out << style_for(char)
52
+ out << char.value
53
+ end
54
+ out
55
+ end
56
+
57
+ def uncompress
58
+ out = ''
59
+ Array(output).flatten.each do |char|
60
+ out << char.position.to_s
61
+ out << char.colour.to_s
62
+ out << char.style.to_s
63
+ out << char.value
64
+ end
65
+ out
66
+ end
67
+
47
68
  # @param char [Vedeu::Char]
48
69
  # @return [String]
49
70
  def colour_for(char)
@@ -1,3 +1,5 @@
1
+ require_relative 'refresh_group'
2
+
1
3
  module Vedeu
2
4
 
3
5
  # Refreshes the terminal.
@@ -11,7 +13,7 @@ module Vedeu
11
13
  #
12
14
  # @return [Array]
13
15
  def all
14
- Vedeu.timer('Refreshing all interfaces') do
16
+ Vedeu.timer('Refresh All') do
15
17
  Vedeu.interfaces.zindexed.each { |model| by_name(model.name) }
16
18
  end
17
19
  end
@@ -34,11 +36,8 @@ module Vedeu
34
36
  # @return [Array|ModelNotFound] A collection of the names of interfaces
35
37
  # refreshed, or an exception if the group was not found.
36
38
  def by_group(group_name)
37
- Vedeu.timer("Refreshing group: '#{group_name}'") do
38
- members = Vedeu.groups.find!(group_name).members
39
- interfaces = members.each { |name| Vedeu.interfaces.by_name(name) }
40
- by_zindex = interfaces.sort { |a, b| a.zindex <=> b.zindex }
41
- by_zindex.each { |name| by_name(name) }
39
+ Vedeu.timer("Refresh Group: '#{group_name}'") do
40
+ Vedeu::RefreshGroup.by_name(group_name)
42
41
  end
43
42
  end
44
43
 
@@ -48,7 +47,7 @@ module Vedeu
48
47
  # named buffer.
49
48
  # @return [Array|ModelNotFound]
50
49
  def by_name(name)
51
- Vedeu.timer("Refreshing interface: '#{name}'") do
50
+ Vedeu.timer("Refresh Interface: '#{name}'") do
52
51
  Vedeu.buffers.by_name(name).render
53
52
  end
54
53
  end
@@ -0,0 +1,52 @@
1
+ require_relative 'refresh'
2
+
3
+ module Vedeu
4
+
5
+ # Refreshes the given named group of interfaces.
6
+ #
7
+ # @api private
8
+ class RefreshGroup
9
+
10
+ # @param name [String]
11
+ # @return [void]
12
+ def self.by_name(name)
13
+ new(name).by_name
14
+ end
15
+
16
+ # @param name [String]
17
+ # @return [Vedeu::RefreshGroup]
18
+ def initialize(name)
19
+ @name = name
20
+ end
21
+
22
+ # @return [void]
23
+ def by_name
24
+ zindexed.each { |name| Vedeu::Refresh.by_name(name) }
25
+ end
26
+
27
+ protected
28
+
29
+ # @!attribute [r] name
30
+ # @return [String]
31
+ attr_reader :name
32
+
33
+ private
34
+
35
+ # @return [Array<String>]
36
+ def zindexed
37
+ interfaces.sort { |a, b| a.zindex <=> b.zindex }.map(&:name)
38
+ end
39
+
40
+ # @return [Array<Vedeu::Interface>]
41
+ def interfaces
42
+ members.map { |name| Vedeu.interfaces.by_name(name) }
43
+ end
44
+
45
+ # @return [Set]
46
+ def members
47
+ Vedeu.groups.find!(name).members
48
+ end
49
+
50
+ end # RefreshGroup
51
+
52
+ end # Vedeu
@@ -56,7 +56,7 @@ module Vedeu
56
56
  return [] unless interface.visible?
57
57
  return [] unless enabled?
58
58
 
59
- Vedeu.timer("Rendering border: #{name}") do
59
+ Vedeu.timer("Bordering: '#{name}'") do
60
60
  out = [top, bottom]
61
61
 
62
62
  height.times { |y| out << [left(y), right(y)] }
@@ -37,7 +37,8 @@ module Vedeu
37
37
  threads = storage.map do |renderer|
38
38
  Thread.new(renderer) do
39
39
  mutex.synchronize do
40
- Vedeu.log(type: :debug, message: "Rendering with: '#{renderer}'")
40
+ Vedeu.log(type: :debug,
41
+ message: "Renderer: '#{renderer.class.name}'")
41
42
 
42
43
  renderer.render(output)
43
44
  end
@@ -52,7 +52,7 @@ module Vedeu
52
52
  def render
53
53
  return [] unless visible?
54
54
 
55
- Vedeu.timer("Rendering: #{name}") do
55
+ Vedeu.timer("Rendering: '#{name}'") do
56
56
  out = []
57
57
 
58
58
  show.each_with_index do |line, iy|
@@ -245,9 +245,28 @@ module Vedeu
245
245
 
246
246
  # Returns a tuple containing the height and width of the current terminal.
247
247
  #
248
+ # @note
249
+ # If the terminal is a odd number of characters in height or width, then
250
+ # 1 is deducted from the dimension to make it even. For example; the
251
+ # actual terminal is height: 37, width: 145, then the reported size will
252
+ # be 36, 144 respectively.
253
+ #
254
+ # This is done to make it easier for client applications to divide the
255
+ # terminal space up when defining interfaces or views, leading to more
256
+ # consistent rendering.
257
+ #
258
+ # If the client application is using the {Vedeu::Grid#rows} or
259
+ # {Vedeu::Grid#columns} helpers, the dimensions are made more consistent
260
+ # using this approach.
261
+ #
248
262
  # @return [Array]
249
263
  def size
250
- console.winsize
264
+ h, w = console.winsize
265
+
266
+ h = (h.even? ? h : h - 1)
267
+ w = (w.even? ? w : w - 1)
268
+
269
+ [h, w]
251
270
  end
252
271
 
253
272
  # Provides our gateway into the wonderful rainbow-filled world of IO.
data/lib/vedeu/version.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  module Vedeu
2
2
 
3
3
  # The current version of Vedeu.
4
- VERSION = '0.4.51'
4
+ VERSION = '0.4.52'
5
5
 
6
6
  end
@@ -252,6 +252,25 @@ module Vedeu
252
252
  # it { skip }
253
253
  end
254
254
 
255
+ describe '#compression!' do
256
+ it { instance.must_respond_to(:compression) }
257
+
258
+ it 'sets the option to the desired value' do
259
+ configuration = Vedeu.configure { compression! }
260
+ configuration.compression.must_equal(true)
261
+ end
262
+
263
+ it 'sets the option to the desired value' do
264
+ configuration = Vedeu.configure { compression(true) }
265
+ configuration.compression.must_equal(true)
266
+ end
267
+
268
+ it 'sets the option to the desired value' do
269
+ configuration = Vedeu.configure { compression(false) }
270
+ configuration.compression.must_equal(false)
271
+ end
272
+ end
273
+
255
274
  end # API
256
275
 
257
276
  end # Config
@@ -17,6 +17,14 @@ module Vedeu
17
17
  end
18
18
  end
19
19
 
20
+ describe '.compression?' do
21
+ it { described.must_respond_to(:compression) }
22
+
23
+ it 'returns the value of the compression option' do
24
+ Configuration.compression?.must_equal(true)
25
+ end
26
+ end
27
+
20
28
  describe '.debug?' do
21
29
  it { described.must_respond_to(:debug) }
22
30
 
@@ -31,12 +31,6 @@ module Vedeu
31
31
  end
32
32
  end
33
33
 
34
- describe '#height' do
35
- subject { instance.height }
36
-
37
- it { subject.must_equal(2) }
38
- end
39
-
40
34
  describe '.rows' do
41
35
  context 'when the value is less than 1' do
42
36
  it { proc { Grid.rows(0) }.must_raise(OutOfRange) }
@@ -53,12 +47,6 @@ module Vedeu
53
47
  end
54
48
  end
55
49
 
56
- describe '#width' do
57
- subject { instance.width }
58
-
59
- it { subject.must_equal(6) }
60
- end
61
-
62
50
  end # Grid
63
51
 
64
52
  end # Vedeu
@@ -67,6 +67,24 @@ module Vedeu
67
67
  it { instance.must_respond_to(:lines=) }
68
68
  end
69
69
 
70
+ describe '#add' do
71
+ subject { instance.add(child) }
72
+
73
+ it { instance.must_respond_to(:add) }
74
+ end
75
+
76
+ describe '#inspect' do
77
+ subject { instance.inspect }
78
+
79
+ it { subject.must_be_instance_of(String) }
80
+
81
+ it { subject.must_equal(
82
+ "<Vedeu::Interface name: 'hydrogen', group: '', visible: 'true', " \
83
+ "zindex: '1'>"
84
+ )
85
+ }
86
+ end
87
+
70
88
  describe '#lines' do
71
89
  subject { instance.lines }
72
90
 
@@ -15,6 +15,10 @@ module Vedeu
15
15
  it { instance.instance_variable_get('@name').must_equal(_name) }
16
16
  end
17
17
 
18
+ describe 'accessors' do
19
+ it { instance.must_respond_to(:name) }
20
+ end
21
+
18
22
  describe '#attributes' do
19
23
  subject { instance.attributes }
20
24
 
@@ -24,45 +24,52 @@ module Vedeu
24
24
 
25
25
  it { subject.must_be_instance_of(String) }
26
26
 
27
- context 'when the output is all Vedeu::Char elements' do
28
- let(:output) {
29
- [
30
- Vedeu::Char.new(value: 'Y', colour: { foreground: '#ff0000' }),
31
- Vedeu::Char.new(value: 'e', colour: { foreground: '#ff0000' }),
32
- Vedeu::Char.new(value: 's', colour: { foreground: '#ff0000' }),
33
- ]
34
- }
35
- it 'converts the non-Vedeu::Char elements into String elements' do
36
- subject.must_equal("\e[38;2;255;0;0mYes")
27
+ context 'when compression is enabled' do
28
+ context 'when the output is all Vedeu::Char elements' do
29
+ let(:output) {
30
+ [
31
+ Vedeu::Char.new(value: 'Y', colour: { foreground: '#ff0000' }),
32
+ Vedeu::Char.new(value: 'e', colour: { foreground: '#ff0000' }),
33
+ Vedeu::Char.new(value: 's', colour: { foreground: '#ff0000' }),
34
+ ]
35
+ }
36
+ it 'converts the non-Vedeu::Char elements into String elements' do
37
+ subject.must_equal("\e[38;2;255;0;0mYes")
38
+ end
37
39
  end
38
- end
39
40
 
40
- context 'when the output is all Vedeu::Char elements' do
41
- let(:output) {
42
- [
43
- Vedeu::Char.new(value: 'a', colour: { foreground: '#ff0000' }),
44
- Vedeu::Char.new(value: 'b', colour: { foreground: '#ff0000' }),
45
- Vedeu::Char.new(value: 'c', colour: { foreground: '#0000ff' }),
46
- Vedeu::Char.new(value: 'd', colour: { foreground: '#0000ff' }),
47
- ]
48
- }
49
- it 'compresses multiple colours and styles where possible' do
50
- subject.must_equal("\e[38;2;255;0;0mab\e[38;2;0;0;255mcd")
41
+ context 'when the output is all Vedeu::Char elements' do
42
+ let(:output) {
43
+ [
44
+ Vedeu::Char.new(value: 'a', colour: { foreground: '#ff0000' }),
45
+ Vedeu::Char.new(value: 'b', colour: { foreground: '#ff0000' }),
46
+ Vedeu::Char.new(value: 'c', colour: { foreground: '#0000ff' }),
47
+ Vedeu::Char.new(value: 'd', colour: { foreground: '#0000ff' }),
48
+ ]
49
+ }
50
+ it 'compresses multiple colours and styles where possible' do
51
+ subject.must_equal("\e[38;2;255;0;0mab\e[38;2;0;0;255mcd")
52
+ end
51
53
  end
52
- end
53
54
 
54
- context 'when the output is not all Vedeu::Char elements' do
55
- let(:output) {
56
- [
57
- Vedeu::Char.new(value: 'N'),
58
- Vedeu::EscapeChar.new("\e[?25l"),
59
- Vedeu::Char.new(value: 't'),
60
- ]
61
- }
62
- it 'converts the non-Vedeu::Char elements into String elements' do
63
- subject.must_equal("N\e[?25lt")
55
+ context 'when the output is not all Vedeu::Char elements' do
56
+ let(:output) {
57
+ [
58
+ Vedeu::Char.new(value: 'N'),
59
+ Vedeu::EscapeChar.new("\e[?25l"),
60
+ Vedeu::Char.new(value: 't'),
61
+ ]
62
+ }
63
+ it 'converts the non-Vedeu::Char elements into String elements' do
64
+ subject.must_equal("N\e[?25lt")
65
+ end
64
66
  end
65
67
  end
68
+
69
+ context 'when compression is not enabled' do
70
+ # @todo
71
+ # it { skip }
72
+ end
66
73
  end
67
74
 
68
75
  end # Compressor
@@ -0,0 +1,29 @@
1
+ require 'test_helper'
2
+
3
+ module Vedeu
4
+
5
+ describe RefreshGroup do
6
+
7
+ let(:described) { Vedeu::RefreshGroup }
8
+ let(:instance) { described.new(_name) }
9
+ let(:_name) { 'Vedeu::RefreshGroup' }
10
+
11
+ describe '#initialize' do
12
+ it { instance.must_be_instance_of(described) }
13
+ it { instance.instance_variable_get('@name').must_equal(_name) }
14
+ end
15
+
16
+ describe '.by_name' do
17
+ it { described.must_respond_to(:by_name) }
18
+ end
19
+
20
+ describe '#by_name' do
21
+ subject { instance.by_name }
22
+
23
+ # @todo
24
+ # it { skip }
25
+ end
26
+
27
+ end # RefreshGroup
28
+
29
+ end # Vedeu
@@ -15,7 +15,7 @@ module Vedeu
15
15
  timestamp: timestamp,
16
16
  }
17
17
  }
18
- let(:filename) { 'out' }
18
+ let(:filename) { 'vedeu_renderers_file' }
19
19
  let(:timestamp) { false }
20
20
 
21
21
  describe '#initialize' do
@@ -26,9 +26,13 @@ module Vedeu
26
26
  describe '#render' do
27
27
  let(:_time) { Time.new(2015, 4, 12, 20, 05, 00, "+01:00") }
28
28
 
29
+ before do
30
+ ::File.stubs(:write)
31
+ end
32
+
29
33
  subject { instance.render(output) }
30
34
 
31
- it { subject.must_be_instance_of(String) }
35
+ # it { subject.must_be_instance_of(String) }
32
36
 
33
37
  context 'when the filename option is not set' do
34
38
  context 'when the timestamp option is not set' do
@@ -17,6 +17,10 @@ module Vedeu
17
17
  let(:content) { [''] }
18
18
  let(:write_file) { false }
19
19
 
20
+ before do
21
+ ::File.stubs(:write)
22
+ end
23
+
20
24
  describe '#initialize' do
21
25
  it { instance.must_be_instance_of(described) }
22
26
  it { instance.instance_variable_get('@options').must_equal(options) }
@@ -11,6 +11,10 @@ module Vedeu
11
11
  let(:options) { {} }
12
12
  let(:output) {}
13
13
 
14
+ before do
15
+ ::File.stubs(:write)
16
+ end
17
+
14
18
  describe '#initialize' do
15
19
  it { instance.must_be_instance_of(described) }
16
20
  it { instance.instance_variable_get('@options').must_equal(options) }
@@ -263,13 +263,13 @@ module Vedeu
263
263
 
264
264
  context 'via method' do
265
265
  it 'returns the height' do
266
- subject.must_equal(25)
266
+ subject.must_equal(24)
267
267
  end
268
268
  end
269
269
 
270
270
  context 'via API' do
271
271
  it 'returns the height' do
272
- Vedeu.height.must_equal(25)
272
+ Vedeu.height.must_equal(24)
273
273
  end
274
274
  end
275
275
  end
@@ -280,7 +280,7 @@ module Vedeu
280
280
  it { subject.must_be_instance_of(Array) }
281
281
 
282
282
  it 'returns the width and height' do
283
- subject.must_equal([25, 80])
283
+ subject.must_equal([24, 80])
284
284
  end
285
285
  end
286
286
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vedeu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.51
4
+ version: 0.4.52
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gavin Laking
@@ -289,6 +289,7 @@ files:
289
289
  - lib/vedeu/cli/generator/all.rb
290
290
  - lib/vedeu/cli/generator/application.rb
291
291
  - lib/vedeu/cli/generator/helpers.rb
292
+ - lib/vedeu/cli/generator/templates/application/.gitignore
292
293
  - lib/vedeu/cli/generator/templates/application/Gemfile
293
294
  - lib/vedeu/cli/generator/templates/application/LICENSE.txt
294
295
  - lib/vedeu/cli/generator/templates/application/README.md
@@ -401,6 +402,7 @@ files:
401
402
  - lib/vedeu/output/output.rb
402
403
  - lib/vedeu/output/presentation.rb
403
404
  - lib/vedeu/output/refresh.rb
405
+ - lib/vedeu/output/refresh_group.rb
404
406
  - lib/vedeu/output/render_border.rb
405
407
  - lib/vedeu/output/renderers/all.rb
406
408
  - lib/vedeu/output/renderers/escape_sequence.rb
@@ -543,6 +545,7 @@ files:
543
545
  - test/lib/vedeu/output/html_char_test.rb
544
546
  - test/lib/vedeu/output/output_test.rb
545
547
  - test/lib/vedeu/output/presentation_test.rb
548
+ - test/lib/vedeu/output/refresh_group_test.rb
546
549
  - test/lib/vedeu/output/refresh_test.rb
547
550
  - test/lib/vedeu/output/render_border_test.rb
548
551
  - test/lib/vedeu/output/renderers/all_test.rb
@@ -711,6 +714,7 @@ test_files:
711
714
  - test/lib/vedeu/output/html_char_test.rb
712
715
  - test/lib/vedeu/output/output_test.rb
713
716
  - test/lib/vedeu/output/presentation_test.rb
717
+ - test/lib/vedeu/output/refresh_group_test.rb
714
718
  - test/lib/vedeu/output/refresh_test.rb
715
719
  - test/lib/vedeu/output/render_border_test.rb
716
720
  - test/lib/vedeu/output/renderers/all_test.rb