soybean 1.0.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -7,8 +7,8 @@
7
7
  # either the dual license version in 2003, or any later version.
8
8
 
9
9
 
10
- require 'soap/baseData'
11
- require 'soap/rpc/methodDef'
10
+ require 'soap/base_data'
11
+ require 'soap/rpc/method_def'
12
12
 
13
13
 
14
14
  module SOAP
@@ -21,206 +21,206 @@ require 'wsdl/soap/class_name_creator'
21
21
 
22
22
 
23
23
  module WSDL
24
- module SOAP
24
+ module SOAP
25
+
26
+
27
+ class WSDL2Ruby
28
+ attr_accessor :location
29
+ attr_reader :opt
30
+ attr_accessor :logger
31
+ attr_accessor :basedir
32
+
33
+ def run
34
+ unless @location
35
+ raise RuntimeError, "WSDL location not given"
36
+ end
37
+ @wsdl = import(@location)
38
+ if @opt['classdef']
39
+ @name = @opt['classdef']
40
+ else
41
+ @name = @wsdl.name ? @wsdl.name.name : 'default'
42
+ end
43
+ create_file
44
+ end
25
45
 
46
+ private
47
+
48
+ def initialize
49
+ @modulepath = nil
50
+ @location = nil
51
+ @opt = {}
52
+ @logger = Logger.new(STDERR)
53
+ @basedir = nil
54
+ @wsdl = nil
55
+ @name = nil
56
+ @classdef_filename = nil
57
+ @mr_filename = nil
58
+ @name_creator = ClassNameCreator.new
59
+ end
26
60
 
27
- class WSDL2Ruby
28
- attr_accessor :location
29
- attr_reader :opt
30
- attr_accessor :logger
31
- attr_accessor :basedir
61
+ def create_file
62
+ @modulepath = @opt['module_path']
63
+ create_classdef if @opt.key?('classdef')
64
+ create_mapping_registry if @opt.key?('mapping_registry')
65
+ create_servant_skelton(@opt['servant_skelton']) if @opt.key?('servant_skelton')
66
+ create_cgi_stub(@opt['cgi_stub']) if @opt.key?('cgi_stub')
67
+ create_standalone_server_stub(@opt['standalone_server_stub']) if @opt.key?('standalone_server_stub')
68
+ create_servlet_stub(@opt['servlet_stub']) if @opt.key?('servlet_stub')
69
+ create_driver(@opt['driver'], @opt['drivername_postfix'] || '') if @opt.key?('driver')
70
+ create_client_skelton(@opt['client_skelton']) if @opt.key?('client_skelton')
71
+ end
32
72
 
33
- def run
34
- unless @location
35
- raise RuntimeError, "WSDL location not given"
36
- end
37
- @wsdl = import(@location)
38
- if @opt['classdef']
39
- @name = @opt['classdef']
40
- else
41
- @name = @wsdl.name ? @wsdl.name.name : 'default'
42
- end
43
- create_file
44
- end
73
+ def create_classdef
74
+ @logger.info { "Creating class definition." }
75
+ @classdef_filename = @name + '.rb'
76
+ check_file(@classdef_filename) or return
77
+ write_file(@classdef_filename) do |f|
78
+ f.puts "# encoding: ASCII-8BIT"
79
+ f << WSDL::SOAP::ClassDefCreator.new(@wsdl, @name_creator, @modulepath).dump
80
+ end
81
+ end
45
82
 
46
- private
47
-
48
- def initialize
49
- @modulepath = nil
50
- @location = nil
51
- @opt = {}
52
- @logger = Logger.new(STDERR)
53
- @basedir = nil
54
- @wsdl = nil
55
- @name = nil
56
- @classdef_filename = nil
57
- @mr_filename = nil
58
- @name_creator = ClassNameCreator.new
59
- end
83
+ def create_mapping_registry
84
+ @logger.info { "Creating mapping registry definition." }
85
+ @mr_filename = @name + 'MappingRegistry.rb'
86
+ check_file(@mr_filename) or return
87
+ write_file(@mr_filename) do |f|
88
+ f.puts "# encoding: ASCII-8BIT"
89
+ f << "require '#{@classdef_filename}'\n" if @classdef_filename
90
+ f << WSDL::SOAP::MappingRegistryCreator.new(@wsdl, @name_creator, @modulepath).dump
91
+ end
92
+ end
60
93
 
