ruby-xquery 0.0.8.227 → 0.1.0.269
Sign up to get free protection for your applications and to get access to all the features.
- data/README +1 -1
- data/Rakefile +2 -2
- data/lib/{xml/xquery/node_set.rb → libxml/xquery.rb} +13 -37
- data/lib/{xml → libxml}/xquery/attr.rb +1 -1
- data/lib/{xml → libxml}/xquery/enhanced_find.rb +6 -6
- data/lib/{xml → libxml}/xquery/node.rb +1 -1
- data/lib/libxml/xquery/node_set.rb +87 -0
- data/lib/libxml/xquery/version.rb +35 -0
- data/lib/{xml → libxml}/xquery/xpath_object.rb +13 -1
- data/lib/xml/xquery.rb +2 -37
- metadata +13 -12
- data/lib/xml/xquery/version.rb +0 -31
data/README
CHANGED
data/Rakefile
CHANGED
@@ -4,7 +4,7 @@ rescue LoadError
|
|
4
4
|
abort "Please install the 'hen' gem first."
|
5
5
|
end
|
6
6
|
|
7
|
-
require 'lib/
|
7
|
+
require 'lib/libxml/xquery/version'
|
8
8
|
|
9
9
|
Hen.lay! {{
|
10
10
|
:rubyforge => {
|
@@ -12,7 +12,7 @@ Hen.lay! {{
|
|
12
12
|
},
|
13
13
|
|
14
14
|
:gem => {
|
15
|
-
:version => XML::XQuery::VERSION,
|
15
|
+
:version => LibXML::XML::XQuery::VERSION,
|
16
16
|
:summary => "Libxml's XPath support + plain ol' Ruby = XQuery (kind of... ;-)",
|
17
17
|
:files => FileList['lib/**/*.rb'].to_a,
|
18
18
|
:extra_files => FileList['[A-Z]*', 'specs/*.rb', 'test_data/*'].to_a
|
@@ -1,7 +1,8 @@
|
|
1
1
|
#--
|
2
2
|
###############################################################################
|
3
3
|
# #
|
4
|
-
#
|
4
|
+
# ruby-xquery -- Libxml's XPath support + plain ol' Ruby = XQuery (kind of... #
|
5
|
+
# ;-) #
|
5
6
|
# #
|
6
7
|
# Copyright (C) 2007-2008 Jens Wille #
|
7
8
|
# #
|
@@ -24,43 +25,18 @@
|
|
24
25
|
###############################################################################
|
25
26
|
#++
|
26
27
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
# Object#dup gives a segmentation fault on #to_a (via Enumerable)!!
|
32
|
-
def dup
|
33
|
-
xpath.set
|
34
|
-
end
|
35
|
-
|
36
|
-
def uniq
|
37
|
-
dup.uniq!
|
38
|
-
end
|
39
|
-
|
40
|
-
def uniq!
|
41
|
-
# return unique when asked for array
|
42
|
-
@to_a = to_a.uniq
|
43
|
-
|
44
|
-
class << self
|
45
|
-
|
46
|
-
extend Forwardable
|
47
|
-
|
48
|
-
attr_reader :to_a
|
49
|
-
|
50
|
-
# forward to unique array
|
51
|
-
def_delegators :@to_a, :each, :length, :size
|
52
|
-
|
53
|
-
end
|
54
|
-
|
55
|
-
self
|
56
|
-
end
|
28
|
+
begin
|
29
|
+
require 'rubygems'
|
30
|
+
rescue LoadError
|
31
|
+
end
|
57
32
|
|
58
|
-
|
59
|
-
map { |n| (c = n.to_s(sep)).empty? ? nil : c }.compact
|
60
|
-
end
|
33
|
+
require 'libxml'
|
61
34
|
|
62
|
-
|
63
|
-
contents(sep).join(sep)
|
64
|
-
end
|
35
|
+
# Libxml's XPath support + plain ol' Ruby = XQuery (kind of... ;-)
|
65
36
|
|
37
|
+
module LibXML::XML::XQuery
|
66
38
|
end
|
39
|
+
|
40
|
+
Dir[File.join(File.dirname(__FILE__), 'xquery', '**', '*.rb')].each { |rb|
|
41
|
+
require rb
|
42
|
+
}
|
@@ -24,7 +24,7 @@
|
|
24
24
|
###############################################################################
|
25
25
|
#++
|
26
26
|
|
27
|
-
module XML::XQuery
|
27
|
+
module LibXML::XML::XQuery
|
28
28
|
|
29
29
|
module EnhancedFind
|
30
30
|
|
@@ -48,9 +48,9 @@ module XML::XQuery
|
|
48
48
|
|
49
49
|
end
|
50
50
|
|
51
|
-
class XML::Document
|
51
|
+
class LibXML::XML::Document
|
52
52
|
|
53
|
-
include XML::XQuery::EnhancedFind
|
53
|
+
include LibXML::XML::XQuery::EnhancedFind
|
54
54
|
|
55
55
|
DEFAULT_NAMESPACES = []
|
56
56
|
|
@@ -71,12 +71,12 @@ class XML::Document
|
|
71
71
|
|
72
72
|
end
|
73
73
|
|
74
|
-
class XML::Node
|
74
|
+
class LibXML::XML::Node
|
75
75
|
|
76
|
-
include XML::XQuery::EnhancedFind
|
76
|
+
include LibXML::XML::XQuery::EnhancedFind
|
77
77
|
|
78
78
|
def namespaces
|
79
|
-
XML::Document.namespaces[doc.url]
|
79
|
+
LibXML::XML::Document.namespaces[doc.url]
|
80
80
|
end
|
81
81
|
|
82
82
|
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
#--
|
2
|
+
###############################################################################
|
3
|
+
# #
|
4
|
+
# A component of ruby-xquery, mimicking XQuery in Ruby. #
|
5
|
+
# #
|
6
|
+
# Copyright (C) 2007-2008 Jens Wille #
|
7
|
+
# #
|
8
|
+
# Authors: #
|
9
|
+
# Jens Wille <jens.wille@uni-koeln.de> #
|
10
|
+
# #
|
11
|
+
# ruby-xquery 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
|
+
# ruby-xquery 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 ruby-xquery. If not, see <http://www.gnu.org/licenses/>. #
|
23
|
+
# #
|
24
|
+
###############################################################################
|
25
|
+
#++
|
26
|
+
|
27
|
+
require 'forwardable'
|
28
|
+
|
29
|
+
class LibXML::XML::Node::Set
|
30
|
+
|
31
|
+
extend Forwardable
|
32
|
+
|
33
|
+
def_delegators :to_a, :each, :length, :size
|
34
|
+
|
35
|
+
alias_method :_xquery_original_to_a, :to_a
|
36
|
+
|
37
|
+
def to_a
|
38
|
+
if @_uniq
|
39
|
+
# return unique nodes according to their #to_s
|
40
|
+
seen = Hash.new { |h, k| h[k] = true; false }
|
41
|
+
uniq = []
|
42
|
+
|
43
|
+
_xquery_original_to_a.each { |n|
|
44
|
+
uniq << n unless seen[n.to_s]
|
45
|
+
}
|
46
|
+
|
47
|
+
uniq
|
48
|
+
else
|
49
|
+
_xquery_original_to_a
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def uniq
|
54
|
+
proxy = LibXML::XML::Node::Set.new.uniq!
|
55
|
+
proxy.instance_variable_set(:@_this, self)
|
56
|
+
|
57
|
+
class << proxy
|
58
|
+
(instance_methods - %w[to_a each length size]).each { |method|
|
59
|
+
undef_method(method) unless method =~ /\A__/
|
60
|
+
}
|
61
|
+
|
62
|
+
def method_missing(*args)
|
63
|
+
block_given? ? @_this.send(*args) { |a| yield a } : @_this.send(*args)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
proxy
|
68
|
+
end
|
69
|
+
|
70
|
+
def uniq!
|
71
|
+
@_uniq = true
|
72
|
+
self
|
73
|
+
end
|
74
|
+
|
75
|
+
def uniq?
|
76
|
+
@_uniq
|
77
|
+
end
|
78
|
+
|
79
|
+
def contents(sep = ' | ')
|
80
|
+
map { |n| (c = n.to_s(sep)).empty? ? nil : c }.compact
|
81
|
+
end
|
82
|
+
|
83
|
+
def to_s(sep = ' | ')
|
84
|
+
contents(sep).join(sep)
|
85
|
+
end
|
86
|
+
|
87
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module LibXML
|
2
|
+
|
3
|
+
module XML
|
4
|
+
|
5
|
+
module XQuery
|
6
|
+
|
7
|
+
module Version
|
8
|
+
|
9
|
+
MAJOR = 0
|
10
|
+
MINOR = 1
|
11
|
+
TINY = 0
|
12
|
+
|
13
|
+
class << self
|
14
|
+
|
15
|
+
# Returns array representation.
|
16
|
+
def to_a
|
17
|
+
[MAJOR, MINOR, TINY]
|
18
|
+
end
|
19
|
+
|
20
|
+
# Short-cut for version string.
|
21
|
+
def to_s
|
22
|
+
to_a.join('.')
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
VERSION = Version.to_s
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
@@ -24,7 +24,19 @@
|
|
24
24
|
###############################################################################
|
25
25
|
#++
|
26
26
|
|
27
|
-
|
27
|
+
require 'forwardable'
|
28
|
+
|
29
|
+
class LibXML::XML::XPath::Object
|
30
|
+
|
31
|
+
extend Forwardable
|
32
|
+
|
33
|
+
def_delegators :set, :to_a, :each, :length, :size, :uniq, :uniq!, :uniq?
|
34
|
+
|
35
|
+
alias_method :_xquery_original_set, :set
|
36
|
+
|
37
|
+
def set
|
38
|
+
@set ||= _xquery_original_set
|
39
|
+
end
|
28
40
|
|
29
41
|
def to_s(sep = ' | ')
|
30
42
|
set.to_s(sep)
|
data/lib/xml/xquery.rb
CHANGED
@@ -1,37 +1,2 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
# #
|
4
|
-
# ruby-xquery -- Libxml's XPath support + plain ol' Ruby = XQuery (kind of... #
|
5
|
-
# ;-) #
|
6
|
-
# #
|
7
|
-
# Copyright (C) 2007-2008 Jens Wille #
|
8
|
-
# #
|
9
|
-
# Authors: #
|
10
|
-
# Jens Wille <jens.wille@uni-koeln.de> #
|
11
|
-
# #
|
12
|
-
# ruby-xquery is free software; you can redistribute it and/or modify it #
|
13
|
-
# under the terms of the GNU General Public License as published by the Free #
|
14
|
-
# Software Foundation; either version 3 of the License, or (at your option) #
|
15
|
-
# any later version. #
|
16
|
-
# #
|
17
|
-
# ruby-xquery is distributed in the hope that it will be useful, but WITHOUT #
|
18
|
-
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
|
19
|
-
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for #
|
20
|
-
# more details. #
|
21
|
-
# #
|
22
|
-
# You should have received a copy of the GNU General Public License along #
|
23
|
-
# with ruby-xquery. If not, see <http://www.gnu.org/licenses/>. #
|
24
|
-
# #
|
25
|
-
###############################################################################
|
26
|
-
#++
|
27
|
-
|
28
|
-
require 'xml/libxml'
|
29
|
-
|
30
|
-
# Libxml's XPath support + plain ol' Ruby = XQuery (kind of... ;-)
|
31
|
-
|
32
|
-
module XML::XQuery
|
33
|
-
end
|
34
|
-
|
35
|
-
Dir[File.join(File.dirname(__FILE__), 'xquery', '**', '*.rb')].each { |rb|
|
36
|
-
require rb
|
37
|
-
}
|
1
|
+
# for backwards-compatibility
|
2
|
+
require 'libxml/xquery'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-xquery
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.1.0.269
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jens Wille
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-
|
12
|
+
date: 2008-07-30 00:00:00 +02:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -24,12 +24,13 @@ extra_rdoc_files:
|
|
24
24
|
- ChangeLog
|
25
25
|
- README
|
26
26
|
files:
|
27
|
-
- lib/
|
28
|
-
- lib/
|
29
|
-
- lib/
|
30
|
-
- lib/
|
31
|
-
- lib/
|
32
|
-
- lib/
|
27
|
+
- lib/libxml/xquery/node_set.rb
|
28
|
+
- lib/libxml/xquery/xpath_object.rb
|
29
|
+
- lib/libxml/xquery/attr.rb
|
30
|
+
- lib/libxml/xquery/version.rb
|
31
|
+
- lib/libxml/xquery/enhanced_find.rb
|
32
|
+
- lib/libxml/xquery/node.rb
|
33
|
+
- lib/libxml/xquery.rb
|
33
34
|
- lib/xml/xquery.rb
|
34
35
|
- COPYING
|
35
36
|
- README
|
@@ -41,14 +42,14 @@ has_rdoc: true
|
|
41
42
|
homepage: http://prometheus.rubyforge.org/ruby-xquery
|
42
43
|
post_install_message:
|
43
44
|
rdoc_options:
|
45
|
+
- --line-numbers
|
44
46
|
- --inline-source
|
45
|
-
- --charset
|
46
|
-
- UTF-8
|
47
47
|
- --title
|
48
48
|
- ruby-xquery Application documentation
|
49
|
+
- --charset
|
50
|
+
- UTF-8
|
49
51
|
- --main
|
50
52
|
- README
|
51
|
-
- --line-numbers
|
52
53
|
- --all
|
53
54
|
require_paths:
|
54
55
|
- lib
|
@@ -67,7 +68,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
67
68
|
requirements: []
|
68
69
|
|
69
70
|
rubyforge_project: prometheus
|
70
|
-
rubygems_version: 1.0
|
71
|
+
rubygems_version: 1.2.0
|
71
72
|
signing_key:
|
72
73
|
specification_version: 2
|
73
74
|
summary: Libxml's XPath support + plain ol' Ruby = XQuery (kind of... ;-)
|
data/lib/xml/xquery/version.rb
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
module XML
|
2
|
-
|
3
|
-
module XQuery
|
4
|
-
|
5
|
-
module Version
|
6
|
-
|
7
|
-
MAJOR = 0
|
8
|
-
MINOR = 0
|
9
|
-
TINY = 8
|
10
|
-
|
11
|
-
class << self
|
12
|
-
|
13
|
-
# Returns array representation.
|
14
|
-
def to_a
|
15
|
-
[MAJOR, MINOR, TINY]
|
16
|
-
end
|
17
|
-
|
18
|
-
# Short-cut for version string.
|
19
|
-
def to_s
|
20
|
-
to_a.join('.')
|
21
|
-
end
|
22
|
-
|
23
|
-
end
|
24
|
-
|
25
|
-
end
|
26
|
-
|
27
|
-
VERSION = Version.to_s
|
28
|
-
|
29
|
-
end
|
30
|
-
|
31
|
-
end
|