vedeu 0.0.25 → 0.0.26

Sign up to get free protection for your applications and to get access to all the features.
Files changed (157) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +10 -9
  3. data/Rakefile +0 -10
  4. data/bin/composition +1 -1
  5. data/examples/single_interface_app.rb +7 -4
  6. data/lib/vedeu.rb +19 -48
  7. data/lib/vedeu/application.rb +8 -7
  8. data/lib/vedeu/configuration.rb +4 -4
  9. data/lib/vedeu/input/input.rb +3 -0
  10. data/lib/vedeu/launcher.rb +3 -0
  11. data/lib/vedeu/models/background.rb +13 -0
  12. data/lib/vedeu/models/coercions.rb +21 -0
  13. data/lib/vedeu/models/colour.rb +22 -0
  14. data/lib/vedeu/{repository → models}/command.rb +2 -0
  15. data/lib/vedeu/models/composition.rb +30 -0
  16. data/lib/vedeu/models/foreground.rb +13 -0
  17. data/lib/vedeu/models/interface.rb +62 -0
  18. data/lib/vedeu/models/interface_collection.rb +24 -0
  19. data/lib/vedeu/models/line.rb +22 -0
  20. data/lib/vedeu/models/line_collection.rb +27 -0
  21. data/lib/vedeu/models/presentation.rb +13 -0
  22. data/lib/vedeu/models/stream.rb +21 -0
  23. data/lib/vedeu/models/stream_collection.rb +27 -0
  24. data/lib/vedeu/models/style_collection.rb +23 -0
  25. data/lib/vedeu/output/interface_renderer.rb +62 -0
  26. data/lib/vedeu/output/output.rb +6 -5
  27. data/lib/vedeu/process/process.rb +15 -31
  28. data/lib/vedeu/repository/command_repository.rb +13 -14
  29. data/lib/vedeu/repository/interface_repository.rb +12 -13
  30. data/lib/vedeu/repository/repository.rb +2 -0
  31. data/lib/vedeu/{output → support}/cursor.rb +2 -0
  32. data/lib/vedeu/support/esc.rb +112 -0
  33. data/lib/vedeu/support/events.rb +21 -0
  34. data/lib/vedeu/support/geometry.rb +66 -0
  35. data/lib/vedeu/support/parser.rb +27 -0
  36. data/lib/vedeu/support/terminal.rb +31 -134
  37. data/lib/vedeu/{output → support}/translator.rb +12 -8
  38. data/lib/vedeu/{output → support}/wordwrap.rb +2 -4
  39. data/lib/vedeu/version.rb +1 -1
  40. data/test/lib/vedeu/application_test.rb +7 -2
  41. data/test/lib/vedeu/configuration_test.rb +13 -8
  42. data/test/lib/vedeu/input/input_test.rb +2 -1
  43. data/test/lib/vedeu/launcher_test.rb +7 -2
  44. data/test/lib/vedeu/models/background_test.rb +35 -0
  45. data/test/lib/vedeu/models/colour_test.rb +71 -0
  46. data/test/lib/vedeu/models/command_test.rb +109 -0
  47. data/test/lib/vedeu/models/composition_test.rb +187 -0
  48. data/test/lib/vedeu/models/foreground_test.rb +35 -0
  49. data/test/lib/vedeu/models/interface_collection_test.rb +57 -0
  50. data/test/lib/vedeu/models/interface_test.rb +220 -0
  51. data/test/lib/vedeu/models/line_collection_test.rb +69 -0
  52. data/test/lib/vedeu/models/line_test.rb +76 -0
  53. data/test/lib/vedeu/models/presentation_test.rb +8 -0
  54. data/test/lib/vedeu/models/stream_collection_test.rb +57 -0
  55. data/test/lib/vedeu/models/stream_test.rb +76 -0
  56. data/test/lib/vedeu/models/style_collection_test.rb +22 -0
  57. data/test/lib/vedeu/output/interface_renderer_test.rb +12 -0
  58. data/test/lib/vedeu/output/output_test.rb +15 -30
  59. data/test/lib/vedeu/process/process_test.rb +22 -44
  60. data/test/lib/vedeu/repository/command_repository_test.rb +22 -16
  61. data/test/lib/vedeu/repository/interface_repository_test.rb +62 -14
  62. data/test/lib/vedeu/repository/repository_test.rb +1 -0
  63. data/test/lib/vedeu/repository/storage_test.rb +13 -6
  64. data/test/lib/vedeu/{output → support}/cursor_test.rb +1 -0
  65. data/test/lib/vedeu/support/esc_test.rb +348 -0
  66. data/test/lib/vedeu/support/events_test.rb +37 -0
  67. data/test/lib/vedeu/support/exit_test.rb +1 -0
  68. data/test/lib/vedeu/support/geometry_test.rb +131 -0
  69. data/test/lib/vedeu/support/parser_test.rb +56 -0
  70. data/test/lib/vedeu/support/queue_test.rb +1 -0
  71. data/test/lib/vedeu/support/terminal_test.rb +1 -119
  72. data/test/lib/vedeu/{output → support}/translator_test.rb +17 -12
  73. data/test/lib/vedeu/{output → support}/wordwrap_test.rb +1 -0
  74. data/test/lib/vedeu/version_test.rb +1 -0
  75. data/test/lib/vedeu_test.rb +1 -0
  76. data/{lib/vedeu/repository → test/support}/dummy_command.rb +0 -0
  77. data/{lib/vedeu/repository → test/support}/dummy_interface.rb +0 -0
  78. data/test/support/json/int1_lin1_str1.json +10 -0
  79. data/test/support/json/int1_lin1_str3.json +18 -0
  80. data/test/support/json/int1_lin2_str1.json +17 -0
  81. data/test/support/json/int1_lin2_str3.json +33 -0
  82. data/test/support/json/int1_lin2_str3_styles.json +43 -0
  83. data/test/support/json/int2_lin1_str1.json +20 -0
  84. data/test/support/json/int2_lin1_str3.json +36 -0
  85. data/test/support/json/int2_lin2_str1.json +34 -0
  86. data/test/support/json/int2_lin2_str3.json +66 -0
  87. data/test/support/json/int2_lin2_str3_styles.json +158 -0
  88. data/test/support/output_1.json +9 -0
  89. data/test/support/output_1.rb +14 -0
  90. data/test/support/output_2.json +1 -0
  91. data/test/support/output_2.rb +19 -0
  92. data/test/test_helper.rb +0 -2
  93. data/vedeu.gemspec +0 -3
  94. metadata +98 -150
  95. data/config/cucumber.yml +0 -8
  96. data/documentation/composition.ebnf +0 -7
  97. data/documentation/diagram/ColourDirective.png +0 -0
  98. data/documentation/diagram/Directive.png +0 -0
  99. data/documentation/diagram/Interface.png +0 -0
  100. data/documentation/diagram/Output.png +0 -0
  101. data/documentation/diagram/PositionDirective.png +0 -0
  102. data/documentation/diagram/Stream.png +0 -0
  103. data/documentation/diagram/StyleDirective.png +0 -0
  104. data/documentation/diagram/rr-1.35.837.png +0 -0
  105. data/documentation/index.html +0 -325
  106. data/features/getting_started.feature +0 -10
  107. data/features/step_definitions/vedeu_steps.rb +0 -11
  108. data/features/support/env.rb +0 -12
  109. data/lib/vedeu/output/background.rb +0 -27
  110. data/lib/vedeu/output/base.rb +0 -57
  111. data/lib/vedeu/output/buffer/composition.rb +0 -24
  112. data/lib/vedeu/output/buffer/formatting.rb +0 -25
  113. data/lib/vedeu/output/buffer/interface.rb +0 -14
  114. data/lib/vedeu/output/buffer/line.rb +0 -14
  115. data/lib/vedeu/output/buffer/stream.rb +0 -14
  116. data/lib/vedeu/output/buffer/style.rb +0 -11
  117. data/lib/vedeu/output/colour.rb +0 -39
  118. data/lib/vedeu/output/compositor.rb +0 -72
  119. data/lib/vedeu/output/directive.rb +0 -63
  120. data/lib/vedeu/output/esc.rb +0 -61
  121. data/lib/vedeu/output/foreground.rb +0 -27
  122. data/lib/vedeu/output/geometry.rb +0 -71
  123. data/lib/vedeu/output/layer.rb +0 -9
  124. data/lib/vedeu/output/menu.rb +0 -26
  125. data/lib/vedeu/output/position.rb +0 -35
  126. data/lib/vedeu/output/style.rb +0 -38
  127. data/lib/vedeu/repository/interface.rb +0 -62
  128. data/lib/vedeu/support/json_parser.rb +0 -25
  129. data/lib/vedeu/support/options.rb +0 -4
  130. data/test/lib/vedeu/output/background_test.rb +0 -67
  131. data/test/lib/vedeu/output/base_test.rb +0 -8
  132. data/test/lib/vedeu/output/buffer/composition_test.rb +0 -57
  133. data/test/lib/vedeu/output/buffer/formatting_test.rb +0 -9
  134. data/test/lib/vedeu/output/buffer/interface_test.rb +0 -38
  135. data/test/lib/vedeu/output/buffer/line_test.rb +0 -64
  136. data/test/lib/vedeu/output/buffer/stream_test.rb +0 -61
  137. data/test/lib/vedeu/output/buffer/style_test.rb +0 -8
  138. data/test/lib/vedeu/output/colour_test.rb +0 -104
  139. data/test/lib/vedeu/output/compositor_test.rb +0 -247
  140. data/test/lib/vedeu/output/directive_test.rb +0 -82
  141. data/test/lib/vedeu/output/esc_test.rb +0 -175
  142. data/test/lib/vedeu/output/foreground_test.rb +0 -67
  143. data/test/lib/vedeu/output/geometry_test.rb +0 -190
  144. data/test/lib/vedeu/output/layer_test.rb +0 -35
  145. data/test/lib/vedeu/output/menu_test.rb +0 -13
  146. data/test/lib/vedeu/output/position_test.rb +0 -48
  147. data/test/lib/vedeu/output/style_test.rb +0 -132
  148. data/test/lib/vedeu/repository/command_test.rb +0 -73
  149. data/test/lib/vedeu/repository/dummy_command_test.rb +0 -27
  150. data/test/lib/vedeu/repository/dummy_interface_test.rb +0 -7
  151. data/test/lib/vedeu/repository/interface_test.rb +0 -79
  152. data/test/lib/vedeu/support/json_parser_test.rb +0 -45
  153. data/test/support/composition.json +0 -47
  154. data/test/support/composition.rb +0 -5
  155. data/test/support/composition.xml +0 -36
  156. data/test/support/multi_interface.json +0 -34
  157. data/test/support/single_interface.json +0 -19
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5a6b5d80f3321da207ef185b7437f50b5e31aaaf
4
- data.tar.gz: b6ca2fdd18c9912f54bfcf5629d293e9dd2e5468
3
+ metadata.gz: 7f1c1d57417fc05b09722865230c56b1ae0c255f
4
+ data.tar.gz: bc49bf53438c817107da4b3487f3f3c7d8d65e88
5
5
  SHA512:
