vedeu 0.8.6 → 0.8.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (152) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +2 -2
  3. data/.travis.yml +1 -1
  4. data/README.md +2 -6
  5. data/config/rubocop_enabled.yml +0 -6
  6. data/docs/dsl/by_method/clock_time.md +4 -1
  7. data/lib/vedeu/application/application_controller.rb +2 -2
  8. data/lib/vedeu/application/controller.rb +3 -3
  9. data/lib/vedeu/borders/border.rb +6 -6
  10. data/lib/vedeu/borders/dsl.rb +26 -26
  11. data/lib/vedeu/borders/refresh.rb +2 -2
  12. data/lib/vedeu/borders/title.rb +4 -4
  13. data/lib/vedeu/buffers/refresh.rb +8 -7
  14. data/lib/vedeu/buffers/terminal.rb +1 -1
  15. data/lib/vedeu/buffers/view.rb +2 -2
  16. data/lib/vedeu/cells/clear.rb +1 -1
  17. data/lib/vedeu/cells/cursor.rb +6 -6
  18. data/lib/vedeu/cells/empty.rb +2 -2
  19. data/lib/vedeu/cells/escape.rb +6 -6
  20. data/lib/vedeu/coercers/alignment.rb +1 -1
  21. data/lib/vedeu/coercers/colour_attributes.rb +8 -16
  22. data/lib/vedeu/colours/background.rb +4 -8
  23. data/lib/vedeu/colours/colour.rb +4 -4
  24. data/lib/vedeu/colours/foreground.rb +4 -8
  25. data/lib/vedeu/colours/repository.rb +1 -1
  26. data/lib/vedeu/colours/translator.rb +6 -6
  27. data/lib/vedeu/common.rb +1 -1
  28. data/lib/vedeu/configuration/api.rb +15 -15
  29. data/lib/vedeu/configuration/configuration.rb +8 -8
  30. data/lib/vedeu/cursors/coordinate.rb +4 -4
  31. data/lib/vedeu/cursors/cursor.rb +2 -2
  32. data/lib/vedeu/distributed/client.rb +2 -2
  33. data/lib/vedeu/distributed/server.rb +8 -10
  34. data/lib/vedeu/distributed/subprocess.rb +1 -1
  35. data/lib/vedeu/distributed/uri.rb +1 -1
  36. data/lib/vedeu/dsl/cursors.rb +2 -2
  37. data/lib/vedeu/dsl/elements.rb +5 -5
  38. data/lib/vedeu/dsl/helpers/align.rb +1 -1
  39. data/lib/vedeu/dsl/helpers/attributes.rb +1 -1
  40. data/lib/vedeu/dsl/presentation.rb +15 -15
  41. data/lib/vedeu/dsl/view.rb +1 -1
  42. data/lib/vedeu/dsl/views.rb +1 -1
  43. data/lib/vedeu/editor/cursor.rb +1 -1
  44. data/lib/vedeu/editor/line.rb +2 -2
  45. data/lib/vedeu/editor/lines.rb +2 -2
  46. data/lib/vedeu/esc/borders.rb +19 -19
  47. data/lib/vedeu/esc/colours.rb +1 -1
  48. data/lib/vedeu/events/aliases.rb +3 -15
  49. data/lib/vedeu/events/event.rb +14 -14
  50. data/lib/vedeu/events/repository.rb +1 -1
  51. data/lib/vedeu/geometries/area/area.rb +5 -5
  52. data/lib/vedeu/geometries/area/dimension.rb +1 -1
  53. data/lib/vedeu/geometries/dsl/dsl.rb +7 -7
  54. data/lib/vedeu/geometries/geometry.rb +2 -2
  55. data/lib/vedeu/geometries/position.rb +6 -6
  56. data/lib/vedeu/groups/clear.rb +2 -2
  57. data/lib/vedeu/groups/group.rb +2 -2
  58. data/lib/vedeu/input/dsl.rb +1 -1
  59. data/lib/vedeu/input/key.rb +3 -3
  60. data/lib/vedeu/input/mapper.rb +2 -2
  61. data/lib/vedeu/input/read.rb +2 -4
  62. data/lib/vedeu/input/store.rb +1 -17
  63. data/lib/vedeu/input/translator.rb +49 -45
  64. data/lib/vedeu/interfaces/clear.rb +3 -3
  65. data/lib/vedeu/interfaces/dsl.rb +4 -4
  66. data/lib/vedeu/interfaces/interface.rb +2 -2
  67. data/lib/vedeu/logging/clock_time.rb +3 -3
  68. data/lib/vedeu/logging/debug.rb +14 -6
  69. data/lib/vedeu/logging/log.rb +1 -1
  70. data/lib/vedeu/menus/dsl.rb +2 -2
  71. data/lib/vedeu/menus/menu.rb +9 -9
  72. data/lib/vedeu/models/focus.rb +11 -11
  73. data/lib/vedeu/models/page.rb +1 -1
  74. data/lib/vedeu/models/row.rb +1 -1
  75. data/lib/vedeu/models/toggleable.rb +7 -7
  76. data/lib/vedeu/null/generic.rb +29 -29
  77. data/lib/vedeu/output/compressor_cache.rb +1 -11
  78. data/lib/vedeu/output/viewport.rb +4 -12
  79. data/lib/vedeu/output/write.rb +3 -3
  80. data/lib/vedeu/plugins/plugin.rb +1 -1
  81. data/lib/vedeu/presentation/colour.rb +1 -1
  82. data/lib/vedeu/presentation/presentation.rb +1 -1
  83. data/lib/vedeu/presentation/style.rb +4 -4
  84. data/lib/vedeu/renderers/all.rb +1 -14
  85. data/lib/vedeu/renderers/options.rb +1 -1
  86. data/lib/vedeu/repositories/all.rb +1 -0
  87. data/lib/vedeu/repositories/assemblage.rb +1 -1
  88. data/lib/vedeu/repositories/collection.rb +4 -4
  89. data/lib/vedeu/repositories/registerable.rb +2 -2
  90. data/lib/vedeu/repositories/repositories.rb +1 -1
  91. data/lib/vedeu/repositories/repository.rb +3 -3
  92. data/lib/vedeu/repositories/storage.rb +38 -0
  93. data/lib/vedeu/repositories/store.rb +5 -22
  94. data/lib/vedeu/runtime/application.rb +1 -1
  95. data/lib/vedeu/runtime/flags.rb +3 -3
  96. data/lib/vedeu/runtime/router.rb +3 -18
  97. data/lib/vedeu/templating/helpers.rb +5 -3
  98. data/lib/vedeu/templating/view_template.rb +26 -18
  99. data/lib/vedeu/terminal/terminal.rb +5 -5
  100. data/lib/vedeu/version.rb +1 -1
  101. data/lib/vedeu/views/chars.rb +1 -1
  102. data/lib/vedeu/views/composition.rb +4 -4
  103. data/lib/vedeu/views/default_attributes.rb +2 -2
  104. data/lib/vedeu/views/line.rb +6 -6
  105. data/lib/vedeu/views/lines.rb +1 -1
  106. data/lib/vedeu/views/stream.rb +6 -6
  107. data/lib/vedeu/views/streams.rb +1 -1
  108. data/lib/vedeu/views/view.rb +4 -4
  109. data/test/lib/vedeu/borders/border_test.rb +1 -1
  110. data/test/lib/vedeu/borders/caption_test.rb +1 -1
  111. data/test/lib/vedeu/borders/dsl_test.rb +2 -3
  112. data/test/lib/vedeu/borders/refresh_test.rb +1 -1
  113. data/test/lib/vedeu/borders/title_test.rb +1 -1
  114. data/test/lib/vedeu/buffers/buffer_test.rb +7 -7
  115. data/test/lib/vedeu/buffers/refresh_test.rb +1 -1
  116. data/test/lib/vedeu/colours/background_test.rb +27 -0
  117. data/test/lib/vedeu/colours/foreground_test.rb +27 -0
  118. data/test/lib/vedeu/cursors/cursor_test.rb +3 -3
  119. data/test/lib/vedeu/cursors/move_test.rb +1 -1
  120. data/test/lib/vedeu/cursors/refresh_test.rb +1 -1
  121. data/test/lib/vedeu/cursors/reposition_test.rb +2 -2
  122. data/test/lib/vedeu/dsl/view_test.rb +6 -8
  123. data/test/lib/vedeu/editor/cropper_test.rb +1 -1
  124. data/test/lib/vedeu/editor/cursor_test.rb +1 -1
  125. data/test/lib/vedeu/editor/document_test.rb +1 -1
  126. data/test/lib/vedeu/editor/editor_test.rb +1 -1
  127. data/test/lib/vedeu/events/aliases_test.rb +0 -14
  128. data/test/lib/vedeu/geometries/area/area_test.rb +1 -1
  129. data/test/lib/vedeu/geometries/geometry_test.rb +1 -1
  130. data/test/lib/vedeu/geometries/move_test.rb +1 -1
  131. data/test/lib/vedeu/groups/clear_test.rb +1 -1
  132. data/test/lib/vedeu/groups/dsl_test.rb +1 -1
  133. data/test/lib/vedeu/groups/group_test.rb +1 -1
  134. data/test/lib/vedeu/groups/refresh_test.rb +1 -1
  135. data/test/lib/vedeu/input/capture_test.rb +2 -2
  136. data/test/lib/vedeu/input/store_test.rb +0 -34
  137. data/test/lib/vedeu/interfaces/clear_test.rb +1 -1
  138. data/test/lib/vedeu/interfaces/dsl_test.rb +4 -4
  139. data/test/lib/vedeu/interfaces/interface_test.rb +1 -1
  140. data/test/lib/vedeu/menus/dsl_test.rb +1 -1
  141. data/test/lib/vedeu/null/generic_test.rb +1 -1
  142. data/test/lib/vedeu/output/compressor_cache_test.rb +0 -33
  143. data/test/lib/vedeu/renderers/all_test.rb +0 -8
  144. data/test/lib/vedeu/repositories/repository_test.rb +2 -2
  145. data/test/lib/vedeu/repositories/storage_test.rb +74 -0
  146. data/test/lib/vedeu/repositories/store_test.rb +10 -28
  147. data/test/lib/vedeu/runtime/router_test.rb +0 -8
  148. data/test/lib/vedeu/views/default_attributes_test.rb +5 -5
  149. data/test/lib/vedeu/views/view_test.rb +5 -2
  150. data/test/test_helper.rb +1 -1
  151. data/vedeu.gemspec +1 -1
  152. metadata +7 -4
