vedeu 0.6.25 → 0.6.26

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. checksums.yaml +4 -4
  2. data/lib/vedeu/application/application_view.rb +2 -2
  3. data/lib/vedeu/bindings/drb.rb +1 -1
  4. data/lib/vedeu/bindings/movement.rb +4 -4
  5. data/lib/vedeu/borders/border.rb +5 -13
  6. data/lib/vedeu/borders/refresh.rb +4 -1
  7. data/lib/vedeu/buffers/buffer.rb +1 -1
  8. data/lib/vedeu/colours/background.rb +2 -2
  9. data/lib/vedeu/colours/foreground.rb +2 -2
  10. data/lib/vedeu/colours/translator.rb +4 -4
  11. data/lib/vedeu/configuration/api.rb +1 -1
  12. data/lib/vedeu/configuration/configuration.rb +1 -1
  13. data/lib/vedeu/cursors/cursor.rb +2 -2
  14. data/lib/vedeu/distributed/client.rb +3 -3
  15. data/lib/vedeu/distributed/server.rb +16 -15
  16. data/lib/vedeu/distributed/subprocess.rb +2 -2
  17. data/lib/vedeu/distributed/uri.rb +1 -1
  18. data/lib/vedeu/dsl/composition.rb +3 -2
  19. data/lib/vedeu/dsl/dsl.rb +2 -1
  20. data/lib/vedeu/dsl/interface.rb +1 -1
  21. data/lib/vedeu/dsl/keymap.rb +3 -3
  22. data/lib/vedeu/editor/cropper.rb +1 -1
  23. data/lib/vedeu/editor/cursor.rb +1 -1
  24. data/lib/vedeu/editor/line.rb +1 -1
  25. data/lib/vedeu/error.rb +2 -2
  26. data/lib/vedeu/esc/actions.rb +15 -15
  27. data/lib/vedeu/esc/borders.rb +12 -12
  28. data/lib/vedeu/esc/colours.rb +10 -8
  29. data/lib/vedeu/esc/esc.rb +10 -9
  30. data/lib/vedeu/events/aliases.rb +1 -4
  31. data/lib/vedeu/events/event.rb +5 -4
  32. data/lib/vedeu/geometry/generic_coordinate.rb +1 -1
  33. data/lib/vedeu/geometry/geometry.rb +2 -4
  34. data/lib/vedeu/geometry/position.rb +2 -2
  35. data/lib/vedeu/groups/refresh.rb +2 -2
  36. data/lib/vedeu/input/keymap.rb +3 -2
  37. data/lib/vedeu/input/mapper.rb +1 -1
  38. data/lib/vedeu/logging/lockless_log_device.rb +1 -1
  39. data/lib/vedeu/logging/log.rb +2 -2
  40. data/lib/vedeu/logging/mono_logger.rb +1 -1
  41. data/lib/vedeu/logging/timer.rb +2 -1
  42. data/lib/vedeu/models/escape.rb +2 -2
  43. data/lib/vedeu/models/focus.rb +5 -3
  44. data/lib/vedeu/models/page.rb +2 -2
  45. data/lib/vedeu/models/views/html_char.rb +15 -14
  46. data/lib/vedeu/models/views/view.rb +2 -1
  47. data/lib/vedeu/output/clear/interface.rb +4 -4
  48. data/lib/vedeu/output/compressor.rb +3 -3
  49. data/lib/vedeu/output/presentation/presentation.rb +2 -2
  50. data/lib/vedeu/output/presentation/style.rb +1 -1
  51. data/lib/vedeu/output/refresh/refresh.rb +1 -1
  52. data/lib/vedeu/output/renderers/all.rb +2 -0
  53. data/lib/vedeu/output/renderers/file.rb +1 -1
  54. data/lib/vedeu/output/viewport.rb +1 -1
  55. data/lib/vedeu/output/wordwrap.rb +4 -4
  56. data/lib/vedeu/plugins/plugin.rb +3 -3
  57. data/lib/vedeu/plugins/plugins.rb +4 -3
  58. data/lib/vedeu/repositories/model.rb +6 -6
  59. data/lib/vedeu/repositories/repositories.rb +1 -1
  60. data/lib/vedeu/repositories/repository.rb +11 -10
  61. data/lib/vedeu/repositories/store.rb +1 -1
  62. data/lib/vedeu/runtime/bootstrap.rb +8 -8
  63. data/lib/vedeu/runtime/launcher.rb +1 -1
  64. data/lib/vedeu/runtime/main_loop.rb +1 -1
  65. data/lib/vedeu/runtime/router.rb +10 -8
  66. data/lib/vedeu/templating/template.rb +2 -2
  67. data/lib/vedeu/terminal/buffer.rb +10 -11
  68. data/lib/vedeu/terminal/terminal.rb +2 -2
  69. data/lib/vedeu/version.rb +1 -1
  70. data/test/lib/vedeu/borders/border_test.rb +1 -11
  71. data/test/lib/vedeu/colours/repository_test.rb +2 -1
  72. data/test/lib/vedeu/esc/colours_test.rb +50 -0
  73. data/test/lib/vedeu/repositories/repository_test.rb +0 -2
  74. data/test/lib/vedeu/terminal/buffer_test.rb +0 -209
  75. metadata +2 -2