6
- metadata.gz: 6411a9e56a0eb82187442214a9fe95cbde95cdba99370e94888ce60f23dfa1383d9d966d9d3114fcf5e52f769044a6430e69ad7fd4f95d15f6dd13fb83700fe2
7
- data.tar.gz: db041a47634fbe157be6f23c4ddb920a6b853aa1be20b4bb6528229e64bc3abdcd535deb9b0965ce3a8191c3673b089c8c94d9ecdf6a4b3d6526a8941676e2c9
6
+ metadata.gz: 64922d74b257a74850aa87cf2455ba58a368060b0d3316f2a14fd3d63b774aaf2017c3ffb11dcdd2934e5f0007661d2c7b252a933a5e1a32ddad7cf761a2a8eb
7
+ data.tar.gz: 5e3b0890b6121e88a5001e29b6cdf1541e2db0499bfe02f08fecc486bf9347956813394d5e5c7909e4453a0bb9e206a231272933d884afca2690e6a5bc9c1c88
data/README.md CHANGED
@@ -38,17 +38,22 @@ Expect proper documentation soon!
38
38
  interface :main, {
39
39
  y: 1,
40
40
  x: 1,
41
+ z: 1,
41
42
  width: :auto, # will set to terminal width
42
43
  height: 10, # also accepts :auto
43
- foreground: :white,
44
- background: :black,
44
+ colour: {
45
+ foreground: '#ffffff',
46
+ background: '#000000'
47
+ },
45
48
  cursor: false,
46
- layer: 0 }
49
+ }
47
50
 
48
51
  Referring to the above example, interfaces have a name, and various default attributes.
49
52
 
50
53
  `:y` sets the starting row point. (See Geometry)
51
54
  `:x` sets the starting column point.
55
+ `:z` an integer specifying the z-index of the interface.
56
+ (See Layers)
52
57
  `:width` sets how many characters wide the interface will be.
53
58
  `:height` sets how many characters tall the interface will be.
54
59
 
@@ -57,8 +62,6 @@ Referring to the above example, interfaces have a name, and various default attr
57
62
 
58
63
  `:cursor` a boolean specifying whether the cursor should show.
59
64
 
60
- `:layer` an integer specifying the z-index of the interface.
61
- (See Layers)
62
65
 
63
66
  ### On Defining Commands
64
67
 
@@ -79,9 +82,7 @@ Geometry for Vedeu, as the same for ANSI terminals, is set top-left, which is po
79
82
 
80
83
  ### Colours
81
84
 
82
- Vedeu uses the standard ANSI terminal colours, though you can also set arbitrary colours using HTML/CSS style notation (i.e. '#aadd00').
83
-
84
- :black, :red, :green, :yellow, :blue, :magenta, :cyan, :white, :default
85
+ Vedeu uses HTML/CSS style notation (i.e. '#aadd00').
85
86
 