61
- def create_file
62
- @modulepath = @opt['module_path']
63
- create_classdef if @opt.key?('classdef')
64
- create_mapping_registry if @opt.key?('mapping_registry')
65
- create_servant_skelton(@opt['servant_skelton']) if @opt.key?('servant_skelton')
66
- create_cgi_stub(@opt['cgi_stub']) if @opt.key?('cgi_stub')
67
- create_standalone_server_stub(@opt['standalone_server_stub']) if @opt.key?('standalone_server_stub')
68
- create_servlet_stub(@opt['servlet_stub']) if @opt.key?('servlet_stub')
69
- create_driver(@opt['driver'], @opt['drivername_postfix'] || '') if @opt.key?('driver')
70
- create_client_skelton(@opt['client_skelton']) if @opt.key?('client_skelton')
71
- end
94
+ def create_client_skelton(servicename)
95
+ return if @wsdl.services.empty?
96
+ @logger.info { "Creating client skelton." }
97
+ servicename ||= @wsdl.services[0].name.name
98
+ @client_skelton_filename = servicename + 'Client.rb'
99
+ check_file(@client_skelton_filename) or return
100
+ write_file(@client_skelton_filename) do |f|
101
+ f << shbang << "\n"
102
+ f.puts "# encoding: ASCII-8BIT"
103
+ f << "require '#{@driver_filename}'\n\n" if @driver_filename
104
+ f << WSDL::SOAP::ClientSkeltonCreator.new(@wsdl, @name_creator, @modulepath).dump(create_name(servicename))
105
+ end
106
+ end
72
107
 
73
- def create_classdef
74
- @logger.info { "Creating class definition." }
75
- @classdef_filename = @name + '.rb'
76
- check_file(@classdef_filename) or return
77
- write_file(@classdef_filename) do |f|
78
- f.puts "# encoding: ASCII-8BIT"
79
- f << WSDL::SOAP::ClassDefCreator.new(@wsdl, @name_creator, @modulepath).dump
80
- end
81
- end
108
+ def create_servant_skelton(porttypename)
109
+ @logger.info { "Creating servant skelton." }
110
+ @servant_skelton_filename = (porttypename || @name + 'Servant') + '.rb'
111
+ check_file(@servant_skelton_filename) or return
112
+ write_file(@servant_skelton_filename) do |f|
113
+ f.puts "# encoding: ASCII-8BIT"
114
+ f << "require '#{@classdef_filename}'\n\n" if @classdef_filename
115
+ f << WSDL::SOAP::ServantSkeltonCreator.new(@wsdl, @name_creator, @modulepath).dump(create_name(porttypename))
116
+ end
117
+ end
82
118
 
83
- def create_mapping_registry
84
- @logger.info { "Creating mapping registry definition." }
85
- @mr_filename = @name + 'MappingRegistry.rb'
86
- check_file(@mr_filename) or return
87
- write_file(@mr_filename) do |f|
88
- f.puts "# encoding: ASCII-8BIT"
89
- f << "require '#{@classdef_filename}'\n" if @classdef_filename
90
- f << WSDL::SOAP::MappingRegistryCreator.new(@wsdl, @name_creator, @modulepath).dump
91
- end
92
- end
119
+ def create_cgi_stub(servicename)
120
+ @logger.info { "Creating CGI stub." }
121
+ servicename ||= @wsdl.services[0].name.name
122
+ @cgi_stubFilename = servicename + '.cgi'
123
+ check_file(@cgi_stubFilename) or return
124
+ write_file(@cgi_stubFilename) do |f|
125
+ f << shbang << "\n"
126
+ f.puts "# encoding: ASCII-8BIT"
127
+ f << "require '#{@servant_skelton_filename}'\n" if @servant_skelton_filename
128
+ f << "require '#{@mr_filename}'\n" if @mr_filename
129
+ f << WSDL::SOAP::CGIStubCreator.new(@wsdl, @name_creator, @modulepath).dump(create_name(servicename))
130
+ end
131
+ end
93
132
 