@@ -49,7 +49,8 @@ module Vedeu
49
49
  if Vedeu::Configuration.debug?
50
50
  work = yield
51
51
 
52
- Vedeu.log(type: :timer, message: "#{message} took #{elapsed}ms.")
52
+ Vedeu.log(type: :timer,
53
+ message: "#{message} took #{elapsed}ms.".freeze)
53
54
 
54
55
  work
55
56
 
@@ -65,12 +65,12 @@ module Vedeu
65
65
  # @param _options [Hash] Ignored.
66
66
  # @return [String]
67
67
  def to_html(_options = {})
68
- ''
68
+ ''.freeze
69
69
  end
70
70
 
71
71
  # @return [String]
72
72
  def to_s
73
- "#{position}#{value}"
73
+ "#{position}#{value}".freeze
74
74
  end
75
75
  alias_method :to_str, :to_s
76
76
 
@@ -36,7 +36,8 @@ module Vedeu
36
36
  storage
37
37
 
38
38
  else
39
- Vedeu.log(type: :store, message: "Storing focus entry: '#{name}'")
39
+ Vedeu.log(type: :store,
40
+ message: "Storing focus entry: '#{name}'".freeze)
40
41
 
41
42
  if focus
42
43
  storage.unshift(name)
@@ -65,7 +66,7 @@ module Vedeu
65
66
  unless registered?(name)
66
67
  fail Vedeu::Error::ModelNotFound,
67
68
  "Cannot focus '#{name}' as this interface has not been " \
68
- 'registered.'
69
+ 'registered.'.freeze
69
70
  end
70
71
 
71
72
  storage.rotate!(storage.index(name))
@@ -215,7 +216,8 @@ module Vedeu
215
216
  def update
216
217
  return false if empty?
217
218
 
218
- Vedeu.log(type: :info, message: "Interface in focus: '#{current}'")
219
+ Vedeu.log(type: :info,
220
+ message: "Interface in focus: '#{current}'".freeze)
219
221
 
220
222
  refresh
221
223
 
@@ -39,7 +39,7 @@ module Vedeu
39
39
 
40
40
  else
41
41
  fail Vedeu::Error::InvalidSyntax,
42
- 'Cannot coerce as value is not an Array.'
42
+ 'Cannot coerce as value is not an Array.'.freeze
43
43
 
44
44
  end
45
45
  end
@@ -54,7 +54,7 @@ module Vedeu
54
54
 
55
55
  # @return [Array<void>]
56
56
  def content
57
- rows.map(&:content).flatten
57
+ rows.flat_map(&:content)
58
58
  end
