vedeu 0.4.65 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 75b2e5231b8b3902b1efb1235d1b3713452d65d7
4
- data.tar.gz: 70bdf955c10a76f9c7fdd5e42720dca9468a1102
3
+ metadata.gz: 7524aaacdae0af0c028b3fe2f6eabbea601099c8
4
+ data.tar.gz: a8ed59caec01210c9a71971828ffabf1c994fbc9
5
5
  SHA512:
6
- metadata.gz: 1dfccfc1a1954962f7db2b419b8ff9def9ebba98d90445c8092291738b7ade467e60264dc86ca7f8fb4874f34c7588ae4581054dafadb075c3ab5d49deda1add
7
- data.tar.gz: e766f3d3564dd8eab71731127885474c122cf2c9d7c1741b9dcef5338644e8a144c1eb05ddead0b4d9c369f96390b26c76da15ba8653ba3c4def96cd16ca4cf5
6
+ metadata.gz: 91b571759068fef75df5942f4ca957a8d4237c2dc8b77731fb11df1178e043819f493ebf96d615b892172a9d29a2536f118ebee39d960e362b76c855ce4da4f3
7
+ data.tar.gz: 917454f5c7d6d280552259bc795dd9b54a16dc162b24919e3edc17f0e6c475f7b2cbece626626c0c4043294eb0ff5d375566486d54773a70901b7ac639534ccf
@@ -19,7 +19,7 @@ require 'zlib'
19
19
 
20
20
  require 'thor'
21
21
 
22
- require 'vedeu/log'
22
+ require 'vedeu/log/log'
23
23
 
24
24
  # Vedeu is a GUI framework for terminal/console applications written in Ruby.
25
25
  #
@@ -2,8 +2,9 @@ require 'vedeu/version'
2
2
  require 'vedeu/runtime/launcher'
3
3
  require 'vedeu/runtime/bootstrap'
4
4
  require 'vedeu/exceptions'
5
- require 'vedeu/log'
6
- require 'vedeu/debug'
5
+ require 'vedeu/log/log'
6
+ require 'vedeu/log/debug'
7
+ require 'vedeu/log/timer'
7
8
  require 'vedeu/traps'
8
9
  require 'vedeu/common'
9
10
  require 'vedeu/terminal_mode'
@@ -14,7 +15,6 @@ require 'vedeu/configuration/api'
14
15
  require 'vedeu/configuration/configuration'
15
16
 
16
17
  require 'vedeu/terminal'
17
- require 'vedeu/timer'
18
18
  require 'vedeu/runtime/main_loop'
19
19
  require 'vedeu/runtime/application'
20
20
 
@@ -106,7 +106,6 @@ require 'vedeu/templating/all'
106
106
  require 'vedeu/templating/encoder'
107
107
  require 'vedeu/templating/decoder'
108
108
  require 'vedeu/templating/helpers'
109
- require 'vedeu/templating/view_helpers'
110
109
  require 'vedeu/templating/template'
111
110
  require 'vedeu/templating/view_template'
112
111
 
@@ -23,6 +23,14 @@ module Vedeu
23
23
  @args = args
24
24
  end
25
25
 
26
+ # @raise [Vedeu::NotImplemented] Subclasses of this class must implement
27
+ # this method.
28
+ def render
29
+ fail Vedeu::NotImplemented,
30
+ 'The subclass of Vedeu::ApplicationView must implement the #render' \
31
+ 'method.'
32
+ end
33
+
26
34
  protected
27
35
 
28
36
  # @!attribute [r] args
@@ -44,14 +44,17 @@ module Vedeu
44
44
  # @param value [Vedeu::Colour|Hash<Symbol => void>]
45
45
  # @return [Object]
46
46
  def self.coerce(value)
47
- return value if value.is_a?(Vedeu::Colour)
48
- return new unless value.is_a?(Hash)
47
+ return value if value.is_a?(self)
48
+ return new unless value.is_a?(Hash)
49
49
 
50
- if value.key?(:colour)
51
- coerce(value[:colour])
50
+ if value[:colour] && value[:colour].is_a?(self)
51
+ value[:colour]
52
52
 
53
- elsif value.key?(:background) || value.key?(:foreground)
54
- new(value)
53
+ elsif value[:colour] && value[:colour].is_a?(Hash)
54
+ new(value[:colour])
55
+
56
+ elsif value[:background] || value[:foreground]
57
+ new(value)
55
58
 
56
59
  else
57
60
  new
@@ -46,6 +46,15 @@ module Vedeu
46
46
  # @return [Vedeu::Cursors]
47
47
  def_delegators Vedeu::Cursors, :cursors
