vedeu 0.8.17 → 0.8.18

Sign up to get free protection for your applications and to get access to all the features.
Files changed (85) hide show
  1. checksums.yaml +4 -4
  2. data/Guardfile +1 -1
  3. data/docs/configuration/base_path.md +11 -0
  4. data/docs/configuration/colour.md +6 -0
  5. data/docs/configuration/colour_mode.md +13 -0
  6. data/docs/configuration/compression.md +22 -0
  7. data/docs/configuration/cooked.md +7 -0
  8. data/docs/configuration/debug.md +20 -0
  9. data/docs/configuration/drb_height.md +6 -0
  10. data/docs/configuration/drb_width.md +6 -0
  11. data/docs/configuration/fake.md +6 -0
  12. data/docs/configuration/height.md +12 -0
  13. data/docs/configuration/log.md +15 -0
  14. data/docs/configuration/log_except.md +11 -0
  15. data/docs/configuration/log_only.md +11 -0
  16. data/docs/configuration/mouse.md +11 -0
  17. data/docs/configuration/profile.md +22 -0
  18. data/docs/configuration/raw.md +7 -0
  19. data/docs/configuration/renderer.md +13 -0
  20. data/docs/configuration/root.md +9 -0
  21. data/docs/configuration/stderr.md +6 -0
  22. data/docs/configuration/stdin.md +6 -0
  23. data/docs/configuration/stdout.md +6 -0
  24. data/docs/configuration/terminal_mode.md +23 -0
  25. data/docs/configuration/threaded.md +3 -0
  26. data/docs/configuration/width.md +11 -0
  27. data/integrations/dsl_app_001.rb +1 -1
  28. data/integrations/dsl_app_002.rb +1 -1
  29. data/integrations/dsl_app_003.rb +1 -1
  30. data/integrations/dsl_app_004.rb +1 -1
  31. data/integrations/dsl_app_005.rb +1 -1
  32. data/integrations/dsl_app_006.rb +1 -1
  33. data/integrations/dsl_app_007.rb +1 -1
  34. data/integrations/dsl_app_008.rb +1 -1
  35. data/integrations/dsl_app_009.rb +1 -1
  36. data/integrations/dsl_app_010.rb +1 -1
  37. data/integrations/dsl_app_011.rb +1 -1
  38. data/integrations/dsl_app_012.rb +1 -1
  39. data/integrations/dsl_app_013.rb +1 -1
  40. data/integrations/dsl_app_014.rb +1 -1
  41. data/integrations/dsl_app_015.rb +1 -1
  42. data/integrations/dsl_app_016.rb +1 -1
  43. data/integrations/dsl_app_017.rb +1 -1
  44. data/integrations/dsl_app_018.rb +1 -1
  45. data/integrations/dsl_app_019.rb +1 -1
  46. data/integrations/dsl_app_020.rb +1 -1
  47. data/integrations/dsl_app_021.rb +1 -1
  48. data/integrations/dsl_app_022.rb +1 -1
  49. data/integrations/dsl_app_border_001.rb +1 -1
  50. data/integrations/dsl_app_border_002.rb +1 -1
  51. data/integrations/dsl_app_border_003.rb +1 -1
  52. data/integrations/dsl_app_border_004.rb +1 -1
  53. data/integrations/dsl_app_border_005.rb +1 -1
  54. data/lib/vedeu/application/application_view.rb +3 -3
  55. data/lib/vedeu/coercers/coercer.rb +17 -6
  56. data/lib/vedeu/coercers/colour.rb +2 -2
  57. data/lib/vedeu/coercers/editor_line.rb +1 -1
  58. data/lib/vedeu/colours/translator.rb +7 -4
  59. data/lib/vedeu/common.rb +1 -1
  60. data/lib/vedeu/configuration/api.rb +24 -279
  61. data/lib/vedeu/configuration/configuration.rb +53 -53
  62. data/lib/vedeu/distributed/all.rb +0 -1
  63. data/lib/vedeu/distributed/subprocess.rb +3 -4
  64. data/lib/vedeu/error.rb +11 -6
  65. data/lib/vedeu/events/trigger.rb +1 -1
  66. data/lib/vedeu/groups/group.rb +0 -1
  67. data/lib/vedeu/logging/log.rb +7 -8
  68. data/lib/vedeu/renderers/support/options.rb +2 -2
  69. data/lib/vedeu/support/point.rb +1 -1
  70. data/lib/vedeu/version.rb +1 -1
  71. data/test/lib/vedeu/coercers/coercer_test.rb +9 -3
  72. data/test/lib/vedeu/coercers/editor_line_test.rb +12 -5
  73. data/test/lib/vedeu/common_test.rb +6 -0
  74. data/test/lib/vedeu/configuration/configuration_test.rb +0 -6
  75. data/test/lib/vedeu/error_test.rb +19 -9
  76. data/test/lib/vedeu/repositories/assemblage_test.rb +2 -2
  77. data/test/lib/vedeu/repositories/collection_test.rb +5 -2
  78. data/test/lib/vedeu/repositories/model_test.rb +16 -2
  79. data/test/lib/vedeu/repositories/registerable_test.rb +7 -2
  80. data/test/lib/vedeu/support/point_test.rb +6 -0
  81. data/test/test_helper.rb +0 -1
  82. metadata +26 -7
  83. data/lib/vedeu/distributed/test_application.rb +0 -117
  84. data/test/lib/vedeu/distributed/test_application_test.rb +0 -95
  85. data/test/support/helpers/model_test_class.rb +0 -74
@@ -2,6 +2,48 @@
2
2
 
3
3
  module Vedeu
4
4
 
5
+ # The defined message types for Vedeu with their respective
6
+ # colours. When used, produces a log entry of the format:
7
+ #
8
+ # [type] message
9
+ #
10
+ # The 'type' will be shown as the first colour defined in the
11
+ # value array, whilst the 'message' will be shown using the
12
+ # last colour.
13
+ #
14
+ # @return [Hash<Symbol => Array<Symbol>>]
15
+ LOG_TYPES = {
16
+ blue: [:light_blue, :blue],
17
+ buffer: [:light_green, :green],
18
+ compress: [:white, :light_grey],
19
+ config: [:light_blue, :blue],
20
+ create: [:light_cyan, :cyan],
21
+ cursor: [:light_green, :green],
22
+ cyan: [:light_cyan, :cyan],
23
+ debug: [:white, :light_grey],
24
+ drb: [:light_blue, :blue],
25
+ dsl: [:light_blue, :blue],
26
+ editor: [:light_blue, :blue],
27
+ error: [:light_red, :red],
28
+ event: [:light_magenta, :magenta],
29
+ green: [:light_green, :green],
30
+ info: [:white, :light_grey],
31
+ input: [:light_yellow, :yellow],
32
+ magenta: [:light_magenta, :magenta],
33
+ output: [:light_yellow, :yellow],
34
+ red: [:light_red, :red],
35
+ render: [:light_green, :green],
36
+ reset: [:light_cyan, :cyan],
37
+ store: [:light_cyan, :cyan],
38
+ test: [:white, :light_grey],
39
+ timer: [:light_blue, :blue],
40
+ update: [:light_cyan, :cyan],
41
+ white: [:white, :light_grey],
42
+ yellow: [:light_yellow, :yellow],
43
+ }.freeze
44
+
45
+ LOG_TYPES_KEYS = Vedeu::LOG_TYPES.keys.freeze
46
+
5
47
  # Allows the customisation of Vedeu's behaviour through the
6
48
  # configuration API.
7
49
  #
@@ -186,48 +228,6 @@ module Vedeu
186
228
  instance.options[:log_only]
187
229
  end
188
230
 
189
- # The defined message types for Vedeu with their respective
190
- # colours. When used, produces a log entry of the format:
191
- #
192
- # [type] message
193
- #
194
- # The 'type' will be shown as the first colour defined in the
195
- # value array, whilst the 'message' will be shown using the
196
- # last colour.
197
- #
198
- # @return [Hash<Symbol => Array<Symbol>>]
199
- def log_types
200
- {
201
- blue: [:light_blue, :blue],
202
- buffer: [:light_green, :green],
203
- compress: [:white, :light_grey],
204
- config: [:light_blue, :blue],
205
- create: [:light_cyan, :cyan],
206
- cursor: [:light_green, :green],
207
- cyan: [:light_cyan, :cyan],
208
- debug: [:white, :light_grey],
209
- drb: [:light_blue, :blue],
210
- dsl: [:light_blue, :blue],
211
- editor: [:light_blue, :blue],
212
- error: [:light_red, :red],
213
- event: [:light_magenta, :magenta],
214
- green: [:light_green, :green],
215
- info: [:white, :light_grey],
216
- input: [:light_yellow, :yellow],
217
- magenta: [:light_magenta, :magenta],
218
- output: [:light_yellow, :yellow],
219
- red: [:light_red, :red],
220
- render: [:light_green, :green],
221
- reset: [:light_cyan, :cyan],
222
- store: [:light_cyan, :cyan],
223
- test: [:white, :light_grey],
224
- timer: [:light_blue, :blue],
225
- update: [:light_cyan, :cyan],
226
- white: [:white, :light_grey],
227
- yellow: [:light_yellow, :yellow],
228
- }
229
- end
230
-
231
231
  # Returns true if the given type was included in the :log_only
232
232
  # configuration option or not included in the :log_except
233
233
  # option.
@@ -235,20 +235,20 @@ module Vedeu
235
235
  # @param type [Symbol]
236
236
  # @return [Boolean]
237
237
  def loggable?(type)
238
- return false unless log_types.keys.include?(type)
239
- return true if log_only.empty? && log_except.empty?
238
+ return false unless log?
239
+ return false unless Vedeu::LOG_TYPES_KEYS.include?(type)
240
+ return true if log_only.empty? && log_except.empty?
240
241
 
241
- types = if log_except.any?
242
- log_types.keys - log_except
243
- else
244
- log_types.keys
245
- end
242
+ if log_except.any?
243
+ Vedeu::LOG_TYPES_KEYS - log_except
244
+
245
+ elsif log_only.any?
246
+ log_only
246
247
 
247
- if log_only.any?
248
- log_only.include?(type)
249
248
  else
250
- types.include?(type) ? true : false
251
- end
249
+ Vedeu::LOG_TYPES_KEYS
250
+
251
+ end.include?(type)
252
252
  end
253
253
 
254
254
  # Returns whether mouse support was enabled or disabled.
@@ -31,4 +31,3 @@ require 'vedeu/distributed/uri'
31
31
  require 'vedeu/distributed/server'
32
32
  require 'vedeu/distributed/client'
33
33
  require 'vedeu/distributed/subprocess'
34
- require 'vedeu/distributed/test_application'
@@ -4,8 +4,7 @@ module Vedeu
4
4
 
5
5
  module Distributed
6
6
 
7
- # @example
8
- # Vedeu::TestApplication.build
7
+ # Creates a subprocess of the DRb server.
9
8
  #
10
9
  class Subprocess
11
10
 
@@ -16,7 +15,7 @@ module Vedeu
16
15
 
17
16
  # Returns a new instance of Vedeu::Distributed::Subprocess.
18
17
  #
19
- # @param application [Vedeu::TestApplication]
18
+ # @param application [void]
20
19
  # @return [Vedeu::Distributed::Subprocess]
21
20
  def initialize(application)
22
21
  @application = application
@@ -50,7 +49,7 @@ module Vedeu
50
49
  protected
51
50
 
52
51
  # @!attribute [r] application
53
- # @return [Vedeu::TestApplication]
52
+ # @return [void]
54
53
  attr_reader :application
55
54
 
56
55
  # @!attribute [r] pid
data/lib/vedeu/error.rb CHANGED
@@ -98,16 +98,21 @@ module Vedeu
98
98
  # Raised to remind me (or client application developers) that the
99
99
  # subclass implements the functionality sought.
100
100
  #
101
- # @see Vedeu::Colours::Translator
102
- #
103
101
  # @!macro [new] raise_not_implemented
104
- # @raise [Vedeu::Error::NotImplemented] When a subclass of the
105
- # current class actually implements the method. Usually an
106
- # indicator that the subclass should be used instead of the
107
- # current class.
102
+ # @raise [Vedeu::Error::NotImplemented] When the method called
103
+ # should be handled by a subclass of the current class, or
104
+ # by the class including or extending the current module.
108
105
  #
109
106
  class NotImplemented < StandardError
110
107
 
108
+ # Returns an error message.
109
+ #
110
+ # @return [String]
111
+ def message
112
+ 'Subclasses of this class or classes including/extending ' \
113
+ 'this module should implement this method.'
114
+ end
115
+
111
116
  end # NotImplemented
112
117
 
113
118
  # Raised when trying to access an interface column less than 1 or
@@ -41,7 +41,7 @@ module Vedeu
41
41
  #
42
42
  # @return [Array]
43
43
  def trigger
44
- if results.empty?
44
+ if Vedeu.config.debug? && results.empty?
45
45
  Vedeu.log(type: :event,
46
46
  message: "No action for: '#{name.inspect}'")
47
47
  end
@@ -193,5 +193,4 @@ module Vedeu
193
193
  :show_group,
194
194
  :toggle_group
195
195
 
196
-
197
196
  end # Vedeu
@@ -24,12 +24,11 @@ module Vedeu
24
24
  #
25
25
  # @macro vedeu_logging_log_param_message
26
26
  # @param type [Symbol] Colour code messages in the log file
27
- # depending on their source. See
28
- # {Vedeu::Configuration.log_types}
27
+ # depending on their source. See {Vedeu::LOG_TYPES}
29
28
  #
30
29
  # @return [String]
31
30
  def log(message:, type: :info)
32
- if Vedeu.config.log? && Vedeu.config.loggable?(type)
31
+ if Vedeu.config.loggable?(type)
33
32
  output = log_entry(type, message)
34
33
  logger.debug(output)
35
34
  output
@@ -38,8 +37,8 @@ module Vedeu
38
37
 
39
38
  # {include:file:docs/dsl/by_method/log_stdout.md}
40
39
  # @macro vedeu_logging_log_param_message
41
- # @param type [Symbol] See {Vedeu::Configuration.log_types}
42
- # for valid values.
40
+ # @param type [Symbol] See {Vedeu::LOG_TYPES} for valid
41
+ # values.
43
42
  # @return [String]
44
43
  def log_stdout(message:, type: :info)
45
44
  log(message: message, type: type)
@@ -49,8 +48,8 @@ module Vedeu
49
48
 
50
49
  # {include:file:docs/dsl/by_method/log_stderr.md}
51
50
  # @macro vedeu_logging_log_param_message
52
- # @param type [Symbol] See {Vedeu::Logging::Log.types}
53
- # for valid values.
51
+ # @param type [Symbol] See {Vedeu::LOG_TYPES} for valid
52
+ # values.
54
53
  # @return [String]
55
54
  def log_stderr(message:, type: :error)
56
55
  log(message: message, type: type)
@@ -100,7 +99,7 @@ module Vedeu
100
99
  # @macro vedeu_logging_log_param_message
101
100
  # @return [String]
102
101
  def log_entry(type, message)
103
- colours = Vedeu.config.log_types.fetch(type, [:default, :default])
102
+ colours = Vedeu::LOG_TYPES.fetch(type, [:default, :default])
104
103
 
105
104
  [
106
105
  Vedeu.esc.colour(colours[0]) { "[#{type}]".ljust(11) },
@@ -53,7 +53,7 @@ module Vedeu
53
53
 
54
54
  # @macro raise_not_implemented
55
55
  def write
56
- raise Vedeu::Error::NotImplemented, 'Including classes implement this.'
56
+ raise Vedeu::Error::NotImplemented
57
57
  end
58
58
 
59
59
  private
@@ -81,7 +81,7 @@ module Vedeu
81
81
 
82
82
  # @macro raise_not_implemented
83
83
  def content
84
- raise Vedeu::Error::NotImplemented, 'Including classes implement this.'
84
+ raise Vedeu::Error::NotImplemented
85
85
  end
86
86
 
87
87
  # @macro defaults_method
@@ -79,7 +79,7 @@ module Vedeu
79
79
  # @macro raise_invalid_syntax
80
80
  # @return [Fixnum]
81
81
  def max
82
- return @max if numeric?(@max) || @max == Float::INFINITY
82
+ return @max if numeric?(@max)
83
83
 
84
84
  raise Vedeu::Error::InvalidSyntax,
85
85
  "Expecting 'max' to be a Fixnum or Float::INFINITY."
data/lib/vedeu/version.rb CHANGED
@@ -3,6 +3,6 @@
3
3
  module Vedeu
4
4
 
5
5
  # The current version of Vedeu.
6
- VERSION = '0.8.17'
6
+ VERSION = '0.8.18'
7
7
 
8
8
  end
@@ -8,13 +8,19 @@ module Vedeu
8
8
 
9
9
  describe Coercer do
10
10
 
11
- let(:described) { Vedeu::Coercers::Coercer }
12
- let(:instance) { described.new(_value) }
13
- let(:_value) {}
11
+ let(:described) { Vedeu::Coercers::Coercer }
12
+ let(:instance) { described.new(_value, attributes) }
13
+ let(:_value) {}
14
+ let(:attributes) {
15
+ {}
16
+ }
14
17
 
15
18
  describe '#initialize' do
16
19
  it { instance.must_be_instance_of(described) }
17
20
  it { instance.instance_variable_get('@value').must_equal(_value) }
21
+ it do
22
+ instance.instance_variable_get('@attributes').must_equal(attributes)
23
+ end
18
24
  end
19
25
 
20
26
  describe '.coerce' do
@@ -35,19 +35,26 @@ module Vedeu
35
35
  end
36
36
 
37
37
  context 'when the value is a String' do
38
- context 'when the value is empty' do
39
- let(:_value) { '' }
38
+ let(:_value) { '' }
39
+
40
+ it { subject.must_be_instance_of(klass) }
40
41
 
41
- it { subject.must_be_instance_of(klass) }
42
+ context 'when the value is empty' do
42
43
  it { subject.collection.must_equal('') }
43
44
  end
44
45
 
45
- context 'when the value is an String' do
46
+ context 'when the value is not empty' do
46
47
  let(:_value) { 'some value...' }
47
48
 
48
- it { subject.must_be_instance_of(klass) }
49
49
  it { subject.collection.must_equal(_value) }
50
50
  end
51
+
52
+ context 'when the value contains a line feed' do
53
+ let(:_value) { "some value...\n" }
54
+ let(:expected) { 'some value...' }
55
+
56
+ it { subject.collection.must_equal(expected) }
57
+ end
51
58
  end
52
59
 
53
60
  context 'when the value is not already the target class or ' \
@@ -270,6 +270,12 @@ module Vedeu
270
270
  it { subject.must_equal(true) }
271
271
  end
272
272
 
273
+ context 'when the value is a Float::INFINITY' do
274
+ let(:_value) { Float::INFINITY }
275
+
276
+ it { subject.must_equal(true) }
277
+ end
278
+
273
279
  context 'when the value is not numeric' do
274
280
  it { subject.must_equal(false) }
275
281
  end
@@ -141,12 +141,6 @@ module Vedeu
141
141
  end
142
142
  end
143
143
 
144
- describe '.log_types' do
145
- subject { described.log_types }
146
-
147
- it { subject.must_be_instance_of(Hash) }
148
- end
149
-
150
144
  describe '.loggable?' do
151
145
  subject { described.loggable?(type) }
152
146
 
@@ -7,31 +7,41 @@ module Vedeu
7
7
  module Error
8
8
 
9
9
  describe ActionNotFound do
10
- end
10
+ end # ActionNotFound
11
11
 
12
12
  describe ControllerNotFound do
13
- end
13
+ end # ControllerNotFound
14
14
 
15
15
  describe Fatal do
16
- end
16
+ end # Fatal
17
17
 
18
18
  describe Interrupt do
19
- end
19
+ end # Interrupt
20
20
 
21
21
  describe InvalidSyntax do
22
- end
22
+ end # InvalidSyntax
23
23
 
24
24
  describe MissingRequired do
25
- end
25
+ end # MissingRequired
26
26
 
27
27
  describe ModelNotFound do
28
- end
28
+ end # ModelNotFound
29
29
 
30
30
  describe ModeSwitch do
31
- end
31
+ end # ModeSwitch
32
32
 
33
33
  describe NotImplemented do
34
- end
34
+
35
+ let(:described) { Vedeu::Error::NotImplemented }
36
+ let(:instance) { described.new }
37
+
38
+ describe '#message' do
39
+ subject { instance.message }
40
+
41
+ it { subject.must_be_instance_of(String) }
42
+ end
43
+
44
+ end # NotImplemented
35
45
 
36
46
  describe OutOfRange do
37
47
 
@@ -6,7 +6,7 @@ module Vedeu
6
6
 
7
7
  module Repositories
8
8
 
9
- class CollectionTestClass
9
+ class AssemblageTestClass
10
10
 
11
11
  include Vedeu::Repositories::Assemblage
12
12
 
@@ -21,7 +21,7 @@ module Vedeu
21
21
  describe Assemblage do
22
22
 
23
23
  let(:described) { Vedeu::Repositories::Assemblage }
24
- let(:included_described) { Vedeu::Repositories::CollectionTestClass }
24
+ let(:included_described) { Vedeu::Repositories::AssemblageTestClass }
25
25
  let(:included_instance) { included_described.new(collection) }
26
26
  let(:collection) { 'Some text...'.chars }
27
27