soybean 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (175) hide show
  1. data/.document +5 -0
  2. data/.rspec +1 -0
  3. data/Gemfile +15 -0
  4. data/Gemfile.lock +38 -0
  5. data/LICENSE.txt +20 -0
  6. data/README.rdoc +19 -0
  7. data/Rakefile +44 -0
  8. data/VERSION +1 -0
  9. data/bin/soybean +22 -0
  10. data/bin/xsd2ruby +90 -0
  11. data/lib/soybean.rb +11 -0
  12. data/lib/soybean/actions/generate_classes.rb +33 -0
  13. data/soybean.gemspec +236 -0
  14. data/spec/soybean_spec.rb +5 -0
  15. data/spec/spec_helper.rb +12 -0
  16. data/vendor/soap4r/soap/attachment.rb +109 -0
  17. data/vendor/soap4r/soap/attrproxy.rb +35 -0
  18. data/vendor/soap4r/soap/base_data.rb +1095 -0
  19. data/vendor/soap4r/soap/element.rb +278 -0
  20. data/vendor/soap4r/soap/encodingstyle/asp_dot_net_handler.rb +208 -0
  21. data/vendor/soap4r/soap/encodingstyle/handler.rb +121 -0
  22. data/vendor/soap4r/soap/encodingstyle/literal_handler.rb +196 -0
  23. data/vendor/soap4r/soap/encodingstyle/soap_handler.rb +560 -0
  24. data/vendor/soap4r/soap/filter.rb +14 -0
  25. data/vendor/soap4r/soap/filter/filterchain.rb +52 -0
  26. data/vendor/soap4r/soap/filter/handler.rb +32 -0
  27. data/vendor/soap4r/soap/filter/streamhandler.rb +30 -0
  28. data/vendor/soap4r/soap/generator.rb +299 -0
  29. data/vendor/soap4r/soap/header/handler.rb +62 -0
  30. data/vendor/soap4r/soap/header/handlerset.rb +71 -0
  31. data/vendor/soap4r/soap/header/mappinghandler.rb +48 -0
  32. data/vendor/soap4r/soap/header/simplehandler.rb +45 -0
  33. data/vendor/soap4r/soap/httpconfigloader.rb +140 -0
  34. data/vendor/soap4r/soap/mapping.rb +13 -0
  35. data/vendor/soap4r/soap/mapping/encodedregistry.rb +539 -0
  36. data/vendor/soap4r/soap/mapping/factory.rb +389 -0
  37. data/vendor/soap4r/soap/mapping/literalregistry.rb +392 -0
  38. data/vendor/soap4r/soap/mapping/mapping.rb +577 -0
  39. data/vendor/soap4r/soap/mapping/registry.rb +296 -0
  40. data/vendor/soap4r/soap/mapping/rubytype_factory.rb +446 -0
  41. data/vendor/soap4r/soap/mapping/schemadefinition.rb +171 -0
  42. data/vendor/soap4r/soap/mapping/type_map.rb +107 -0
  43. data/vendor/soap4r/soap/mapping/wsdlencodedregistry.rb +212 -0
  44. data/vendor/soap4r/soap/mapping/wsdlliteralregistry.rb +249 -0
  45. data/vendor/soap4r/soap/marshal.rb +60 -0
  46. data/vendor/soap4r/soap/mimemessage.rb +243 -0
  47. data/vendor/soap4r/soap/nestedexception.rb +43 -0
  48. data/vendor/soap4r/soap/net_http_client.rb +242 -0
  49. data/vendor/soap4r/soap/ns.rb +39 -0
  50. data/vendor/soap4r/soap/parser.rb +253 -0
  51. data/vendor/soap4r/soap/processor.rb +67 -0
  52. data/vendor/soap4r/soap/property.rb +340 -0
  53. data/vendor/soap4r/soap/proxy.rb +15 -0
  54. data/vendor/soap4r/soap/rpc/cgistub.rb +248 -0
  55. data/vendor/soap4r/soap/rpc/driver.rb +222 -0
  56. data/vendor/soap4r/soap/rpc/element.rb +375 -0
  57. data/vendor/soap4r/soap/rpc/httpserver.rb +143 -0
  58. data/vendor/soap4r/soap/rpc/method_def.rb +69 -0
  59. data/vendor/soap4r/soap/rpc/proxy.rb +573 -0
  60. data/vendor/soap4r/soap/rpc/router.rb +663 -0
  61. data/vendor/soap4r/soap/rpc/rpc.rb +26 -0
  62. data/vendor/soap4r/soap/rpc/soaplet.rb +201 -0
  63. data/vendor/soap4r/soap/rpc/standalone_server.rb +44 -0
  64. data/vendor/soap4r/soap/soap.rb +154 -0
  65. data/vendor/soap4r/soap/stream_handler.rb +302 -0
  66. data/vendor/soap4r/soap/version.rb +9 -0
  67. data/vendor/soap4r/soap/wsdl_driver.rb +165 -0
  68. data/vendor/soap4r/wsdl/binding.rb +66 -0
  69. data/vendor/soap4r/wsdl/data.rb +65 -0
  70. data/vendor/soap4r/wsdl/definitions.rb +237 -0
  71. data/vendor/soap4r/wsdl/documentation.rb +33 -0
  72. data/vendor/soap4r/wsdl/import.rb +81 -0
  73. data/vendor/soap4r/wsdl/importer.rb +39 -0
  74. data/vendor/soap4r/wsdl/info.rb +51 -0
  75. data/vendor/soap4r/wsdl/message.rb +55 -0
  76. data/vendor/soap4r/wsdl/operation.rb +152 -0
  77. data/vendor/soap4r/wsdl/operation_binding.rb +241 -0
  78. data/vendor/soap4r/wsdl/param.rb +94 -0
  79. data/vendor/soap4r/wsdl/parser.rb +165 -0
  80. data/vendor/soap4r/wsdl/part.rb +53 -0
  81. data/vendor/soap4r/wsdl/port.rb +67 -0
  82. data/vendor/soap4r/wsdl/port_type.rb +76 -0
  83. data/vendor/soap4r/wsdl/service.rb +62 -0
  84. data/vendor/soap4r/wsdl/soap/address.rb +41 -0
  85. data/vendor/soap4r/wsdl/soap/binding.rb +50 -0
  86. data/vendor/soap4r/wsdl/soap/body.rb +59 -0
  87. data/vendor/soap4r/wsdl/soap/cgi_stub_creator.rb +93 -0
  88. data/vendor/soap4r/wsdl/soap/class_def_creator.rb +437 -0
  89. data/vendor/soap4r/wsdl/soap/class_def_creator_support.rb +241 -0
  90. data/vendor/soap4r/wsdl/soap/class_name_creator.rb +55 -0
  91. data/vendor/soap4r/wsdl/soap/client_skelton_creator.rb +107 -0
  92. data/vendor/soap4r/wsdl/soap/complex_type.rb +174 -0
  93. data/vendor/soap4r/wsdl/soap/data.rb +43 -0
  94. data/vendor/soap4r/wsdl/soap/definitions.rb +201 -0
  95. data/vendor/soap4r/wsdl/soap/driver_creator.rb +121 -0
  96. data/vendor/soap4r/wsdl/soap/element.rb +34 -0
  97. data/vendor/soap4r/wsdl/soap/encoded_mapping_registry_creator.rb +74 -0
  98. data/vendor/soap4r/wsdl/soap/fault.rb +57 -0
  99. data/vendor/soap4r/wsdl/soap/header.rb +87 -0
  100. data/vendor/soap4r/wsdl/soap/headerfault.rb +57 -0
  101. data/vendor/soap4r/wsdl/soap/literal_mapping_registry_creator.rb +116 -0
  102. data/vendor/soap4r/wsdl/soap/mapping_registry_creator.rb +59 -0
  103. data/vendor/soap4r/wsdl/soap/mapping_registry_creator_support.rb +377 -0
  104. data/vendor/soap4r/wsdl/soap/method_def_creator.rb +200 -0
  105. data/vendor/soap4r/wsdl/soap/operation.rb +113 -0
  106. data/vendor/soap4r/wsdl/soap/servant_skelton_creator.rb +92 -0
  107. data/vendor/soap4r/wsdl/soap/servlet_stub_creator.rb +105 -0
  108. data/vendor/soap4r/wsdl/soap/standalone_server_stub_creator.rb +101 -0
  109. data/vendor/soap4r/wsdl/soap/wsdl2ruby.rb +226 -0
  110. data/vendor/soap4r/wsdl/types.rb +45 -0
  111. data/vendor/soap4r/wsdl/wsdl.rb +25 -0
  112. data/vendor/soap4r/wsdl/xml_schema/all.rb +25 -0
  113. data/vendor/soap4r/wsdl/xml_schema/annotation.rb +35 -0
  114. data/vendor/soap4r/wsdl/xml_schema/any.rb +62 -0
  115. data/vendor/soap4r/wsdl/xml_schema/any_attribute.rb +49 -0
  116. data/vendor/soap4r/wsdl/xml_schema/attribute.rb +105 -0
  117. data/vendor/soap4r/wsdl/xml_schema/attribute_group.rb +69 -0
  118. data/vendor/soap4r/wsdl/xml_schema/choice.rb +59 -0
  119. data/vendor/soap4r/wsdl/xml_schema/complex_content.rb +98 -0
  120. data/vendor/soap4r/wsdl/xml_schema/complex_extension.rb +120 -0
  121. data/vendor/soap4r/wsdl/xml_schema/complex_restriction.rb +105 -0
  122. data/vendor/soap4r/wsdl/xml_schema/complex_type.rb +194 -0
  123. data/vendor/soap4r/wsdl/xml_schema/content.rb +96 -0
  124. data/vendor/soap4r/wsdl/xml_schema/data.rb +117 -0
  125. data/vendor/soap4r/wsdl/xml_schema/element.rb +154 -0
  126. data/vendor/soap4r/wsdl/xml_schema/enumeration.rb +37 -0
  127. data/vendor/soap4r/wsdl/xml_schema/fractiondigits.rb +38 -0
  128. data/vendor/soap4r/wsdl/xml_schema/group.rb +101 -0
  129. data/vendor/soap4r/wsdl/xml_schema/import.rb +54 -0
  130. data/vendor/soap4r/wsdl/xml_schema/import_handler.rb +46 -0
  131. data/vendor/soap4r/wsdl/xml_schema/importer.rb +103 -0
  132. data/vendor/soap4r/wsdl/xml_schema/include.rb +49 -0
  133. data/vendor/soap4r/wsdl/xml_schema/length.rb +38 -0
  134. data/vendor/soap4r/wsdl/xml_schema/list.rb +49 -0
  135. data/vendor/soap4r/wsdl/xml_schema/maxexclusive.rb +38 -0
  136. data/vendor/soap4r/wsdl/xml_schema/maxinclusive.rb +38 -0
  137. data/vendor/soap4r/wsdl/xml_schema/maxlength.rb +38 -0
  138. data/vendor/soap4r/wsdl/xml_schema/minexclusive.rb +38 -0
  139. data/vendor/soap4r/wsdl/xml_schema/mininclusive.rb +38 -0
  140. data/vendor/soap4r/wsdl/xml_schema/minlength.rb +38 -0
  141. data/vendor/soap4r/wsdl/xml_schema/parser.rb +168 -0
  142. data/vendor/soap4r/wsdl/xml_schema/pattern.rb +37 -0
  143. data/vendor/soap4r/wsdl/xml_schema/ref.rb +34 -0
  144. data/vendor/soap4r/wsdl/xml_schema/schema.rb +179 -0
  145. data/vendor/soap4r/wsdl/xml_schema/sequence.rb +55 -0
  146. data/vendor/soap4r/wsdl/xml_schema/simple_content.rb +70 -0
  147. data/vendor/soap4r/wsdl/xml_schema/simple_extension.rb +63 -0
  148. data/vendor/soap4r/wsdl/xml_schema/simple_restriction.rb +133 -0
  149. data/vendor/soap4r/wsdl/xml_schema/simple_type.rb +88 -0
  150. data/vendor/soap4r/wsdl/xml_schema/totaldigits.rb +38 -0
  151. data/vendor/soap4r/wsdl/xml_schema/union.rb +36 -0
  152. data/vendor/soap4r/wsdl/xml_schema/unique.rb +35 -0
  153. data/vendor/soap4r/wsdl/xml_schema/whitespace.rb +38 -0
  154. data/vendor/soap4r/wsdl/xml_schema/xsd2ruby.rb +176 -0
  155. data/vendor/soap4r/xsd/charset.rb +190 -0
  156. data/vendor/soap4r/xsd/codegen.rb +13 -0
  157. data/vendor/soap4r/xsd/codegen/classdef.rb +209 -0
  158. data/vendor/soap4r/xsd/codegen/commentdef.rb +35 -0
  159. data/vendor/soap4r/xsd/codegen/gensupport.rb +277 -0
  160. data/vendor/soap4r/xsd/codegen/methoddef.rb +71 -0
  161. data/vendor/soap4r/xsd/codegen/moduledef.rb +209 -0
  162. data/vendor/soap4r/xsd/datatypes.rb +1466 -0
  163. data/vendor/soap4r/xsd/datatypes1999.rb +21 -0
  164. data/vendor/soap4r/xsd/iconvcharset.rb +34 -0
  165. data/vendor/soap4r/xsd/mapping.rb +69 -0
  166. data/vendor/soap4r/xsd/namedelements.rb +133 -0
  167. data/vendor/soap4r/xsd/ns.rb +183 -0
  168. data/vendor/soap4r/xsd/qname.rb +80 -0
  169. data/vendor/soap4r/xsd/xmlparser.rb +77 -0
  170. data/vendor/soap4r/xsd/xmlparser/libxmlparser.rb +116 -0
  171. data/vendor/soap4r/xsd/xmlparser/parser.rb +101 -0
  172. data/vendor/soap4r/xsd/xmlparser/rexmlparser.rb +59 -0
  173. data/vendor/soap4r/xsd/xmlparser/xmlparser.rb +51 -0
  174. data/vendor/soap4r/xsd/xmlparser/xmlscanner.rb +150 -0
  175. metadata +316 -0
