rho-tau-extensions 6.2.0 → 7.1.17

Sign up to get free protection for your applications and to get access to all the features.
Files changed (160) hide show
  1. checksums.yaml +4 -4
  2. data/libs/crosswalk/ext/platform/android/Rakefile +19 -1
  3. data/libs/enterprise-barcode/ext/platform/android/adds/lib/aarch64/liballbarcode.a +0 -0
  4. data/libs/enterprise-barcode/ext/platform/android/adds/lib/armeabi/liballbarcode.a +0 -0
  5. data/libs/enterprise-barcode/ext/platform/android/adds/lib/x86/liballbarcode.a +0 -0
  6. data/libs/enterprise-barcode/ext/platform/android/allbarcode.jar +0 -0
  7. data/libs/fcm-push-18/ext.yml +20 -0
  8. data/libs/fcm-push-18/ext/android/AndroidManifest.rb +10 -0
  9. data/libs/fcm-push-18/ext/android/ApplicationManifestAdds.erb +39 -0
  10. data/libs/fcm-push-18/ext/android/Rakefile +187 -0
  11. data/libs/fcm-push-18/ext/android/ext_java.files +3 -0
  12. data/libs/fcm-push-18/ext/android/ext_native.files +1 -0
  13. data/libs/fcm-push-18/ext/android/jni/src/fcmpushclient.cpp +215 -0
  14. data/libs/fcm-push-18/ext/android/jni/src/fcmpushclient.h +74 -0
  15. data/libs/fcm-push-18/ext/android/res/res/values/fireBaseValues.xml +5 -0
  16. data/libs/fcm-push-18/ext/android/src/com/rhomobile/rhodes/fcm/FCMFacade.java +164 -0
  17. data/libs/fcm-push-18/ext/android/src/com/rhomobile/rhodes/fcm/FCMIntentService.java +219 -0
  18. data/libs/fcm-push-18/ext/android/src/com/rhomobile/rhodes/fcm/FCMListener.java +88 -0
  19. data/libs/fcm-push-18/ext/build +16 -0
  20. data/libs/fcm-push-18/ext/build.bat +8 -0
  21. data/libs/fcm-push-18/ext/fcm.xml +9 -0
  22. data/libs/fcm-push-18/ext/iphone/ApplePush_Prefix.pch +7 -0
  23. data/libs/fcm-push-18/ext/iphone/Firebase.h +68 -0
  24. data/libs/fcm-push-18/ext/iphone/Frameworks/FirebaseAnalytics.framework/FirebaseAnalytics +0 -0
  25. data/libs/fcm-push-18/ext/iphone/Frameworks/FirebaseAnalytics.framework/Headers/FIRAnalytics+AppDelegate.h +62 -0
  26. data/libs/fcm-push-18/ext/iphone/Frameworks/FirebaseAnalytics.framework/Headers/FIRAnalytics.h +115 -0
  27. data/libs/fcm-push-18/ext/iphone/Frameworks/FirebaseAnalytics.framework/Headers/FIRAnalyticsConfiguration.h +1 -0
  28. data/libs/fcm-push-18/ext/iphone/Frameworks/FirebaseAnalytics.framework/Headers/FIRAnalyticsSwiftNameSupport.h +13 -0
  29. data/libs/fcm-push-18/ext/iphone/Frameworks/FirebaseAnalytics.framework/Headers/FIRApp.h +1 -0
  30. data/libs/fcm-push-18/ext/iphone/Frameworks/FirebaseAnalytics.framework/Headers/FIRConfiguration.h +1 -0
  31. data/libs/fcm-push-18/ext/iphone/Frameworks/FirebaseAnalytics.framework/Headers/FIREventNames.h +389 -0
  32. data/libs/fcm-push-18/ext/iphone/Frameworks/FirebaseAnalytics.framework/Headers/FIROptions.h +1 -0
  33. data/libs/fcm-push-18/ext/iphone/Frameworks/FirebaseAnalytics.framework/Headers/FIRParameterNames.h +485 -0
  34. data/libs/fcm-push-18/ext/iphone/Frameworks/FirebaseAnalytics.framework/Headers/FIRUserPropertyNames.h +15 -0
  35. data/libs/fcm-push-18/ext/iphone/Frameworks/FirebaseAnalytics.framework/Headers/FirebaseAnalytics.h +10 -0
  36. data/libs/fcm-push-18/ext/iphone/Frameworks/FirebaseAnalytics.framework/Modules/module.modulemap +10 -0
  37. data/libs/fcm-push-18/ext/iphone/Frameworks/FirebaseCore.framework/FirebaseCore +0 -0
  38. data/libs/fcm-push-18/ext/iphone/Frameworks/FirebaseCore.framework/Headers/FIRAnalyticsConfiguration.h +52 -0
  39. data/libs/fcm-push-18/ext/iphone/Frameworks/FirebaseCore.framework/Headers/FIRApp.h +130 -0
  40. data/libs/fcm-push-18/ext/iphone/Frameworks/FirebaseCore.framework/Headers/FIRConfiguration.h +78 -0
  41. data/libs/fcm-push-18/ext/iphone/Frameworks/FirebaseCore.framework/Headers/FIRLoggerLevel.h +35 -0
  42. data/libs/fcm-push-18/ext/iphone/Frameworks/FirebaseCore.framework/Headers/FIROptions.h +133 -0
  43. data/libs/fcm-push-18/ext/iphone/Frameworks/FirebaseCore.framework/Headers/FirebaseCore.h +5 -0
  44. data/libs/fcm-push-18/ext/iphone/Frameworks/FirebaseCore.framework/Modules/module.modulemap +7 -0
  45. data/libs/fcm-push-18/ext/iphone/Frameworks/FirebaseCoreDiagnostics.framework/FirebaseCoreDiagnostics +0 -0
  46. data/libs/fcm-push-18/ext/iphone/Frameworks/FirebaseCoreDiagnostics.framework/Modules/module.modulemap +6 -0
  47. data/libs/fcm-push-18/ext/iphone/Frameworks/FirebaseInstanceID.framework/FirebaseInstanceID +0 -0
  48. data/libs/fcm-push-18/ext/iphone/Frameworks/FirebaseInstanceID.framework/Headers/FIRInstanceID.h +276 -0
  49. data/libs/fcm-push-18/ext/iphone/Frameworks/FirebaseInstanceID.framework/Headers/FirebaseInstanceID.h +1 -0
  50. data/libs/fcm-push-18/ext/iphone/Frameworks/FirebaseInstanceID.framework/Modules/module.modulemap +7 -0
  51. data/libs/fcm-push-18/ext/iphone/Frameworks/FirebaseMessaging.framework/FirebaseMessaging +0 -0
  52. data/libs/fcm-push-18/ext/iphone/Frameworks/FirebaseMessaging.framework/Headers/FIRMessaging.h +508 -0
  53. data/libs/fcm-push-18/ext/iphone/Frameworks/FirebaseMessaging.framework/Headers/FirebaseMessaging.h +1 -0
  54. data/libs/fcm-push-18/ext/iphone/Frameworks/FirebaseMessaging.framework/Modules/module.modulemap +8 -0
  55. data/libs/fcm-push-18/ext/iphone/Frameworks/FirebaseNanoPB.framework/FirebaseNanoPB +0 -0
  56. data/libs/fcm-push-18/ext/iphone/Frameworks/GoogleToolboxForMac.framework/GoogleToolboxForMac +0 -0
  57. data/libs/fcm-push-18/ext/iphone/Frameworks/GoogleToolboxForMac.framework/Modules/module.modulemap +5 -0
  58. data/libs/fcm-push-18/ext/iphone/Frameworks/Protobuf.framework/Modules/module.modulemap +5 -0
  59. data/libs/fcm-push-18/ext/iphone/Frameworks/Protobuf.framework/Protobuf +0 -0
  60. data/libs/fcm-push-18/ext/iphone/Frameworks/nanopb.framework/Modules/module.modulemap +5 -0
  61. data/libs/fcm-push-18/ext/iphone/Frameworks/nanopb.framework/nanopb +0 -0
  62. data/libs/fcm-push-18/ext/iphone/Rakefile +81 -0
  63. data/libs/fcm-push-18/ext/iphone/fcm-push.xcodeproj/project.pbxproj +370 -0
  64. data/libs/fcm-push-18/ext/iphone/impl/PushNotificationsReceiver.h +28 -0
  65. data/libs/fcm-push-18/ext/iphone/impl/PushNotificationsReceiver.m +27 -0
  66. data/libs/fcm-push-18/ext/iphone/impl/PushNotificationsReceiver.mm +234 -0
  67. data/libs/fcm-push-18/ext/iphone/impl/applePushSetup.c +10 -0
  68. data/libs/fcm-push-18/ext/iphone/impl/applepushclient.h +69 -0
  69. data/libs/fcm-push-18/ext/iphone/impl/applepushclient.mm +164 -0
  70. data/libs/fcm-push-18/ext/iphone/impl/readme.txt +7 -0
  71. data/libs/fcm-push-18/ext/platform/iphone/impl/readme.txt +7 -0
  72. data/libs/nodejs/ext/platform/android/jxCore/jx.h +17 -1
  73. data/libs/nodejs/ext/platform/android/jxCore/libcares_arm.a +0 -0
  74. data/libs/nodejs/ext/platform/android/jxCore/libcares_ia32.a +0 -0
  75. data/libs/nodejs/ext/platform/android/jxCore/libcares_x64.a +0 -0
  76. data/libs/nodejs/ext/platform/android/jxCore/libchrome_zlib_arm.a +0 -0
  77. data/libs/nodejs/ext/platform/android/jxCore/libchrome_zlib_ia32.a +0 -0
  78. data/libs/nodejs/ext/platform/android/jxCore/libchrome_zlib_x64.a +0 -0
  79. data/libs/nodejs/ext/platform/android/jxCore/libhttp_parser_arm.a +0 -0
  80. data/libs/nodejs/ext/platform/android/jxCore/libhttp_parser_ia32.a +0 -0
  81. data/libs/nodejs/ext/platform/android/jxCore/libhttp_parser_x64.a +0 -0
  82. data/libs/nodejs/ext/platform/android/jxCore/libjx_arm.a +0 -0
  83. data/libs/nodejs/ext/platform/android/jxCore/libjx_ia32.a +0 -0
  84. data/libs/nodejs/ext/platform/android/jxCore/libjx_x64.a +0 -0
  85. data/libs/nodejs/ext/platform/android/jxCore/libopenssl_arm.a +0 -0
  86. data/libs/nodejs/ext/platform/android/jxCore/libopenssl_ia32.a +0 -0
  87. data/libs/nodejs/ext/platform/android/jxCore/libopenssl_x64.a +0 -0
  88. data/libs/nodejs/ext/platform/android/jxCore/libsqlite3_arm.a +0 -0
  89. data/libs/nodejs/ext/platform/android/jxCore/libsqlite3_ia32.a +0 -0
  90. data/libs/nodejs/ext/platform/android/jxCore/libsqlite3_x64.a +0 -0
  91. data/libs/nodejs/ext/platform/android/jxCore/libuv_arm.a +0 -0
  92. data/libs/nodejs/ext/platform/android/jxCore/libuv_ia32.a +0 -0
  93. data/libs/nodejs/ext/platform/android/jxCore/libuv_x64.a +0 -0
  94. data/libs/nodejs/ext/platform/android/jxCore/libv8_base_arm.a +0 -0
  95. data/libs/nodejs/ext/platform/android/jxCore/libv8_base_ia32.a +0 -0
  96. data/libs/nodejs/ext/platform/android/jxCore/libv8_base_x64.a +0 -0
  97. data/libs/nodejs/ext/platform/android/jxCore/libv8_nosnapshot_arm.a +0 -0
  98. data/libs/nodejs/ext/platform/android/jxCore/libv8_nosnapshot_ia32.a +0 -0
  99. data/libs/nodejs/ext/platform/android/jxCore/libv8_nosnapshot_x64.a +0 -0
  100. data/libs/nodejs/ext/platform/iphone/jxCore/jx.h +17 -1
  101. data/libs/nodejs/ext/platform/iphone/jxCore/libcares.a +0 -0
  102. data/libs/nodejs/ext/platform/iphone/jxCore/libchrome_zlib.a +0 -0
  103. data/libs/nodejs/ext/platform/iphone/jxCore/libhttp_parser.a +0 -0
  104. data/libs/nodejs/ext/platform/iphone/jxCore/libjx.a +0 -0
  105. data/libs/nodejs/ext/platform/iphone/jxCore/libmozjs.a +0 -0
  106. data/libs/nodejs/ext/platform/iphone/jxCore/libopenssl.a +0 -0
  107. data/libs/nodejs/ext/platform/iphone/jxCore/libsqlite3.a +0 -0
  108. data/libs/nodejs/ext/platform/iphone/jxCore/libuv.a +0 -0
  109. data/libs/rexml-edge/rexml/attlistdecl.rb +63 -0
  110. data/libs/rexml-edge/rexml/attribute.rb +192 -0
  111. data/libs/rexml-edge/rexml/cdata.rb +68 -0
  112. data/libs/rexml-edge/rexml/child.rb +97 -0
  113. data/libs/rexml-edge/rexml/comment.rb +80 -0
  114. data/libs/rexml-edge/rexml/doctype.rb +270 -0
  115. data/libs/rexml-edge/rexml/document.rb +291 -0
  116. data/libs/rexml-edge/rexml/dtd/attlistdecl.rb +11 -0
  117. data/libs/rexml-edge/rexml/dtd/dtd.rb +47 -0
  118. data/libs/rexml-edge/rexml/dtd/elementdecl.rb +18 -0
  119. data/libs/rexml-edge/rexml/dtd/entitydecl.rb +57 -0
  120. data/libs/rexml-edge/rexml/dtd/notationdecl.rb +40 -0
  121. data/libs/rexml-edge/rexml/element.rb +1241 -0
  122. data/libs/rexml-edge/rexml/encoding.rb +51 -0
  123. data/libs/rexml-edge/rexml/entity.rb +174 -0
  124. data/libs/rexml-edge/rexml/formatters/default.rb +112 -0
  125. data/libs/rexml-edge/rexml/formatters/pretty.rb +142 -0
  126. data/libs/rexml-edge/rexml/formatters/transitive.rb +58 -0
  127. data/libs/rexml-edge/rexml/functions.rb +418 -0
  128. data/libs/rexml-edge/rexml/instruction.rb +71 -0
  129. data/libs/rexml-edge/rexml/light/node.rb +196 -0
  130. data/libs/rexml-edge/rexml/namespace.rb +48 -0
  131. data/libs/rexml-edge/rexml/node.rb +76 -0
  132. data/libs/rexml-edge/rexml/output.rb +30 -0
  133. data/libs/rexml-edge/rexml/parent.rb +166 -0
  134. data/libs/rexml-edge/rexml/parseexception.rb +52 -0
  135. data/libs/rexml-edge/rexml/parsers/baseparser.rb +533 -0
  136. data/libs/rexml-edge/rexml/parsers/lightparser.rb +59 -0
  137. data/libs/rexml-edge/rexml/parsers/pullparser.rb +197 -0
  138. data/libs/rexml-edge/rexml/parsers/sax2parser.rb +273 -0
  139. data/libs/rexml-edge/rexml/parsers/streamparser.rb +61 -0
  140. data/libs/rexml-edge/rexml/parsers/treeparser.rb +101 -0
  141. data/libs/rexml-edge/rexml/parsers/ultralightparser.rb +57 -0
  142. data/libs/rexml-edge/rexml/parsers/xpathparser.rb +657 -0
  143. data/libs/rexml-edge/rexml/quickpath.rb +266 -0
  144. data/libs/rexml-edge/rexml/rexml.rb +32 -0
  145. data/libs/rexml-edge/rexml/sax2listener.rb +98 -0
  146. data/libs/rexml-edge/rexml/security.rb +28 -0
  147. data/libs/rexml-edge/rexml/source.rb +297 -0
  148. data/libs/rexml-edge/rexml/streamlistener.rb +93 -0
  149. data/libs/rexml-edge/rexml/syncenumerator.rb +33 -0
  150. data/libs/rexml-edge/rexml/text.rb +426 -0
  151. data/libs/rexml-edge/rexml/undefinednamespaceexception.rb +9 -0
  152. data/libs/rexml-edge/rexml/validation/relaxng.rb +539 -0
  153. data/libs/rexml-edge/rexml/validation/validation.rb +144 -0
  154. data/libs/rexml-edge/rexml/validation/validationexception.rb +10 -0
  155. data/libs/rexml-edge/rexml/xmldecl.rb +116 -0
  156. data/libs/rexml-edge/rexml/xmltokens.rb +85 -0
  157. data/libs/rexml-edge/rexml/xpath.rb +81 -0
  158. data/libs/rexml-edge/rexml/xpath_parser.rb +704 -0
  159. data/version +1 -1
  160. metadata +118 -2