@@ -59,7 +59,7 @@ module Vedeu
59
59
  # @!attribute [r] output
60
60
  # @return [String]
61
61
  attr_reader :output
62
- alias_method :value, :output
62
+ alias value output
63
63
 
64
64
  private
65
65
 
@@ -75,7 +75,7 @@ module Vedeu
75
75
  def options
76
76
  defaults.merge!(@options)
77
77
  end
78
- alias_method :attributes, :options
78
+ alias attributes options
79
79
 
80
80
  # @return [String]
81
81
  def output
@@ -102,7 +102,7 @@ module Vedeu
102
102
  def to_s
103
103
  @_to_s ||= super + Vedeu.esc.reset + position(position_end)
104
104
  end
105
- alias_method :to_str, :to_s
105
+ alias to_str to_s
106
106
 
107
107
  end # Write
108
108
 
@@ -21,7 +21,7 @@ module Vedeu
21
21
  # @!attribute [rw] enabled
22
22
  # @return [Boolean]
23
23
  attr_accessor :enabled
24
- alias_method :enabled?, :enabled
24
+ alias enabled? enabled
25
25
 
26
26
  # Returns a new instance of Vedeu::Plugin.
27
27
  #
@@ -125,7 +125,7 @@ module Vedeu
125
125
 
126
126
  # @return [Boolean]