@@ -0,0 +1,67 @@
1
+ # encoding: ASCII-8BIT
2
+ # SOAP4R - marshal/unmarshal interface.
3
+ # Copyright (C) 2000-2007 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
4
+
5
+ # This program is copyrighted free software by NAKAMURA, Hiroshi. You can
6
+ # redistribute it and/or modify it under the same terms of Ruby's license;
7
+ # either the dual license version in 2003, or any later version.
8
+
9
+
10
+ require 'xsd/datatypes'
11
+ require 'soap/soap'
12
+ require 'soap/element'
13
+ require 'soap/parser'
14
+ require 'soap/generator'
15
+ require 'soap/encodingstyle/soapHandler'
16
+ require 'soap/encodingstyle/literalHandler'
17
+ require 'soap/encodingstyle/aspDotNetHandler'
18
+
19
+
20
+ module SOAP
21
+
22
+
23
+ module Processor
24
+ @@default_parser_option = {}
25
+
26
+ class << self
27
+ public
28
+
29
+ def marshal(env, opt = {}, io = nil)
30
+ generator = create_generator(opt)
31
+ marshalled_str = generator.generate(env, io)
32
+ unless env.external_content.empty?
33
+ opt[:external_content] = env.external_content
34
+ end
35
+ marshalled_str
36
+ end
37
+
38
+ def unmarshal(stream, opt = {})
39
+ parser = create_parser(opt)
40
+ parser.parse(stream)
41
+ end
42
+
43
+ def default_parser_option=(rhs)
44
+ @@default_parser_option = rhs
45
+ end
46
+
47
+ def default_parser_option
48
+ @@default_parser_option
49
+ end
50
+
51
+ private
52
+
53
+ def create_generator(opt)
54
+ Generator.new(opt)
55
+ end
56
+
57
+ def create_parser(opt)
58
+ if opt.empty?
59
+ opt = @@default_parser_option
60
+ end
61
+ ::SOAP::Parser.new(opt)
62
+ end
63
+ end
64
+ end
65
+
66
+
67
+ end
@@ -0,0 +1,340 @@
1
+ # encoding: ASCII-8BIT
2
+ # soap/property.rb: SOAP4R - Property implementation.
3
+ # Copyright (C) 2000-2007 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
4
+
5
+ # This program is copyrighted free software by NAKAMURA, Hiroshi. You can
6
+ # redistribute it and/or modify it under the same terms of Ruby's license;
7
+ # either the dual license version in 2003, or any later version.
8
+
9
+
10
+ module SOAP
11
+
12
+
13
+ # Property stream format:
14
+ #
15
+ # line separator is \r?\n. 1 line per a property.
16
+ # line which begins with '#' is a comment line. empty line is ignored, too.
17
+ # key/value separator is ':' or '='.
18
+ # '\' as escape character. but line separator cannot be escaped.
19
+ # \s at the head/tail of key/value are trimmed.
20
+ #
21
+ # '[' + key + ']' indicates property section. for example,
22
+ #
23
+ # [aaa.bbb]
24
+ # ccc = ddd
25
+ # eee.fff = ggg
26
+ # []
27
+ # aaa.hhh = iii
28
+ #
29
+ # is the same as;
30
+ #
31
+ # aaa.bbb.ccc = ddd
32
+ # aaa.bbb.eee.fff = ggg
33
+ # aaa.hhh = iii
34
+ #
35
+ class Property
36
+ FrozenError = (RUBY_VERSION >= "1.9.0") ? RuntimeError : TypeError
37
+
38
+ include Enumerable
39
+
40
+ module Util
41
+ def const_from_name(fqname)
42
+ fqname.split("::").inject(Kernel) { |klass, name| klass.const_get(name) }
43
+ end
44
+ module_function :const_from_name
45
+
46
+ def require_from_name(fqname)
47
+ require File.join(fqname.split("::").collect { |ele| ele.downcase })
48
+ end
49
+ module_function :require_from_name
50
+ end
51
+
52
+ def self.load(stream)
53
+ new.load(stream)
54
+ end
55
+
56
+ def self.loadproperty(propname)
57
+ new.loadproperty(propname)
58
+ end
59
+
60
+ def initialize
61
+ @store = Hash.new
62
+ @hook = Hash.new
63
+ @self_hook = Array.new
64
+ @locked = false
65
+ end
66
+
67
+ KEY_REGSRC = '([^=:\\\\]*(?:\\\\.[^=:\\\\]*)*)'
68
+ DEF_REGSRC = '\\s*' + KEY_REGSRC + '\\s*[=:]\\s*(.*)'
69
+ #COMMENT_REGEXP = Regexp.new('^(?:#.*|)$', nil, 'u')
70
+ #CATDEF_REGEXP = Regexp.new("^\\[\\s*#{KEY_REGSRC}\\s*\\]$", nil, 'u')
71
+ #LINE_REGEXP = Regexp.new("^#{DEF_REGSRC}$", nil, 'u')
72
+
73
+ COMMENT_REGEXP = Regexp.new('^(?:#.*|)$') # RubyJedi: Attempt at 1.9 Compatibility // , nil, 'u')
74
+ CATDEF_REGEXP = Regexp.new("^\\[\\s*#{KEY_REGSRC}\\s*\\]$") # RubyJedi: Attempt at 1.9 Compatibility // , nil, 'u')
75
+ LINE_REGEXP = Regexp.new("^#{DEF_REGSRC}$") # RubyJedi: Attempt at 1.9 Compatibility // , nil, 'u')
76
+
77
+ def load(stream)
78
+ key_prefix = ""
79
+ stream = stream.lines if stream.respond_to?(:lines) # RubyJedi: compatible with Ruby 1.8.6 and above
80
+ stream.each_with_index do |line, lineno|
81
+ line.sub!(/\r?\n\z/u, '')
82
+ case line
83
+ when COMMENT_REGEXP
84
+ next
85
+ when CATDEF_REGEXP
86
+ key_prefix = $1.strip
87
+ when LINE_REGEXP
88
+ key, value = $1.strip, $2.strip
89
+ key = "#{key_prefix}.#{key}" unless key_prefix.empty?
90
+ key, value = loadstr(key), loadstr(value)
91
+ self[key] = value
92
+ else
93
+ raise TypeError.new(
94
+ "property format error at line #{lineno + 1}: `#{line}'")
95
+ end
96
+ end
97
+ self
98
+ end
99
+
100
+ # find property from $:.
101
+ def loadproperty(propname)
102
+ return loadpropertyfile(propname) if File.file?(propname)
103
+ $:.each do |path|
104
+ if File.file?(file = File.join(path, propname))
105
+ return loadpropertyfile(file)
106
+ end
107
+ end
108
+ nil
109
+ end
110
+
111
+ # name: a Symbol, String or an Array
112
+ def [](name)
113
+ referent(name_to_a(name))
114
+ end
115
+
116
+ # name: a Symbol, String or an Array
117
+ # value: an Object
118
+ def []=(name, value)
119
+ name_pair = name_to_a(name).freeze
120
+ hooks = assign(name_pair, value)
121
+ hooks.each do |hook|
122
+ hook.call(name_pair, value)
123
+ end
124
+ value
125
+ end
126
+
127
+ # value: an Object
128
+ # key is generated by property
129
+ def <<(value)
130
+ self[generate_new_key] = value
131
+ end
132
+
133
+ # name: a Symbol, String or an Array; nil means hook to the root
134
+ # cascade: true/false; for cascading hook of sub key
135
+ # hook: block which will be called with 2 args, name and value
136
+ def add_hook(name = nil, cascade = false, &hook)
137
+ if name == nil or name == true or name == false
138
+ cascade = name
139
+ assign_self_hook(cascade, &hook)
140
+ else
141
+ assign_hook(name_to_a(name), cascade, &hook)
142
+ end
143
+ end
144
+
145
+ def each
146
+ @store.each do |key, value|
147
+ yield(key, value)
148
+ end
149
+ end
150
+
151
+ def empty?
152
+ @store.empty?
153
+ end
154
+
155
+ def keys
156
+ @store.keys
157
+ end
158
+
159
+ def values
160
+ @store.values
161
+ end
162
+
163
+ def lock(cascade = false)
164
+ if cascade
165
+ each_key do |key|
166
+ key.lock(cascade)
167
+ end
168
+ end
169
+ @locked = true
170
+ self
171
+ end
172
+
173
+ def unlock(cascade = false)
174
+ @locked = false
175
+ if cascade
176
+ each_key do |key|
177
+ key.unlock(cascade)
178
+ end
179
+ end
180
+ self
181
+ end
182
+
183
+ def locked?
184
+ @locked
185
+ end
186
+
187
+ protected
188
+
189
+ def deref_key(key)
190
+ check_lock(key)
191
+ ref = @store[key] ||= self.class.new
192
+ unless propkey?(ref)
193
+ raise ArgumentError.new("key `#{key}' already defined as a value")
194
+ end
195
+ ref
196
+ end
197
+
198
+ def local_referent(key)
199
+ check_lock(key)
200
+ if propkey?(@store[key]) and @store[key].locked?
201
+ raise FrozenError.new("cannot split any key from locked property")
202
+ end
203
+ @store[key]
204
+ end
205
+
206
+ def local_assign(key, value)
207
+ check_lock(key)
208
+ if @locked
209
+ if propkey?(value)
210
+ raise FrozenError.new("cannot add any key to locked property")
211
+ elsif propkey?(@store[key])
212
+ raise FrozenError.new("cannot override any key in locked property")
213
+ end
214
+ end
215
+ @store[key] = value
216
+ end
217
+
218
+ def local_hook(key, direct)
219
+ hooks = []
220
+ (@self_hook + (@hook[key] || NO_HOOK)).each do |hook, cascade|
221
+ hooks << hook if direct or cascade
222
+ end
223
+ hooks
224
+ end
225
+
226
+ def local_assign_hook(key, cascade, &hook)
227
+ check_lock(key)
228
+ @store[key] ||= nil
229
+ (@hook[key] ||= []) << [hook, cascade]
230
+ end
231
+
232
+ private
233
+
234
+ NO_HOOK = [].freeze
235
+
236
+ def referent(ary)
237
+ ary[0..-2].inject(self) { |ref, name|
238
+ ref.deref_key(to_key(name))
239
+ }.local_referent(to_key(ary.last))
240
+ end
241
+
242
+ def assign(ary, value)
243
+ ref = self
244
+ hook = NO_HOOK
245
+ ary[0..-2].each do |name|
246
+ key = to_key(name)
247
+ hook += ref.local_hook(key, false)
248
+ ref = ref.deref_key(key)
249
+ end
250
+ last_key = to_key(ary.last)
251
+ ref.local_assign(last_key, value)
252
+ hook + ref.local_hook(last_key, true)
253
+ end
254
+
255
+ def assign_hook(ary, cascade, &hook)
256
+ ary[0..-2].inject(self) { |ref, name|
257
+ ref.deref_key(to_key(name))
258
+ }.local_assign_hook(to_key(ary.last), cascade, &hook)
259
+ end
260
+
261
+ def assign_self_hook(cascade, &hook)
262
+ check_lock(nil)
263
+ @self_hook << [hook, cascade]
264
+ end
265
+
266
+ def each_key
267
+ self.each do |key, value|
268
+ if propkey?(value)
269
+ yield(value)
270
+ end
271
+ end
272
+ end
273
+
274
+ def check_lock(key)
275
+ if @locked and (key.nil? or !@store.key?(key))
276
+ raise FrozenError.new("cannot add any key to locked property")
277
+ end
278
+ end
279
+
280
+ def propkey?(value)
281
+ value.is_a?(::SOAP::Property)
282
+ end
283
+
284
+ def name_to_a(name)
285
+ case name
286
+ when Symbol
287
+ [name]
288
+ when String
289
+ name.scan(/[^.\\]+(?:\\.[^.\\])*/u) # split with unescaped '.'
290
+ when Array
291
+ name
292
+ else
293
+ raise ArgumentError.new("Unknown name #{name}(#{name.class})")
294
+ end
295
+ end
296
+
297
+ def to_key(name)
298
+ name.to_s.downcase
299
+ end
300
+
301
+ def generate_new_key
302
+ if @store.empty?
303
+ "0"
304
+ else
305
+ (key_max + 1).to_s
306
+ end
307
+ end
308
+
309
+ def key_max
310
+ (@store.keys.max { |l, r| l.to_s.to_i <=> r.to_s.to_i }).to_s.to_i
311
+ end
312
+
313
+ def loadpropertyfile(file)
314
+ puts "find property at #{file}" if $DEBUG
315
+ File.open(file) do |f|
316
+ load(f)
317
+ end
318
+ end
319
+
320
+ def loadstr(str)
321
+ str.gsub(/\\./u) { |c| eval("\"#{c}\"") }
322
+ end
323
+ end
324
+
325
+
326
+ end
327
+
328
+
329
+ # for ruby/1.6.
330
+ #unless Enumerable.instance_methods.include?(:inject)
331
+ # module Enumerable
332
+ # def inject(init)
333
+ # result = init
334
+ # each do |item|
335
+ # result = yield(result, item)
336
+ # end
337
+ # result
338
+ # end
339
+ # end
340
+ #end
@@ -0,0 +1,15 @@
1
+ # encoding: ASCII-8BIT
2
+ # SOAP4R - Proxy library.
3
+ # Copyright (C) 2000-2007 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
4
+
5
+ # This program is copyrighted free software by NAKAMURA, Hiroshi. You can
6
+ # redistribute it and/or modify it under the same terms of Ruby's license;
7
+ # either the dual license version in 2003, or any later version.
8
+
9
+
10
+ require 'soap/rpc/proxy'
11
+
12
+
13
+ module SOAP
14
+ SOAPProxy = RPC::Proxy
15
+ end
@@ -0,0 +1,248 @@
1
+ # encoding: ASCII-8BIT
2
+ # SOAP4R - CGI/mod_ruby stub library
3
+ # Copyright (C) 2000-2007 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
4
+
5
+ # This program is copyrighted free software by NAKAMURA, Hiroshi. You can
6
+ # redistribute it and/or modify it under the same terms of Ruby's license;
7
+ # either the dual license version in 2003, or any later version.
8
+
9
+
10
+ require 'soap/streamHandler'
11
+ require 'webrick/httpresponse'
12
+ require 'webrick/httpstatus'
13
+ require 'logger'
14
+ require 'soap/rpc/soaplet'
15
+
16
+
17
+ module SOAP
18
+ module RPC
19
+
20
+
21
+ ###
22
+ # SYNOPSIS
23
+ # CGIStub.new
24
+ #
25
+ # DESCRIPTION
26
+ # To be written...
27
+ #
28
+ class CGIStub < Logger::Application
29
+ include SOAP
30
+ include WEBrick
31
+
32
+ class SOAPRequest
33
+ attr_reader :body
34
+
35
+ def [](var); end
36
+
37
+ def meta_vars; end
38
+
39
+ EMPTY_COOKIES = [].freeze
40
+ def cookies; EMPTY_COOKIES; end
41
+
42
+ def user; end
43
+ end
44
+
45
+ class SOAPStdinRequest < SOAPRequest
46
+ attr_reader :body
47
+
48
+ def initialize(stream)
49
+ size = ENV['CONTENT_LENGTH'].to_i || 0
50
+ @body = stream.read(size)
51
+ end
52
+
53
+ def [](var)
54
+ ENV[var.gsub(/-/, '_').upcase]
55
+ end
56
+
57
+ def meta_vars
58
+ {
59
+ 'HTTP_SOAPACTION' => ENV['HTTP_SOAPAction']
60
+ }
61
+ end
62
+
63
+ def cookies
64
+ if cookie = ENV['HTTP_Cookie'] || ENV['Cookie']
65
+ [WEBrick::Cookie.parse(cookie)]
66
+ else
67
+ EMPTY_COOKIES
68
+ end
69
+ end
70
+
71
+ def user
72
+ ENV['REMOTE_USER']
73
+ end
74
+ end
75
+
76
+ class SOAPFCGIRequest < SOAPRequest
77
+ attr_reader :body
78
+
79
+ def initialize(request)
80
+ @request = request
81
+ @body = @request.in.read
82
+ end
83
+
84
+ def [](var)
85
+ @request.env[var.gsub(/-/, '_').upcase]
86
+ end
87
+
88
+ def meta_vars
89
+ {
90
+ 'HTTP_SOAPACTION' => @request.env['HTTP_SOAPAction']
91
+ }
92
+ end
93
+
94
+ def cookies
95
+ if cookie = @request.env['HTTP_Cookie'] || @request.env['Cookie']
96
+ [WEBrick::Cookie.parse(cookie)]
97
+ else
98
+ EMPTY_COOKIES
99
+ end
100
+ end
101
+
102
+ def user
103
+ @request.env['REMOTE_USER']
104
+ end
105
+ end
106
+
107
+ def initialize(appname, default_namespace)
108
+ super(appname)
109
+ set_log(STDERR)
110
+ self.level = ERROR
111
+ @default_namespace = default_namespace
112
+ @remote_host = ENV['REMOTE_HOST'] || ENV['REMOTE_ADDR'] || 'unknown'
113
+ @router = ::SOAP::RPC::Router.new(self.class.name)
114
+ @soaplet = ::SOAP::RPC::SOAPlet.new(@router)
115
+ on_init
116
+ end
117
+
118
+ def on_init
119
+ # do extra initialization in a derived class if needed.
120
+ end
121
+
122
+ def mapping_registry
123
+ @router.mapping_registry
124
+ end
125
+
126
+ def mapping_registry=(mapping_registry)
127
+ @router.mapping_registry = mapping_registry
128
+ end
129
+
130
+ def literal_mapping_registry
131
+ @router.literal_mapping_registry
132
+ end
133
+
134
+ def literal_mapping_registry=(literal_mapping_registry)
135
+ @router.literal_mapping_registry = literal_mapping_registry
136
+ end
137
+
138
+ def generate_explicit_type
139
+ @router.generate_explicit_type
140
+ end
141
+
142
+ def generate_explicit_type=(generate_explicit_type)
143
+ @router.generate_explicit_type = generate_explicit_type
144
+ end
145
+
146
+ # servant entry interface
147
+
148
+ def add_rpc_servant(obj, namespace = @default_namespace)
149
+ @router.add_rpc_servant(obj, namespace)
150
+ end
151
+ alias add_servant add_rpc_servant
152
+
153
+ def add_headerhandler(obj)
154
+ @router.add_headerhandler(obj)
155
+ end
156
+ alias add_rpc_headerhandler add_headerhandler
157
+
158
+ def filterchain
159
+ @router.filterchain
160
+ end
161
+
162
+ # method entry interface
163
+
164
+ def add_rpc_method(obj, name, *param)
165
+ add_rpc_method_with_namespace_as(@default_namespace, obj, name, name, *param)
166
+ end
167
+ alias add_method add_rpc_method
168
+
169
+ def add_rpc_method_as(obj, name, name_as, *param)
170
+ add_rpc_method_with_namespace_as(@default_namespace, obj, name, name_as, *param)
171
+ end
172
+ alias add_method_as add_rpc_method_as
173
+
174
+ def add_rpc_method_with_namespace(namespace, obj, name, *param)
175
+ add_rpc_method_with_namespace_as(namespace, obj, name, name, *param)
176
+ end
177
+ alias add_method_with_namespace add_rpc_method_with_namespace
178
+
179
+ def add_rpc_method_with_namespace_as(namespace, obj, name, name_as, *param)
180
+ qname = XSD::QName.new(namespace, name_as)
181
+ soapaction = nil
182
+ param_def = SOAPMethod.derive_rpc_param_def(obj, name, *param)
183
+ @router.add_rpc_operation(obj, qname, soapaction, name, param_def)
184
+ end
185
+ alias add_method_with_namespace_as add_rpc_method_with_namespace_as
186
+
187
+ def add_rpc_operation(receiver, qname, soapaction, name, param_def, opt = {})
188
+ @router.add_rpc_operation(receiver, qname, soapaction, name, param_def, opt)
189
+ end
190
+
191
+ def add_document_operation(receiver, soapaction, name, param_def, opt = {})
192
+ @router.add_document_operation(receiver, soapaction, name, param_def, opt)
193
+ end
194
+
195
+ def set_fcgi_request(request)
196
+ @fcgi = request
197
+ end
198
+
199
+ private
200
+
201
+ HTTPVersion = WEBrick::HTTPVersion.new('1.0') # dummy; ignored
202
+
203
+ def run
204
+ res = WEBrick::HTTPResponse.new({:HTTPVersion => HTTPVersion})
205
+ begin
206
+ @log.info { "received a request from '#{ @remote_host }'" }
207
+ if @fcgi
208
+ req = SOAPFCGIRequest.new(@fcgi)
209
+ else
210
+ req = SOAPStdinRequest.new($stdin)
211
+ end
212
+ @soaplet.do_POST(req, res)
213
+ rescue HTTPStatus::EOFError, HTTPStatus::RequestTimeout => ex
214
+ res.set_error(ex)
215
+ rescue HTTPStatus::Error => ex
216
+ res.set_error(ex)
217
+ rescue HTTPStatus::Status => ex
218
+ res.status = ex.code
219
+ rescue StandardError, NameError => ex # for Ruby 1.6
220
+ res.set_error(ex, true)
221
+ ensure
222
+ if defined?(MOD_RUBY)
223
+ r = Apache.request
224
+ r.status = res.status
225
+ r.content_type = res.content_type
226
+ r.send_http_header
227
+ buf = res.body
228
+ else
229
+ buf = ''
230
+ res.send_response(buf)
231
+ buf.sub!(/^[^\r]+\r\n/, '') # Trim status line.
232
+ end
233
+ @log.debug { "SOAP CGI Response:\n#{ buf }" }
234
+ if @fcgi
235
+ @fcgi.out.print buf
236
+ @fcgi.finish
237
+ @fcgi = nil
238
+ else
239
+ print buf
240
+ end
241
+ end
242
+ 0
243
+ end
244
+ end
245
+
246
+
247
+ end
248
+ end