@@ -0,0 +1,58 @@
1
+ # frozen_string_literal: false
2
+ require 'rexml/formatters/pretty'
3
+
4
+ module REXML
5
+ module Formatters
6
+ # The Transitive formatter writes an XML document that parses to an
7
+ # identical document as the source document. This means that no extra
8
+ # whitespace nodes are inserted, and whitespace within text nodes is
9
+ # preserved. Within these constraints, the document is pretty-printed,
10
+ # with whitespace inserted into the metadata to introduce formatting.
11
+ #
12
+ # Note that this is only useful if the original XML is not already
13
+ # formatted. Since this formatter does not alter whitespace nodes, the
14
+ # results of formatting already formatted XML will be odd.
15
+ class Transitive < Default
16
+ def initialize( indentation=2, ie_hack=false )
17
+ @indentation = indentation
18
+ @level = 0
19
+ @ie_hack = ie_hack
20
+ end
21
+
22
+ protected
23
+ def write_element( node, output )
24
+ output << "<#{node.expanded_name}"
25
+
26
+ node.attributes.each_attribute do |attr|
27
+ output << " "
28
+ attr.write( output )
29
+ end unless node.attributes.empty?
30
+
31
+ output << "\n"
32
+ output << ' '*@level
33
+ if node.children.empty?
34
+ output << " " if @ie_hack
35
+ output << "/"
36
+ else
37
+ output << ">"
38
+ # If compact and all children are text, and if the formatted output
39
+ # is less than the specified width, then try to print everything on
40
+ # one line
41
+ @level += @indentation
42
+ node.children.each { |child|
43
+ write( child, output )
44
+ }
45
+ @level -= @indentation
46
+ output << "</#{node.expanded_name}"
47
+ output << "\n"
48
+ output << ' '*@level
49
+ end
50
+ output << ">"
51
+ end
52
+
53
+ def write_text( node, output )
54
+ output << node.to_s()
55
+ end
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,418 @@
1
+ # frozen_string_literal: false
2
+ module REXML
3
+ # If you add a method, keep in mind two things:
4
+ # (1) the first argument will always be a list of nodes from which to
5
+ # filter. In the case of context methods (such as position), the function
6
+ # should return an array with a value for each child in the array.
7
+ # (2) all method calls from XML will have "-" replaced with "_".
8
+ # Therefore, in XML, "local-name()" is identical (and actually becomes)
9
+ # "local_name()"
10
+ module Functions
11
+ @@available_functions = {}
12
+ @@context = nil
13
+ @@namespace_context = {}
14
+ @@variables = {}
15
+
16
+ INTERNAL_METHODS = [
17
+ :namespace_context,
18
+ :namespace_context=,
19
+ :variables,
20
+ :variables=,
21
+ :context=,
22
+ :get_namespace,
23
+ :send,
24
+ ]
25
+ class << self
26
+ def singleton_method_added(name)
27
+ unless INTERNAL_METHODS.include?(name)
28
+ @@available_functions[name] = true
29
+ end
30
+ end
31
+ end
32
+
33
+ def Functions::namespace_context=(x) ; @@namespace_context=x ; end
34
+ def Functions::variables=(x) ; @@variables=x ; end
35
+ def Functions::namespace_context ; @@namespace_context ; end
36
+ def Functions::variables ; @@variables ; end
37
+
38
+ def Functions::context=(value); @@context = value; end
39
+
40
+ def Functions::text( )
41
+ if @@context[:node].node_type == :element
42
+ return @@context[:node].find_all{|n| n.node_type == :text}.collect{|n| n.value}
43
+ elsif @@context[:node].node_type == :text
44
+ return @@context[:node].value
45
+ else
46
+ return false
47
+ end
48
+ end
49
+
50
+ # Returns the last node of the given list of nodes.
51
+ def Functions::last( )
52
+ @@context[:size]
53
+ end
54
+
55
+ def Functions::position( )
56
+ @@context[:index]
57
+ end
58
+
59
+ # Returns the size of the given list of nodes.
60
+ def Functions::count( node_set )
61
+ node_set.size
62
+ end
63
+
64
+ # Since REXML is non-validating, this method is not implemented as it
65
+ # requires a DTD
66
+ def Functions::id( object )
67
+ end
68
+
69
+ # UNTESTED
70
+ def Functions::local_name( node_set=nil )
71
+ get_namespace( node_set ) do |node|
72
+ return node.local_name
73
+ end
74
+ end
75
+
76
+ def Functions::namespace_uri( node_set=nil )
77
+ get_namespace( node_set ) {|node| node.namespace}
78
+ end
79
+
80
+ def Functions::name( node_set=nil )
81
+ get_namespace( node_set ) do |node|
82
+ node.expanded_name
83
+ end
84
+ end
85
+
86
+ # Helper method.
87
+ def Functions::get_namespace( node_set = nil )
88
+ if node_set == nil
89
+ yield @@context[:node] if defined? @@context[:node].namespace
90
+ else
91
+ if node_set.respond_to? :each
92
+ node_set.each { |node| yield node if defined? node.namespace }
93
+ elsif node_set.respond_to? :namespace
94
+ yield node_set
95
+ end
96
+ end
97
+ end
98
+
99
+ # A node-set is converted to a string by returning the string-value of the
100
+ # node in the node-set that is first in document order. If the node-set is
101
+ # empty, an empty string is returned.
102
+ #
103
+ # A number is converted to a string as follows
104
+ #
105
+ # NaN is converted to the string NaN
106
+ #
107
+ # positive zero is converted to the string 0
108
+ #
109
+ # negative zero is converted to the string 0
110
+ #
111
+ # positive infinity is converted to the string Infinity
112
+ #
113
+ # negative infinity is converted to the string -Infinity
114
+ #
115
+ # if the number is an integer, the number is represented in decimal form
116
+ # as a Number with no decimal point and no leading zeros, preceded by a
117
+ # minus sign (-) if the number is negative
118
+ #
119
+ # otherwise, the number is represented in decimal form as a Number
120
+ # including a decimal point with at least one digit before the decimal
121
+ # point and at least one digit after the decimal point, preceded by a
122
+ # minus sign (-) if the number is negative; there must be no leading zeros
123
+ # before the decimal point apart possibly from the one required digit
124
+ # immediately before the decimal point; beyond the one required digit
125
+ # after the decimal point there must be as many, but only as many, more
126
+ # digits as are needed to uniquely distinguish the number from all other
127
+ # IEEE 754 numeric values.
128
+ #
129
+ # The boolean false value is converted to the string false. The boolean
130
+ # true value is converted to the string true.
131
+ #
132
+ # An object of a type other than the four basic types is converted to a
133
+ # string in a way that is dependent on that type.
134
+ def Functions::string( object=nil )
135
+ #object = @context unless object
136
+ if object.instance_of? Array
137
+ string( object[0] )
138
+ elsif defined? object.node_type
139
+ if object.node_type == :attribute
140
+ object.value
141
+ elsif object.node_type == :element || object.node_type == :document
142
+ string_value(object)
143
+ else
144
+ object.to_s
145
+ end
146
+ elsif object.nil?
147
+ return ""
148
+ else
149
+ object.to_s
150
+ end
151
+ end
152
+
153
+ # A node-set is converted to a string by
154
+ # returning the concatenation of the string-value
155
+ # of each of the children of the node in the
156
+ # node-set that is first in document order.
157
+ # If the node-set is empty, an empty string is returned.
158
+ def Functions::string_value( o )
159
+ rv = ""
160
+ o.children.each { |e|
161
+ if e.node_type == :text
162
+ rv << e.to_s
163
+ elsif e.node_type == :element
164
+ rv << string_value( e )
165
+ end
166
+ }
167
+ rv
168
+ end
169
+
170
+ # UNTESTED
171
+ def Functions::concat( *objects )
172
+ objects.join
173
+ end
174
+
175
+ # Fixed by Mike Stok
176
+ def Functions::starts_with( string, test )
177
+ string(string).index(string(test)) == 0
178
+ end
179
+
180
+ # Fixed by Mike Stok
181
+ def Functions::contains( string, test )
182
+ string(string).include?(string(test))
183
+ end
184
+
185
+ # Kouhei fixed this
186
+ def Functions::substring_before( string, test )
187
+ ruby_string = string(string)
188
+ ruby_index = ruby_string.index(string(test))
189
+ if ruby_index.nil?
190
+ ""
191
+ else
192
+ ruby_string[ 0...ruby_index ]
193
+ end
194
+ end
195
+
196
+ # Kouhei fixed this too
197
+ def Functions::substring_after( string, test )
198
+ ruby_string = string(string)
199
+ return $1 if ruby_string =~ /#{test}(.*)/
200
+ ""
201
+ end
202
+
203
+ # Take equal portions of Mike Stok and Sean Russell; mix
204
+ # vigorously, and pour into a tall, chilled glass. Serves 10,000.
205
+ def Functions::substring( string, start, length=nil )
206
+ ruby_string = string(string)
207
+ ruby_length = if length.nil?
208
+ ruby_string.length.to_f
209
+ else
210
+ number(length)
211
+ end
212
+ ruby_start = number(start)
213
+
214
+ # Handle the special cases
215
+ return '' if (
216
+ ruby_length.nan? or
217
+ ruby_start.nan? or
218
+ ruby_start.infinite?
219
+ )
220
+
221
+ infinite_length = ruby_length.infinite? == 1
222
+ ruby_length = ruby_string.length if infinite_length
223
+
224
+ # Now, get the bounds. The XPath bounds are 1..length; the ruby bounds
225
+ # are 0..length. Therefore, we have to offset the bounds by one.
226
+ ruby_start = ruby_start.round - 1
227
+ ruby_length = ruby_length.round
228
+
229
+ if ruby_start < 0
230
+ ruby_length += ruby_start unless infinite_length
231
+ ruby_start = 0
232
+ end
233
+ return '' if ruby_length <= 0
234
+ ruby_string[ruby_start,ruby_length]
235
+ end
236
+
237
+ # UNTESTED
238
+ def Functions::string_length( string )
239
+ string(string).length
240
+ end
241
+
242
+ # UNTESTED
243
+ def Functions::normalize_space( string=nil )
244
+ string = string(@@context[:node]) if string.nil?
245
+ if string.kind_of? Array
246
+ string.collect{|x| string.to_s.strip.gsub(/\s+/um, ' ') if string}
247
+ else
248
+ string.to_s.strip.gsub(/\s+/um, ' ')
249
+ end
250
+ end
251
+
252
+ # This is entirely Mike Stok's beast
253
+ def Functions::translate( string, tr1, tr2 )
254
+ from = string(tr1)
255
+ to = string(tr2)
256
+
257
+ # the map is our translation table.
258
+ #
259
+ # if a character occurs more than once in the
260
+ # from string then we ignore the second &
261
+ # subsequent mappings
262
+ #
263
+ # if a character maps to nil then we delete it
264
+ # in the output. This happens if the from
265
+ # string is longer than the to string
266
+ #
267
+ # there's nothing about - or ^ being special in
268
+ # http://www.w3.org/TR/xpath#function-translate
269
+ # so we don't build ranges or negated classes
270
+
271
+ map = Hash.new
272
+ 0.upto(from.length - 1) { |pos|
273
+ from_char = from[pos]
274
+ unless map.has_key? from_char
275
+ map[from_char] =
276
+ if pos < to.length
277
+ to[pos]
278
+ else
279
+ nil
280
+ end
281
+ end
282
+ }
283
+
284
+ if ''.respond_to? :chars
285
+ string(string).chars.collect { |c|
286
+ if map.has_key? c then map[c] else c end
287
+ }.compact.join
288
+ else
289
+ string(string).unpack('U*').collect { |c|
290
+ if map.has_key? c then map[c] else c end
291
+ }.compact.pack('U*')
292
+ end
293
+ end
294
+
295
+ # UNTESTED
296
+ def Functions::boolean( object=nil )
297
+ if object.kind_of? String
298
+ if object =~ /\d+/u
299
+ return object.to_f != 0
300
+ else
301
+ return object.size > 0
302
+ end
303
+ elsif object.kind_of? Array
304
+ object = object.find{|x| x and true}
305
+ end
306
+ return object ? true : false
307
+ end
308
+
309
+ # UNTESTED
310
+ def Functions::not( object )
311
+ not boolean( object )
312
+ end
313
+
314
+ # UNTESTED
315
+ def Functions::true( )
316
+ true
317
+ end
318
+
319
+ # UNTESTED
320
+ def Functions::false( )
321
+ false
322
+ end
323
+
324
+ # UNTESTED
325
+ def Functions::lang( language )
326
+ lang = false
327
+ node = @@context[:node]
328
+ attr = nil
329
+ until node.nil?
330
+ if node.node_type == :element
331
+ attr = node.attributes["xml:lang"]
332
+ unless attr.nil?
333
+ lang = compare_language(string(language), attr)
334
+ break
335
+ else
336
+ end
337
+ end
338
+ node = node.parent
339
+ end
340
+ lang
341
+ end
342
+
343
+ def Functions::compare_language lang1, lang2
344
+ lang2.downcase.index(lang1.downcase) == 0
345
+ end
346
+
347
+ # a string that consists of optional whitespace followed by an optional
348
+ # minus sign followed by a Number followed by whitespace is converted to
349
+ # the IEEE 754 number that is nearest (according to the IEEE 754
350
+ # round-to-nearest rule) to the mathematical value represented by the
351
+ # string; any other string is converted to NaN
352
+ #
353
+ # boolean true is converted to 1; boolean false is converted to 0
354
+ #
355
+ # a node-set is first converted to a string as if by a call to the string
356
+ # function and then converted in the same way as a string argument
357
+ #
358
+ # an object of a type other than the four basic types is converted to a
359
+ # number in a way that is dependent on that type
360
+ def Functions::number( object=nil )
361
+ object = @@context[:node] unless object
362
+ case object
363
+ when true
364
+ Float(1)
365
+ when false
366
+ Float(0)
367
+ when Array
368
+ number(string( object ))
369
+ when Numeric
370
+ object.to_f
371
+ else
372
+ str = string( object )
373
+ # If XPath ever gets scientific notation...
374
+ #if str =~ /^\s*-?(\d*\.?\d+|\d+\.)([Ee]\d*)?\s*$/
375
+ if str =~ /^\s*-?(\d*\.?\d+|\d+\.)\s*$/
376
+ str.to_f
377
+ else
378
+ (0.0 / 0.0)
379
+ end
380
+ end
381
+ end
382
+
383
+ def Functions::sum( nodes )
384
+ nodes = [nodes] unless nodes.kind_of? Array
385
+ nodes.inject(0) { |r,n| r + number(string(n)) }
386
+ end
387
+
388
+ def Functions::floor( number )
389
+ number(number).floor
390
+ end
391
+
392
+ def Functions::ceiling( number )
393
+ number(number).ceil
394
+ end
395
+
396
+ def Functions::round( number )
397
+ begin
398
+ number(number).round
399
+ rescue FloatDomainError
400
+ number(number)
401
+ end
402
+ end
403
+
404
+ def Functions::processing_instruction( node )
405
+ node.node_type == :processing_instruction
406
+ end
407
+
408
+ def Functions::send(name, *args)
409
+ if @@available_functions[name.to_sym]
410
+ super
411
+ else
412
+ # TODO: Maybe, this is not XPath spec behavior.
413
+ # This behavior must be reconsidered.
414
+ XPath.match(@@context[:node], name.to_s)
415
+ end
416
+ end
417
+ end
418
+ end