59
59
 
60
60
  # @param row_index [Fixnum]
@@ -29,7 +29,7 @@ module Vedeu
29
29
 
30
30
  # @return [String]
31
31
  def render
32
- "#{start_tag}#{tag_style}>#{tag_value}#{end_tag}"
32
+ "#{start_tag}#{tag_style}>#{tag_value}#{end_tag}".freeze
33
33
  end
34
34
 
35
35
  protected
@@ -53,17 +53,17 @@ module Vedeu
53
53
  # @return [String]
54
54
  def tag_style_background
55
55
  "border:1px #{char.background.to_html} solid;" \
56
- "background:#{char.background.to_html};"
56
+ "background:#{char.background.to_html};".freeze
57
57
  end
58
58
 
59
59
  # @return [String]
60
60
  def tag_style_foreground
61
- "color:#{char.foreground.to_html};#{border_style}"
61
+ "color:#{char.foreground.to_html};#{border_style}".freeze
62
62
  end
63
63
 
64
64
  # @return [String]
65
65
  def tag_value
66
- return '&nbsp;' if border || !present?(value)
66
+ return '&nbsp;'.freeze if border || !present?(value)
67
67
 
68
68
  value
69
69
  end
@@ -71,22 +71,23 @@ module Vedeu
71
71
  # @return [String]
72
72
  def border_style
73
73
  case border
74
- when :top_horizontal then css('top')
75
- when :left_vertical then css('left')
76
- when :right_vertical then css('right')
77
- when :bottom_horizontal then css('bottom')
78
- when :top_left then "#{css('top')}#{css('left')}"
79
- when :top_right then "#{css('top')}#{css('right')}"
80
- when :bottom_left then "#{css('bottom')}#{css('left')}"
81
- when :bottom_right then "#{css('bottom')}#{css('right')}"
74
+ when :top_horizontal then css(:top)
75
+ when :left_vertical then css(:left)
76
+ when :right_vertical then css(:right)
77
+ when :bottom_horizontal then css(:bottom)
78
+ when :top_left then "#{css(:top)}#{css(:left)}".freeze
79
+ when :top_right then "#{css(:top)}#{css(:right)}".freeze
80
+ when :bottom_left then "#{css(:bottom)}#{css(:left)}".freeze
81
+ when :bottom_right then "#{css(:bottom)}#{css(:right)}".freeze
82
82
  else
83
83
  ''
84
84
  end
85
85
  end
86
86
 
87
+ # @param direction [Symbol]
87
88
  # @return [String]
88
- def css(direction = '')
89
- "border-#{direction}:1px #{char.foreground.to_html} solid;"
89
+ def css(direction)
90
+ "border-#{direction}:1px #{char.foreground.to_html} solid;".freeze
90
91
  end
91
92
 
92
93
  # @return [Symbol|NilClass]
@@ -96,7 +96,8 @@ module Vedeu
96
96
  # @return [Vedeu::Views::View]
97
97
  def store_deferred
98
98
  fail Vedeu::Error::InvalidSyntax,
99
- 'Cannot store an interface without a name.' unless present?(name)
99
+ 'Cannot store an interface ' \
100
+ 'without a name.'.freeze unless present?(name)
100
101
 
101
102
  Vedeu.buffers.by_name(name).add(self)
102
103
 
@@ -113,7 +113,7 @@ module Vedeu
113
113
  #
114
114
  # @return [Array<Array<Vedeu::Views::Char>>]
115
115
  def output
116
- Vedeu.timer("Clearing #{clearing}: '#{name}'") do
116
+ Vedeu.timer("Clearing #{clearing}: '#{name}'".freeze) do
117
117
  @y = y
118
118
  @x = x
119
119
  @width = width
@@ -122,7 +122,7 @@ module Vedeu
122
122
 
123
123
  @clear ||= Array.new(@height) do |iy|
124
124
  Array.new(@width) do |ix|