48
48
 
49
+ # Allow debugging via the creation of stack traces courtesy of ruby-prof.
50
+ #
51
+ # @example
52
+ # Vedeu.debug
53
+ #
54
+ # @!method debug
55
+ # @return [Vedeu::Debug]
56
+ def_delegators Vedeu::Debug, :debug
57
+
49
58
  # Manipulate the repository of events.
50
59
  #
51
60
  # @example
@@ -0,0 +1,75 @@
1
+ module Vedeu
2
+
3
+ module Debug
4
+
5
+ extend self
6
+
7
+ # :nocov:
8
+ # Helps to debug a running application by providing a stack trace of its
9
+ # execution upon exiting.
10
+ #
11
+ # @param filename [String]
12
+ # @return [void]
13
+ # @yieldreturn [void] The section of the application to debug.
14
+ def self.debug(filename = 'profile.html')
15
+ return nil unless block_given?
16
+
17
+ require 'ruby-prof'
18
+
19
+ # RubyProf.measure_mode = RubyProf::WALL_TIME
20
+ # RubyProf.measure_mode = RubyProf::PROCESS_TIME
21
+ RubyProf.measure_mode = RubyProf::CPU_TIME
22
+ # RubyProf.measure_mode = RubyProf::ALLOCATIONS
23
+ # RubyProf.measure_mode = RubyProf::MEMORY
24
+ # RubyProf.measure_mode = RubyProf::GC_TIME
25
+ # RubyProf.measure_mode = RubyProf::GC_RUNS
26
+
27
+ RubyProf.start
28
+
29
+ work = yield
30
+
31
+ result = RubyProf.stop
32
+ result.eliminate_methods!([
33
+ /^Array/,
34
+ /^Hash/,
35
+ /^String/,
36
+ /^Fixnum/,
37
+ ])
38
+
39
+ File.open('/tmp/' + filename, 'w') do |file|
40
+ # - Creates a HTML visualization of the Ruby stack
41
+ RubyProf::CallStackPrinter.new(result).print(file)
42
+
43
+ # Used with QTCacheGrind to analyse performance.
44
+ # RubyProf::CallTreePrinter.new(result).print(file)
45
+
46
+ # Creates a flat report in text format
47
+ # RubyProf::FlatPrinter
48
+
49
+ # - same as above but more verbose
50
+ # RubyProf::FlatPrinterWithLineNumbers
51
+
52
+ # - Creates a call graph report in text format
53
+ # RubyProf::GraphPrinter
54
+
55
+ # - Creates a call graph report in HTML (separate files per thread)
56
+ # RubyProf::GraphHtmlPrinter
57
+
58
+ # - Creates a call graph report in GraphViz's DOT format which can be
59
+ # converted to an image
60
+ # RubyProf::DotPrinter
61
+
62
+ # - Creates a call tree report compatible with KCachegrind.
63
+ # RubyProf::CallTreePrinter
64
+
65
+ # - Uses the other printers to create several reports in one profiling run
66
+ # RubyProf::MultiPrinter
67
+ end
68
+
69
+ work
70
+ end
71
+ # :nocov:
72
+
73
+ end # Debug
74
+
75
+ end # Vedeu
File without changes
File without changes
@@ -11,7 +11,7 @@ module Vedeu
11
11
  # @param klass [Class]
12
12
  # @return [Set]
13
13
  def register(klass)
14
- storage.add(klass)
14
+ storage.add(klass) if klass
15
15
  end
16
16
 
17
17
  # List all models stored in each registered repository.
@@ -47,9 +47,16 @@ module Vedeu
47
47
  def define_stream(attributes = {}, &block)
48
48
  fail Vedeu::InvalidSyntax, 'block not given' unless block_given?
49
49
 
50
- Vedeu::Stream.build(colour: Vedeu::Colour.new(attributes),
51
- style: Vedeu::Style.new(attributes[:style]),
52
- value: block.call)
50
+ encode(
51
+ Vedeu::Stream.build(colour: Vedeu::Colour.new(attributes),
52
+ style: Vedeu::Style.new(attributes[:style]),
53
+ value: block.call))
54
+ end
55
+
56
+ # @param data [String]
57
+ # @return [String]
58
+ def encode(data)
59
+ Vedeu::Templating::Encoder.process(data)
53
60
  end
54
61
 
55
62
  end # Helpers
@@ -7,7 +7,7 @@ module Vedeu
7
7
  class ViewTemplate < Template
8
8
 
9
9
  include Vedeu::Common
10
- include Vedeu::Templating::ViewHelpers
10
+ include Vedeu::Templating::Helpers
11
11
 
