soybean 2.1.3 → 2.1.4

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.1.3
1
+ 2.1.4
@@ -3,7 +3,7 @@ module Soybean
3
3
  class ModelGenerator
4
4
  include BaseGenerator
5
5
 
6
- attr_reader :name
6
+ attr_reader :name, :wsdl
7
7
 
8
8
  def initialize(wsdl)
9
9
  @wsdl = wsdl
@@ -26,6 +26,10 @@ module Soybean
26
26
  content
27
27
  end
28
28
 
29
+ def actions
30
+ @actions ||= InterfaceBuilder.new(@model.wsdl, WSDL::SOAP::ClassNameCreator.new).actions
31
+ end
32
+
29
33
  def class_name
30
34
  @model.class_name
31
35
  end
@@ -11,4 +11,12 @@ describe <%= class_name %> do
11
11
  <%= class_name %>.actions.should eql <%= interface_name %>.actions
12
12
  end
13
13
 
14
+ context 'actions' do
15
+ <% actions.each do |action, params| %>
16
+ it '#<%= action %> should not raise NotImplementedError' do
17
+ expect { subject.send action<%= params ? ', stub' * params.size : '' %> }.to_not raise_error(NotImplementedError)
18
+ end
19
+ <% end %>
20
+ end
21
+
14
22
  end
@@ -9,9 +9,10 @@ module Soybean
9
9
  @definitions = definitions
10
10
  @name_creator = name_creator
11
11
  @modulepath = modulepath
12
+ @porttype = @definitions.porttypes.first
12
13
  end
13
14
 
14
- def dump(porttype = nil)
15
+ def dump
15
16
  result = ""
16
17
  if @modulepath
17
18
  result << "\n"
@@ -19,14 +20,7 @@ module Soybean
19
20
  result << modulepath.collect { |ele| "module #{ele}" }.join("; ")
20
21
  result << "\n\n"
21
22
  end
22
- if porttype.nil?
23
- @definitions.porttypes.each do |porttype|
24
- result << dump_porttype(porttype)
25
- result << "\n"
26
- end
27
- else
28
- result << dump_porttype(porttype)
29
- end
23
+ result << dump_porttype
30
24
  if @modulepath
31
25
  result << "\n\n"
32
26
  modulepath = @modulepath.respond_to?(:lines) ? @modulepath.lines : @modulepath # RubyJedi: compatible with Ruby 1.8.6 and above
@@ -40,19 +34,11 @@ module Soybean
40
34
  (@definitions.name.name.gsub(/Service$/, '') rescue 'Base') + 'Interface'
41
35
  end
42
36
 