94
- def create_client_skelton(servicename)
95
- return if @wsdl.services.empty?
96
- @logger.info { "Creating client skelton." }
97
- servicename ||= @wsdl.services[0].name.name
98
- @client_skelton_filename = servicename + 'Client.rb'
99
- check_file(@client_skelton_filename) or return
100
- write_file(@client_skelton_filename) do |f|
101
- f << shbang << "\n"
102
- f.puts "# encoding: ASCII-8BIT"
103
- f << "require '#{@driver_filename}'\n\n" if @driver_filename
104
- f << WSDL::SOAP::ClientSkeltonCreator.new(@wsdl, @name_creator, @modulepath).dump(create_name(servicename))
105
- end
106
- end
133
+ def create_standalone_server_stub(servicename)
134
+ @logger.info { "Creating standalone stub." }
135
+ servicename ||= @wsdl.services[0].name.name
136
+ @standalone_server_stub_filename = servicename + '.rb'
137
+ check_file(@standalone_server_stub_filename) or return
138
+ write_file(@standalone_server_stub_filename) do |f|
139
+ f << shbang << "\n"
140
+ f.puts "# encoding: ASCII-8BIT"
141
+ f << "require '#{@servant_skelton_filename}'\n" if @servant_skelton_filename
142
+ f << "require '#{@mr_filename}'\n" if @mr_filename
143
+ f << WSDL::SOAP::StandaloneServerStubCreator.new(@wsdl, @name_creator, @modulepath).dump(create_name(servicename))
144
+ end
145
+ end
107
146
 
108
- def create_servant_skelton(porttypename)
109
- @logger.info { "Creating servant skelton." }
110
- @servant_skelton_filename = (porttypename || @name + 'Servant') + '.rb'
111
- check_file(@servant_skelton_filename) or return
112
- write_file(@servant_skelton_filename) do |f|
113
- f.puts "# encoding: ASCII-8BIT"
114
- f << "require '#{@classdef_filename}'\n\n" if @classdef_filename
115
- f << WSDL::SOAP::ServantSkeltonCreator.new(@wsdl, @name_creator, @modulepath).dump(create_name(porttypename))
116
- end
117
- end
147
+ def create_servlet_stub(servicename)
148
+ @logger.info { "Creating servlet stub." }
149
+ servicename ||= @wsdl.services[0].name.name
150
+ @servlet_stub_filename = servicename + 'Servlet.rb'
151
+ check_file(@servlet_stub_filename) or return
152
+ write_file(@servlet_stub_filename) do |f|
153
+ f << shbang << "\n"
154
+ f.puts "# encoding: ASCII-8BIT"
155
+ f << "require '#{@servant_skelton_filename}'\n" if @servant_skelton_filename
156
+ f << "require '#{@mr_filename}'\n" if @mr_filename
157
+ f << WSDL::SOAP::ServletStubCreator.new(@wsdl, @name_creator, @modulepath).dump(create_name(servicename))
158
+ end
159
+ end
118
160
 