12
12
  # @return [Vedeu::Lines]
13
13
  def parse
@@ -1,6 +1,6 @@
1
1
  module Vedeu
2
2
 
3
3
  # The current version of Vedeu.
4
- VERSION = '0.4.65'
4
+ VERSION = '0.5.0'
5
5
 
6
6
  end
@@ -14,7 +14,13 @@ module Vedeu
14
14
  end
15
15
 
16
16
  describe '.render' do
17
- it { described.must_respond_to(:render) }
17
+ subject { described.render(object) }
18
+
19
+ it { proc { subject }.must_raise(Vedeu::NotImplemented) }
20
+ end
21
+
22
+ describe '#render' do
23
+ it { instance.must_respond_to(:render) }
18
24
  end
19
25
 
20
26
  end # ApplicationView
@@ -8,6 +8,7 @@ module Vedeu
8
8
  it { Vedeu.must_respond_to(:borders) }
9
9
  it { Vedeu.must_respond_to(:buffers) }
10
10
  it { Vedeu.must_respond_to(:cursors) }
11
+ it { Vedeu.must_respond_to(:debug) }
11
12
  it { Vedeu.must_respond_to(:events) }
12
13
  it { Vedeu.must_respond_to(:foreground_colours) }
13
14
  it { Vedeu.must_respond_to(:geometries) }
@@ -0,0 +1,16 @@
1
+ require 'test_helper'
2
+
3
+ module Vedeu
4
+
5
+ describe Debug do
6
+
7
+ let(:described) { Vedeu::Debug }
8
+
9
+ describe '.debug' do
10
+ # @todo
11
+ # it { skip }
12
+ end
13
+
14
+ end # Debug
15
+
16
+ end # Vedeu
@@ -4,16 +4,37 @@ module Vedeu
4
4
 
5
5
  describe Repositories do
6
6
 
7
+ let(:described) { Vedeu::Repositories }
8
+
7
9
  describe '.register' do
8
- # it { skip! }
10
+ subject { described.register(klass) }
11
+
12
+ context 'when the klass is nil' do
13
+ let(:klass) {}
14
+
15
+ it { subject.must_equal(nil) }
16
+ end
17
+
18
+ context 'when the klass is a repository class' do
19
+ let(:klass) { Vedeu::Buffers }
20
+
21
+ it { subject.wont_be_empty }
22
+ end
9
23
  end
10
24
 
11
25
  describe '.registered' do
12
- # it { skip! }
26
+ before { described.reset! }
27
+
28
+ subject { described.registered }
29
+
30
+ # @todo
31
+ # it { skip }
13
32
  end
14
33
 
15
34
  describe '.reset!' do
16
- # it { skip! }
35
+ subject { described.reset! }
36
+
37
+ it { subject.must_equal(true) }
17
38
  end
18
39
 
19
40
  end # Repositories
@@ -17,8 +17,12 @@ module Vedeu
17
17
 
18
18
  describe '#background' do
19
19
  let(:expected) {
20
- Vedeu::Stream.new(value: 'background text',
21
- colour: Vedeu::Colour.coerce(background: '#000000'))
20
+ "{{" \
21
+ "eJxdj00LwjAMhj1Ip7aKX3iW+Qd2zi5BUdhZ8d5tUYZzla4VxT9vrTrBXJI34UnetD" \
22
+ "sKxnvKyQJsjSZ5FjBEaYwuUmuofnDgWVlQZSJXqFJZ/QNWXgcOSGV2Omplq1zB7DNd" \
23
+ "Nj0GAt9sEopF5IMBW+8ceVCa/slN02OxSMIWi/s74BepvY1ebe4lKRg1tp1kwPEqS0" \
24
+ "tu7nMSTn+m5oZuxm/pVvJM35XO1fu1WGDg1PcCR38CRTzBPvTwxeDgCdSbXHg=" \
25
+ "}}"
22
26
  }
23
27
 
24
28
  subject { instance.background('#000000') { 'background text' } }
@@ -34,7 +38,7 @@ module Vedeu
34
38
  subject { instance.colour(attributes) { 'colour text' } }
35
39
 
36
40
  context 'with no attributes' do
37
- it { subject.must_be_instance_of(Vedeu::Stream) }
41
+ it { subject.must_be_instance_of(String) }
38
42
  end
39
43
 
40
44
  context 'with a background attribute' do
@@ -44,8 +48,13 @@ module Vedeu
44
48
  }
45
49
  }