43
- private
44
-
45
- def dump_porttype(porttype)
46
- assigned_method = collect_assigned_method(@definitions, porttype.name, @modulepath)
47
- class_name = mapped_class_basename(porttype.name, @modulepath)
48
- c = XSD::CodeGen::ClassDef.new(class_name, 'Soybean::Interface')
49
- methoddef = WSDL::SOAP::MethodDefCreator.new(@definitions, @name_creator, @modulepath, {}).dump(porttype.name)
50
- c.def_code %Q{Methods = [\n#{methoddef.gsub(/^/, " ")}\n]}
51
-
52
- element_definitions = @definitions.collect_elements
53
- binding = porttype.find_binding
37
+ def actions
38
+ assigned_method = collect_assigned_method(@definitions, @porttype.name, @modulepath)
39
+ binding = @porttype.find_binding
54
40
  if binding
55
- binding.operations.each do |op_bind|
41
+ binding.operations.map do |op_bind|
56
42
  operation = op_bind.find_operation
57
43
  if operation.nil?
58
44
  warn("operation not found for binding: #{op_bind}")
@@ -64,18 +50,68 @@ module Soybean
64
50
  params = input.find_message.parts.collect { |part|
65
51
  safevarname(part.name)
66
52
  }
67
- m = XSD::CodeGen::MethodDef.new(methodname, params) do
68
- <<-EOD
69
- p [#{params.join(", ")}]
70
- raise NotImplementedError.new
71
- EOD
72
- end
73
- m.comment = dump_method_signature(methodname, operation, element_definitions)
74
- c.add_method(m)
53
+ [methodname.underscore, params, operation]
54
+ end
55
+ else
56
+ []
57
+ end
58
+ end
59
+
60
+ private
61
+
62
+ def dump_porttype
63
+ class_name = mapped_class_basename(@porttype.name, @modulepath)
64
+ c = XSD::CodeGen::ClassDef.new(class_name, 'Soybean::Interface')
65
+ methoddef = MethodDefCreator.new(@definitions, @name_creator, @modulepath, {}).dump(@porttype.name)
66
+ c.def_code %Q{Methods = [\n#{methoddef.gsub(/^/, " ")}\n]}
67
+
68
+ element_definitions = @definitions.collect_elements
69
+ actions.each do |method_name, params, operation|
70
+ m = XSD::CodeGen::MethodDef.new(method_name, params) do
71
+ <<-EOD
72
+ p [#{params.join(", ")}]
73
+ raise NotImplementedError.new
74
+ EOD
75
75
  end
76
+ m.comment = dump_method_signature(method_name, operation, element_definitions)
77
+ c.add_method(m)
76
78
  end
79
+
77
80
  c.dump
78
81
  end
79
82
 
83
+ class MethodDefCreator < WSDL::SOAP::MethodDefCreator
84
+ private
85
+ def dump_method(mdef)
86
+ style = mdef.style
87
+ inputuse = mdef.inputuse
88
+ outputuse = mdef.outputuse
89
+ paramstr = param2str(mdef.parameters)
90
+ if paramstr.empty?
91
+ paramstr = '[]'
92
+ else
93
+ paramstr = "[ " << paramstr.split(/\r?\n/).join("\n ") << " ]"
94
+ end
95
+ definitions = <<__EOD__
96
+ #{ndq(mdef.soapaction)},
97
+ #{dq(mdef.name).underscore},
98
+ #{paramstr},
99
+ { :request_style => #{nsym(style)}, :request_use => #{nsym(inputuse)},
100
+ :response_style => #{nsym(style)}, :response_use => #{nsym(outputuse)},
101
+ :faults => #{mdef.faults.inspect} }
102
+ __EOD__
103
+ if style == :rpc
104
+ assign_const(mdef.qname.namespace, 'Ns')
105
+ return <<__EOD__
106
+ [ #{dqname(mdef.qname)},
107
+ #{definitions}]
108
+ __EOD__
109
+ else
110
+ return <<__EOD__
111
+ [ #{definitions}]
112
+ __EOD__
113
+ end
114
+ end
115
+ end
80
116
  end
81
117
  end
data/soybean.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{soybean}
8
- s.version = "2.1.3"
8
+ s.version = "2.1.4"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Anton Sozontov"]
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: 2.1.3
4
+ version: 2.1.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -14,7 +14,7 @@ default_executable: soybean
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: thor
17
- requirement: &18193120 !ruby/object:Gem::Requirement
17
+ requirement: &18250000 !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: *18193120
25
+ version_requirements: *18250000
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: activesupport
28
- requirement: &18192460 !ruby/object:Gem::Requirement
28
+ requirement: &18248200 !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: *18192460
36
+ version_requirements: *18248200
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: i18n
39
- requirement: &18191520 !ruby/object:Gem::Requirement
39
+ requirement: &18247640 !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: *18191520
47
+ version_requirements: *18247640
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: rspec
50
- requirement: &18190800 !ruby/object:Gem::Requirement
50
+ requirement: &18246900 !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: *18190800
58
+ version_requirements: *18246900
59
59
  - !ruby/object:Gem::Dependency
60
60
  name: yard
61
- requirement: &18190100 !ruby/object:Gem::Requirement
61
+ requirement: &18246020 !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: *18190100
69
+ version_requirements: *18246020
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: bundler
72
- requirement: &18189280 !ruby/object:Gem::Requirement
72
+ requirement: &18230280 !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: *18189280
80
+ version_requirements: *18230280
81
81
  - !ruby/object:Gem::Dependency
82
82
  name: jeweler
83
- requirement: &18188500 !ruby/object:Gem::Requirement
83
+ requirement: &18229440 !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: *18188500
91
+ version_requirements: *18229440
92
92
  - !ruby/object:Gem::Dependency
93
93
  name: rcov
94
- requirement: &18187740 !ruby/object:Gem::Requirement
94
+ requirement: &18228860 !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: *18187740
102
+ version_requirements: *18228860
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
@@ -312,7 +312,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
312
312
  version: '0'
313
313
  segments:
314
314
  - 0
315
- hash: 3623905933430620017
315
+ hash: 1732627524973815179
316
316
  required_rubygems_version: !ruby/object:Gem::Requirement
317
317
  none: false
318
318
  requirements: