vedeu 0.4.9 → 0.4.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (92) hide show
  1. checksums.yaml +4 -4
  2. data/lib/vedeu/api.rb +8 -0
  3. data/lib/vedeu/application.rb +2 -0
  4. data/lib/vedeu/bindings.rb +3 -0
  5. data/lib/vedeu/configuration/configuration.rb +1 -1
  6. data/lib/vedeu/cursor/cursor.rb +1 -1
  7. data/lib/vedeu/cursor/move.rb +1 -1
  8. data/lib/vedeu/cursor/refresh_cursor.rb +2 -0
  9. data/lib/vedeu/cursor/toggle.rb +1 -1
  10. data/lib/vedeu/debug.rb +36 -1
  11. data/lib/vedeu/distributed/client.rb +2 -0
  12. data/lib/vedeu/distributed/subprocess.rb +2 -0
  13. data/lib/vedeu/distributed/test_application.rb +2 -0
  14. data/lib/vedeu/distributed/uri.rb +2 -0
  15. data/lib/vedeu/events/event.rb +1 -1
  16. data/lib/vedeu/events/trigger.rb +2 -0
  17. data/lib/vedeu/geometry/all.rb +0 -1
  18. data/lib/vedeu/geometry/area.rb +22 -0
  19. data/lib/vedeu/geometry/centre.rb +2 -0
  20. data/lib/vedeu/geometry/content.rb +2 -0
  21. data/lib/vedeu/geometry/coordinate.rb +2 -0
  22. data/lib/vedeu/geometry/dimension.rb +2 -0
  23. data/lib/vedeu/geometry/geometry.rb +8 -3
  24. data/lib/vedeu/geometry/grid.rb +2 -0
  25. data/lib/vedeu/geometry/index_position.rb +21 -0
  26. data/lib/vedeu/geometry/limit.rb +2 -0
  27. data/lib/vedeu/geometry/position.rb +1 -1
  28. data/lib/vedeu/geometry/position_index.rb +2 -0
  29. data/lib/vedeu/geometry/position_validator.rb +2 -0
  30. data/lib/vedeu/input/input.rb +1 -1
  31. data/lib/vedeu/input/key.rb +1 -1
  32. data/lib/vedeu/input/keymap.rb +2 -0
  33. data/lib/vedeu/input/mapper.rb +8 -0
  34. data/lib/vedeu/launcher.rb +2 -0
  35. data/lib/vedeu/main_loop.rb +1 -3
  36. data/lib/vedeu/models/cell.rb +2 -0
  37. data/lib/vedeu/models/composition.rb +1 -1
  38. data/lib/vedeu/models/group.rb +1 -1
  39. data/lib/vedeu/models/interface.rb +35 -3
  40. data/lib/vedeu/models/line.rb +6 -1
  41. data/lib/vedeu/models/menu.rb +1 -1
  42. data/lib/vedeu/models/stream.rb +6 -17
  43. data/lib/vedeu/output/all.rb +3 -2
  44. data/lib/vedeu/output/background.rb +26 -0
  45. data/lib/vedeu/output/border.rb +105 -25
  46. data/lib/vedeu/output/clear.rb +17 -10
  47. data/lib/vedeu/output/colour.rb +1 -1
  48. data/lib/vedeu/output/compositor.rb +4 -1
  49. data/lib/vedeu/output/foreground.rb +26 -0
  50. data/lib/vedeu/output/html_char.rb +2 -0
  51. data/lib/vedeu/output/null_border.rb +49 -0
  52. data/lib/vedeu/output/output.rb +8 -44
  53. data/lib/vedeu/output/renderers/all.rb +3 -0
  54. data/lib/vedeu/output/{renderer.rb → renderers/file_renderer.rb} +14 -6
  55. data/lib/vedeu/output/{html_renderer.rb → renderers/html_renderer.rb} +3 -1
  56. data/lib/vedeu/output/renderers/terminal_renderer.rb +50 -0
  57. data/lib/vedeu/output/text.rb +1 -1
  58. data/lib/vedeu/output/translator.rb +21 -2
  59. data/lib/vedeu/output/viewport.rb +17 -50
  60. data/lib/vedeu/output/virtual_terminal.rb +2 -0
  61. data/lib/vedeu/output/wordwrap.rb +2 -0
  62. data/lib/vedeu/repositories/all.rb +82 -0
  63. data/lib/vedeu/repositories/collection.rb +16 -0
  64. data/lib/vedeu/repositories/repository.rb +2 -0
  65. data/lib/vedeu/support/log.rb +3 -0
  66. data/lib/vedeu/support/sentence.rb +2 -0
  67. data/lib/vedeu/support/template.rb +2 -0
  68. data/lib/vedeu/support/terminal.rb +6 -1
  69. data/lib/vedeu/support/trace.rb +2 -0
  70. data/lib/vedeu/support/visible.rb +6 -0
  71. data/test/lib/vedeu/dsl/components/border_test.rb +0 -270
  72. data/test/lib/vedeu/dsl/shared/text_test.rb +19 -0
  73. data/test/lib/vedeu/geometry/area_test.rb +32 -0
  74. data/test/lib/vedeu/geometry/index_position_test.rb +36 -0
  75. data/test/lib/vedeu/models/interface_test.rb +42 -1
  76. data/test/lib/vedeu/models/line_test.rb +15 -1
  77. data/test/lib/vedeu/models/stream_test.rb +15 -1
  78. data/test/lib/vedeu/output/background_test.rb +4 -2
  79. data/test/lib/vedeu/output/border_test.rb +229 -127
  80. data/test/lib/vedeu/output/clear_test.rb +14 -0
  81. data/test/lib/vedeu/output/foreground_test.rb +4 -2
  82. data/test/lib/vedeu/output/null_border_test.rb +53 -0
  83. data/test/lib/vedeu/output/output_test.rb +2 -0
  84. data/test/lib/vedeu/output/{renderer_test.rb → renderers/file_renderer_test.rb} +5 -5
  85. data/test/lib/vedeu/output/renderers/html_renderer_test.rb +71 -0
  86. data/test/lib/vedeu/output/renderers/terminal_renderer_test.rb +24 -0
  87. data/test/lib/vedeu/output/viewport_test.rb +100 -74
  88. data/vedeu.gemspec +1 -1
  89. metadata +15 -11
  90. data/lib/vedeu/geometry/bounding_area.rb +0 -136
  91. data/test/lib/vedeu/geometry/bounding_area_test.rb +0 -123
  92. data/test/lib/vedeu/output/html_renderer_test.rb +0 -42
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2f8e55b96180371a74727bb5684f829aea4fb3ae
4
- data.tar.gz: d3bbd55216ffff82ebf2007cd7616228be86e155
3
+ metadata.gz: a9fe2d78e6318aca74ab320786c9074d8b745eff
4
+ data.tar.gz: 824f82bca58a42308ad10bec73fd49fbd1c20884
5
5
  SHA512:
6
- metadata.gz: 52b9ca57b1f4258a516e236a49e42840665bb4f40352e8d7b562de206eb1a23340fe4be40acfe02d41a28618db3e36a8841964d2a1fa2c3108bd841bdb6aa29f
7
- data.tar.gz: b5caa9c02529b83537e2894d4fbc287beedef7c1cbcd7de1bc5d2eafb178d225ec9709c14fda5a8872bd2760f04c3df0ed2a95051e8fc1a8ebe1002506ff8b4e
6
+ metadata.gz: 103b80280897cd8904924011ef77a0060256f60a5475c1725ad118a0b606861eaa7c0f4938fe2b4c1e06fb6edd9ff84809ee209aa57b07a73b49f8b12ba61c8f
7
+ data.tar.gz: d39f7987ca6a1f517ad469d3be912d7748e2f7592128689eb3aace31cc5e59c57f5c2d62200d4c4f9abc009e91b017f6ecb8a2de5c420ac28983649c42356925
data/lib/vedeu/api.rb CHANGED
@@ -46,6 +46,14 @@ module Vedeu
46
46
  # @see Vedeu::Canvas.canvas
47
47
  def_delegators Vedeu::Canvas, :canvas
48
48
 
49
+ # @!method background_colours
50
+ # @see Vedeu::BackgroundColours.background_colours
51
+ def_delegators Vedeu::BackgroundColours, :background_colours
52
+
53
+ # @!method foreground_colours
54
+ # @see Vedeu::ForegroundColours.foreground_colours
55
+ def_delegators Vedeu::ForegroundColours, :foreground_colours
56
+
49
57
  # @!method cursors
50
58
  # @see Vedeu::Cursors.cursors
51
59
  def_delegators Vedeu::Cursors, :cursors
@@ -29,6 +29,8 @@ module Vedeu
29
29
  end
30
30
 
31
31
  # :nocov:
32
+ # Returns a new instance of Vedeu::Application.
33
+ #
32
34
  # @param configuration [Vedeu::Configuration]
33
35
  # @return [Application]
34
36
  def initialize(configuration)
@@ -84,6 +84,9 @@ module Vedeu
84
84
  # events. Please see those events for their behaviour.
85
85
  Vedeu.bind(:_resize_, { delay: 0.25 }) { Vedeu.resize }
86
86
 
87
+ Vedeu.bind(:tick) { |time| Vedeu.log(type: :debug, message: "Tick: #{time}") }
88
+ Vedeu.bind(:tock) { |time| Vedeu.log(type: :debug, message: "Tock: #{time}") }
89
+
87
90
  # Hide the cursor of the named interface or interface currently in focus.
88
91
  Vedeu.bind(:_cursor_hide_) do |name|
89
92
  named = name ? Vedeu.cursors.by_name(name) : Vedeu.cursor
@@ -218,7 +218,7 @@ module Vedeu
218
218
  # @return [Hash]
219
219
  attr_reader :options
220
220
 
221
- # Create a new singleton instance of Configuration.
221
+ # Create a new singleton instance of Vedeu::Configuration.
222
222
  #
223
223
  # @return [Configuration]
224
224
  def initialize
@@ -44,7 +44,7 @@ module Vedeu
44
44
  # @return [Fixnum]
45
45
  attr_reader :y
46
46
 
47
- # Returns a new instance of Cursor.
47
+ # Returns a new instance of Vedeu::Cursor.
48
48
  #
49
49
  # @param attributes [Hash]
50
50
  # @option attributes name [String] The name of the interface this cursor
@@ -46,7 +46,7 @@ module Vedeu
46
46
  :height,
47
47
  :width
48
48
 
49
- # Returns an instance of Move.
49
+ # Returns an instance of Vedeu::Move.
50
50
  #
51
51
  # @param cursor [Cursor]
52
52
  # @param interface [Interface]
@@ -10,6 +10,8 @@ module Vedeu
10
10
  new(name).render
11
11
  end
12
12
 
13
+ # Returns a new instance of Vedeu::RefreshCursor.
14
+ #
13
15
  # @param name [String] The name of the cursor.
14
16
  # @return [Vedeu::RefreshCursor]
15
17
  def initialize(name)
@@ -4,7 +4,7 @@ module Vedeu
4
4
  #
5
5
  class Toggle
6
6
 
7
- # Returns an instance of Toggle.
7
+ # Returns an instance of Vedeu::Toggle.
8
8
  #
9
9
  # @param cursor [Cursor]
10
10
  # @return [Toggle]
data/lib/vedeu/debug.rb CHANGED
@@ -9,18 +9,53 @@ module Vedeu
9
9
  def self.debug(filename = 'profile.html', &block)
10
10
  require 'ruby-prof'
11
11
 
12
+ RubyProf.measure_mode = RubyProf::WALL_TIME
13
+ # RubyProf.measure_mode = RubyProf::PROCESS_TIME
14
+ # RubyProf.measure_mode = RubyProf::CPU_TIME
15
+ # RubyProf.measure_mode = RubyProf::ALLOCATIONS
16
+ # RubyProf.measure_mode = RubyProf::MEMORY
17
+ # RubyProf.measure_mode = RubyProf::GC_TIME
18
+ # RubyProf.measure_mode = RubyProf::GC_RUNS
19
+
12
20
  RubyProf.start
13
21
 
14
22
  yield
15
23
 
16
24
  result = RubyProf.stop
17
- result.eliminate_methods!([/^Array/, /^Hash/])
25
+ result.eliminate_methods!([
26
+ /^Array/,
27
+ /^Hash/,
28
+ ])
18
29
 
19
30
  File.open('/tmp/' + filename, 'w') do |file|
20
31
  RubyProf::CallStackPrinter.new(result).print(file)
21
32
 
22
33
  # Used with QTCacheGrind to analyse performance.
23
34
  # RubyProf::CallTreePrinter.new(result).print(file)
35
+
36
+ # Creates a flat report in text format
37
+ # RubyProf::FlatPrinter
38
+
39
+ # - same as above but more verbose
40
+ # RubyProf::FlatPrinterWithLineNumbers
41
+
42
+ # - Creates a call graph report in text format
43
+ # RubyProf::GraphPrinter
44
+
45
+ # - Creates a call graph report in HTML (separate files per thread)
46
+ # RubyProf::GraphHtmlPrinter
47
+
48
+ # - Creates a call graph report in GraphViz's DOT format which can be converted to an image
49
+ # RubyProf::DotPrinter
50
+
51
+ # - Creates a call tree report compatible with KCachegrind.
52
+ # RubyProf::CallTreePrinter
53
+
54
+ # - Creates a HTML visualization of the Ruby stack
55
+ # RubyProf::CallStackPrinter
56
+
57
+ # - Uses the other printers to create several reports in one profiling run
58
+ # RubyProf::MultiPrinter
24
59
  end
25
60
  end
26
61
  # :nocov:
@@ -18,6 +18,8 @@ module Vedeu
18
18
  new(uri).connect
19
19
  end
20
20
 
21
+ # Returns a new instance of Vedeu::Distributed::Client.
22
+ #
21
23
  # @param uri [Vedeu::Distributed::Uri|String]
22
24
  # @return [Client]
23
25
  def initialize(uri)
@@ -12,6 +12,8 @@ module Vedeu
12
12
  new(application).execute!
13
13
  end
14
14
 
15
+ # Returns a new instance of Vedeu::Subprocess.
16
+ #
15
17
  # @param application [Vedeu::TestApplication]
16
18
  # @return [Vedeu::Subprocess]
17
19
  def initialize(application)
@@ -53,6 +53,8 @@ module Vedeu
53
53
  new(attributes).build(&block)
54
54
  end
55
55
 
56
+ # Returns a new instance of Vedeu::TestApplication.
57
+ #
56
58
  # @param attributes [Hash<Symbol => String>]
57
59
  # @option attributes borders [String]
58
60
  # @option attributes configuration [String]
@@ -15,6 +15,8 @@ module Vedeu
15
15
  # @return [Fixnum|String]
16
16
  attr_reader :port
17
17
 
18
+ # Returns a new instance of Vedeu::Distributed::Uri.
19
+ #
18
20
  # @param host [String] Hostname or IP address.
19
21
  # @param port [Fixnum|String]
20
22
  # @return [Uri]
@@ -110,7 +110,7 @@ module Vedeu
110
110
  Vedeu::Trigger.trigger(name, *args)
111
111
  end
112
112
 
113
- # Returns a new instance of Event.
113
+ # Returns a new instance of Vedeu::Event.
114
114
  #
115
115
  # @param (see Vedeu::Event.bind)
116
116
  # @return [Event]
@@ -18,6 +18,8 @@ module Vedeu
18
18
  new(name, *args).trigger
19
19
  end
20
20
 
21
+ # Returns a new instance of Vedeu::Trigger.
22
+ #
21
23
  # @param (see .trigger)
22
24
  # @return [Vedeu::Trigger]
23
25
  def initialize(name, *args)
@@ -1,5 +1,4 @@
1
1
  require 'vedeu/geometry/area'
2
- require 'vedeu/geometry/bounding_area'
3
2
  require 'vedeu/geometry/canvas'
4
3
  require 'vedeu/geometry/centre'
5
4
  require 'vedeu/geometry/content'
@@ -44,6 +44,8 @@ module Vedeu
44
44
  new(y: y, yn: yn, x: x, xn: xn)
45
45
  end
46
46
 
47
+ # Returns a new instance of Vedeu::Area.
48
+ #
47
49
  # @param y [Fixnum]
48
50
  # @param yn [Fixnum]
49
51
  # @param x [Fixnum]
@@ -149,6 +151,26 @@ module Vedeu
149
151
  x - offset
150
152
  end
151
153
 
154
+ # @return [Vedeu::Position]
155
+ def top_left
156
+ Vedeu::Position[y, x]
157
+ end
158
+
159
+ # @return [Vedeu::Position]
160
+ def bottom_left
161
+ Vedeu::Position[yn, x]
162
+ end
163
+
164
+ # @return [Vedeu::Position]
165
+ def top_right
166
+ Vedeu::Position[y, xn]
167
+ end
168
+
169
+ # @return [Vedeu::Position]
170
+ def bottom_right
171
+ Vedeu::Position[yn, xn]
172
+ end
173
+
152
174
  private
153
175
 
154
176
  end # Area
@@ -27,6 +27,8 @@ module Vedeu
27
27
  new({ v: v, vn: vn }).centre
28
28
  end
29
29
 
30
+ # Returns a new instance of Vedeu::Centre.
31
+ #
30
32
  # @param attributes [Hash<Symbol => Fixnum>]
31
33
  # @option attributes v [Fixnum] The starting coordinate value.
32
34
  # @option attributes vn [Fixnum] The ending coordinate value.
@@ -17,6 +17,8 @@ module Vedeu
17
17
  :x,
18
18
  :y
19
19
 
20
+ # Returns a new instance of Vedeu::Content.
21
+ #
20
22
  # @param interface [Vedeu::Interface]
21
23
  # @return [Vedeu::Content]
22
24
  def initialize(interface)
@@ -20,6 +20,8 @@ module Vedeu
20
20
  # @return [Fixnum]
21
21
  attr_reader :y
22
22
 
23
+ # Returns a new instance of Vedeu::Coordinate.
24
+ #
23
25
  # @param height [Fixnum]
24
26
  # @param width [Fixnum]
25
27
  # @param x [Fixnum]
@@ -10,6 +10,8 @@ module Vedeu
10
10
  new(attributes).pair
11
11
  end
12
12
 
13
+ # Returns a new instance of Vedeu::Dimension.
14
+ #
13
15
  # @param attributes [Hash<Symbol => Fixnum, NilClass>]
14
16
  # @option attributes d [Fixnum|NilClass] The starting value (y or x).
15
17
  # @option attributes dn [Fixnum|NilClass] The ending value (yn or xn).
@@ -32,7 +32,8 @@ module Vedeu
32
32
  extend Forwardable
33
33
  include Vedeu::Model
34
34
 
35
- def_delegators :area, :north,
35
+ def_delegators :area,
36
+ :north,
36
37
  :east,
37
38
  :south,
38
39
  :west,
@@ -45,7 +46,11 @@ module Vedeu
45
46
  :yn,
46
47
  :x,
47
48
  :height,
48
- :width
49
+ :width,
50
+ :top_left,
51
+ :top_right,
52
+ :bottom_left,
53
+ :bottom_right
49
54
 
50
55
  # @!attribute [rw] centred
51
56
  # @return [Boolean]
@@ -83,7 +88,7 @@ module Vedeu
83
88
  # @return [Fixnum]
84
89
  attr_writer :yn
85
90
 
86
- # Returns a new instance of Geometry.
91
+ # Returns a new instance of Vedeu::Geometry.
87
92
  #
88
93
  # @param attributes [Hash]
89
94
  # @option attributes centred [Boolean]
@@ -31,6 +31,8 @@ module Vedeu
31
31
  new(value).columns
32
32
  end
33
33
 
34
+ # Returns a new instance of Vedeu::Grid.
35
+ #
34
36
  # @param value [Fixnum]
35
37
  # @return [Grid]
36
38
  def initialize(value)
@@ -13,6 +13,27 @@ module Vedeu
13
13
  new(iy, ix, oy, ox).[]
14
14
  end
15
15
 
16
+ # @param name [String] The name of the interface.
17
+ # @param iy [Fixnum]
18
+ # @param ix [Fixnum]
19
+ # @return [Vedeu::Position]
20
+ def self.from_interface(name, iy, ix)
21
+ if Vedeu.interfaces.registered?(name)
22
+ interface = Vedeu.interfaces.find(name)
23
+ oy = interface.border.by
24
+ ox = interface.border.bx
25
+
26
+ else
27
+ oy = 1
28
+ ox = 1
29
+
30
+ end
31
+
32
+ new(iy, ix, oy, ox).[]
33
+ end
34
+
35
+ # Returns a new instance of Vedeu::IndexPosition.
36
+ #
16
37
  # @param iy [Fixnum]
17
38
  # @param ix [Fixnum]
18
39
  # @param oy [Fixnum]
@@ -9,6 +9,8 @@ module Vedeu
9
9
  new(v, vn, max, min).apply
10
10
  end
11
11
 
12
+ # Returns a new instance of Vedeu::Limit.
13
+ #
12
14
  # @param v [Fixnum]
13
15
  # @param vn [Fixnum]
14
16
  # @param max [Fixnum]
@@ -38,7 +38,7 @@ module Vedeu
38
38
  end
39
39
  end
40
40
 
41
- # Initializes a new instance of Position.
41
+ # Initializes a new instance of Vedeu::Position.
42
42
  #
43
43
  # @param y [Fixnum] The row/line position.
44
44
  # @param x [Fixnum] The column/character position.
@@ -20,6 +20,8 @@ module Vedeu
20
20
  new(y, x).[]
21
21
  end
22
22
 
23
+ # Returns a new instance of Vedeu::PositionIndex.
24
+ #
23
25
  # @param y [Fixnum]
24
26
  # @param x [Fixnum]
25
27
  # @return [Vedeu::PositionIndex]
@@ -45,6 +45,8 @@ module Vedeu
45
45
  new(interface, x, y).validate
46
46
  end
47
47
 
48
+ # Returns a new instance of Vedeu::PositionValidator.
49
+ #
48
50
  # @param interface [Interface]
49
51
  # @param x [Fixnum]
50
52
  # @param y [Fixnum]
@@ -13,7 +13,7 @@ module Vedeu
13
13
  new(reader).capture
14
14
  end
15
15
 
16
- # Returns a new instance of Input.
16
+ # Returns a new instance of Vedeu::Input.
17
17
  #
18
18
  # @param reader [IO] An object that responds to `#read`. Typically, this is
19
19
  # Vedeu::Terminal.
@@ -4,7 +4,7 @@ module Vedeu
4
4
  #
5
5
  class Key
6
6
 
7
- # Returns a new instance of Key.
7
+ # Returns a new instance of Vedeu::Key.
8
8
  #
9
9
  # @param input [String|Symbol]
10
10
  # @param block [Proc]
@@ -18,6 +18,8 @@ module Vedeu
18
18
  # @return [String]
19
19
  attr_accessor :name
20
20
 
21
+ # Returns a new instance of Vedeu::Keymap.
22
+ #
21
23
  # @param attributes [Hash]
22
24
  # @option attributes name [String] The name of the keymap.
23
25
  # @option attributes keys [Vedeu::Keys|Array] A collection of keys.