86
87
 
87
88
  ### Layers
@@ -89,7 +90,7 @@ Vedeu uses the standard ANSI terminal colours, though you can also set arbitrary
89
90
  Vedeu allows the overlaying of interfaces. To render these correctly,
90
91
  Vedeu uses two rules.
91
92
 
92
- 1) The :layer value. 0 would be default, or bottom. 1 would be placed on top of 0. 2 on top of 1, and so on.
93
+ 1) The :z value. 1 would be default, or bottom. 2 would be placed on top of 1. 3 on top of 2, and so on.
93
94
  2) If two interfaces occupy the same 'space', the interface which was defined last, wins.
94
95
 
95
96
 
data/Rakefile CHANGED
@@ -1,11 +1,5 @@
1
1
  require "bundler/gem_tasks"
2
2
  require "rake/testtask"
3
- require 'cucumber'
4
- require 'cucumber/rake/task'
5
-
6
- Cucumber::Rake::Task.new(:cucumber) do |t|
7
- t.cucumber_opts = "features --format progress"
8
- end
9
3
 
10
4
  Rake::TestTask.new(:minitest) do |t|
11
5
  t.libs << 'lib/vedeu'
@@ -15,7 +9,3 @@ Rake::TestTask.new(:minitest) do |t|
15
9
  end
16
10
 
17
11
  task default: :minitest
18
-
19
- Rake::Task['minitest'].execute
20
-
21
- Rake::Task['cucumber'].execute
data/bin/composition CHANGED
@@ -11,4 +11,4 @@ require 'pry'
11
11
 
12
12
  json = File.read('../test/support/composition.json')
13
13
  hash = Yajl::Parser.parse(json)
14
- comp = Vedeu::Buffer::Composition.new(hash)
14
+ comp = Vedeu::Composition.new(hash)
@@ -8,12 +8,15 @@ class SingleInterfaceApp
8
8
  interface :main, {
9
9
  y: 1,
10
10
  x: 1,
11
+ z: 1,
11
12
  width: :auto,
12
13
  height: :auto,
13
- foreground: :white,
14
- background: :black,
15
- cursor: true,
16
- layer: 0 }
14
+ colour: {
15
+ foreground: '#ffffff',
16
+ background: '#000000',
17
+ },
18
+ cursor: true
19
+ }
17
20
 
18
21
  command :refresh, {
19
22
  entity: SingleInterfaceApp,
data/lib/vedeu.rb CHANGED
@@ -1,59 +1,32 @@
1
1
  require 'date'
2
2
  require 'logger'
3
- require 'io/console'
4
- require 'oj'
5
- require 'optparse'
6
- require 'virtus'
7
3
 
8
- require_relative 'vedeu/input/input'
9
-
10
- require_relative 'vedeu/support/exit'
11
- require_relative 'vedeu/support/json_parser'
12
- require_relative 'vedeu/support/queue'
13
- require_relative 'vedeu/support/terminal'
14
-
15
- require_relative 'vedeu/output/buffer/style'
16
- require_relative 'vedeu/output/buffer/formatting'
17
- require_relative 'vedeu/output/buffer/stream'
18
- require_relative 'vedeu/output/buffer/line'
19
- require_relative 'vedeu/output/buffer/interface'
20
- require_relative 'vedeu/output/buffer/composition'
21
-
22
- require_relative 'vedeu/output/base'
23
- require_relative 'vedeu/output/background'
24
- require_relative 'vedeu/output/compositor'
25
- require_relative 'vedeu/output/cursor'
26
- require_relative 'vedeu/output/directive'
27
- require_relative 'vedeu/output/foreground'
28
- require_relative 'vedeu/output/geometry'
29
- require_relative 'vedeu/output/layer'
30
- require_relative 'vedeu/output/menu'
31
- require_relative 'vedeu/output/esc'
32
- require_relative 'vedeu/output/colour'
33
- require_relative 'vedeu/output/output'
34
- require_relative 'vedeu/output/position'
35
- require_relative 'vedeu/output/style'
36
- require_relative 'vedeu/output/translator'
37
- require_relative 'vedeu/output/wordwrap'
38
-
39
- require_relative 'vedeu/process/process'
40
-
41
- require_relative 'vedeu/repository/repository'
42
4
  require_relative 'vedeu/repository/command_repository'
43
- require_relative 'vedeu/repository/command'
44
5
  require_relative 'vedeu/repository/interface_repository'
45
- require_relative 'vedeu/repository/interface'
46
- require_relative 'vedeu/repository/storage'
47
- require_relative 'vedeu/repository/dummy_interface'
48
- require_relative 'vedeu/repository/dummy_command'
49
-
50
- require_relative 'vedeu/application'
51
- require_relative 'vedeu/configuration'
6
+ require_relative 'vedeu/support/exit'
52
7
  require_relative 'vedeu/launcher'
53
8
  require_relative 'vedeu/version'
54
9
 
55
10
  module Vedeu
56
11
  # :nocov:
12
+ module ClassMethods
13
+ def command(name, options = {})
14
+ CommandRepository.create({ name: stringify_symbols(name) }
15
+ .merge!(options))
16
+ end
17
+
18
+ def interface(name, options = {})
19
+ InterfaceRepository.create({ name: stringify_symbols(name) }
20
+ .merge!(options))
21
+ end
22
+
23
+ private
24
+
25
+ def stringify_symbols(value)
26
+ value.is_a?(::Symbol) ? value.to_s : value
27
+ end
28
+ end
29
+
57
30
  def self.logger
58
31
  @logger ||= Logger.new(root_path + '/logs/vedeu.log').tap do |log|
59
32
  log.formatter = proc do |_, time, _, msg|
@@ -78,11 +51,9 @@ module Vedeu
78
51
  def self.included(receiver)
79
52
  receiver.extend(ClassMethods)
80
53
  end
81
- # :nocov:
82
54
 
83
55
  private
84
56
 
85
- # :nocov:
86
57
  def self.root_path
87
58
  File.expand_path('../..', __FILE__)
88
59
  end
@@ -1,9 +1,12 @@
1
+ require_relative 'input/input'
2
+ require_relative 'output/output'
3
+ require_relative 'process/process'
4
+ require_relative 'support/terminal'
5
+
1
6
  module Vedeu
2
7
  class Application
3
- class << self
4
- def start(options = {})
5
- new(options).start
6
- end
8
+ def self.start(options = {})
9
+ new(options).start
7
10
  end
8
11
 
9
12
  def initialize(options = {})
@@ -11,13 +14,11 @@ module Vedeu
11
14
  end
12
15
 
13
16
  def start
14
- Terminal.open(options) do
17
+ Terminal.open do
15
18
  Output.render
16
19
 
17
20
  runner { main_sequence }
18
21
  end
19
- ensure
20
- Terminal.close
21
22
  end
22
23
 
23
24
  private
@@ -1,9 +1,9 @@
1
+ require 'optparse'
2
+
1
3
  module Vedeu
2
4
  class Configuration
3
- class << self
4
- def configure(args = [])
5
- new(args).configure
6
- end
5
+ def self.configure(args = [])
6
+ new(args).configure
7
7
  end
8
8
 
9
9
  def initialize(args = [])
@@ -1,3 +1,6 @@
1
+ require_relative '../support/queue'
2
+ require_relative '../support/terminal'
3
+
1
4
  module Vedeu
2
5
  module Input
3
6
  extend self
@@ -1,3 +1,6 @@
1
+ require_relative 'application'
2
+ require_relative 'configuration'
3
+
1
4
  module Vedeu
2
5
  class Launcher
3
6
  def initialize(argv, stdin = STDIN,
@@ -0,0 +1,13 @@
1
+ require 'virtus'
2
+
3
+ require_relative '../support/esc'
4
+
5
+ module Vedeu
6
+ class Background < Virtus::Attribute
7
+ def coerce(value)
8
+ return '' unless value
9
+
10
+ Esc.background_colour(value)
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,21 @@
1
+ module Vedeu
2
+ module Coercions
3
+ private
4
+
5
+ def multiple?(values)
6
+ values.is_a?(::Array)
7
+ end
8
+
9
+ def single?(values)
10
+ values.is_a?(::Hash)
11
+ end
12
+
13
+ def just_text?(values)
14
+ values.is_a?(::String)
15
+ end
16
+
17
+ def empty?(values)
18
+ values.nil? || values.empty?
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,22 @@
1
+ require 'oj'
2
+ require 'virtus'
3
+
4
+ require_relative 'foreground'
5
+ require_relative 'background'
6
+
7
+ module Vedeu
8
+ class Colour
9
+ include Virtus.model
10
+
11
+ attribute :foreground, Foreground
12
+ attribute :background, Background
13
+
14
+ def to_json
15
+ Oj.dump(attributes, mode: :compat)
16
+ end
17
+
18
+ def to_s
19
+ foreground + background
20
+ end
21
+ end
22
+ end
@@ -1,3 +1,5 @@
1
+ require 'virtus'
2
+
1
3
  module Vedeu
2
4
  class Command
3
5
  include Virtus.model
@@ -0,0 +1,30 @@
1
+ require 'oj'
2
+ require 'virtus'
3
+
4
+ require_relative 'interface_collection'
5
+
6
+ module Vedeu
7
+ class Composition
8
+ include Virtus.model
9
+
10
+ attribute :interfaces, InterfaceCollection
11
+
12
+ def self.enqueue(composition)
13
+ new(composition).enqueue
14
+ end
15
+
16
+ def enqueue
17
+ interfaces.map do |interface|
18
+ interface.enqueue(interface.to_s)
19
+ end
20
+ end
21
+
22
+ def to_json
23
+ Oj.dump(attributes, mode: :compat)
24
+ end
25
+
26
+ def to_s
27
+ interfaces.map(&:to_s).join
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,13 @@
1
+ require 'virtus'
2
+
3
+ require_relative '../support/esc'
4
+
5
+ module Vedeu
6
+ class Foreground < Virtus::Attribute
7
+ def coerce(value)
8
+ return '' unless value
9
+
10
+ Esc.foreground_colour(value)
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,62 @@
1
+ require 'virtus'
2
+
3
+ require_relative 'presentation'
4
+ require_relative 'line_collection'
5
+ require_relative '../output/interface_renderer'
6
+ require_relative '../support/esc'
7
+ require_relative '../support/cursor'
8
+ require_relative '../support/queue'
9
+ require_relative '../support/terminal'
10
+
11
+ module Vedeu
12
+ class Interface
13
+ include Virtus.model
14
+ include Presentation
15
+ include Vedeu::Queue
16
+
17
+ attribute :name, String
18
+ attribute :lines, LineCollection
19
+ attribute :y, Integer, default: 1
20
+ attribute :x, Integer, default: 1
21
+ attribute :z, Integer, default: 1
22
+ attribute :width, Integer, default: Terminal.width
23
+ attribute :height, Integer, default: Terminal.height
24
+ attribute :current, String, default: ''
25
+ attribute :cursor, Boolean, default: true
26
+
27
+ def refresh
28
+ if enqueued?
29
+ current = dequeue
30
+
31
+ elsif no_content?
32
+ current = clear_interface
33
+
34
+ else
35
+ current
36
+
37
+ end
38
+ end
39
+
40
+ def to_json
41
+ Oj.dump(attributes, mode: :compat)
42
+ end
43
+
44
+ def to_s
45
+ clear_interface + render_content
46
+ end
47
+
48
+ private
49
+
50
+ def no_content?
51
+ current.nil? || current.empty?
52
+ end
53
+
54
+ def render_content
55
+ InterfaceRenderer.render(self)
56
+ end
57
+
58
+ def clear_interface
59
+ InterfaceRenderer.clear(self)
60
+ end
61
+ end
62
+ end