rexle 0.9.9 → 0.9.10

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/rexle.rb +16 -4
  2. metadata +3 -14
data/lib/rexle.rb CHANGED
@@ -10,6 +10,8 @@ include REXML
10
10
 
11
11
 
12
12
  # modifications:
13
+ # 03-Sep-2011: Implemented deep_clone as well as modifying clone to function
14
+ # similar to REXML.
13
15
  # 28-Au-2011: New line characters between elements are now preserved
14
16
  # 24-Jul-2011: Smybols are used for attribute keys instead of strings now
15
17
  # 18-Jun-2011: A Rexle document can now be added to another Rexle document
@@ -143,6 +145,8 @@ class Rexle
143
145
 
144
146
  attr_accessor :name, :value, :parent
145
147
  attr_reader :child_lookup
148
+
149
+ alias original_clone clone
146
150
 
147
151
  def initialize(name=nil, value='', attributes={}, rexle=nil)
148
152
  @rexle = rexle
@@ -211,7 +215,8 @@ class Rexle
211
215
  attr_search = format_condition(condition) if condition and condition.length > 0
212
216
 
213
217
  if raw_path[0,2] == '//'
214
- return scan_match(self, xpath_value)
218
+ rs = scan_match(self, xpath_value).flatten.compact
219
+ return rs
215
220
  else
216
221
 
217
222
  return_elements = @child_lookup.map.with_index.select do |x|
@@ -278,7 +283,11 @@ class Rexle
278
283
  end
279
284
 
280
285
  def inspect()
286
+ if self.xml.length > 30 then
281
287
  "%s ... </>" % self.xml[/<[^>]+>/]
288
+ else
289
+ self.xml
290
+ end
282
291
  end
283
292
 
284
293
  alias add add_element
@@ -301,8 +310,10 @@ class Rexle
301
310
  def attribute(key) @attributes[key] end
302
311
  def attributes() @attributes end
303
312
  def children() @child_elements end
304
- def children=(a) @child_elements = a end
305
-
313
+ def children=(a) @child_elements = a end
314
+ def deep_clone() self.original_clone end
315
+ def clone() Element.new(@name, @value, @attributes) end
316
+
306
317
  def delete(obj=nil)
307
318
  if obj then
308
319
  i = @child_elements.index(obj)
@@ -367,6 +378,7 @@ class Rexle
367
378
  method(msg).call(self.children)
368
379
  end
369
380
 
381
+ alias to_s xml
370
382
 
371
383
  private
372
384
 
@@ -433,7 +445,7 @@ class Rexle
433
445
  def scan_match(node, xpath)
434
446
 
435
447
  r = node.xpath(xpath[2..-1])
436
- r << node.children.map {|n| scan_match(n, xpath)}
448
+ r << node.children.map {|n| scan_match(n, xpath) if n.is_a? Rexle::Element}
437
449
  #puts 'r: ' + r.inspect
438
450
  r
439
451
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: rexle
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.9.9
5
+ version: 0.9.10
6
6
  platform: ruby
7
7
  authors:
8
8
  - James Robertson
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-08-28 00:00:00 +01:00
13
+ date: 2011-09-03 00:00:00 +01:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -47,7 +47,7 @@ dependencies:
47
47
  type: :runtime
48
48
  version_requirements: *id003
49
49
  - !ruby/object:Gem::Dependency
50
- name: nokogiri
50
+ name: rexle-builder
51
51
  prerelease: false
52
52
  requirement: &id004 !ruby/object:Gem::Requirement
53
53
  none: false
@@ -57,17 +57,6 @@ dependencies:
57
57
  version: "0"
58
58
  type: :runtime
59
59
  version_requirements: *id004
60
- - !ruby/object:Gem::Dependency
61
- name: rexle-builder
62
- prerelease: false
63
- requirement: &id005 !ruby/object:Gem::Requirement
64
- none: false
65
- requirements:
66
- - - ">="
67
- - !ruby/object:Gem::Version
68
- version: "0"
69
- type: :runtime
70
- version_requirements: *id005
71
60
  description:
72
61
  email:
73
62
  executables: []