libxml-ext 0.3.0 → 0.3.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.
- data/README +1 -1
- data/lib/libxml/ext/find.rb +6 -0
- data/lib/libxml/ext/{enhanced_find.rb → find_mixin.rb} +4 -10
- data/lib/libxml/ext/namespaces.rb +1 -64
- data/lib/libxml/ext/namespaces_mixin.rb +61 -0
- data/lib/libxml/ext/{string_representation.rb → string.rb} +0 -0
- data/lib/libxml/ext/uniq.rb +6 -0
- data/lib/libxml/ext/{uniqueness.rb → uniq_mixin.rb} +2 -8
- data/lib/libxml/ext/version.rb +1 -1
- metadata +9 -6
data/README
CHANGED
@@ -24,20 +24,18 @@
|
|
24
24
|
###############################################################################
|
25
25
|
#++
|
26
26
|
|
27
|
-
require 'libxml'
|
28
|
-
|
29
27
|
module LibXML
|
30
28
|
module Ext
|
31
|
-
module
|
29
|
+
module Find
|
32
30
|
|
33
|
-
def
|
31
|
+
def xfind(xpath)
|
34
32
|
find(xpath.gsub(/\*\*/, 'descendant::node()'), namespaces)
|
35
33
|
end
|
36
34
|
|
37
|
-
alias_method :[], :
|
35
|
+
alias_method :[], :xfind
|
38
36
|
|
39
37
|
def /(xpath)
|
40
|
-
|
38
|
+
xfind(xpath.to_s)
|
41
39
|
end
|
42
40
|
|
43
41
|
def self.included(base)
|
@@ -50,7 +48,3 @@ module LibXML
|
|
50
48
|
end
|
51
49
|
end
|
52
50
|
end
|
53
|
-
|
54
|
-
[LibXML::XML::Document, LibXML::XML::Node].each { |klass|
|
55
|
-
klass.send :include, LibXML::Ext::EnhancedFind
|
56
|
-
}
|
@@ -1,73 +1,11 @@
|
|
1
|
-
#--
|
2
|
-
###############################################################################
|
3
|
-
# #
|
4
|
-
# A component of libxml-ext, the LibXML extensions. #
|
5
|
-
# #
|
6
|
-
# Copyright (C) 2007-2010 Jens Wille #
|
7
|
-
# #
|
8
|
-
# Authors: #
|
9
|
-
# Jens Wille <jens.wille@uni-koeln.de> #
|
10
|
-
# #
|
11
|
-
# libxml-ext is free software; you can redistribute it and/or modify it #
|
12
|
-
# under the terms of the GNU General Public License as published by the Free #
|
13
|
-
# Software Foundation; either version 3 of the License, or (at your option) #
|
14
|
-
# any later version. #
|
15
|
-
# #
|
16
|
-
# libxml-ext is distributed in the hope that it will be useful, but WITHOUT #
|
17
|
-
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
|
18
|
-
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for #
|
19
|
-
# more details. #
|
20
|
-
# #
|
21
|
-
# You should have received a copy of the GNU General Public License along #
|
22
|
-
# with libxml-ext. If not, see <http://www.gnu.org/licenses/>. #
|
23
|
-
# #
|
24
|
-
###############################################################################
|
25
|
-
#++
|
26
|
-
|
27
1
|
require 'libxml'
|
28
|
-
|
29
|
-
module LibXML
|
30
|
-
module Ext
|
31
|
-
module Namespaces
|
32
|
-
|
33
|
-
def namespaces
|
34
|
-
@namespaces ||= self.class::DEFAULT_NAMESPACES
|
35
|
-
end
|
36
|
-
|
37
|
-
def namespaces=(ns)
|
38
|
-
if url
|
39
|
-
@namespaces = self.class.namespaces[url] = ns
|
40
|
-
else
|
41
|
-
raise "can't set namespaces (document has no URL)"
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
def self.included(base)
|
46
|
-
base.const_set(:DEFAULT_NAMESPACES, [])
|
47
|
-
|
48
|
-
# container for XML::Node's access to its document's namespaces
|
49
|
-
base.instance_variable_set(
|
50
|
-
:@namespaces, Hash.new(base.const_get(:DEFAULT_NAMESPACES))
|
51
|
-
)
|
52
|
-
|
53
|
-
class << base; attr_reader :namespaces; end
|
54
|
-
|
55
|
-
# overwrite original methods
|
56
|
-
instance_methods.each { |method|
|
57
|
-
base.send(:define_method, method, instance_method(method))
|
58
|
-
}
|
59
|
-
end
|
60
|
-
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
2
|
+
require 'libxml/ext/namespaces_mixin'
|
64
3
|
|
65
4
|
[LibXML::XML::Document].each { |klass|
|
66
5
|
klass.send :include, LibXML::Ext::Namespaces
|
67
6
|
}
|
68
7
|
|
69
8
|
class LibXML::XML::Node
|
70
|
-
|
71
9
|
def namespaces
|
72
10
|
@namespaces ||= LibXML::XML::Document.namespaces[doc.url]
|
73
11
|
end
|
@@ -75,5 +13,4 @@ class LibXML::XML::Node
|
|
75
13
|
def namespaces=(ns)
|
76
14
|
@namespaces = ns
|
77
15
|
end
|
78
|
-
|
79
16
|
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
#--
|
2
|
+
###############################################################################
|
3
|
+
# #
|
4
|
+
# A component of libxml-ext, the LibXML extensions. #
|
5
|
+
# #
|
6
|
+
# Copyright (C) 2007-2010 Jens Wille #
|
7
|
+
# #
|
8
|
+
# Authors: #
|
9
|
+
# Jens Wille <jens.wille@uni-koeln.de> #
|
10
|
+
# #
|
11
|
+
# libxml-ext is free software; you can redistribute it and/or modify it #
|
12
|
+
# under the terms of the GNU General Public License as published by the Free #
|
13
|
+
# Software Foundation; either version 3 of the License, or (at your option) #
|
14
|
+
# any later version. #
|
15
|
+
# #
|
16
|
+
# libxml-ext is distributed in the hope that it will be useful, but WITHOUT #
|
17
|
+
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
|
18
|
+
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for #
|
19
|
+
# more details. #
|
20
|
+
# #
|
21
|
+
# You should have received a copy of the GNU General Public License along #
|
22
|
+
# with libxml-ext. If not, see <http://www.gnu.org/licenses/>. #
|
23
|
+
# #
|
24
|
+
###############################################################################
|
25
|
+
#++
|
26
|
+
|
27
|
+
module LibXML
|
28
|
+
module Ext
|
29
|
+
module Namespaces
|
30
|
+
|
31
|
+
def namespaces
|
32
|
+
@namespaces ||= self.class::DEFAULT_NAMESPACES
|
33
|
+
end
|
34
|
+
|
35
|
+
def namespaces=(ns)
|
36
|
+
if url
|
37
|
+
@namespaces = self.class.namespaces[url] = ns
|
38
|
+
else
|
39
|
+
raise "can't set namespaces (document has no URL)"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.included(base)
|
44
|
+
base.const_set(:DEFAULT_NAMESPACES, [])
|
45
|
+
|
46
|
+
# container for XML::Node's access to its document's namespaces
|
47
|
+
base.instance_variable_set(
|
48
|
+
:@namespaces, Hash.new(base.const_get(:DEFAULT_NAMESPACES))
|
49
|
+
)
|
50
|
+
|
51
|
+
class << base; attr_reader :namespaces; end
|
52
|
+
|
53
|
+
# overwrite original methods
|
54
|
+
instance_methods.each { |method|
|
55
|
+
base.send(:define_method, method, instance_method(method))
|
56
|
+
}
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
File without changes
|
@@ -24,17 +24,15 @@
|
|
24
24
|
###############################################################################
|
25
25
|
#++
|
26
26
|
|
27
|
-
require 'libxml'
|
28
27
|
require 'forwardable'
|
29
28
|
|
30
29
|
module LibXML
|
31
30
|
module Ext
|
32
|
-
module
|
31
|
+
module Uniq
|
33
32
|
|
34
33
|
extend Forwardable
|
35
34
|
|
36
|
-
DELEGATORS = %w[to_a each length size]
|
37
|
-
|
35
|
+
DELEGATORS = %w[to_a each length size] unless const_defined?(:DELEGATORS)
|
38
36
|
def_delegators *DELEGATORS
|
39
37
|
|
40
38
|
def to_a
|
@@ -91,7 +89,3 @@ module LibXML
|
|
91
89
|
end
|
92
90
|
end
|
93
91
|
end
|
94
|
-
|
95
|
-
[LibXML::XML::XPath::Object].each { |klass|
|
96
|
-
klass.send :include, LibXML::Ext::Uniqueness
|
97
|
-
}
|
data/lib/libxml/ext/version.rb
CHANGED
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 3
|
8
|
-
-
|
9
|
-
version: 0.3.
|
8
|
+
- 1
|
9
|
+
version: 0.3.1
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Jens Wille
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-03-
|
17
|
+
date: 2010-03-16 00:00:00 +01:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -42,11 +42,14 @@ extra_rdoc_files:
|
|
42
42
|
- ChangeLog
|
43
43
|
- README
|
44
44
|
files:
|
45
|
-
- lib/libxml/ext/
|
46
|
-
- lib/libxml/ext/
|
45
|
+
- lib/libxml/ext/find.rb
|
46
|
+
- lib/libxml/ext/namespaces_mixin.rb
|
47
47
|
- lib/libxml/ext/version.rb
|
48
|
-
- lib/libxml/ext/
|
48
|
+
- lib/libxml/ext/find_mixin.rb
|
49
|
+
- lib/libxml/ext/uniq_mixin.rb
|
49
50
|
- lib/libxml/ext/namespaces.rb
|
51
|
+
- lib/libxml/ext/string.rb
|
52
|
+
- lib/libxml/ext/uniq.rb
|
50
53
|
- lib/libxml/ext.rb
|
51
54
|
- README
|
52
55
|
- ChangeLog
|