vedeu 0.8.12 → 0.8.13

Sign up to get free protection for your applications and to get access to all the features.
Files changed (112) hide show
  1. checksums.yaml +4 -4
  2. data/bin/vedeu +1 -1
  3. data/docs/dsl/by_method/profile.md +1 -1
  4. data/docs/dsl/by_method/view/repositories.md +4 -0
  5. data/integrations/342_streams.rb +1 -1
  6. data/integrations/dsl_app_001.rb +1 -0
  7. data/integrations/dsl_app_002.rb +1 -0
  8. data/integrations/dsl_app_003.rb +1 -0
  9. data/integrations/dsl_app_004.rb +1 -0
  10. data/integrations/dsl_app_005.rb +1 -0
  11. data/integrations/dsl_app_006.rb +1 -0
  12. data/integrations/dsl_app_007.rb +1 -0
  13. data/integrations/dsl_app_008.rb +1 -0
  14. data/integrations/dsl_app_009.rb +1 -0
  15. data/integrations/dsl_app_010.rb +1 -0
  16. data/integrations/dsl_app_011.rb +1 -0
  17. data/integrations/dsl_app_012.rb +1 -0
  18. data/integrations/dsl_app_013.rb +1 -0
  19. data/integrations/dsl_app_014.rb +1 -0
  20. data/integrations/dsl_app_015.rb +1 -0
  21. data/integrations/dsl_app_016.rb +1 -0
  22. data/integrations/dsl_app_017.rb +1 -0
  23. data/integrations/dsl_app_018.rb +1 -0
  24. data/integrations/dsl_app_019.rb +1 -0
  25. data/integrations/dsl_app_020.rb +1 -0
  26. data/integrations/dsl_app_021.rb +1 -0
  27. data/integrations/dsl_app_022.rb +1 -0
  28. data/integrations/dsl_app_border_001.rb +1 -0
  29. data/integrations/dsl_app_border_002.rb +1 -0
  30. data/integrations/dsl_app_border_003.rb +1 -0
  31. data/integrations/dsl_app_border_004.rb +1 -0
  32. data/integrations/dsl_app_border_005.rb +1 -0
  33. data/lib/vedeu/application/application_view.rb +3 -3
  34. data/lib/vedeu/borders/dsl.rb +2 -2
  35. data/lib/vedeu/borders/title.rb +1 -1
  36. data/lib/vedeu/buffers/view.rb +1 -11
  37. data/lib/vedeu/cells/empty.rb +2 -2
  38. data/lib/vedeu/coercers/alignment.rb +5 -5
  39. data/lib/vedeu/coercers/coercer.rb +4 -5
  40. data/lib/vedeu/coercers/colour_attributes.rb +1 -1
  41. data/lib/vedeu/coercers/horizontal_alignment.rb +3 -3
  42. data/lib/vedeu/coercers/position.rb +4 -9
  43. data/lib/vedeu/coercers/vertical_alignment.rb +3 -3
  44. data/lib/vedeu/colours/colour.rb +2 -1
  45. data/lib/vedeu/colours/translator.rb +2 -2
  46. data/lib/vedeu/common.rb +20 -1
  47. data/lib/vedeu/configuration/api.rb +8 -6
  48. data/lib/vedeu/configuration/configuration.rb +2 -2
  49. data/lib/vedeu/cursors/coordinate.rb +2 -2
  50. data/lib/vedeu/cursors/cursor.rb +3 -2
  51. data/lib/vedeu/dsl/border.rb +1 -1
  52. data/lib/vedeu/dsl/elements.rb +9 -9
  53. data/lib/vedeu/dsl/geometry.rb +3 -3
  54. data/lib/vedeu/dsl/helpers/wordwrap.rb +4 -4
  55. data/lib/vedeu/dsl/view.rb +9 -9
  56. data/lib/vedeu/dsl/views.rb +2 -2
  57. data/lib/vedeu/editor/document.rb +1 -1
  58. data/lib/vedeu/editor/item.rb +17 -15
  59. data/lib/vedeu/esc/colours.rb +21 -20
  60. data/lib/vedeu/geometries/area/area.rb +6 -2
  61. data/lib/vedeu/geometries/dsl/grid.rb +2 -2
  62. data/lib/vedeu/geometries/geometry.rb +34 -46
  63. data/lib/vedeu/geometries/move.rb +5 -4
  64. data/lib/vedeu/geometries/position.rb +1 -1
  65. data/lib/vedeu/groups/dsl.rb +2 -2
  66. data/lib/vedeu/groups/group.rb +1 -1
  67. data/lib/vedeu/groups/refresh.rb +2 -2
  68. data/lib/vedeu/input/capture.rb +2 -1
  69. data/lib/vedeu/input/dsl.rb +22 -16
  70. data/lib/vedeu/input/key.rb +1 -1
  71. data/lib/vedeu/input/mapper.rb +6 -6
  72. data/lib/vedeu/input/read.rb +2 -2
  73. data/lib/vedeu/interfaces/dsl.rb +2 -2
  74. data/lib/vedeu/logging/debug.rb +10 -10
  75. data/lib/vedeu/logging/timer.rb +7 -11
  76. data/lib/vedeu/menus/dsl.rb +2 -2
  77. data/lib/vedeu/models/focus.rb +3 -3
  78. data/lib/vedeu/models/page.rb +1 -1
  79. data/lib/vedeu/models/row.rb +1 -1
  80. data/lib/vedeu/presentation/style.rb +1 -1
  81. data/lib/vedeu/renderers/escape.rb +0 -6
  82. data/lib/vedeu/renderers/options.rb +3 -3
  83. data/lib/vedeu/renderers/text.rb +0 -6
  84. data/lib/vedeu/repositories/assemblage.rb +1 -1
  85. data/lib/vedeu/repositories/defaults.rb +2 -2
  86. data/lib/vedeu/repositories/repositories.rb +17 -1
  87. data/lib/vedeu/repositories/repository.rb +5 -5
  88. data/lib/vedeu/runtime/application.rb +3 -3
  89. data/lib/vedeu/runtime/main_loop.rb +2 -2
  90. data/lib/vedeu/runtime/router.rb +11 -11
  91. data/lib/vedeu/support/point.rb +18 -15
  92. data/lib/vedeu/templating/helpers.rb +1 -1
  93. data/lib/vedeu/templating/template.rb +4 -4
  94. data/lib/vedeu/terminal/terminal.rb +1 -1
  95. data/lib/vedeu/version.rb +1 -1
  96. data/lib/vedeu/views/chars.rb +3 -3
  97. data/lib/vedeu/views/line.rb +1 -1
  98. data/lib/vedeu/views/lines.rb +3 -3
  99. data/lib/vedeu/views/stream.rb +1 -1
  100. data/lib/vedeu/views/streams.rb +3 -3
  101. data/lib/vedeu/views/view.rb +2 -2
  102. data/test/lib/vedeu/common_test.rb +43 -0
  103. data/test/lib/vedeu/cursors/cursor_test.rb +1 -1
  104. data/test/lib/vedeu/esc/colours_test.rb +42 -0
  105. data/test/lib/vedeu/input/dsl_test.rb +8 -8
  106. data/test/lib/vedeu/logging/debug_test.rb +2 -2
  107. data/test/lib/vedeu/logging/timer_test.rb +4 -13
  108. data/test/lib/vedeu/renderers/escape_test.rb +24 -0
  109. data/test/lib/vedeu/repositories/repositories_test.rb +6 -0
  110. data/test/support/examples/material_colours_app.rb +30 -51
  111. data/vedeu.gemspec +2 -2
  112. metadata +9 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0bb5fc66d38ef9dbbdad8ea2209c510b335a4fb8
4
- data.tar.gz: da7ea21b8fc9004bd0db6661b89b526cc40a10ce
3
+ metadata.gz: 002c233933994a1c074caa09713374413fb3ec7e
4
+ data.tar.gz: f083bf135c2d9307329af03198159f73ecc88548
5
5
  SHA512:
6
- metadata.gz: 4b3cf2c29c24ddf35b1da2926b8d172035c3592e95e00f2ec589bc0d82c373b3d4471b1df6695afa15097f5e483c2cf3689c82e3db83271126d730c254895cc7
7
- data.tar.gz: cf9b359cf05f70b9ea6093712fc57efae2379e6864a8311f64e6c0896b86441d2629e70b4f9683d7f7945826c57c5d494a2e7e51410c51135bed9b469c975733
6
+ metadata.gz: a0c4f251a4537d4907ec3b9b1eea499be60b8be212fc8544e3ce7beef9eaff3b33ed8d5ef73cd0dc6ad85965a88f77aa0f7dd06336bb2f5718db33e0dabfaa3e
7
+ data.tar.gz: 86f69b80ad1db0b0df5ef2bce701c33e6f09e8d57ab9784331f1cca01b3eb48781992ce61d451915b9caf0557564a8ec91d451bed3ba27b3187803907c486f78
data/bin/vedeu CHANGED
@@ -9,7 +9,7 @@ rescue LoadError
9
9
  STDERR.puts bundler_message
10
10
  end
11
11
 
12
- fail bundler_message unless defined?(Bundler)
12
+ raise bundler_message unless defined?(Bundler)
13
13
 
14
14
  require 'vedeu'
15
15
  require 'vedeu_cli'
@@ -2,6 +2,6 @@
2
2
  Allow debugging via the creation of stack traces courtesy of
3
3
  'ruby-prof'. Will raise an exception if 'ruby-prof' is not available.
4
4
 
5
- Vedeu.profile('/tmp/profile.html') do
5
+ Vedeu.profile('/tmp/vedeu_profile') do
6
6
  # ... code to profile ...
7
7
  end
@@ -0,0 +1,4 @@
1
+ ### Vedeu.repositories
2
+ Returns an array of all repositories registered with Vedeu.
3
+
4
+ Vedeu.repositories
@@ -10,7 +10,7 @@ class DSLApp
10
10
  Vedeu.bind(:_initialize_) { Vedeu.trigger(:_refresh_) }
11
11
 
12
12
  Vedeu.configure do
13
- height 5
13
+ height 10
14
14
  debug!
15
15
  log '/tmp/vedeu_views_dsl.log'
16
16
  renderers(Vedeu::Renderers::Terminal.new(
@@ -11,6 +11,7 @@ class DSLApp
11
11
 
12
12
  Vedeu.configure do
13
13
  debug!
14
+ height 10
14
15
  log '/tmp/vedeu_views_dsl.log'
15
16
  renderers [
16
17
  Vedeu::Renderers::Terminal.new(
@@ -11,6 +11,7 @@ class DSLApp
11
11
 
12
12
  Vedeu.configure do
13
13
  debug!
14
+ height 10
14
15
  log '/tmp/vedeu_views_dsl.log'
15
16
  renderers [
16
17
  Vedeu::Renderers::Terminal.new(
@@ -11,6 +11,7 @@ class DSLApp
11
11
 
12
12
  Vedeu.configure do
13
13
  debug!
14
+ height 10
14
15
  log '/tmp/vedeu_views_dsl.log'
15
16
  renderers [
16
17
  Vedeu::Renderers::Terminal.new(
@@ -11,6 +11,7 @@ class DSLApp
11
11
 
12
12
  Vedeu.configure do
13
13
  debug!
14
+ height 10
14
15
  log '/tmp/vedeu_views_dsl.log'
15
16
  renderers [
16
17
  Vedeu::Renderers::Terminal.new(
@@ -11,6 +11,7 @@ class DSLApp
11
11
 
12
12
  Vedeu.configure do
13
13
  debug!
14
+ height 10
14
15
  log '/tmp/vedeu_views_dsl.log'
15
16
  renderers [
16
17
  Vedeu::Renderers::Terminal.new(
@@ -11,6 +11,7 @@ class DSLApp
11
11
 
12
12
  Vedeu.configure do
13
13
  debug!
14
+ height 10
14
15
  log '/tmp/vedeu_views_dsl.log'
15
16
  renderers [
16
17
  Vedeu::Renderers::Terminal.new(
@@ -11,6 +11,7 @@ class DSLApp
11
11
 
12
12
  Vedeu.configure do
13
13
  debug!
14
+ height 10
14
15
  log '/tmp/vedeu_views_dsl.log'
15
16
  renderers [
16
17
  Vedeu::Renderers::Terminal.new(
@@ -11,6 +11,7 @@ class DSLApp
11
11
 
12
12
  Vedeu.configure do
13
13
  debug!
14
+ height 10
14
15
  log '/tmp/vedeu_views_dsl.log'
15
16
  renderers [
16
17
  Vedeu::Renderers::Terminal.new(
@@ -11,6 +11,7 @@ class DSLApp
11
11
 
12
12
  Vedeu.configure do
13
13
  debug!
14
+ height 10
14
15
  log '/tmp/vedeu_views_dsl.log'
15
16
  renderers [
16
17
  Vedeu::Renderers::Terminal.new(
@@ -11,6 +11,7 @@ class DSLApp
11
11
 
12
12
  Vedeu.configure do
13
13
  debug!
14
+ height 10
14
15
  log '/tmp/vedeu_views_dsl.log'
15
16
  renderers [
16
17
  Vedeu::Renderers::Terminal.new(
@@ -11,6 +11,7 @@ class DSLApp
11
11
 
12
12
  Vedeu.configure do
13
13
  debug!
14
+ height 10
14
15
  log '/tmp/vedeu_views_dsl.log'
15
16
  renderers [
16
17
  Vedeu::Renderers::Terminal.new(
@@ -11,6 +11,7 @@ class DSLApp
11
11
 
12
12
  Vedeu.configure do
13
13
  debug!
14
+ height 10
14
15
  log '/tmp/vedeu_views_dsl.log'
15
16
  renderers [
16
17
  Vedeu::Renderers::Terminal.new(
@@ -11,6 +11,7 @@ class DSLApp
11
11
 
12
12
  Vedeu.configure do
13
13
  debug!
14
+ height 10
14
15
  log '/tmp/vedeu_views_dsl.log'
15
16
  renderers [
16
17
  Vedeu::Renderers::Terminal.new(
@@ -11,6 +11,7 @@ class DSLApp
11
11
 
12
12
  Vedeu.configure do
13
13
  debug!
14
+ height 10
14
15
  log '/tmp/vedeu_views_dsl.log'
15
16
  renderers [
16
17
  Vedeu::Renderers::Terminal.new(
@@ -11,6 +11,7 @@ class DSLApp
11
11
 
12
12
  Vedeu.configure do
13
13
  debug!
14
+ height 10
14
15
  log '/tmp/vedeu_views_dsl.log'
15
16
  renderers [
16
17
  Vedeu::Renderers::Terminal.new(
@@ -11,6 +11,7 @@ class DSLApp
11
11
 
12
12
  Vedeu.configure do
13
13
  debug!
14
+ height 10
14
15
  log '/tmp/vedeu_views_dsl.log'
15
16
  renderers [
16
17
  Vedeu::Renderers::Terminal.new(
@@ -11,6 +11,7 @@ class DSLApp
11
11
 
12
12
  Vedeu.configure do
13
13
  debug!
14
+ height 10
14
15
  log '/tmp/vedeu_views_dsl.log'
15
16
  renderers [
16
17
  Vedeu::Renderers::Terminal.new(
@@ -11,6 +11,7 @@ class DSLApp
11
11
 
12
12
  Vedeu.configure do
13
13
  debug!
14
+ height 10
14
15
  log '/tmp/vedeu_views_dsl.log'
15
16
  renderers [
16
17
  Vedeu::Renderers::Terminal.new(
@@ -11,6 +11,7 @@ class DSLApp
11
11
 
12
12
  Vedeu.configure do
13
13
  debug!
14
+ height 10
14
15
  log '/tmp/vedeu_views_dsl.log'
15
16
  renderers [
16
17
  Vedeu::Renderers::Terminal.new(
@@ -11,6 +11,7 @@ class DSLApp
11
11
 
12
12
  Vedeu.configure do
13
13
  debug!
14
+ height 10
14
15
  log '/tmp/vedeu_views_dsl.log'
15
16
  renderers [
16
17
  Vedeu::Renderers::Terminal.new(
@@ -11,6 +11,7 @@ class DSLApp
11
11
 
12
12
  Vedeu.configure do
13
13
  debug!
14
+ height 10
14
15
  log '/tmp/vedeu_views_dsl.log'
15
16
  renderers [
16
17
  Vedeu::Renderers::Terminal.new(
@@ -11,6 +11,7 @@ class DSLApp
11
11
 
12
12
  Vedeu.configure do
13
13
  debug!
14
+ height 10
14
15
  log '/tmp/vedeu_views_dsl.log'
15
16
  renderers [
16
17
  Vedeu::Renderers::Terminal.new(
@@ -11,6 +11,7 @@ class DSLApp
11
11
 
12
12
  Vedeu.configure do
13
13
  debug!
14
+ height 10
14
15
  log '/tmp/vedeu_views_dsl.log'
15
16
  renderers [
16
17
  Vedeu::Renderers::Terminal.new(
@@ -11,6 +11,7 @@ class DSLApp
11
11
 
12
12
  Vedeu.configure do
13
13
  debug!
14
+ height 10
14
15
  log '/tmp/vedeu_views_dsl.log'
15
16
  renderers [
16
17
  Vedeu::Renderers::Terminal.new(
@@ -11,6 +11,7 @@ class DSLApp
11
11
 
12
12
  Vedeu.configure do
13
13
  debug!
14
+ height 10
14
15
  log '/tmp/vedeu_views_dsl.log'
15
16
  renderers [
16
17
  Vedeu::Renderers::Terminal.new(
@@ -11,6 +11,7 @@ class DSLApp
11
11
 
12
12
  Vedeu.configure do
13
13
  debug!
14
+ height 10
14
15
  log '/tmp/vedeu_views_dsl.log'
15
16
  renderers [
16
17
  Vedeu::Renderers::Terminal.new(
@@ -11,6 +11,7 @@ class DSLApp
11
11
 
12
12
  Vedeu.configure do
13
13
  debug!
14
+ height 10
14
15
  log '/tmp/vedeu_views_dsl.log'
15
16
  renderers [
16
17
  Vedeu::Renderers::Terminal.new(
@@ -34,9 +34,9 @@ module Vedeu
34
34
 
35
35
  # @macro raise_not_implemented
36
36
  def render
37
- fail Vedeu::Error::NotImplemented,
38
- 'The subclass of Vedeu::ApplicationView must implement the #render' \
39
- 'method.'
37
+ raise Vedeu::Error::NotImplemented,
38
+ 'The subclass of Vedeu::ApplicationView must implement the ' \
39
+ '#render method.'
40
40
  end
41
41
 
42
42
  protected
@@ -21,8 +21,8 @@ module Vedeu
21
21
  # @macro raise_missing_required
22
22
  # @return [Vedeu::Borders::Border]
23
23
  def self.border(name, &block)
24
- fail Vedeu::Error::MissingRequired unless name
25
- fail Vedeu::Error::RequiresBlock unless block_given?
24
+ raise Vedeu::Error::MissingRequired unless name
25
+ raise Vedeu::Error::RequiresBlock unless block_given?
26
26
 
27
27
  Vedeu::Borders::Border.build(enabled: true, name: name, &block).store
28
28
  end
@@ -40,7 +40,7 @@ module Vedeu
40
40
  # @param other [Vedeu::Borders::Title|Vedeu::Borders::Caption]
41
41
  # @return [Boolean]
42
42
  def eql?(other)
43
- self.class == other.class && value == other.value
43
+ self.class.equal?(other.class) && value == other.value
44
44
  end
45
45
  alias == eql?
46
46
 
@@ -88,21 +88,11 @@ module Vedeu
88
88
  # @param value [void]
89
89
  # @return [Boolean]
90
90
  def valid?(value)
91
- valid_value?(value) &&
91
+ positionable?(value) &&
92
92
  valid_y?(value.position.y) &&
93
93
  valid_x?(value.position.x)
94
94
  end
95
95
 
96
- # Returns a boolean indicating the value has a position
97
- # attribute.
98
- #
99
- # @param value [void]
100
- # @return [Boolean]
101
- def valid_value?(value)
102
- value.respond_to?(:position) &&
103
- value.position.is_a?(Vedeu::Geometries::Position)
104
- end
105
-
106
96
  # Returns a boolean indicating whether the x position of the
107
97
  # value object is valid for this geometry.
108
98
  #
@@ -38,9 +38,9 @@ module Vedeu
38
38
  # @param other [void]
39
39
  # @return [Boolean]
40
40
  def eql?(other)
41
- self.class == other.class &&
41
+ self.class.equal?(other.class) &&
42
42
  position == other.position &&
43
- value == other.value &&
43
+ value == other.value &&
44
44
  colour == other.colour
45
45
  end
46
46
  alias == eql?
@@ -76,7 +76,7 @@ module Vedeu
76
76
  # @param other [void]
77
77
  # @return [Boolean]
78
78
  def eql?(other)
79
- self.class == other.class && value == other.value
79
+ self.class.equal?(other.class) && value == other.value
80
80
  end
81
81
  alias == eql?
82
82
 
@@ -132,9 +132,9 @@ module Vedeu
132
132
  def validate
133
133
  return coerce if valid_horizontal? || valid_vertical?
134
134
 
135
- fail Vedeu::Error::InvalidSyntax,
136
- 'Missing or invalid alignment value. ' \
137
- "Valid values are: #{to_sentence}"
135
+ raise Vedeu::Error::InvalidSyntax,
136
+ 'Missing or invalid alignment value. ' \
137
+ "Valid values are: #{to_sentence}"
138
138
  end
139
139
 
140
140
  # @return [Boolean]
@@ -167,7 +167,7 @@ module Vedeu
167
167
 
168
168
  # @return [Boolean]
169
169
  def valid_type?
170
- present?(value) && value.is_a?(Symbol)
170
+ present?(value) && symbol?(value)
171
171
  end
172
172
 
173
173
  # @return [Array<Symbol>]
@@ -30,7 +30,7 @@ module Vedeu
30
30
  # @macro raise_not_implemented
31
31
  # @return [void]
32
32
  def coerce
33
- fail Vedeu::Error::NotImplemented, 'Subclasses implement this.'
33
+ raise Vedeu::Error::NotImplemented, 'Subclasses implement this.'
34
34
  end
35
35
 
36
36
  protected
@@ -49,15 +49,14 @@ module Vedeu
49
49
  # @macro raise_fatal
50
50
  # @return [void]
51
51
  def incoercible!
52
- fail Vedeu::Error::Fatal,
53
- "Vedeu cannot coerce a '#{value.class.name}' into a " \
54
- "'#{klass}'."
52
+ raise Vedeu::Error::Fatal,
53
+ "Vedeu cannot coerce a '#{value.class.name}' into a '#{klass}'."
55
54
  end
56
55
 
57
56
  # @macro raise_not_implemented
58
57
  # @return [Class]
59
58
  def klass
60
- fail Vedeu::Error::NotImplemented, 'Subclasses implement this.'
59
+ raise Vedeu::Error::NotImplemented, 'Subclasses implement this.'
61
60
  end
62
61
 
63
62
  end # Coercer
@@ -28,7 +28,7 @@ module Vedeu
28
28
  # @macro raise_invalid_syntax
29
29
  # @return [Hash]
30
30
  def coerce
31
- fail Vedeu::Error::InvalidSyntax unless hash?(value)
31
+ raise Vedeu::Error::InvalidSyntax unless hash?(value)
32
32
 
33
33
  if colour? && hash?(colour)
34
34
  Vedeu::Coercers::ColourAttributes.coerce(colour)
@@ -15,9 +15,9 @@ module Vedeu
15
15
  def validate
16
16
  return coerce if valid_horizontal?
17
17
 
18
- fail Vedeu::Error::InvalidSyntax,
19
- 'Missing or invalid horizontal alignment value. ' \
20
- "Valid values are: #{to_sentence}"
18
+ raise Vedeu::Error::InvalidSyntax,
19
+ 'Missing or invalid horizontal alignment value. ' \
20
+ "Valid values are: #{to_sentence}"
21
21
  end
22
22
 
23
23
  private
@@ -23,7 +23,7 @@ module Vedeu
23
23
  elsif hash?
24
24
  klass.new(value.fetch(:y, 1), value.fetch(:x, 1))
25
25
 
26
- elsif fixnum?
26
+ elsif numeric?(value)
27
27
  klass.new(value, 1)
28
28
 
29
29
  else
@@ -34,11 +34,6 @@ module Vedeu
34
34
 
35
35
  private
36
36
 
37
- # @return [Boolean]
38
- def fixnum?
39
- value.is_a?(Fixnum)
40
- end
41
-
42
37
  # @return [Boolean]
43
38
  def hash?
44
39
  value.is_a?(Hash)
@@ -55,9 +50,9 @@ module Vedeu
55
50
  return false unless value.is_a?(Array)
56
51
  return true if value.size == 2
57
52
 
58
- fail Vedeu::Error::Fatal,
59
- "A '#{klass}' is made up of two elements. (Provided " \
60
- "#{value.size}.)"
53
+ raise Vedeu::Error::Fatal,
54
+ "A '#{klass}' is made up of two elements. (Provided " \
55
+ "#{value.size}.)"
61
56
  end
62
57
 
63
58
  end # Position
@@ -15,9 +15,9 @@ module Vedeu
15
15
  def validate
16
16
  return coerce if valid_vertical?
17
17
 
18
- fail Vedeu::Error::InvalidSyntax,
19
- 'Missing or invalid vertical alignment value. ' \
20
- "Valid values are: #{to_sentence}"
18
+ raise Vedeu::Error::InvalidSyntax,
19
+ 'Missing or invalid vertical alignment value. ' \
20
+ "Valid values are: #{to_sentence}"
21
21
  end
22
22
 
23
23
  private
@@ -90,7 +90,8 @@ module Vedeu
90
90
  # @param other [void]
91
91
  # @return [Boolean]
92
92
  def eql?(other)
93
- self.class == other.class && background == other.background &&
93
+ self.class.equal?(other.class) &&
94
+ background == other.background &&
94
95
  foreground == other.foreground
95
96
  end
96
97
  alias == eql?
@@ -74,7 +74,7 @@ module Vedeu
74
74
  # @param other [void]
75
75
  # @return [Boolean]
76
76
  def eql?(other)
77
- self.class == other.class && colour == other.colour
77
+ self.class.equal?(other.class) && colour == other.colour
78
78
  end
79
79
  alias == eql?
80
80
 
@@ -217,7 +217,7 @@ module Vedeu
217
217
 
218
218
  # @macro raise_not_implemented
219
219
  def not_implemented
220
- fail Vedeu::Error::NotImplemented, 'Subclasses implement this.'
220
+ raise Vedeu::Error::NotImplemented, 'Subclasses implement this.'
221
221
  end
222
222
  alias named not_implemented
223
223
  alias repository not_implemented
data/lib/vedeu/common.rb CHANGED
@@ -81,6 +81,17 @@ module Vedeu
81
81
  def numeric?(value)
82
82
  value.is_a?(Fixnum)
83
83
  end
84
+ alias fixnum? numeric?
85
+
86
+ # Returns a boolean indicating the value has a position
87
+ # attribute.
88
+ #
89
+ # @param value [void]
90
+ # @return [Boolean]
91
+ def positionable?(value)
92
+ value.respond_to?(:position) &&
93
+ value.position.is_a?(Vedeu::Geometries::Position)
94
+ end
84
95
 
85
96
  # Returns a boolean indicating whether a variable has a useful
86
97
  # value.
@@ -135,7 +146,7 @@ module Vedeu
135
146
  end
136
147
  end
137
148
 
138
- # Returns a boolean indicating whether the value is a Fixnum.
149
+ # Returns a boolean indicating whether the value is a String.
139
150
  #
140
151
  # @param value [String|void]
141
152
  # @return [Boolean]
@@ -143,6 +154,14 @@ module Vedeu
143
154
  value.is_a?(String)
144
155
  end
145
156
 
157
+ # Returns a boolean indicating whether the value is a Symbol.
158
+ #
159
+ # @param value [Symbol|void]
160
+ # @return [Boolean]
161
+ def symbol?(value)
162
+ value.is_a?(Symbol)
163
+ end
164
+
146
165
  # Returns a boolean indicating whether the value should be
147
166
  # considered true.
148
167
  #
@@ -10,6 +10,8 @@ module Vedeu
10
10
  #
11
11
  class API
12
12
 
13
+ include Vedeu::Common
14
+
13
15
  # @param (see #initialize)
14
16
  def self.configure(&block)
15
17
  new(&block).configuration
@@ -200,8 +202,8 @@ module Vedeu
200
202
  # @return [Boolean]
201
203
  def colour_mode(value = nil)
202
204
  unless valid_colour_mode?(value)
203
- fail Vedeu::Error::InvalidSyntax,
204
- '`colour_mode` must be `8`, `16`, `256`, `16777216`.'
205
+ raise Vedeu::Error::InvalidSyntax,
206
+ '`colour_mode` must be `8`, `16`, `256`, `16777216`.'
205
207
  end
206
208
 
207
209
  options[:colour_mode] = value
@@ -282,7 +284,7 @@ module Vedeu
282
284
  # setting is for profiling to be disabled. Using `profile!` or
283
285
  # setting `profile` to true will enable profiling.
284
286
  #
285
- # Profile uses 'ruby-prof' to write a 'profile.html' file to
287
+ # Profile uses 'ruby-prof' to write a 'vedeu_profile' file to
286
288
  # the /tmp directory which contains a call trace of the running
287
289
  # application. Upon exit, this file can be examined to ascertain
288
290
  # certain behaviours of Vedeu.
@@ -559,8 +561,8 @@ module Vedeu
559
561
 
560
562
  # @macro raise_invalid_syntax
561
563
  def invalid_mode!
562
- fail Vedeu::Error::InvalidSyntax,
563
- 'Terminal mode can be set to either :cooked, :fake or :raw'
564
+ raise Vedeu::Error::InvalidSyntax,
565
+ 'Terminal mode can be set to either :cooked, :fake or :raw'
564
566
  end
565
567
 
566
568
  # Returns the options set via the configuration API DSL or an
@@ -576,7 +578,7 @@ module Vedeu
576
578
  # @param value [Fixnum]
577
579
  # @return [Boolean]
578
580
  def valid_colour_mode?(value)
579
- value.is_a?(Fixnum) && [8, 16, 256, 16_777_216].include?(value)
581
+ numeric?(value) && [8, 16, 256, 16_777_216].include?(value)
580
582
  end
581
583
 
582
584
  # Checks that the mode provided is valid.
@@ -149,7 +149,7 @@ module Vedeu
149
149
 
150
150
  # @return [Boolean]
151
151
  def height?
152
- instance.options[:height].is_a?(Fixnum)
152
+ numeric?(instance.options[:height])
153
153
  end
154
154
 
155
155
  # Returns whether the application is interactive (required user
@@ -299,7 +299,7 @@ module Vedeu
299
299
 
300
300
  # @return [Boolean]
301
301
  def width?
302
- instance.options[:width].is_a?(Fixnum)
302
+ numeric?(instance.options[:width])
303
303
  end
304
304
 
305
305
  # @param value [void]
@@ -86,8 +86,8 @@ module Vedeu
86
86
  when :x then Vedeu::XCoordinate.new(geometry)
87
87
  when :y then Vedeu::YCoordinate.new(geometry)
88
88
  else
89
- fail Vedeu::Error::InvalidSyntax,
90
- 'Coordinate type not given, cannot continue.'
89
+ raise Vedeu::Error::InvalidSyntax,
90
+ 'Coordinate type not given, cannot continue.'
91
91
  end
92
92
  end
93
93