assert2 0.5.1 → 0.5.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/assert2/xhtml.rb +27 -1
  2. metadata +2 -2
data/lib/assert2/xhtml.rb CHANGED
@@ -122,7 +122,6 @@ class BeHtmlWith
122
122
  end
123
123
 
124
124
  def translate_tag(element)
125
- # p element.name if element.name =~ /\!/
126
125
  if element.name == 'any!'
127
126
  '*'
128
127
  else
@@ -360,3 +359,30 @@ class Nokogiri::XML::Node
360
359
 
361
360
  end
362
361
 
362
+ module Nokogiri
363
+ module XML
364
+ class Builder
365
+ def cleanse_element_name(method)
366
+ method.to_s.sub(/[_]$/, '') # or [_!]
367
+ end # monkey patch me!
368
+
369
+ def method_missing method, *args, &block # :nodoc:
370
+ if @context && @context.respond_to?(method)
371
+ @context.send(method, *args, &block)
372
+ else
373
+ node = Nokogiri::XML::Node.new(cleanse_element_name(method), @doc) { |n|
374
+ args.each do |arg|
375
+ case arg
376
+ when Hash
377
+ arg.each { |k,v| n[k.to_s] = v.to_s }
378
+ else
379
+ n.content = arg
380
+ end
381
+ end
382
+ }
383
+ insert(node, &block)
384
+ end
385
+ end
386
+ end
387
+ end
388
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: assert2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Phlip
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-04-12 00:00:00 -07:00
12
+ date: 2009-05-07 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15