119
- def create_cgi_stub(servicename)
120
- @logger.info { "Creating CGI stub." }
121
- servicename ||= @wsdl.services[0].name.name
122
- @cgi_stubFilename = servicename + '.cgi'
123
- check_file(@cgi_stubFilename) or return
124
- write_file(@cgi_stubFilename) do |f|
125
- f << shbang << "\n"
126
- f.puts "# encoding: ASCII-8BIT"
127
- f << "require '#{@servant_skelton_filename}'\n" if @servant_skelton_filename
128
- f << "require '#{@mr_filename}'\n" if @mr_filename
129
- f << WSDL::SOAP::CGIStubCreator.new(@wsdl, @name_creator, @modulepath).dump(create_name(servicename))
130
- end
131
- end
161
+ def create_driver(porttypename, drivername_postfix)
162
+ @logger.info { "Creating driver." }
163
+ @driver_filename = (porttypename || @name) + 'Driver.rb'
164
+ creator = WSDL::SOAP::DriverCreator.new(@wsdl, @name_creator, @modulepath)
165
+ creator.drivername_postfix = drivername_postfix
166
+ check_file(@driver_filename) or return
167
+ write_file(@driver_filename) do |f|
168
+ f.puts "# encoding: ASCII-8BIT"
169
+ f << "require '#{@classdef_filename}'\n" if @classdef_filename
170
+ f << "require '#{@mr_filename}'\n" if @mr_filename
171
+ f << creator.dump(create_name(porttypename))
172
+ end
173
+ end
132
174
 
133
- def create_standalone_server_stub(servicename)
134
- @logger.info { "Creating standalone stub." }
135
- servicename ||= @wsdl.services[0].name.name
136
- @standalone_server_stub_filename = servicename + '.rb'
137
- check_file(@standalone_server_stub_filename) or return
138
- write_file(@standalone_server_stub_filename) do |f|
139
- f << shbang << "\n"
140
- f.puts "# encoding: ASCII-8BIT"
141
- f << "require '#{@servant_skelton_filename}'\n" if @servant_skelton_filename
142
- f << "require '#{@mr_filename}'\n" if @mr_filename
143
- f << WSDL::SOAP::StandaloneServerStubCreator.new(@wsdl, @name_creator, @modulepath).dump(create_name(servicename))
144
- end
145
- end
175
+ def write_file(filename)
176
+ if @basedir
177
+ filename = File.join(basedir, filename)
178
+ end
179
+ File.open(filename, "w") do |f|
180
+ yield f
181
+ end
182
+ end
146
183
 
147
- def create_servlet_stub(servicename)
148
- @logger.info { "Creating servlet stub." }
149
- servicename ||= @wsdl.services[0].name.name
150
- @servlet_stub_filename = servicename + 'Servlet.rb'
151
- check_file(@servlet_stub_filename) or return
152
- write_file(@servlet_stub_filename) do |f|
153
- f << shbang << "\n"
154
- f.puts "# encoding: ASCII-8BIT"
155
- f << "require '#{@servant_skelton_filename}'\n" if @servant_skelton_filename
156
- f << "require '#{@mr_filename}'\n" if @mr_filename
157
- f << WSDL::SOAP::ServletStubCreator.new(@wsdl, @name_creator, @modulepath).dump(create_name(servicename))
158
- end
159
- end
184
+ def check_file(filename)
185
+ if @basedir
186
+ filename = File.join(basedir, filename)
187
+ end
188
+ if FileTest.exist?(filename)
189
+ if @opt.key?('force')
190
+ @logger.warn {
191
+ "File '#{filename}' exists but overrides it."
192
+ }
193
+ true
194
+ else
195
+ @logger.warn {
196
+ "File '#{filename}' exists. #{$0} did not override it."
197
+ }
198
+ false
199
+ end
200
+ else
201
+ @logger.info { "Creates file '#{filename}'." }
202
+ true
203
+ end
204
+ end
160
205
 
161
- def create_driver(porttypename, drivername_postfix)
162
- @logger.info { "Creating driver." }
163
- @driver_filename = (porttypename || @name) + 'Driver.rb'
164
- creator = WSDL::SOAP::DriverCreator.new(@wsdl, @name_creator, @modulepath)
165
- creator.drivername_postfix = drivername_postfix
166
- check_file(@driver_filename) or return
167
- write_file(@driver_filename) do |f|
168
- f.puts "# encoding: ASCII-8BIT"
169
- f << "require '#{@classdef_filename}'\n" if @classdef_filename
170
- f << "require '#{@mr_filename}'\n" if @mr_filename
171
- f << creator.dump(create_name(porttypename))
172
- end
173
- end
206
+ def shbang
207
+ "#!/usr/bin/env ruby"
208
+ end
174
209
 