127
127
  def named_colour?
128
- return false if self.is_a?(Vedeu::Interfaces::Interface)
128
+ return false if is_a?(Vedeu::Interfaces::Interface)
129
129
 
130
130
  present?(name) && Vedeu.interfaces.registered?(name)
131
131
  end
@@ -16,7 +16,7 @@ module Vedeu
16
16
  def to_s
17
17
  render_position { render_colour { render_style { value } } }
18
18
  end
19
- alias_method :to_str, :to_s
19
+ alias to_str to_s
20
20
 
21
21
  private
22
22
 
@@ -62,7 +62,7 @@ module Vedeu
62
62
  # @return [Hash<Symbol => Array<String|Symbol>|String|Symbol>]
63
63
  def attributes
64
64
  {
65
- style: value
65
+ style: value,
66
66
  }
67
67
  end
68
68
 
@@ -73,7 +73,7 @@ module Vedeu
73
73
  def eql?(other)
74
74
  self.class == other.class && value == other.value
75
75
  end
76
- alias_method :==, :eql?
76
+ alias == eql?
77
77
 
78
78
  # @return [String]
79
79
  def to_ast
@@ -89,8 +89,8 @@ module Vedeu
89
89
 
90
90
  @sequences ||= Array(value).flat_map { |v| Vedeu.esc.string(v) }.join
