rexle 0.5.7 → 0.5.8
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.
- data/lib/rexle.rb +28 -10
- metadata +1 -1
    
        data/lib/rexle.rb
    CHANGED
    
    | @@ -74,9 +74,16 @@ class Rexle | |
| 74 74 |  | 
| 75 75 | 
             
                    s = a_path.shift
         | 
| 76 76 | 
             
                  end
         | 
| 77 | 
            -
             | 
| 77 | 
            +
              
         | 
| 78 78 | 
             
                  elmnt_path = s[/^([\w\*]+\[[^\]]+\])|[\/]+{,2}[^\/]+/]
         | 
| 79 | 
            -
                   | 
| 79 | 
            +
                  element_part, condition = elmnt_path.match(/(^@?[^\[]+)(\[[^\]]+\])?/).captures
         | 
| 80 | 
            +
             | 
| 81 | 
            +
                  unless element_part[/^@/] then
         | 
| 82 | 
            +
                    element_name = element_part
         | 
| 83 | 
            +
                  else
         | 
| 84 | 
            +
                    condition = element_part
         | 
| 85 | 
            +
                    element_name = nil
         | 
| 86 | 
            +
                  end
         | 
| 80 87 |  | 
| 81 88 | 
             
                  attr_search = format_attributes(condition) if condition
         | 
| 82 89 |  | 
| @@ -212,16 +219,27 @@ class Rexle | |
| 212 219 |  | 
| 213 220 | 
             
                def scan_match(nodes, element, attr_search, condition, rlist)
         | 
| 214 221 | 
             
                  nodes.children.each.with_index do |x, i|
         | 
| 215 | 
            -
             | 
| 216 | 
            -
             | 
| 217 | 
            -
             | 
| 218 | 
            -
             | 
| 219 | 
            -
                       | 
| 220 | 
            -
                         | 
| 222 | 
            +
             | 
| 223 | 
            +
                    h = x.attributes
         | 
| 224 | 
            +
             | 
| 225 | 
            +
                    if element and not(element.empty?) then
         | 
| 226 | 
            +
                      if x.name == element
         | 
| 227 | 
            +
                        if attr_search then
         | 
| 228 | 
            +
                          rlist << x if h and eval(attr_search)
         | 
| 229 | 
            +
                        else
         | 
| 230 | 
            +
                          rlist << x 
         | 
| 231 | 
            +
                        end
         | 
| 221 232 | 
             
                      end
         | 
| 222 | 
            -
                     | 
| 233 | 
            +
                    else
         | 
| 223 234 |  | 
| 224 | 
            -
             | 
| 235 | 
            +
                      attribute = condition[/@(.*)/,1]
         | 
| 236 | 
            +
              
         | 
| 237 | 
            +
                      if h.has_key? attribute then
         | 
| 238 | 
            +
                        rlist << h[attribute]
         | 
| 239 | 
            +
                      end
         | 
| 240 | 
            +
                    end
         | 
| 241 | 
            +
                
         | 
| 242 | 
            +
                    x.xpath('//' + element.to_s + condition.to_s, rlist) unless x.children.empty?
         | 
| 225 243 | 
             
                  end
         | 
| 226 244 | 
             
                  rlist
         | 
| 227 245 | 
             
                end
         |