175
- def write_file(filename)
176
- if @basedir
177
- filename = File.join(basedir, filename)
178
- end
179
- File.open(filename, "w") do |f|
180
- yield f
181
- end
182
- end
210
+ def create_name(name)
211
+ name ? XSD::QName.new(@wsdl.targetnamespace, name) : nil
212
+ end
183
213
 
184
- def check_file(filename)
185
- if @basedir
186
- filename = File.join(basedir, filename)
187
- end
188
- if FileTest.exist?(filename)
189
- if @opt.key?('force')
190
- @logger.warn {
191
- "File '#{filename}' exists but overrides it."
192
- }
193
- true
194
- else
195
- @logger.warn {
196
- "File '#{filename}' exists. #{$0} did not override it."
197
- }
198
- false
199
- end
200
- else
201
- @logger.info { "Creates file '#{filename}'." }
202
- true
214
+ def import(location)
215
+ WSDL::Importer.import(location)
216
+ end
203
217
  end
204
- end
205
-
206
- def shbang
207
- "#!/usr/bin/env ruby"
208
- end
209
218
 
210
- def create_name(name)
211
- name ? XSD::QName.new(@wsdl.targetnamespace, name) : nil
212
- end
213
219
 
214
- def import(location)
215
- WSDL::Importer.import(location)
216
220
  end
217
221
  end
218
222
 
219
223
 
220
- end
221
- end
222
-
223
-
224
224
  if __FILE__ == $0
225
225
  warn("WARNING: #{File.expand_path(__FILE__)} is a library file used by bin/wsdl2ruby.rb. Find bin/wsdl2ruby.rb from tarball version of soap4r or install soap4r via gem.")
226
226
  end
@@ -91,9 +91,9 @@ private
91
91
  def dump_class_def
92
92
  name = @name.to_s.split(/::/)
93
93
  if @baseclass
94
- format("class #{name.last} < #{@baseclass}")
94
+ "class #{name.last} < #{@baseclass}\n"
95
95
  else
96
- format("class #{name.last}")
96
+ "class #{name.last}\n"
97
97
  end
98
98
  end
99
99
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: soybean
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 2.0.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,12 +9,12 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-09-27 00:00:00.000000000 +04:00
12
+ date: 2011-09-29 00:00:00.000000000 +04:00
13
13
  default_executable: soybean
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: thor
17
- requirement: &6927240 !ruby/object:Gem::Requirement
17
+ requirement: &22138300 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ! '>='
@@ -22,10 +22,10 @@ dependencies:
22
22
  version: '0'
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *6927240
25
+ version_requirements: *22138300
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: activesupport
28
- requirement: &6926440 !ruby/object:Gem::Requirement
28
+ requirement: &22136000 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ~>
@@ -33,10 +33,10 @@ dependencies:
33
33
  version: '3.1'
34
34
  type: :runtime
35
35
  prerelease: false
36
- version_requirements: *6926440
36
+ version_requirements: *22136000
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: i18n
39
- requirement: &6925620 !ruby/object:Gem::Requirement
39
+ requirement: &22125840 !ruby/object:Gem::Requirement
40
40
  none: false
41
41
  requirements:
42
42
  - - ! '>='
@@ -44,10 +44,10 @@ dependencies:
44
44
  version: '0'
45
45
  type: :runtime
46
46
  prerelease: false
47
- version_requirements: *6925620
47
+ version_requirements: *22125840
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: rspec
50
- requirement: &6924700 !ruby/object:Gem::Requirement
50
+ requirement: &22117260 !ruby/object:Gem::Requirement
51
51
  none: false
52
52
  requirements:
53
53
  - - ~>
@@ -55,10 +55,10 @@ dependencies:
55
55
  version: 2.3.0
56
56
  type: :development
57
57
  prerelease: false