91
91
  end
92
- alias_method :escape_sequences, :to_s
93
- alias_method :to_str, :to_s
92
+ alias escape_sequences to_s
93
+ alias to_str to_s
94
94
 
95
95
  end # Style
96
96
 
@@ -8,6 +8,7 @@ module Vedeu
8
8
 
9
9
  extend Enumerable
10
10
  extend self
11
+ extend Vedeu::Repositories::Storage
11
12
 
12
13
  # Instructs each renderer registered with Vedeu to clear their
13
14
  # content.
@@ -56,15 +57,6 @@ module Vedeu
56
57
  output
57
58
  end
58
59
 
59
- # @example
60
- # Vedeu.renderers.reset!
61
- #
62
- # @return [Set]
63
- def reset!
64
- @storage = in_memory
65
- end
66
- alias_method :reset, :reset!
67
-
68
60
  private
69
61
 
70
62
  # @return [Set]
@@ -91,11 +83,6 @@ module Vedeu
91
83
  @mutex ||= Mutex.new
92
84
  end
93
85
 
94
- # @return [Set]
95
- def storage
96
- @storage ||= in_memory
97
- end
98
-
99
86
  # @param block [Proc]
100
87
  # @return [void]
101
88
  def threaded(renderer, &block)
@@ -44,7 +44,7 @@ module Vedeu
44
44
  # @param output [Vedeu::Models::Page]
45
45
  # @return [void]
46
46
  def render(output = '')
47
- options.merge!(output: output)
47
+ options[:output] = output
48
48
 
49
49
  write
50
50
  end
@@ -10,6 +10,7 @@ module Vedeu
10
10
 
11
11
  end # Vedeu
12
12
 
13
+ require 'vedeu/repositories/storage'
13
14
  require 'vedeu/repositories/assemblage'
14
15
  require 'vedeu/repositories/collection'
15
16
  require 'vedeu/repositories/defaults'
@@ -52,7 +52,7 @@ module Vedeu
52
52
  def eql?(other)
53
53
  self.class == other.class && collection == other.collection
54
54
  end
55
- alias_method :==, :eql?
55
+ alias == eql?
56
56
 
57
57
  # Return the size of the collection.
58
58
  #
@@ -16,8 +16,8 @@ module Vedeu
16
16
  # @!attribute [r] collection
17
17
  # @return [Array|Vedeu::Repositories::Collection]
18
18
  attr_reader :collection
19
- alias_method :all, :collection
20
- alias_method :value, :collection
19
+ alias all collection
20
+ alias value collection
21
21
 
22
22
  # @!attribute [rw] parent
23
23
  # @return [Fixnum]
@@ -66,7 +66,7 @@ module Vedeu
66
66
 
67
67
  end
68
68
  end
69
- alias_method :<<, :add
69
+ alias << add
70
70
 
71
71
  # Returns the collection as a String.
72
72
  #
@@ -74,7 +74,7 @@ module Vedeu
74
74
  def to_s
75
75
  collection.map(&:to_s).join
76
76
  end
77
- alias_method :to_str, :to_s
77
+ alias to_str to_s
78
78
 
79
79
  end # Collection
80
80
 
@@ -60,7 +60,7 @@ module Vedeu
60
60
  def reset!
61
61
  @models = register
62
62
  end
63
- alias_method :reset, :reset!
63
+ alias reset reset!
64
64
 
65
65
  end # ClassMethods
66
66
 
@@ -72,7 +72,7 @@ module Vedeu
72
72
 
73
73
  # @return [Boolean]
74
74
  def null_model?
75
- self.respond_to?(:null_model) && present?(:null_model)
75
+ respond_to?(:null_model) && present?(:null_model)
76
76
  end
77
77
 
78
78
  end # InstanceMethods
@@ -46,7 +46,7 @@ module Vedeu
46
46
 
47
47
  true
48
48
  end
49
- alias_method :reset, :reset!
49
+ alias reset reset!
50
50
 
51
51
  private
52
52
 
@@ -143,7 +143,7 @@ module Vedeu
143
143
  storage.delete(name)
144
144
  storage unless storage.is_a?(Set)
145
145
  end
146
- alias_method :delete, :remove
146
+ alias delete remove
147
147
 
148
148
  # Stores the model instance by name in the repository of the
149
149
  # model.
@@ -164,8 +164,8 @@ module Vedeu
164
164
 
165
165
  model
166
166
  end
167
- alias_method :register, :store
168
- alias_method :add, :store
167
+ alias register store
168
+ alias add store
169
169
 
170
170
  private
171
171
 
@@ -0,0 +1,38 @@
1
+ module Vedeu
2
+
3
+ module Repositories
4
+
5
+ # Provides behaviour for resetting and accessing the storage of
6
+ # various repositories.
7
+ #
8
+ # @api private
9
+ #
10
+ module Storage
11
+
12
+ extend self
13
+
14
+ # Remove all currently stored data for this repository.
15
+ #
16
+ # @return [void]
17
+ def reset!
18
+ Vedeu.log(type: :reset,
19
+ message: "Resetting repository '#{self.class.name}'")
20
+
21
+ @storage = in_memory
22
+ end
23
+ alias reset reset!
24
+
25
+ # Return whole repository; provides raw access to the storage
26
+ # for this repository.
27
+ #
28
+ # @return [void]
29
+ def storage
30
+ @storage ||= in_memory
31
+ end
32
+ alias all storage
33
+
34
+ end # Storage
35
+
36
+ end # Repositories
37
+
38
+ end # Vedeu
@@ -12,6 +12,10 @@ module Vedeu
12
12
 
13
13
  include Enumerable
14
14
  include Vedeu::Common
15
+ include Vedeu::Repositories::Storage
16
+
17
+ alias all storage
18
+ alias clear reset!
15
19
 
16
20
  # @param block [Proc]
17
21
  # @return [Enumerator]
@@ -36,7 +40,7 @@ module Vedeu
36
40
 
37
41
  storage.include?(name)
38
42
  end
39
- alias_method :registered?, :exists?
43
+ alias registered? exists?
40
44
 
41
45
  # Returns a collection of the names of all the registered
42
46
  # entities.
@@ -50,18 +54,6 @@ module Vedeu
50
54
  storage
51
55
  end
52
56
 
53
- # Remove all currently stored data.
54
- #
55
- # @return [Array|Hash|Set]
56
- def reset!
57
- Vedeu.log(type: :reset,
58
- message: "(#{self.class.name}) #{registered.inspect}")
59
-
60
- @storage = in_memory
61
- end
62
- alias_method :reset, :reset!
63
- alias_method :clear, :reset
64
-
65
57
  # Return the number of entries stored.
66
58
  #
67
59
  # @return [Fixnum]
@@ -69,15 +61,6 @@ module Vedeu
69
61
  storage.size
70
62
  end
71
63
 
72
- # Return whole repository; provides raw access to the storage
73
- # for this repository.
74
- #
75
- # @return [Array|Hash|Set]
76
- def storage
77
- @storage ||= in_memory
78
- end
79
- alias_method :all, :storage
80
-
81
64
  # @return [Hash]
82
65
  def in_memory
83
66
  {}
@@ -36,7 +36,7 @@ module Vedeu
36
36
 
37
37
  Vedeu::Runtime::MainLoop.stop!
38
38
  end
39
- alias_method :exit, :stop
39
+ alias exit stop
40
40
 
41
41
  end # Eigenclass
42
42
 
@@ -30,7 +30,7 @@ module Vedeu
30
30
  def reset!
31
31
  instance.reset!
32
32
  end
33
- alias_method :reset, :reset!
33
+ alias reset reset!
34
34
 
35
35
  end # Eigenclass
36
36
 
@@ -49,14 +49,14 @@ module Vedeu
49
49
  def reset!
50
50
  self.options = defaults
51
51
  end
52
- alias_method :reset, :reset!
52
+ alias reset reset!
53
53
 
54
54
  private
55
55
 
56
56
  # @return [Hash]
57
57
  def defaults
58
58
  {
59
- ready: false
59
+ ready: false,
60
60
  }
61
61
  end
62
62
 
@@ -11,6 +11,7 @@ module Vedeu
11
11
 
12
12
  include Vedeu::Common
13
13
 
14
+ extend Vedeu::Repositories::Storage
14
15
  extend self
15
16
 
16
17
  # Registers a controller with the given controller name for the
@@ -30,7 +31,7 @@ module Vedeu
30
31
  message: "Controller: ':#{controller}'")
31
32
 
32
33
  if registered?(controller)
33
- storage[controller].merge!(klass: klass)
34
+ storage[controller][:klass] = klass
34
35
 
35
36
  else
36
37
  storage.store(controller, klass: klass, actions: [])
@@ -85,7 +86,7 @@ module Vedeu
85
86
 
86
87
  route(controller, action, args) if action_defined?(action, controller)
87
88
  end
88
- alias_method :action, :goto
89
+ alias action goto
89
90
 
90
91
  # Returns a boolean indicating whether the given controller name
91
92
  # is already registered.
@@ -96,14 +97,6 @@ module Vedeu
96
97
  storage.key?(controller)
97
98
  end
98
99
 
99
- # Removes all stored controllers with their respective actions.
100
- #
101
- # @return [Hash<void>]
102
- def reset!
103
- @storage = in_memory
104
- end
105
- alias_method :reset, :reset!
106
-
107
100
  private
108
101
 
109
102
  # Returns a boolean indicating whether the given action name is
@@ -163,14 +156,6 @@ module Vedeu
163
156
  present?(storage[controller][:klass])
164
157
  end
165
158
 
166
- # Returns all the stored controllers and their respective
167
- # actions.
168
- #
169
- # @return [Hash<Symbol => Hash<Symbol => String|Array<Symbol>>>]
170
- def storage
171
- @storage ||= in_memory
172
- end
173
-
174
159
  # Returns an empty collection ready for the storing of client
175
160
  # application controllers and actions.
176
161
  #
@@ -17,7 +17,7 @@ module Vedeu
17
17
  def background(value, &block)
18
18
  define_stream(background: value, &block)
19
19
  end
20
- alias_method :bg, :background
20
+ alias bg background
21
21
 
22
22
  # @param attributes [Hash]
23
23
  # @option attributes foreground [String] The HTML/CSS foreground
@@ -38,7 +38,7 @@ module Vedeu
38
38
  def foreground(value, &block)
39
39
  define_stream(foreground: value, &block)
40
40
  end
41
- alias_method :fg, :foreground
41
+ alias fg foreground
42
42
 
43
43
  # @param value [Symbol]
44
44
  # @param block [Proc]
@@ -53,11 +53,13 @@ module Vedeu
53
53
  def define_stream(attributes = {}, &block)
54
54
  fail Vedeu::Error::RequiresBlock unless block_given?
55
55
 
56
+ value = yield
57
+
56
58
  encode(
57
59
  Vedeu::Views::Stream.build(
58
60
  colour: Vedeu::Colours::Colour.new(attributes),
59
61
  style: Vedeu::Presentation::Style.new(attributes[:style]),
60
- value: block.call))
62
+ value: value))
61
63
  end
62
64
 
63
65
  # @param data [String]