46
50
  let(:expected) {
47
- Vedeu::Stream.new(value: 'colour text',
48
- colour: Vedeu::Colour.coerce(attributes))
51
+ "{{" \
52
+ "eJxdj08LwjAMxT1Ip7aKf8CzzC9QPGaXoCjsrHjvNMpwrlJbUfzy1k4neEpewu/l" \
53
+ "pdnSMNzSnhzA2hpSZwF9VNaaPHOWrk8OfFfkVFrpG11oZ37AIujIA5nanY5Gu3Kv" \
54
+ "YfzZzusZA4EVm8ZiKuVsJiUDttx48qAN/ZOresYSkcYNlnQ3wC/KhBidq30UpGFQ" \
55
+ "x/aSAcebKhz5fahp3K9OTizdbXBol+pMXzufqHorERh59XXnGOxRJCPsQgffDPZe" \
56
+ "Rsda7A==" \
57
+ "}}"
49
58
  }
50
59
 
51
60
  it { subject.must_equal(expected) }
@@ -58,8 +67,13 @@ module Vedeu
58
67
  }
59
68
  }
60
69
  let(:expected) {
61
- Vedeu::Stream.new(value: 'colour text',
62
- colour: Vedeu::Colour.coerce(attributes))
70
+ "{{" \
71
+ "eJxdj08LwjAMxT1I/dMqU8GzzC/gOb0ERWFnh/dOMxHnKrUVxS9v1+kEc2lewu/l" \
72
+ "td3VMN7RgRzA1hpSFwERKmvNKXOWbi8OfF+cqLQL3+hCO/MDVkF3PJCp/flotCsP" \
73
+ "Gqaf7bKZMRBYs0ncYsDWqUdybegf2TQzJkUSi3meL3wxOUiBX5UJMfo3+yxIw6iJ" \
74
+ "7SUDjndVOPL78CZxVJ+cWXrY4NAr1YWqBJXwiepvSYEdr77uHIM9CjnBAfSxYnD4" \
75
+ "BqMMW1Q=" \
76
+ "}}"
63
77
  }
64
78
 
65
79
  it { subject.must_equal(expected) }
@@ -73,8 +87,13 @@ module Vedeu
73
87
  }
74
88
  }
75
89
  let(:expected) {
76
- Vedeu::Stream.new(value: 'colour text',
77
- colour: Vedeu::Colour.coerce(attributes))
90
+ "{{" \
91
+ "eJxdj0sLwjAQhD1IfCSKD/As+geKF2F7WRQFz4r3VLci1kZiIop/3jXVCuaSzCzf" \
92
+ "7KRaN9Db0p48wNpZ0mcFHdTO2WPiHV2fEuQuO1LuIn6YzHj7A+ZB1xhI9O50sMbn" \
93
+ "ewODz3RWegIUFuxqpMYRn8lEgFhsmEyNpX9yWXoiVm8kTafTKBJxawPyom1o07y6" \
94
+ "R0YGumV7lgIk3nTmiefhXo06xeaho7sLCY1cn9mvBMHFit/FCmusvukSQzyquI8t" \
95
+ "aOKbwfYLqERctQ==" \
96
+ "}}"
78
97
  }
79
98
 
80
99
  it { subject.must_equal(expected) }
@@ -83,8 +102,12 @@ module Vedeu
83
102
 
84
103
  describe '#foreground' do
85
104
  let(:expected) {
86
- Vedeu::Stream.new(value: 'foreground text',
87
- colour: Vedeu::Colour.coerce(foreground: '#000000'))
105
+ "{{" \
106
+ "eJxdj08PATEQxR2ki3bFvzjL+gLOs5cJIdkzcS87ZKO2Uq0QX163WIm5dN5MfvNemy" \
107
+ "0Ngy3l5ADW1pA8C+ihtNYUO2fp+uTA96qg0s58o5V25gcsgo48sJP709FoV+Yaxp/t" \
108
+ "vJ4xEPhms6TBgC03HjloQ//Iqp6xVGSJmM5CsTTeAL9IE2J0rvahSEO/ju0lA443qR" \
109
+ "z5fXizZPRzmFi623ClXcozVSkq4VO9v5YKjLz6OnAMFijSIcbQwYrB7gsCxlyT" \
110
+ "}}"
88
111
  }
89
112
 
90
113
  subject { instance.foreground('#000000') { 'foreground text' } }
@@ -96,8 +119,12 @@ module Vedeu
96
119
 
97
120
  describe '#style' do
98
121
  let(:expected) {
99
- Vedeu::Stream.new(value: 'style text',
100
- style: Vedeu::Style.coerce(:bold))
122
+ "{{" \
123
+ "eJxdj08LwjAMxT1I59b6HzzLPoHn7BIUBc+K926LItZVaiuKX96u6gRveUl+7yXtjo" \
124
+ "bRjkpyABtrSJ4FDFBaa465s3R9cuCFOlJlZ77QSjvzAxZBRx7IZXE6GO2qUsPkM503" \
125
+ "PQYC3+w6bTFgy61H9trQP7JqeiwT9W7W3QK/SBPyk6t9KNIwbO71kgHHm1SOIM61Ki" \
126
+ "EJYp32w/LU0t0Gl7iSZ/pa+nPeP2UCI6++CRwDhSIbYxcSrBnsvQDMNVrp" \
127
+ "}}"
101
128
  }
102
129
 
103
130
  subject { instance.style(:bold) { 'style text' } }
@@ -105,7 +132,7 @@ module Vedeu
105
132
  it { subject.must_equal(expected) }
106
133
  end
107
134
 
108
- end # Helpers
135
+ end # ViewHelpers
109
136
 
110
137
  end # Templating
111
138
 
@@ -19,8 +19,10 @@ SimpleCov.start do
19
19
  add_filter '/test/'
20
20
  add_group 'application', 'vedeu/application'
21
21
  add_group 'bindings', 'vedeu/bindings'
22
+ add_group 'borders', 'vedeu/borders'
22
23
  add_group 'buffers', 'vedeu/buffers'
23
24
  add_group 'cli', 'vedeu/cli'
25
+ add_group 'colours', 'vedeu/colours'
24
26
  add_group 'configuration', 'vedeu/configuration'
25
27
  add_group 'cursor', 'vedeu/cursor'
26
28
  add_group 'distributed', 'vedeu/distributed'
@@ -28,10 +30,13 @@ SimpleCov.start do
28
30
  add_group 'events', 'vedeu/events'
29
31
  add_group 'geometry', 'vedeu/geometry'
30
32
  add_group 'input', 'vedeu/input'
33
+ add_group 'log', 'vedeu/log'
31
34
  add_group 'models', 'vedeu/models'
32
35
  add_group 'null', 'vedeu/null'
33
36
  add_group 'output', 'vedeu/output'
37
+ add_group 'plugins', 'vedeu/plygins'
34
38
  add_group 'repositories', 'vedeu/repositories'
39
+ add_group 'runtime', 'vedeu/runtime'
35
40
  add_group 'templating', 'vedeu/templating'
36
41
  end unless ENV['NO_SIMPLECOV']
37
42
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vedeu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.65
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gavin Laking
@@ -322,7 +322,6 @@ files:
322
322
  - lib/vedeu/cursor/move.rb
323
323
  - lib/vedeu/cursor/refresh_cursor.rb
324
324
  - lib/vedeu/cursor/reposition.rb
325
- - lib/vedeu/debug.rb
326
325
  - lib/vedeu/distributed/client.rb
327
326
  - lib/vedeu/distributed/server.rb
328
327
  - lib/vedeu/distributed/subprocess.rb
@@ -373,7 +372,9 @@ files:
373
372
  - lib/vedeu/input/keys.rb
374
373
  - lib/vedeu/input/mapper.rb
375
374
  - lib/vedeu/internal_api.rb
376
- - lib/vedeu/log.rb
375
+ - lib/vedeu/log/debug.rb
376
+ - lib/vedeu/log/log.rb
377
+ - lib/vedeu/log/timer.rb
377
378
  - lib/vedeu/models/cell.rb
378
379
  - lib/vedeu/models/char.rb
379
380
  - lib/vedeu/models/chars.rb
@@ -442,11 +443,9 @@ files:
442
443
  - lib/vedeu/templating/encoder.rb
443
444
  - lib/vedeu/templating/helpers.rb
444
445
  - lib/vedeu/templating/template.rb
445
- - lib/vedeu/templating/view_helpers.rb
446
446
  - lib/vedeu/templating/view_template.rb
447
447
  - lib/vedeu/terminal.rb
448
448
  - lib/vedeu/terminal_mode.rb
449
- - lib/vedeu/timer.rb
450
449
  - lib/vedeu/traps.rb
451
450
  - lib/vedeu/version.rb
452
451
  - test/lib/vedeu/api_test.rb
@@ -530,7 +529,9 @@ files:
530
529
  - test/lib/vedeu/input/keys_test.rb
531
530
  - test/lib/vedeu/input/mapper_test.rb
532
531
  - test/lib/vedeu/internal_api_test.rb
533
- - test/lib/vedeu/log_test.rb
532
+ - test/lib/vedeu/log/debug_test.rb
533
+ - test/lib/vedeu/log/log_test.rb
534
+ - test/lib/vedeu/log/timer_test.rb
534
535
  - test/lib/vedeu/models/cell_test.rb
535
536
  - test/lib/vedeu/models/char_test.rb
536
537
  - test/lib/vedeu/models/chars_test.rb
@@ -596,11 +597,9 @@ files:
596
597
  - test/lib/vedeu/templating/encoder_test.rb
597
598
  - test/lib/vedeu/templating/helpers_test.rb
598
599
  - test/lib/vedeu/templating/template_test.rb
599
- - test/lib/vedeu/templating/view_helpers_test.rb
600
600
  - test/lib/vedeu/templating/view_template_test.rb
601
601
  - test/lib/vedeu/terminal_mode_test.rb
602
602
  - test/lib/vedeu/terminal_test.rb
603
- - test/lib/vedeu/timer_test.rb
604
603
  - test/lib/vedeu/traps_test.rb
605
604
  - test/lib/vedeu_test.rb
606
605
  - test/support/all_seeds.sh
@@ -612,7 +611,6 @@ files:
612
611
  - test/support/templates/foreground.erb
613
612
  - test/support/templates/multiple.erb
614
613
  - test/support/templates/plain.erb
615
- - test/support/templates/simple_stuff.erb
616
614
  - test/support/templates/style.erb
617
615
  - test/test_helper.rb
618
616
  - vedeu.gemspec
@@ -722,7 +720,9 @@ test_files:
722
720
  - test/lib/vedeu/input/keys_test.rb
723
721
  - test/lib/vedeu/input/mapper_test.rb
724
722
  - test/lib/vedeu/internal_api_test.rb
725
- - test/lib/vedeu/log_test.rb
723
+ - test/lib/vedeu/log/debug_test.rb
724
+ - test/lib/vedeu/log/log_test.rb
725
+ - test/lib/vedeu/log/timer_test.rb
726
726
  - test/lib/vedeu/models/cell_test.rb
727
727
  - test/lib/vedeu/models/char_test.rb
728
728
  - test/lib/vedeu/models/chars_test.rb
@@ -788,11 +788,9 @@ test_files:
788
788
  - test/lib/vedeu/templating/encoder_test.rb
789
789
  - test/lib/vedeu/templating/helpers_test.rb
790
790
  - test/lib/vedeu/templating/template_test.rb
791
- - test/lib/vedeu/templating/view_helpers_test.rb
792
791
  - test/lib/vedeu/templating/view_template_test.rb
793
792
  - test/lib/vedeu/terminal_mode_test.rb
794
793
  - test/lib/vedeu/terminal_test.rb
795
- - test/lib/vedeu/timer_test.rb
796
794
  - test/lib/vedeu/traps_test.rb
797
795
  - test/lib/vedeu_test.rb
798
796
  - test/support/all_seeds.sh
@@ -804,7 +802,6 @@ test_files:
804
802
  - test/support/templates/foreground.erb
805
803
  - test/support/templates/multiple.erb
806
804
  - test/support/templates/plain.erb
807
- - test/support/templates/simple_stuff.erb
808
805
  - test/support/templates/style.erb
809
806
  - test/test_helper.rb
810
807
  has_rdoc:
@@ -1,69 +0,0 @@
1
- module Vedeu
2
-
3
- # :nocov:
4
- # Helps to debug a running application by providing a stack trace of its
5
- # execution upon exiting.
6
- #
7
- # @param filename [String]
8
- # @return [void]
9
- # @yieldreturn [void] The section of the application to debug.
10
- def self.debug(filename = 'profile.html')
11
- return nil unless block_given?
12
-
13
- require 'ruby-prof'
14
-
15
- # RubyProf.measure_mode = RubyProf::WALL_TIME
16
- # RubyProf.measure_mode = RubyProf::PROCESS_TIME
17
- RubyProf.measure_mode = RubyProf::CPU_TIME
18
- # RubyProf.measure_mode = RubyProf::ALLOCATIONS
19
- # RubyProf.measure_mode = RubyProf::MEMORY
20
- # RubyProf.measure_mode = RubyProf::GC_TIME
21
- # RubyProf.measure_mode = RubyProf::GC_RUNS
22
-
23
- RubyProf.start
24
-
25
- work = yield
26
-
27
- result = RubyProf.stop
28
- result.eliminate_methods!([
29
- /^Array/,
30
- /^Hash/,
31
- /^String/,
32
- /^Fixnum/,
33
- ])
34
-
35
- File.open('/tmp/' + filename, 'w') do |file|
36
- # - Creates a HTML visualization of the Ruby stack
37
- RubyProf::CallStackPrinter.new(result).print(file)
38
-
39
- # Used with QTCacheGrind to analyse performance.
40
- # RubyProf::CallTreePrinter.new(result).print(file)
41
-
42
- # Creates a flat report in text format
43
- # RubyProf::FlatPrinter
44
-
45
- # - same as above but more verbose
46
- # RubyProf::FlatPrinterWithLineNumbers
47
-
48
- # - Creates a call graph report in text format
49
- # RubyProf::GraphPrinter
50
-
51
- # - Creates a call graph report in HTML (separate files per thread)
52
- # RubyProf::GraphHtmlPrinter
53
-
54
- # - Creates a call graph report in GraphViz's DOT format which can be
55
- # converted to an image
56
- # RubyProf::DotPrinter
57
-
58
- # - Creates a call tree report compatible with KCachegrind.
59
- # RubyProf::CallTreePrinter
60
-
61
- # - Uses the other printers to create several reports in one profiling run
62
- # RubyProf::MultiPrinter
63
- end
64
-
65
- work
66
- end
67
- # :nocov:
68
-
69
- end # Vedeu
@@ -1,33 +0,0 @@
1
- module Vedeu
2
-
3
- module Templating
4
-
5
- # Provide helpers to be used with your Vedeu templates.
6
- #
7
- module ViewHelpers
8
-
9
- include Vedeu::Templating::Helpers
10
-
11
- private
12
-
13
- # @see Vedeu::Templating::Helpers#colour
14
- def define_stream(attributes = {}, &block)
15
- fail Vedeu::InvalidSyntax, 'block not given' unless block_given?
16
-
17
- encode(
18
- Vedeu::Stream.build(colour: Vedeu::Colour.new(attributes),
19
- style: Vedeu::Style.new(attributes[:style]),
20
- value: block.call))
21
- end
22
-
23
- # @param data [String]
24
- # @return [String]
25
- def encode(data)
26
- Vedeu::Templating::Encoder.process(data)
27
- end
28
-
29
- end # ViewHelpers
30
-
31
- end # Templating
32
-
33
- end # Vedeu
@@ -1,139 +0,0 @@
1
- require 'test_helper'
2
-
3
- module Vedeu
4
-
5
- module Templating
6
-
7
- class ViewHelpersTestClass
8
-
9
- include Vedeu::Templating::ViewHelpers
10
-
11
- end
12
-
13
- describe ViewHelpers do
14
-
15
- let(:described) { Vedeu::Templating::ViewHelpers }
16
- let(:instance) { Vedeu::Templating::ViewHelpersTestClass.new }
17
-
18
- describe '#background' do
19
- let(:expected) {
20
- "{{" \
21
- "eJxdj00LwjAMhj1Ip7aKX3iW+Qd2zi5BUdhZ8d5tUYZzla4VxT9vrTrBXJI34UnetD" \
22
- "sKxnvKyQJsjSZ5FjBEaYwuUmuofnDgWVlQZSJXqFJZ/QNWXgcOSGV2Omplq1zB7DNd" \
23
- "Nj0GAt9sEopF5IMBW+8ceVCa/slN02OxSMIWi/s74BepvY1ebe4lKRg1tp1kwPEqS0" \
24
- "tu7nMSTn+m5oZuxm/pVvJM35XO1fu1WGDg1PcCR38CRTzBPvTwxeDgCdSbXHg=" \
25
- "}}"
26
- }
27
-
28
- subject { instance.background('#000000') { 'background text' } }
29
-
30
- it { instance.must_respond_to(:bg) }
31
-
32
- it { subject.must_equal(expected) }
33
- end
34
-
35
- describe '#colour' do
36
- let(:attributes) { {} }
37
-
38
- subject { instance.colour(attributes) { 'colour text' } }
39
-
40
- context 'with no attributes' do
41
- it { subject.must_be_instance_of(String) }
42
- end
43
-
44
- context 'with a background attribute' do
45
- let(:attributes) {
46
- {
47
- background: '#002200'
48
- }
49
- }
50
- let(:expected) {
51
- "{{" \
52
- "eJxdj08LwjAMxT1Ip7aKf8CzzC9QPGaXoCjsrHjvNMpwrlJbUfzy1k4neEpewu/l" \
53
- "pdnSMNzSnhzA2hpSZwF9VNaaPHOWrk8OfFfkVFrpG11oZ37AIujIA5nanY5Gu3Kv" \
54
- "YfzZzusZA4EVm8ZiKuVsJiUDttx48qAN/ZOresYSkcYNlnQ3wC/KhBidq30UpGFQ" \
55
- "x/aSAcebKhz5fahp3K9OTizdbXBol+pMXzufqHorERh59XXnGOxRJCPsQgffDPZe" \
56
- "Rsda7A==" \
57
- "}}"
58
- }
59
-
60
- it { subject.must_equal(expected) }
61
- end
62
-
63
- context 'with a foreground attribute' do
64
- let(:attributes) {
65
- {
66
- foreground: '#ff0000'
67
- }
68
- }
69
- let(:expected) {
70
- "{{" \
71
- "eJxdj08LwjAMxT1I/dMqU8GzzC/gOb0ERWFnh/dOMxHnKrUVxS9v1+kEc2lewu/l" \
72
- "td3VMN7RgRzA1hpSFwERKmvNKXOWbi8OfF+cqLQL3+hCO/MDVkF3PJCp/flotCsP" \
73
- "Gqaf7bKZMRBYs0ncYsDWqUdybegf2TQzJkUSi3meL3wxOUiBX5UJMfo3+yxIw6iJ" \
74
- "7SUDjndVOPL78CZxVJ+cWXrY4NAr1YWqBJXwiepvSYEdr77uHIM9CjnBAfSxYnD4" \
75
- "BqMMW1Q=" \
76
- "}}"
77
- }
78
-
79
- it { subject.must_equal(expected) }
80
- end
81
-
82
- context 'with both attributes' do
83
- let(:attributes) {
84
- {
85
- background: '#000022',
86
- foreground: '#ff7700',
87
- }
88
- }
89
- let(:expected) {
90
- "{{" \
91
- "eJxdj0sLwjAQhD1IfCSKD/As+geKF2F7WRQFz4r3VLci1kZiIop/3jXVCuaSzCzf" \
92
- "7KRaN9Db0p48wNpZ0mcFHdTO2WPiHV2fEuQuO1LuIn6YzHj7A+ZB1xhI9O50sMbn" \
93
- "ewODz3RWegIUFuxqpMYRn8lEgFhsmEyNpX9yWXoiVm8kTafTKBJxawPyom1o07y6" \
94
- "R0YGumV7lgIk3nTmiefhXo06xeaho7sLCY1cn9mvBMHFit/FCmusvukSQzyquI8t" \
95
- "aOKbwfYLqERctQ==" \
96
- "}}"
97
- }
98
-
99
- it { subject.must_equal(expected) }
100
- end
101
- end
102
-
103
- describe '#foreground' do
104
- let(:expected) {
105
- "{{" \
106
- "eJxdj08PATEQxR2ki3bFvzjL+gLOs5cJIdkzcS87ZKO2Uq0QX163WIm5dN5MfvNemy" \
107
- "0Ngy3l5ADW1pA8C+ihtNYUO2fp+uTA96qg0s58o5V25gcsgo48sJP709FoV+Yaxp/t" \
108
- "vJ4xEPhms6TBgC03HjloQ//Iqp6xVGSJmM5CsTTeAL9IE2J0rvahSEO/ju0lA443qR" \
109
- "z5fXizZPRzmFi623ClXcozVSkq4VO9v5YKjLz6OnAMFijSIcbQwYrB7gsCxlyT" \
110
- "}}"
111
- }
112
-
113
- subject { instance.foreground('#000000') { 'foreground text' } }
114
-
115
- it { instance.must_respond_to(:fg) }
116
-
117
- it { subject.must_equal(expected) }
118
- end
119
-
120
- describe '#style' do
121
- let(:expected) {
122
- "{{" \
123
- "eJxdj08LwjAMxT1I59b6HzzLPoHn7BIUBc+K926LItZVaiuKX96u6gRveUl+7yXtjo" \
124
- "bRjkpyABtrSJ4FDFBaa465s3R9cuCFOlJlZ77QSjvzAxZBRx7IZXE6GO2qUsPkM503" \
125
- "PQYC3+w6bTFgy61H9trQP7JqeiwT9W7W3QK/SBPyk6t9KNIwbO71kgHHm1SOIM61Ki" \
126
- "EJYp32w/LU0t0Gl7iSZ/pa+nPeP2UCI6++CRwDhSIbYxcSrBnsvQDMNVrp" \
127
- "}}"
128
- }
129
-
130
- subject { instance.style(:bold) { 'style text' } }
131
-
132
- it { subject.must_equal(expected) }
133
- end
134
-
135
- end # ViewHelpers
136
-
137
- end # Templating
138
-
139
- end # Vedeu
@@ -1,6 +0,0 @@
1
- Some text here {{ colour(background: '#ff0', foreground: '#000') { 'with colour' } }}, then more text, cool.
2
- Here's the next line. All ready for parsing...
3
-
4
- {{ colour(foreground: '#0f0') { 'Yay!' } }}
5
-
6
- That was fun!