spicycode-rcov 0.8.2 → 0.8.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -25,6 +25,8 @@ begin
25
25
  rescue LoadError
26
26
  end
27
27
 
28
+ require File.expand_path(File.join(File.dirname(__FILE__), 'rexml_extensions' ))
29
+
28
30
  if (RUBY_VERSION == "1.8.6" || RUBY_VERSION == "1.8.7") && defined? REXML::Formatters::Transitive
29
31
  class REXML::Document
30
32
  remove_method :write rescue nil
@@ -74,6 +76,7 @@ if (RUBY_VERSION == "1.8.6" || RUBY_VERSION == "1.8.7") && defined? REXML::Forma
74
76
  output << ' '*@level
75
77
  end
76
78
  end
79
+
77
80
  end
78
81
 
79
82
  class Formatter # :nodoc:
@@ -85,11 +88,11 @@ class Formatter # :nodoc:
85
88
  /\btest\//,
86
89
  /\bvendor\//,
87
90
  /\A#{Regexp.escape(__FILE__)}\z/]
88
-
91
+
89
92
  DEFAULT_OPTS = {:ignore => ignore_files, :sort => :name, :sort_reverse => false,
90
93
  :output_threshold => 101, :dont_ignore => [],
91
94
  :callsite_analyzer => nil, :comments_run_by_default => false}
92
-
95
+
93
96
  def initialize(opts = {})
94
97
  options = DEFAULT_OPTS.clone.update(opts)
95
98
  @files = {}
@@ -535,7 +538,7 @@ class HTMLCoverage < Formatter # :nodoc:
535
538
  require 'fileutils'
536
539
  JAVASCRIPT_PROLOG = <<-EOS
537
540
 
538
- // \<![CDATA[
541
+ // <![CDATA[
539
542
  function toggleCode( id ) {
540
543
  if ( document.getElementById )
541
544
  elem = document.getElementById( id );
@@ -556,7 +559,7 @@ class HTMLCoverage < Formatter # :nodoc:
556
559
  }
557
560
 
558
561
  // Make cross-references hidden by default
559
- document.writeln( "\<style type=\\"text/css\\">span.cross-ref { display: none }</style>" )
562
+ document.writeln( "<style type=\\"text/css\\">span.cross-ref { display: none }</style>" )
560
563
  // ]]>
561
564
  EOS
562
565
 
@@ -718,7 +721,7 @@ EOS
718
721
  return if @files.empty?
719
722
  FileUtils.mkdir_p @dest
720
723
  create_index(File.join(@dest, "index.html"))
721
-
724
+
722
725
  each_file_pair_sorted do |filename, fileinfo|
723
726
  create_file(File.join(@dest, mangle_filename(filename)), fileinfo)
724
727
  end
@@ -813,29 +816,29 @@ EOS
813
816
  end
814
817
 
815
818
  class SummaryFileInfo # :nodoc:
816
-
819
+
817
820
  def initialize(obj)
818
- @o = obj
821
+ @o = obj
819
822
  end
820
-
823
+
821
824
  def num_lines
822
825
  @o.num_lines
823
826
  end
824
-
827
+
825
828
  def num_code_lines
826
829
  @o.num_code_lines
827
830
  end
828
-
831
+
829
832
  def code_coverage
830
833
  @o.code_coverage
831
834
  end
832
-
835
+
833
836
  def total_coverage
834
837
  @o.total_coverage
835
838
  end
836
-
839
+
837
840
  def name
838
- "TOTAL"
841
+ "TOTAL"
839
842
  end
840
843
 
841
844
  end
@@ -883,11 +886,7 @@ EOS
883
886
  end
884
887
  }
885
888
  } }
886
- if String.new.respond_to?(:lines) then
887
- lines = output.pretty.lines.to_a
888
- else
889
- lines = output.pretty.to_a
890
- end
889
+ lines = output.pretty.to_a
891
890
  lines.unshift lines.pop if /DOCTYPE/ =~ lines[-1]
892
891
  File.open(destname, "w") do |f|
893
892
  f.puts lines
@@ -1039,11 +1038,7 @@ EOS
1039
1038
  }
1040
1039
  } }
1041
1040
  # .pretty needed to make sure DOCTYPE is in a separate line
1042
- if String.new.respond_to?(:lines)
1043
- lines = output.pretty.lines.to_a
1044
- else
1045
- lines = output.pretty.to_a
1046
- end
1041
+ lines = output.pretty.to_a
1047
1042
  lines.unshift lines.pop if /DOCTYPE/ =~ lines[-1]
1048
1043
  File.open(destfile, "w") do |f|
1049
1044
  f.puts lines
@@ -1158,7 +1153,7 @@ class HTMLProfiling < HTMLCoverage # :nodoc:
1158
1153
  nil
1159
1154
  end
1160
1155
  end
1161
-
1156
+
1162
1157
  end
1163
1158
 
1164
1159
  class RubyAnnotation < Formatter # :nodoc:
@@ -4,7 +4,7 @@
4
4
 
5
5
  module Rcov
6
6
 
7
- VERSION = "0.8.1.5.7"
7
+ VERSION = "0.8.2.1"
8
8
  RELEASE_DATE = "2009-03-17"
9
9
  RCOVRT_ABI = [2,0,0]
10
10
  UPSTREAM_URL = "http://github.com/spicycode/rcov"
@@ -1,7 +1,7 @@
1
1
  # xx can be redistributed and used under the following conditions
2
2
  # (just keep the following copyright notice, list of conditions and disclaimer
3
3
  # in order to satisfy rcov's "Ruby license" and xx's license simultaneously).
4
- #
4
+ #
5
5
  #ePark Labs Public License version 1
6
6
  #Copyright (c) 2005, ePark Labs, Inc. and contributors
7
7
  #All rights reserved.
@@ -29,19 +29,14 @@
29
29
  #(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30
30
  #SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
31
 
32
- unless(defined?($__xx_rb__) or defined?(XX))
32
+ unless defined? $__xx_rb__
33
33
 
34
34
  require "rexml/document"
35
35
 
36
+
36
37
  module XX
37
38
  #--{{{
38
- VERSION = "2.1.0"
39
- def self.version() VERSION end
40
-
41
- LIBDIR = File.dirname(File.expand_path(__FILE__)) << File::SEPARATOR
42
- def self.libdir() LIBDIR end
43
-
44
- require libdir + "binding_of_caller"
39
+ VERSION = "0.1.0"
45
40
 
46
41
  %w(
47
42
  CRAZY_LIKE_A_HELL
@@ -55,13 +50,11 @@ module XX
55
50
  attr "doc"
56
51
  attr "stack"
57
52
  attr "size"
58
- attr_accessor "xmldecl"
59
53
 
60
54
  def initialize *a, &b
61
55
  #--{{{
62
- @doc = ::REXML::Document::new *a, &b
56
+ @doc = ::REXML::Document::new(*a, &b)
63
57
  @stack = [@doc]
64
- @xmldecl = nil
65
58
  @size = 0
66
59
  #--}}}
67
60
  end
@@ -89,23 +82,17 @@ module XX
89
82
  end
90
83
  def to_str port = ""
91
84
  #--{{{
92
- xmldecl ? ugly(port) : pretty(port)
93
- #--}}}
94
- end
95
- alias_method "to_s", "to_str"
96
- def pretty port = ""
97
- #--{{{
98
- @doc.write port, indent=0, transitive=false, ie_hack=true
85
+ @doc.write port, indent=-1, transitive=false, ie_hack=true
99
86
  port
100
87
  #--}}}
101
88
  end
102
- def ugly port = ''
89
+ alias_method "to_s", "to_str"
90
+ def pretty port = ''
103
91
  #--{{{
104
- @doc.write port, indent=-1, transitive=false, ie_hack=true
92
+ @doc.write port, indent=2, transitive=false, ie_hack=true
105
93
  port
106
94
  #--}}}
107
95
  end
108
- alias_method "compact", "ugly"
109
96
  def create element
110
97
  #--{{{
111
98
  push element
@@ -187,7 +174,7 @@ module XX
187
174
  x.to_s
188
175
  end
189
176
 
190
- else # other - try anyhow
177
+ else # other - try anyhow
191
178
  t <<
192
179
  case x
193
180
  when ::REXML::Document
@@ -217,34 +204,67 @@ module XX
217
204
 
218
205
  module InstanceMethods
219
206
  #--{{{
220
- def _ tag_name, *a, &b
207
+ def method_missing m, *a, &b
221
208
  #--{{{
222
- hashes, nothashes = a.partition{|x| Hash === x}
209
+ m = m.to_s
223
210
 
224
- doc = xx_doc
225
- element = ::REXML::Element::new "#{ tag_name }"
211
+ tag_method, tag_name = xx_class::xx_tag_method_name m
212
+
213
+ c_method_missing = xx_class::xx_config_for "method_missing", xx_which
214
+ c_tags = xx_class::xx_config_for "tags", xx_which
226
215
 
227
- hashes.each{|h| h.each{|k,v| element.add_attribute k.to_s, v}}
228
- nothashes.each{|nh| element << ::REXML::Text::new(nh.to_s)}
216
+ pat =
217
+ case c_method_missing
218
+ when ::XX::CRAZY_LIKE_A_HELL
219
+ %r/.*/
220
+ when ::XX::PERMISSIVE
221
+ %r/_$/o
222
+ when ::XX::STRICT
223
+ %r/_$/o
224
+ else
225
+ super(m.to_sym, *a, &b)
226
+ end
229
227
 
230
- doc.create element, &b
228
+ super(m.to_sym, *a, &b) unless m =~ pat
229
+
230
+ if c_method_missing == ::XX::STRICT
231
+ super(m.to_sym, *a, &b) unless c_tags.include? tag_name
232
+ end
233
+
234
+ ret, defined = nil
235
+
236
+ begin
237
+ xx_class::xx_define_tmp_method tag_method
238
+ xx_class::xx_define_tag_method tag_method, tag_name
239
+ ret = send tag_method, *a, &b
240
+ defined = true
241
+ ensure
242
+ xx_class::xx_remove_tag_method tag_method unless defined
243
+ end
244
+
245
+ ret
231
246
  #--}}}
232
247
  end
233
- alias_method "xx_tag" , "_"
234
- alias_method "__" , "_"
235
- alias_method "g__" , "_"
236
- def method_missing m, *a, &b
248
+ def xx_tag_ tag_name, *a, &b
237
249
  #--{{{
238
- m = m.to_s
250
+ tag_method, tag_name = xx_class::xx_tag_method_name tag_name
239
251
 
240
- tag_name = m.sub! %r/_+$/, ''
252
+ ret, defined = nil
241
253
 
242
- super unless tag_name
254
+ begin
255
+ xx_class::xx_define_tmp_method tag_method
256
+ xx_class::xx_define_tag_method tag_method, tag_name
257
+ ret = send tag_method, *a, &b
258
+ defined = true
259
+ ensure
260
+ xx_class::xx_remove_tag_method tag_method unless defined
261
+ end
243
262
 
244
- __ tag_name, *a, &b
263
+ ret
245
264
  #--}}}
246
265
  end
247
- def xx_which *argv
266
+ alias_method "g_", "xx_tag_"
267
+ def xx_which *argv
248
268
  #--{{{
249
269
  @xx_which = nil unless defined? @xx_which
250
270
  if argv.empty?
@@ -252,7 +272,7 @@ module XX
252
272
  else
253
273
  xx_which = @xx_which
254
274
  begin
255
- @xx_which = argv.shift
275
+ @xx_which = argv.shift
256
276
  return yield
257
277
  ensure
258
278
  @xx_which = xx_which
@@ -263,15 +283,16 @@ module XX
263
283
  def xx_with_doc_in_effect *a, &b
264
284
  #--{{{
265
285
  @xx_docs ||= []
266
- doc = ::XX::Document::new *a
286
+ doc = ::XX::Document::new(*a)
267
287
  ddoc = doc.doc
268
288
  begin
269
289
  @xx_docs.push doc
290
+ b.call doc if b
270
291
 
271
292
  doctype = xx_config_for "doctype", xx_which
272
293
  if doctype
273
294
  unless ddoc.doctype
274
- doctype = ::REXML::DocType::new doctype unless
295
+ doctype = ::REXML::DocType::new doctype unless
275
296
  ::REXML::DocType === doctype
276
297
  ddoc << doctype
277
298
  end
@@ -283,12 +304,9 @@ module XX
283
304
  xmldecl = ::REXML::XMLDecl::new xmldecl unless
284
305
  ::REXML::XMLDecl === xmldecl
285
306
  ddoc << xmldecl
286
- doc.xmldecl = ::REXML::XMLDecl
287
307
  end
288
308
  end
289
309
 
290
- b.call doc if b
291
-
292
310
  return doc
293
311
  ensure
294
312
  @xx_docs.pop
@@ -305,26 +323,26 @@ module XX
305
323
  doc = xx_doc
306
324
 
307
325
  text =
308
- ::REXML::Text::new("",
326
+ ::REXML::Text::new("",
309
327
  respect_whitespace=true, parent=nil
310
328
  )
311
329
 
312
- objects.each do |object|
330
+ objects.each do |object|
313
331
  text << object.to_s if object
314
332
  end
315
333
 
316
334
  doc.create text, &b
317
335
  #--}}}
318
336
  end
319
- alias_method "t__", "xx_text_"
320
- alias_method "text__", "xx_text_"
337
+ alias_method "text_", "xx_text_"
338
+ alias_method "t_", "xx_text_"
321
339
  def xx_markup_ *objects, &b
322
340
  #--{{{
323
341
  doc = xx_doc
324
342
 
325
343
  doc2 = ::REXML::Document::new ""
326
344
 
327
- objects.each do |object|
345
+ objects.each do |object|
328
346
  (doc2.root ? doc2.root : doc2) << ::REXML::Document::new(object.to_s)
329
347
  end
330
348
 
@@ -335,43 +353,41 @@ module XX
335
353
  ret
336
354
  #--}}}
337
355
  end
338
- alias_method "x__", "xx_markup_"
339
- alias_method "markup__", "xx_markup_"
356
+ alias_method "x_", "xx_markup_"
340
357
  def xx_any_ *objects, &b
341
358
  #--{{{
342
359
  doc = xx_doc
343
360
  nothing = %r/.^/m
344
361
 
345
362
  text =
346
- ::REXML::Text::new("",
363
+ ::REXML::Text::new("",
347
364
  respect_whitespace=true, parent=nil, raw=true, entity_filter=nil, illegal=nothing
348
365
  )
349
366
 
350
- objects.each do |object|
367
+ objects.each do |object|
351
368
  text << object.to_s if object
352
369
  end
353
370
 
354
371
  doc.create text, &b
355
372
  #--}}}
356
373
  end
357
- alias_method "any__", "xx_any_"
358
- alias_method "h__", "xx_any_"
359
- alias_method "x__", "xx_any_" # supplant for now
374
+ alias_method "h_", "xx_any_"
375
+ remove_method "x_" if instance_methods.include? "x_"
376
+ alias_method "x_", "xx_any_" # supplant for now
360
377
  def xx_cdata_ *objects, &b
361
378
  #--{{{
362
379
  doc = xx_doc
363
380
 
364
381
  cdata = ::REXML::CData::new ""
365
382
 
366
- objects.each do |object|
383
+ objects.each do |object|
367
384
  cdata << object.to_s if object
368
385
  end
369
386
 
370
387
  doc.create cdata, &b
371
388
  #--}}}
372
389
  end
373
- alias_method "cdata__", "xx_cdata_"
374
- alias_method "c__", "xx_cdata_"
390
+ alias_method "c_", "xx_cdata_"
375
391
  def xx_parse_attributes string
376
392
  #--{{{
377
393
  string = string.to_s
@@ -380,7 +396,7 @@ module XX
380
396
  xx_parse_yaml_attributes(tokens.join(','))
381
397
  #--}}}
382
398
  end
383
- alias_method "a__", "xx_parse_attributes"
399
+ alias_method "att_", "xx_parse_attributes"
384
400
  def xx_parse_yaml_attributes string
385
401
  #--{{{
386
402
  require "yaml"
@@ -392,30 +408,31 @@ module XX
392
408
  obj
393
409
  #--}}}
394
410
  end
395
- alias_method "y__", "xx_parse_yaml_attributes"
411
+ alias_method "at_", "xx_parse_yaml_attributes"
412
+ alias_method "yat_", "xx_parse_yaml_attributes"
396
413
  def xx_class
397
414
  #--{{{
398
415
  @xx_class ||= self.class
399
416
  #--}}}
400
417
  end
401
- def xx_tag_method_name *a, &b
418
+ def xx_tag_method_name *a, &b
402
419
  #--{{{
403
- xx_class.xx_tag_method_name *a, &b
420
+ xx_class.xx_tag_method_name(*a, &b)
404
421
  #--}}}
405
422
  end
406
- def xx_define_tmp_method *a, &b
423
+ def xx_define_tmp_method *a, &b
407
424
  #--{{{
408
- xx_class.xx_define_tmp_method *a, &b
425
+ xx_class.xx_define_tmp_methodr(*a, &b)
409
426
  #--}}}
410
427
  end
411
- def xx_define_tag_method *a, &b
428
+ def xx_define_tag_method *a, &b
412
429
  #--{{{
413
- xx_class.xx_define_tag_method *a, &b
430
+ xx_class.xx_define_tag_method(*a, &b)
414
431
  #--}}}
415
432
  end
416
- def xx_remove_tag_method *a, &b
433
+ def xx_remove_tag_method *a, &b
417
434
  #--{{{
418
- xx_class.xx_tag_remove_method *a, &b
435
+ xx_class.xx_tag_remove_method(*a, &b)
419
436
  #--}}}
420
437
  end
421
438
  def xx_ancestors
@@ -431,12 +448,12 @@ module XX
431
448
  end
432
449
  def xx_config_for *a, &b
433
450
  #--{{{
434
- xx_class.xx_config_for *a, &b
451
+ xx_class.xx_config_for(*a, &b)
435
452
  #--}}}
436
453
  end
437
454
  def xx_configure *a, &b
438
455
  #--{{{
439
- xx_class.xx_configure *a, &b
456
+ xx_class.xx_configure(*a, &b)
440
457
  #--}}}
441
458
  end
442
459
  #--}}}
@@ -451,7 +468,7 @@ module XX
451
468
  [ tag_method, tag_name ]
452
469
  #--}}}
453
470
  end
454
- def xx_define_tmp_method m
471
+ def xx_define_tmp_method m
455
472
  #--{{{
456
473
  define_method(m){ raise NotImplementedError, m.to_s }
457
474
  #--}}}
@@ -459,9 +476,10 @@ module XX
459
476
  def xx_define_tag_method tag_method, tag_name = nil
460
477
  #--{{{
461
478
  tag_method = tag_method.to_s
462
- tag_name ||= tag_method.sub(%r/_$/, '')
479
+ tag_name ||= tag_method.gsub %r/_+$/, ""
463
480
 
464
- module_eval <<-code
481
+ remove_method tag_method if instance_methods.include? tag_method
482
+ module_eval <<-code, __FILE__, __LINE__+1
465
483
  def #{ tag_method } *a, &b
466
484
  hashes, nothashes = a.partition{|x| Hash === x}
467
485
 
@@ -499,9 +517,9 @@ module XX
499
517
  @@xx_config ||= Hash::new{|h,k| h[k] = {}}
500
518
  #--}}}
501
519
  end
502
- def xx_config_for key, xx_which = nil
520
+ def xx_config_for key, xx_which = nil
503
521
  #--{{{
504
- key = key.to_s
522
+ key = key.to_s
505
523
  xx_which ||= self
506
524
  xx_ancestors(xx_which).each do |a|
507
525
  if xx_config[a].has_key? key
@@ -511,7 +529,7 @@ module XX
511
529
  nil
512
530
  #--}}}
513
531
  end
514
- def xx_configure key, value, xx_which = nil
532
+ def xx_configure key, value, xx_which = nil
515
533
  #--{{{
516
534
  key = key.to_s
517
535
  xx_which ||= self
@@ -554,10 +572,10 @@ module XX
554
572
  def xhtml_ which = XHTML, *a, &b
555
573
  #--{{{
556
574
  xx_which(which) do
557
- doc = xx_with_doc_in_effect *a, &b
575
+ doc = xx_with_doc_in_effect(*a, &b)
558
576
  ddoc = doc.doc
559
577
  root = ddoc.root
560
- if root and root.name and root.name =~ %r/^html$/i
578
+ if root and root.name and root.name =~ %r/^html$/i
561
579
  if root.attribute("lang",nil).nil? or root.attribute("lang",nil).to_s.empty?
562
580
  root.add_attribute "lang", "en"
563
581
  end
@@ -572,7 +590,6 @@ module XX
572
590
  end
573
591
  #--}}}
574
592
  end
575
- alias_method "xhtml__", "xhtml_"
576
593
 
577
594
  module Strict
578
595
  #--{{{
@@ -594,7 +611,6 @@ module XX
594
611
  super(which, *a, &b)
595
612
  #--}}}
596
613
  end
597
- alias_method "xhtml__", "xhtml_"
598
614
  #--}}}
599
615
  end
600
616
 
@@ -607,7 +623,6 @@ module XX
607
623
  super(which, *a, &b)
608
624
  #--}}}
609
625
  end
610
- alias_method "xhtml__", "xhtml_"
611
626
  #--}}}
612
627
  end
613
628
  #--}}}
@@ -617,13 +632,12 @@ module XX
617
632
  #--{{{
618
633
  include Markup
619
634
  xx_configure "doctype", %(html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN")
620
-
635
+
621
636
  def html4_ which = HTML4, *a, &b
622
637
  #--{{{
623
- xx_which(which){ xx_with_doc_in_effect *a, &b }
638
+ xx_which(which){ xx_with_doc_in_effect(*a, &b) }
624
639
  #--}}}
625
640
  end
626
- alias_method "html4__", "html4_"
627
641
 
628
642
  module Strict
629
643
  #--{{{
@@ -644,7 +658,6 @@ module XX
644
658
  super(which, *a, &b)
645
659
  #--}}}
646
660
  end
647
- alias_method "html4__", "html4_"
648
661
  #--}}}
649
662
  end
650
663
 
@@ -657,7 +670,6 @@ module XX
657
670
  super(which, *a, &b)
658
671
  #--}}}
659
672
  end
660
- alias_method "html4__", "html4_"
661
673
  #--}}}
662
674
  end
663
675
  #--}}}
@@ -671,218 +683,11 @@ module XX
671
683
 
672
684
  def xml_ *a, &b
673
685
  #--{{{
674
- xx_which(XML){ xx_with_doc_in_effect *a, &b }
686
+ xx_which(XML){ xx_with_doc_in_effect(*a, &b)}
675
687
  #--}}}
676
688
  end
677
- alias_method "xml__", "xml_"
678
689
  #--}}}
679
690
  end
680
-
681
- module Template
682
- #--{{{
683
- class Basic
684
- #--{{{
685
- %w( path inline type object template port pretty ).each{|a| attr_accessor a}
686
- def initialize opts = {}, &b
687
- #--{{{
688
- @path = opts['path'] || opts[:path]
689
- @inline = opts['inline'] || opts[:inline]
690
- @type = opts['type'] || opts[:type]
691
- @object = opts['object'] || opts[:object]
692
- @pretty = opts['pretty'] || opts[:pretty]
693
- @port = opts['port'] || opts[:port] || STDOUT
694
-
695
- bool = lambda{|value| value ? true : false}
696
- raise ArgumentError unless(bool[@path] ^ bool[@inline])
697
-
698
- path_init(&b) if @path
699
- inline_init(&b) if @inline
700
-
701
- @type =
702
- case @type.to_s.downcase.strip
703
- when /^xhtml$/
704
- XHTML
705
- when /^xml$/
706
- XML
707
- when /^html4$/
708
- HTML4
709
- else
710
- XHTML
711
- end
712
- #--}}}
713
- end
714
- def path_init &b
715
- #--{{{
716
- @template = IO.read @path
717
- @type = @path[%r/\.[^\.]+$/o] || XHTML unless @type
718
- #--}}}
719
- end
720
- def inline_init &b
721
- #--{{{
722
- @template = (@inline || b.call).to_s
723
- @type ||= XHTML
724
- #--}}}
725
- end
726
- def expand binding, opts = {}
727
- #--{{{
728
- port = opts['port'] || opts[:port] || STDOUT
729
- pretty = opts['pretty'] || opts[:pretty]
730
-
731
- object = eval 'self', binding
732
-
733
- unless type === object
734
- __m = type
735
- klass = object.class
736
- klass.module_eval{ include __m }
737
- end
738
-
739
- doc = eval @template, binding
740
-
741
- display = pretty ? 'pretty' : 'to_str'
742
-
743
- doc.send display, port
744
- #--}}}
745
- end
746
- alias_method "result", "expand"
747
- #--}}}
748
- end
749
-
750
- class File < Basic
751
- #--{{{
752
- def initialize *argv, &b
753
- #--{{{
754
- opts, argv = argv.partition{|arg| Hash === arg}
755
- opts = opts.inject{|a,b| a.update b}
756
- path = argv.shift
757
- raise ArgumentError, "no path" unless path
758
- raise ArgumentError, "bad opts" unless Hash === opts or opts.nil?
759
- opts ||= {}
760
- opts['path'] = opts[:path] = path.to_s
761
- super opts, &b
762
- #--}}}
763
- end
764
- #--}}}
765
- end
766
-
767
- class Inline < Basic
768
- #--{{{
769
- def initialize *argv, &b
770
- #--{{{
771
- opts, argv = argv.partition{|arg| Hash === arg}
772
- opts = opts.inject{|a,b| a.update b}
773
- inline = argv.shift || b.call
774
- raise ArgumentError, "no inline" unless inline
775
- raise ArgumentError, "bad opts" unless Hash === opts or opts.nil?
776
- opts ||= {}
777
- opts['inline'] = opts[:inline] = inline.to_s
778
- super opts, &b
779
- #--}}}
780
- end
781
- #--}}}
782
- end
783
- #--}}}
784
- end
785
-
786
- module Expandable
787
- #--{{{
788
- module InstanceMethods
789
- #--{{{
790
- def xx_template_file *a, &b
791
- #--{{{
792
- template = XX::Template::File.new *a, &b
793
- template.object ||= self
794
- template
795
- #--}}}
796
- end
797
- def xx_template_inline *a, &b
798
- #--{{{
799
- template = XX::Template::Inline.new *a, &b
800
- template.object ||= self
801
- template
802
- #--}}}
803
- end
804
- def xx_expand template, opts = {}
805
- #--{{{
806
- port = opts['port'] || opts[:port] || STDOUT
807
- pretty = opts['pretty'] || opts[:pretty]
808
- binding = opts['binding'] || opts[:binding]
809
-
810
- type = template.type
811
-
812
- unless type === self
813
- klass = self.class
814
- klass.module_eval{ include type }
815
- end
816
-
817
- display = pretty ? 'pretty' : 'to_str'
818
-
819
- Binding.of_caller do |scope|
820
- binding ||= eval('binding', scope)
821
- doc = eval template.template, binding
822
- doc.send display, port
823
- end
824
- #--}}}
825
- end
826
- def xx_expand_file *a, &b
827
- #--{{{
828
- template = xx_template_file *a, &b
829
-
830
- type = template.type
831
- pretty = template.pretty
832
- port = template.port
833
-
834
- unless type === self
835
- klass = self.class
836
- klass.module_eval{ include type }
837
- end
838
-
839
- display = pretty ? 'pretty' : 'to_str'
840
-
841
- Binding.of_caller do |scope|
842
- binding ||= eval('binding', scope)
843
- doc = eval template.template, binding
844
- doc.send display, port
845
- end
846
- #--}}}
847
- end
848
- alias_method "xx_expand_path", "xx_expand_file"
849
- alias_method "xx_expand_template", "xx_expand_file"
850
- def xx_expand_inline *a, &b
851
- #--{{{
852
- template = xx_template_inline *a, &b
853
-
854
- type = template.type
855
- pretty = template.pretty
856
- port = template.port
857
-
858
- unless type === self
859
- klass = self.class
860
- klass.module_eval{ include type }
861
- end
862
-
863
- display = pretty ? 'pretty' : 'to_str'
864
-
865
- Binding.of_caller do |scope|
866
- binding ||= eval('binding', scope)
867
- doc = eval template.template, binding
868
- doc.send display, port
869
- end
870
- #--}}}
871
- end
872
- alias_method "xx_expand_string", "xx_expand_inline"
873
- #--}}}
874
- end
875
- module ClassMethods
876
- end
877
- def self.included other
878
- #--{{{
879
- other.instance_eval{ include InstanceMethods }
880
- other.extend ClassMethods
881
- #--}}}
882
- end
883
- #--}}}
884
- end
885
-
886
691
  #--}}}
887
692
  end
888
693
 
@@ -909,7 +714,7 @@ if __FILE__ == $0
909
714
  include XX::HTML4::Strict
910
715
  include XX::XML
911
716
 
912
- def doc
717
+ def doc
913
718
  html_{
914
719
  head_{ title_{ "xhtml/html4/xml demo" } }
915
720
 
@@ -921,7 +726,7 @@ if __FILE__ == $0
921
726
 
922
727
  x_{ "<any_valid> xml </any_valid>" }
923
728
 
924
- div_(:style => :sweet){
729
+ div_(:style => :sweet){
925
730
  em_ "this is a table"
926
731
 
927
732
  table_(:width => 42, :height => 42){
@@ -944,7 +749,7 @@ if __FILE__ == $0
944
749
  end
945
750
 
946
751
  table = Table[ %w( 0 1 2 ), %w( a b c ) ]
947
-
752
+
948
753
  methods = %w( to_xhtml to_html4 to_xml )
949
754
 
950
755
  methods.each do |method|
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spicycode-rcov
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.2
4
+ version: 0.8.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mauricio Fernandez
@@ -33,7 +33,6 @@ files:
33
33
  - lib/rcov/version.rb
34
34
  - lib/rcov/rant.rb
35
35
  - lib/rcov/report.rb
36
- - lib/rcov/binding_of_caller.rb
37
36
  - lib/rcov/rcovtask.rb
38
37
  - lib/rcov/rexml_extensions.rb
39
38
  - ext/rcovrt/extconf.rb
@@ -1,83 +0,0 @@
1
- unless(defined?(Continuation) and Continuation.respond_to?('create'))
2
- # to satisfy rdoc
3
- class Continuation #:nodoc:
4
- end
5
- def Continuation.create(*args, &block) # :nodoc:
6
- cc = nil; result = callcc {|c| cc = c; block.call(cc) if block and args.empty?}
7
- result ||= args
8
- return *[cc, *result]
9
- end
10
- end
11
-
12
- class Binding; end # for RDoc
13
- # This method returns the binding of the method that called your
14
- # method. It will raise an Exception when you're not inside a method.
15
- #
16
- # It's used like this:
17
- # def inc_counter(amount = 1)
18
- # Binding.of_caller do |binding|
19
- # # Create a lambda that will increase the variable 'counter'
20
- # # in the caller of this method when called.
21
- # inc = eval("lambda { |arg| counter += arg }", binding)
22
- # # We can refer to amount from inside this block safely.
23
- # inc.call(amount)
24
- # end
25
- # # No other statements can go here. Put them inside the block.
26
- # end
27
- # counter = 0
28
- # 2.times { inc_counter }
29
- # counter # => 2
30
- #
31
- # Binding.of_caller must be the last statement in the method.
32
- # This means that you will have to put everything you want to
33
- # do after the call to Binding.of_caller into the block of it.
34
- # This should be no problem however, because Ruby has closures.
35
- # If you don't do this an Exception will be raised. Because of
36
- # the way that Binding.of_caller is implemented it has to be
37
- # done this way.
38
- def Binding.of_caller(&block)
39
- old_critical = Thread.critical
40
- Thread.critical = true
41
- count = 0
42
- cc, result, error, extra_data = Continuation.create(nil, nil)
43
- error.call if error
44
-
45
- tracer = lambda do |*args|
46
- type, context, extra_data = args[0], args[4], args
47
- if type == "return"
48
- count += 1
49
- # First this method and then calling one will return --
50
- # the trace event of the second event gets the context
51
- # of the method which called the method that called this
52
- # method.
53
- if count == 2
54
- # It would be nice if we could restore the trace_func
55
- # that was set before we swapped in our own one, but
56
- # this is impossible without overloading set_trace_func
57
- # in current Ruby.
58
- set_trace_func(nil)
59
- cc.call(eval("binding", context), nil, extra_data)
60
- end
61
- elsif type == "line" then
62
- nil
63
- elsif type == "c-return" and extra_data[3] == :set_trace_func then
64
- nil
65
- else
66
- set_trace_func(nil)
67
- error_msg = "Binding.of_caller used in non-method context or " +
68
- "trailing statements of method using it aren't in the block."
69
- cc.call(nil, lambda { raise(ArgumentError, error_msg) }, nil)
70
- end
71
- end
72
-
73
- unless result
74
- set_trace_func(tracer)
75
- return nil
76
- else
77
- Thread.critical = old_critical
78
- case block.arity
79
- when 1 then yield(result)
80
- else yield(result, extra_data)
81
- end
82
- end
83
- end