125
- Vedeu::Views::Char.new(value: ' ',
125
+ Vedeu::Views::Char.new(value: ' '.freeze,
126
126
  colour: @colour,
127
127
  position: [@y + iy, @x + ix])
128
128
  end
@@ -132,9 +132,9 @@ module Vedeu
132
132
 
133
133
  # @return [String]
134
134
  def clearing
135
- return 'content' if content_only?
135
+ return 'content'.freeze if content_only?
136
136
 
137
- 'interface'
137
+ 'interface'.freeze
138
138
  end
139
139
 
140
140
  # @return [Fixnum]
@@ -53,7 +53,7 @@ module Vedeu
53
53
 
54
54
  # @return [String]
55
55
  def compress
56
- Vedeu.timer('Compression') do
56
+ Vedeu.timer('Compression'.freeze) do
57
57
  out = ''
58
58
 
59
59
  content.each do |cell|
@@ -81,7 +81,7 @@ module Vedeu
81
81
  # @param char [Vedeu::Views::Char]
82
82
  # @return [String]
83
83
  def colour_for(char)
84
- return '' if char.colour == @colour
84
+ return ''.freeze if char.colour == @colour
85
85
 
86
86
  @colour = char.colour
87
87
  @colour.to_s
@@ -90,7 +90,7 @@ module Vedeu
90
90
  # @param char [Vedeu::Views::Char]
91
91
  # @return [String]
92
92
  def style_for(char)
93
- return '' if char.style == @style
93
+ return ''.freeze if char.style == @style
94
94
 
95
95
  @style = char.style
96
96
  @style.to_s
@@ -30,7 +30,7 @@ module Vedeu
30
30
  #
31
31
  # @return [String]
32
32
  def render_colour
33
- "#{colour}#{yield}"
33
+ "#{colour}#{yield}".freeze
34
34
  end
35
35
 
36
36
  # @return [String]
@@ -45,7 +45,7 @@ module Vedeu
45
45
  #
46
46
  # @return [String]
47
47
  def render_style
48
- "#{style}#{yield}"
48
+ "#{style}#{yield}".freeze
49
49
  end
50
50
 
51
51
  end # Presentation
@@ -66,7 +66,7 @@ module Vedeu
66
66
  def to_s
67
67
  return '' unless present?(value)
68
68
 
69
- @sequences ||= Array(value).flatten.map do |v|
69
+ @sequences ||= Array(value).flat_map do |v|
70
70
  Vedeu::EscapeSequences::Esc.string(v)
71
71
  end.join
72
72
  end
@@ -19,7 +19,7 @@ module Vedeu
19
19
  #
20
20
  # @return [Array<Vedeu::Models::Interface>]
21
21
  def all
22
- Vedeu.timer('Refreshing all') do
22
+ Vedeu.timer('Refreshing all'.freeze) do
23
23
  Vedeu.interfaces.zindexed.each do |interface|
24
24
  Vedeu.trigger(:_refresh_view_, interface.name)
25
25
  end
@@ -11,6 +11,8 @@ module Vedeu
11
11
  # content.
12
12
  #
13
13
  # @example
14
+ # Vedeu.clear
15
+ # Vedeu.trigger(:_clear_)
14
16
  # Vedeu.renderers.clear
15
17
  #
16
18
  # @return [Array<void>]
@@ -43,7 +43,7 @@ module Vedeu
43
43
 
44
44
  # @return [String]
45
45
  def filename
46
- options[:filename] + "_#{timestamp}"
46
+ options[:filename] + "_#{timestamp}".freeze
47
47
  end
48
48
 
49
49
  # @return [Float]
@@ -65,7 +65,7 @@ module Vedeu
65
65
 
66
66
  # @return [Array<Array<Vedeu::Views::Char>>]
67
67
  def output
68
- Vedeu.timer("Rendering content: '#{name}'") do
68
+ Vedeu.timer("Rendering content: '#{name}'".freeze) do
69
69
  out = []
70
70
 
71
71
  show.each_with_index do |line, iy|
@@ -109,7 +109,7 @@ module Vedeu
109
109
  def ellipsis_string(string)
110
110
  return prune_string(string) if string.size < ellipsis.size
111
111
 
112
- "#{prune_string(string)}#{ellipsis}"
112
+ "#{prune_string(string)}#{ellipsis}".freeze
113
113
  end
114
114
 
115
115
  # Returns the string pruned.
@@ -131,7 +131,7 @@ module Vedeu
131
131
  #
132
132
  # @return [String]
133
133
  def ellipsis
134
- options.fetch(:ellipsis)
134
+ options[:ellipsis]
135
135
  end
136
136
 
137
137
  # Returns the word wrapping mode. One of :default, :prune or
@@ -143,14 +143,14 @@ module Vedeu
143
143
  # width.
144
144
  # @return [Symbol]
145
145
  def mode
146
- options.fetch(:mode)
146
+ options[:mode]
147
147
  end
148
148
 
149
149
  # Returns the width to prune or wrap to.
150
150
  #
151
151
  # @return [Fixnum]
152
152
  def width
153
- options.fetch(:width)
153
+ options[:width]
154
154
  end
155
155
 
156
156
  # Returns the default options/attributes for this class.
@@ -29,7 +29,7 @@ module Vedeu
29
29
  def initialize(name, gem)
30
30
  @name = name
31
31
  @gem = gem
32
- @gem_name = "vedeu_#{name}"
32
+ @gem_name = "vedeu_#{name}".freeze
33
33
  @enabled = false
34
34
  end
35
35
 
@@ -41,10 +41,10 @@ module Vedeu
41
41
  require gem_name unless enabled?
42
42
  rescue LoadError => error
43
43
  raise Vedeu::Error::Fatal,
44
- "Unable to load plugin #{gem_name} due to #{error}."
44
+ "Unable to load plugin #{gem_name} due to #{error}.".freeze
45
45
  rescue => error
46
46
  raise Vedeu::Error::Fatal,
47
- "require '#{gem_name}' failed with #{error}."
47
+ "require '#{gem_name}' failed with #{error}.".freeze
48
48
  end
49
49
 
50
50
  @enabled = true
@@ -24,7 +24,8 @@ module Vedeu
24
24
  # @param plugin [Vedeu::Plugin]
25
25
  # @return [Array<void>]
26
26
  def register(name, plugin = false)
27
- Vedeu.log(type: :debug, message: "Attempting to register plugin: #{name}")
27
+ Vedeu.log(type: :debug,
28
+ message: "Attempting to register plugin: #{name}".freeze)
28
29
 
29
30
  plugins << plugin if plugin && not_loaded?(name)
30
31
  end
@@ -36,7 +37,7 @@ module Vedeu
36
37
  Gem.refresh
37
38
 
38
39
  Gem::Specification.each do |gem|
39
- next unless gem.name =~ /^#{prefix}/
40
+ next unless gem.name =~ /^#{prefix}/.freeze
40
41
 
41
42
  plugin_name = gem.name[/^#{prefix}(.*)/, 1]
42
43
 
@@ -75,7 +76,7 @@ module Vedeu
75
76
 
76
77
  # @return [String]
77
78
  def prefix
78
- 'vedeu_'
79
+ 'vedeu_'.freeze
79
80
  end
80
81
 
81
82
  end # Plugins
@@ -126,14 +126,14 @@ module Vedeu
126
126
  # @return [String]
127
127
  def dsl_class
128
128
  case demodulize(self.class.name)
129
- when 'Border' then 'Vedeu::Borders::DSL'
130
- when 'Buffer' then 'Vedeu::Buffers::DSL'
131
- when 'Geometry' then 'Vedeu::Geometry::DSL'
132
- when 'Group' then 'Vedeu::Groups::DSL'
133
- when 'Menu' then 'Vedeu::Menus::DSL'
129
+ when 'Border'.freeze then 'Vedeu::Borders::DSL'.freeze
130
+ when 'Buffer'.freeze then 'Vedeu::Buffers::DSL'.freeze
131
+ when 'Geometry'.freeze then 'Vedeu::Geometry::DSL'.freeze
132
+ when 'Group'.freeze then 'Vedeu::Groups::DSL'.freeze
133
+ when 'Menu'.freeze then 'Vedeu::Menus::DSL'.freeze
134
134
  # when 'ModelTestClass' then 'Vedeu::Repositories::ModelTestClass::DSL'
135
135
  else
136
- 'Vedeu::DSL::' + demodulize(self.class.name)
136
+ 'Vedeu::DSL::'.freeze + demodulize(self.class.name)
137
137
  end
138
138
  end
139
139
 
@@ -23,7 +23,7 @@ module Vedeu
23
23
 
24
24
  Vedeu.log(type: :store,
25
25
  message: "Repository '#{repository.class.name}':" \
26
- " #{registered.inspect}")
26
+ " #{registered.inspect}".freeze)
27
27
 
28
28
  registered
29
29
  end
@@ -30,8 +30,8 @@ module Vedeu
30
30
  # @param storage [Class|Hash]
31
31
  # @return [Vedeu::Repositories::Repository]
32
32
  def initialize(model = nil, storage = {})
33
- @model = model
34
- @storage = storage
33
+ @model = model
34
+ @storage = storage
35
35
  end
36
36
 
37
37
  # Returns the repository class.
@@ -94,7 +94,7 @@ module Vedeu
94
94
  # @return [Hash<String => Object>]
95
95
  def find!(name)
96
96
  find(name) || fail(Vedeu::Error::ModelNotFound,
97
- "Cannot find model by name: '#{name}'")
97
+ "Cannot find model by name: '#{name}'".freeze)
98
98
  end
99
99
 
100
100
  # Find a model by name, registers the model by name when not
@@ -106,14 +106,15 @@ module Vedeu
106
106
  return find(name) if registered?(name)
107
107
 
108
108
  Vedeu.log(type: :store,
109
- message: "Model (#{model}) not found, registering: '#{name}'")
109
+ message: "Model (#{model}) not found, " \
110
+ "registering: '#{name}'".freeze)
110
111
 
111
112
  model.new(name).store
112
113
  end
113
114
 
114
115
  # @return [String]
115
116
  def inspect
116
- "<#{self.class.name}>"
117
+ "<#{self.class.name}>".freeze
117
118
  end
118
119
 
119
120
  # Returns a boolean indicating whether the named model is
@@ -140,9 +141,7 @@ module Vedeu
140
141
  storage.delete(name)
141
142
  storage unless storage.is_a?(Set)
142
143
  end
143
- alias_method :destroy, :remove
144
- alias_method :delete, :remove
145
- alias_method :deregister, :remove
144
+ alias_method :delete, :remove
146
145
 
147
146
  # Stores the model instance by name in the repository of the
148
147
  # model.
@@ -154,7 +153,8 @@ module Vedeu
154
153
  def store(model)
155
154
  unless present?(model.name)
156
155
  fail Vedeu::Error::MissingRequired,
157
- "Cannot store model '#{model.class}' without a name attribute."
156
+ "Cannot store model '#{model.class}' " \
157
+ 'without a name attribute.'.freeze
158
158
  end
159
159
 
160
160
  log_store(model)
@@ -170,7 +170,8 @@ module Vedeu
170
170
  def log_store(model)
171
171
  type = registered?(model.name) ? :update : :create
172
172
 
173
- Vedeu.log(type: type, message: "#{model.class.name}: '#{model.name}'")
173
+ Vedeu.log(type: type,
174
+ message: "#{model.class.name}: '#{model.name}'".freeze)
174
175
  end
175
176
 
176
177
  end # Repository