58
- version_requirements: *6924700
58
+ version_requirements: *22117260
59
59
  - !ruby/object:Gem::Dependency
60
60
  name: yard
61
- requirement: &6922300 !ruby/object:Gem::Requirement
61
+ requirement: &22116260 !ruby/object:Gem::Requirement
62
62
  none: false
63
63
  requirements:
64
64
  - - ~>
@@ -66,10 +66,10 @@ dependencies:
66
66
  version: 0.6.0
67
67
  type: :development
68
68
  prerelease: false
69
- version_requirements: *6922300
69
+ version_requirements: *22116260
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: bundler
72
- requirement: &6918060 !ruby/object:Gem::Requirement
72
+ requirement: &22115280 !ruby/object:Gem::Requirement
73
73
  none: false
74
74
  requirements:
75
75
  - - ~>
@@ -77,10 +77,10 @@ dependencies:
77
77
  version: 1.0.0
78
78
  type: :development
79
79
  prerelease: false
80
- version_requirements: *6918060
80
+ version_requirements: *22115280
81
81
  - !ruby/object:Gem::Dependency
82
82
  name: jeweler
83
- requirement: &6917140 !ruby/object:Gem::Requirement
83
+ requirement: &22114240 !ruby/object:Gem::Requirement
84
84
  none: false
85
85
  requirements:
86
86
  - - ~>
@@ -88,10 +88,10 @@ dependencies:
88
88
  version: 1.6.4
89
89
  type: :development
90
90
  prerelease: false
91
- version_requirements: *6917140
91
+ version_requirements: *22114240
92
92
  - !ruby/object:Gem::Dependency
93
93
  name: rcov
94
- requirement: &6914900 !ruby/object:Gem::Requirement
94
+ requirement: &22113040 !ruby/object:Gem::Requirement
95
95
  none: false
96
96
  requirements:
97
97
  - - ! '>='
@@ -99,7 +99,7 @@ dependencies:
99
99
  version: '0'
100
100
  type: :development
101
101
  prerelease: false
102
- version_requirements: *6914900
102
+ version_requirements: *22113040
103
103
  description: ! 'Generate soap web-services from you wsdl. Generate: all classes from
104
104
  xsd, and other.'
105
105
  email: a.sozontov@gmail.com
@@ -119,10 +119,24 @@ files:
119
119
  - Rakefile
120
120
  - VERSION
121
121
  - bin/soybean
122
- - bin/xsd2ruby
123
122
  - lib/soybean.rb
124
- - lib/soybean/actions/generate_classes.rb
123
+ - lib/soybean/complex_type.rb
124
+ - lib/soybean/encoded_mapping_registry_creator.rb
125
+ - lib/soybean/generators/base_generator.rb
126
+ - lib/soybean/generators/class_generator.rb
127
+ - lib/soybean/generators/interface_generator.rb
128
+ - lib/soybean/generators/mapping_generator.rb
129
+ - lib/soybean/generators/model_generator.rb
130
+ - lib/soybean/generators/service_generator.rb
131
+ - lib/soybean/generators/types_generator.rb
132
+ - lib/soybean/literal_mapping_registry_creator.rb
125
133
  - soybean.gemspec
134
+ - spec/services/interfaces/get_registrars_interface.rb
135
+ - spec/services/mappings/base.rb
136
+ - spec/services/mappings/get_registrars.rb
137
+ - spec/services/models/get_registrars_service.rb
138
+ - spec/services/types/get_registrars.rb
139
+ - spec/services/types/type.rb
126
140
  - spec/soybean_spec.rb
127
141
  - spec/spec_helper.rb
128
142
  - vendor/soap4r/soap/attachment.rb
@@ -300,7 +314,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
300
314
  version: '0'
301
315
  segments:
302
316
  - 0
303
- hash: 1600147490527287520
317
+ hash: -4213611498050117476
304
318
  required_rubygems_version: !ruby/object:Gem::Requirement
305
319
  none: false
306
320
  requirements: