shapewear 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +2 -0
- data/lib/shapewear.rb +11 -0
- data/lib/shapewear/dsl.rb +33 -19
- data/lib/shapewear/logging.rb +9 -0
- data/lib/shapewear/request.rb +66 -0
- data/lib/shapewear/version.rb +1 -1
- data/lib/shapewear/wsdl.rb +100 -90
- data/shapewear.gemspec +4 -0
- data/spec/shapewear/dsl_spec.rb +18 -28
- data/spec/shapewear/savon_usage_spec.rb +25 -0
- data/spec/shapewear/service_definitions/complete_service.rb +56 -0
- data/spec/shapewear/service_definitions/minimal_working_service.rb +9 -0
- data/spec/spec_helper.rb +4 -0
- metadata +65 -4
data/README.md
CHANGED
@@ -31,6 +31,8 @@ class MyFirstService
|
|
31
31
|
wsdl_namespace 'http://services.example.com/v1'
|
32
32
|
schema_namespace 'http://schemas.example.com/v1'
|
33
33
|
|
34
|
+
endpoint_url 'http://localhost:3000/my_first_service'
|
35
|
+
|
34
36
|
operation :hello, :parameters => [[:name, String]], :returns => String
|
35
37
|
def hello(name)
|
36
38
|
"hello, #{name}"
|
data/lib/shapewear.rb
CHANGED
@@ -1,13 +1,24 @@
|
|
1
1
|
require 'nokogiri'
|
2
2
|
|
3
3
|
require 'shapewear/version'
|
4
|
+
require 'shapewear/logging'
|
4
5
|
require 'shapewear/dsl'
|
5
6
|
require 'shapewear/wsdl'
|
7
|
+
require 'shapewear/request'
|
6
8
|
|
7
9
|
module Shapewear
|
8
10
|
def self.included(receiver)
|
11
|
+
receiver.extend(Shapewear::Logging)
|
9
12
|
receiver.extend(Shapewear::DSL)
|
10
13
|
receiver.extend(Shapewear::WSDL)
|
14
|
+
receiver.extend(Shapewear::Request)
|
15
|
+
|
16
|
+
class << receiver
|
17
|
+
def method_added(m)
|
18
|
+
# automatically creates an operation for each method added
|
19
|
+
operation m
|
20
|
+
end
|
21
|
+
end
|
11
22
|
end
|
12
23
|
end
|
13
24
|
|
data/lib/shapewear/dsl.rb
CHANGED
@@ -1,29 +1,43 @@
|
|
1
1
|
require 'builder'
|
2
2
|
|
3
|
-
module Shapewear
|
4
|
-
|
5
|
-
private
|
3
|
+
module Shapewear::DSL
|
4
|
+
private
|
6
5
|
|
7
|
-
|
8
|
-
|
9
|
-
|
6
|
+
def options
|
7
|
+
@options ||= {}
|
8
|
+
end
|
9
|
+
|
10
|
+
def operations
|
11
|
+
options[:operations] ||= {}
|
12
|
+
end
|
13
|
+
|
14
|
+
def namespaces
|
15
|
+
options[:namespaces] ||=
|
16
|
+
Hash.new { |_, k| raise "Namespace not defined: #{k}" } \
|
17
|
+
.merge! 'tns' => "http://services.example.com/#{self.name}",
|
18
|
+
'xsd1' => "http://schema.example.com/#{self.name}",
|
19
|
+
'wsdl' => 'http://schemas.xmlsoap.org/wsdl/',
|
20
|
+
'soap' => 'http://schemas.xmlsoap.org/wsdl/soap/',
|
21
|
+
'xsd' => 'http://www.w3.org/2000/10/XMLSchema',
|
22
|
+
'env' => 'http://schemas.xmlsoap.org/soap/envelope/'
|
23
|
+
end
|
10
24
|
|
11
|
-
|
25
|
+
protected
|
12
26
|
|
13
|
-
|
14
|
-
|
15
|
-
|
27
|
+
def wsdl_namespace(ns)
|
28
|
+
namespaces['tns'] = ns
|
29
|
+
end
|
16
30
|
|
17
|
-
|
18
|
-
|
19
|
-
|
31
|
+
def schema_namespace(ns)
|
32
|
+
namespaces['xsd1'] = ns
|
33
|
+
end
|
20
34
|
|
21
|
-
|
22
|
-
|
23
|
-
|
35
|
+
def endpoint_url(url)
|
36
|
+
options[:endpoint_url] = url
|
37
|
+
end
|
24
38
|
|
25
|
-
|
26
|
-
|
27
|
-
|
39
|
+
def operation(name, ops = {})
|
40
|
+
h = (operations[name] ||= {}).merge! ops
|
41
|
+
h[:public_name] ||= name.to_s.camelize
|
28
42
|
end
|
29
43
|
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
module Shapewear::Request
|
2
|
+
# @param request [Rack::Request, Hash]
|
3
|
+
def serve(request)
|
4
|
+
op_node = find_soap_operation_node(request)
|
5
|
+
|
6
|
+
begin
|
7
|
+
call_soap_operation(op_node)
|
8
|
+
rescue => e
|
9
|
+
serialize_soap_fault e
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def find_soap_operation_node(request)
|
16
|
+
body ||= request.body if request.respond_to? :body
|
17
|
+
body ||= request[:body] if request.is_a?(Hash)
|
18
|
+
body ||= request.to_s
|
19
|
+
|
20
|
+
raise "Request body could not be found" if body.nil?
|
21
|
+
|
22
|
+
doc = Nokogiri::XML(body) { |c| c.strict } rescue raise("Request body is not a valid XML")
|
23
|
+
|
24
|
+
raise "Request is not a SOAP::Envelope: #{body}" if doc.at('/env:Envelope', namespaces).nil?
|
25
|
+
|
26
|
+
# find the operation element, or raise if not found
|
27
|
+
doc.at("/env:Envelope/env:Body/tns:*", namespaces) or raise "Operation not found"
|
28
|
+
end
|
29
|
+
|
30
|
+
def call_soap_operation(node)
|
31
|
+
operations.each do |k, v|
|
32
|
+
if v[:public_name] == node.name
|
33
|
+
params = extract_parameters(node)
|
34
|
+
logger.debug "Calling #{k} with args: #{params.map(&:inspect) * ', '}"
|
35
|
+
r = self.new.send(k, *params)
|
36
|
+
logger.debug "Result: #{r.inspect}"
|
37
|
+
return serialize_soap_result v, r
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
raise "Operation not found: #{node.name}"
|
42
|
+
end
|
43
|
+
|
44
|
+
def extract_parameters(node)
|
45
|
+
# TODO: use the metadata collected from the DSL to reoder the parameters and perform the appropriate conversions
|
46
|
+
node.children.map { |n| n.text }
|
47
|
+
end
|
48
|
+
|
49
|
+
#noinspection RubyArgCount
|
50
|
+
def serialize_soap_result(op_options, r)
|
51
|
+
xb = Builder::XmlMarkup.new
|
52
|
+
xb.instruct!
|
53
|
+
|
54
|
+
xb.Envelope :xmlns => namespaces['env'] do |xenv|
|
55
|
+
xenv.Body do |xbody|
|
56
|
+
xbody.tag! "#{op_options[:public_name]}Response", :xmlns => namespaces['xsd1'] do |xres|
|
57
|
+
xres.body r
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def serialize_soap_fault(ex)
|
64
|
+
raise ex
|
65
|
+
end
|
66
|
+
end
|
data/lib/shapewear/version.rb
CHANGED
data/lib/shapewear/wsdl.rb
CHANGED
@@ -1,127 +1,137 @@
|
|
1
1
|
require 'builder'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
tns = options[:wsdl_namespace] || "http://shapewear.elementarsistemas.com.br/auto/#{self.name}.wsdl"
|
9
|
-
xsd = options[:schema_namespace] || "http://shapewear.elementarsistemas.com.br/auto/#{self.name}.xsd"
|
3
|
+
#noinspection RubyArgCount,RubyResolve
|
4
|
+
module Shapewear::WSDL
|
5
|
+
# reference: http://www.w3.org/TR/wsdl
|
6
|
+
def to_wsdl
|
7
|
+
xm = Builder::XmlMarkup.new
|
10
8
|
|
11
|
-
|
9
|
+
xm.instruct!
|
10
|
+
xm.definitions :name => self.name, 'targetNamespace' => namespaces['tns'],
|
11
|
+
'xmlns' => namespaces['wsdl'],
|
12
|
+
'xmlns:soap' => namespaces['soap'],
|
13
|
+
'xmlns:xsd1' => namespaces['xsd1'],
|
14
|
+
'xmlns:tns' => namespaces['tns'] do |xdef|
|
12
15
|
|
13
|
-
|
14
|
-
|
15
|
-
'xmlns' => 'http://schemas.xmlsoap.org/wsdl/',
|
16
|
-
'xmlns:soap' => 'http://schemas.xmlsoap.org/wsdl/soap/',
|
17
|
-
'xmlns:xsd1' => xsd, 'xmlns:tns' => tns do |xdef|
|
16
|
+
xdef.types do |xtypes|
|
17
|
+
xtypes.schema 'xmlns' => namespaces['xsd'], 'targetNamespace' => namespaces['xsd1'] do |xschema|
|
18
18
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
# define elements for each defined method
|
23
|
-
instance_methods(false).each do |m|
|
24
|
-
build_type_elements_for_method(m, xschema)
|
25
|
-
end
|
19
|
+
# define elements for each defined method
|
20
|
+
instance_methods(false).each do |m|
|
21
|
+
build_type_elements_for_method(m, xschema)
|
26
22
|
end
|
27
23
|
end
|
24
|
+
end
|
28
25
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
end
|
26
|
+
instance_methods(false).each do |m|
|
27
|
+
xdef.message :name => "#{m.camelize}Input" do |xmsg|
|
28
|
+
xmsg.part :name => :body, :element => "xsd1:#{m.camelize}Request"
|
29
|
+
end unless instance_method(m).arity == 0
|
30
|
+
xdef.message :name => "#{m.camelize}Output" do |xmsg|
|
31
|
+
xmsg.part :name => :body, :element => "xsd1:#{m.camelize}Response"
|
36
32
|
end
|
33
|
+
end
|
37
34
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
end
|
35
|
+
xdef.portType :name => "#{self.name}PortType" do |xpt|
|
36
|
+
instance_methods(false).each do |m|
|
37
|
+
xpt.operation :name => m.camelize do |xop|
|
38
|
+
xop.input :message => "tns:#{m.camelize}Input" unless instance_method(m).arity == 0
|
39
|
+
xop.output :message => "tns:#{m.camelize}Output"
|
44
40
|
end
|
45
41
|
end
|
42
|
+
end
|
46
43
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
44
|
+
xdef.binding :name => "#{self.name}Binding", :type => "tns:#{self.name}PortType" do |xbind|
|
45
|
+
xbind.tag! 'soap:binding', :style => 'document', :transport => 'http://schemas.xmlsoap.org/soap/http'
|
46
|
+
operations.each do |op, op_opts|
|
47
|
+
xbind.operation :name => op_opts[:public_name] do |xop|
|
48
|
+
doc = op_opts[:documentation] rescue nil
|
49
|
+
xop.documentation doc unless doc.nil?
|
50
|
+
xop.tag! 'soap:operation', :soapAction => "#{namespaces['tns']}/#{op_opts[:public_name]}"
|
51
|
+
xop.input { |xin| xin.tag! 'soap:body', :use => 'literal' } unless instance_method(op).arity == 0
|
52
|
+
xop.output { |xin| xin.tag! 'soap:body', :use => 'literal' }
|
55
53
|
end
|
56
54
|
end
|
55
|
+
end
|
57
56
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
end
|
57
|
+
xdef.service :name => self.name do |xsrv|
|
58
|
+
xsrv.documentation "WSDL auto-generated by shapewear."
|
59
|
+
xsrv.port :name => "#{self.name}Port", :binding => "#{self.name}Binding" do |xport|
|
60
|
+
xport.tag! 'soap:address', :location => options[:endpoint_url]
|
63
61
|
end
|
64
62
|
end
|
65
63
|
end
|
64
|
+
end
|
66
65
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
66
|
+
def build_type_elements_for_method(m, xschema)
|
67
|
+
# element for method arguments
|
68
|
+
um = instance_method(m)
|
69
|
+
op_options = options[:operations][m.to_sym] rescue nil
|
71
70
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
end
|
71
|
+
if um.arity > 0
|
72
|
+
xschema.element :name => "#{op_options[:public_name]}Request" do |xreq|
|
73
|
+
xreq.complexType do |xct|
|
74
|
+
xct.all do |xall|
|
75
|
+
params = op_options[:parameters] rescue nil
|
76
|
+
if params.nil?
|
77
|
+
if um.respond_to?(:parameters)
|
78
|
+
# with Ruby 1.9, we can create the parameters with the correct names
|
79
|
+
params = um.parameters.select { |p| p.first == :in }.map { |p| [p.first, Object] }
|
80
|
+
else
|
81
|
+
params = (0..um.arity).map { |i| ["arg#{i}", Object] }
|
84
82
|
end
|
83
|
+
end
|
85
84
|
|
86
|
-
|
87
|
-
|
85
|
+
params.each do |p|
|
86
|
+
t = p.last
|
87
|
+
if t.nil?
|
88
|
+
xall.element :name => p.first, :type => 'xsd:any'
|
89
|
+
elsif t.is_a?(Class)
|
90
|
+
xall.element :name => p.first, :type => to_xsd_type(t)
|
91
|
+
elsif t.is_a?(Hash)
|
92
|
+
xall.complexType do |xct2|
|
93
|
+
xct2.all do |xall2|
|
94
|
+
t.each do |name, type|
|
95
|
+
xall2.element :name => name, :type => to_xsd_type(type)
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
else
|
100
|
+
raise "Could not interpret #{t.inspect} as a return type definition"
|
88
101
|
end
|
89
102
|
end
|
90
103
|
end
|
91
104
|
end
|
92
105
|
end
|
106
|
+
end
|
93
107
|
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
end
|
107
|
-
else
|
108
|
-
raise "Could not interpret #{ret.inspect} as a return type definition"
|
108
|
+
# element for method result
|
109
|
+
xschema.element :name => "#{op_options[:public_name]}" do |xreq|
|
110
|
+
xreq.complexType do |xct|
|
111
|
+
xct.all do |xall|
|
112
|
+
ret = op_options[:returns] rescue nil
|
113
|
+
if ret.nil?
|
114
|
+
xall.element :name => 'result', :type => 'xsd:any'
|
115
|
+
elsif ret.is_a?(Class)
|
116
|
+
xall.element :name => 'result', :type => to_xsd_type(ret)
|
117
|
+
elsif ret.is_a?(Hash)
|
118
|
+
ret.each do |name, type|
|
119
|
+
xall.element :name => name, :type => to_xsd_type(type)
|
109
120
|
end
|
121
|
+
else
|
122
|
+
raise "Could not interpret #{ret.inspect} as a return type definition"
|
110
123
|
end
|
111
124
|
end
|
112
125
|
end
|
113
126
|
end
|
127
|
+
end
|
114
128
|
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
elsif t.is_a?(Hash)
|
123
|
-
'??'
|
124
|
-
end
|
125
|
-
end
|
129
|
+
# @param t [Class]
|
130
|
+
def to_xsd_type(t)
|
131
|
+
return 'xsd:string' if t == String
|
132
|
+
return 'xsd:integer' if t == Fixnum
|
133
|
+
return 'xsd:dateTime' if t == DateTime
|
134
|
+
return 'xsd:any' if t.nil? || t == Object
|
135
|
+
raise "Could not convert type #{t} to a valid XSD type"
|
126
136
|
end
|
127
137
|
end
|
data/shapewear.gemspec
CHANGED
@@ -19,6 +19,10 @@ Gem::Specification.new do |s|
|
|
19
19
|
|
20
20
|
s.add_development_dependency "rake", "~> 0.9.2"
|
21
21
|
s.add_development_dependency "rspec", "~> 2.7.0"
|
22
|
+
s.add_development_dependency "rack-test"
|
23
|
+
s.add_development_dependency "savon"
|
24
|
+
s.add_development_dependency "wasabi"
|
25
|
+
s.add_development_dependency "webmock"
|
22
26
|
|
23
27
|
s.files = `git ls-files`.split("\n")
|
24
28
|
s.require_path = "lib"
|
data/spec/shapewear/dsl_spec.rb
CHANGED
@@ -5,48 +5,38 @@ describe Shapewear::DSL do
|
|
5
5
|
let(:xmlns) { {'wsdl' => 'http://schemas.xmlsoap.org/wsdl/', 'soap' => 'http://schemas.xmlsoap.org/wsdl/soap/'} }
|
6
6
|
|
7
7
|
describe "basic DSL" do
|
8
|
-
it "should describe
|
9
|
-
|
10
|
-
include Shapewear
|
11
|
-
|
12
|
-
def hello_world
|
13
|
-
"hello"
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
wsdl = ParameterlessHelloWorldService.to_wsdl
|
8
|
+
it "should describe a minimal working service" do
|
9
|
+
wsdl = MinimalWorkingService.to_wsdl
|
18
10
|
puts wsdl
|
19
|
-
wsdl_doc = nil
|
20
|
-
expect { wsdl_doc = Nokogiri::XML(wsdl) { |c| c.strict } }.not_to raise_error
|
21
11
|
|
22
|
-
#
|
23
|
-
|
24
|
-
wsdl_def.should have(1).node
|
25
|
-
wsdl_def.xpath("wsdl:service[@name='ParameterlessHelloWorldService']/wsdl:port[@name='ParameterlessHelloWorldServicePort']/soap:address", xmlns).should have(1).node
|
12
|
+
# wsdl should be valid XML (duh!)
|
13
|
+
expect { Nokogiri::XML(wsdl) { |c| c.strict } }.not_to raise_error
|
26
14
|
|
27
|
-
#
|
28
|
-
|
15
|
+
# wasabi should be able to parse it
|
16
|
+
wdoc = nil
|
17
|
+
expect { wdoc = Wasabi.document wsdl }.not_to raise_error
|
29
18
|
|
30
|
-
|
31
|
-
|
19
|
+
wdoc.namespace.should match /MinimalWorkingService/
|
20
|
+
wdoc.soap_actions.should == [:hello_world]
|
32
21
|
|
33
|
-
|
34
|
-
|
35
|
-
|
22
|
+
wdoc.operations[:hello_world].should_not be_nil
|
23
|
+
wdoc.operations[:hello_world][:input].should == 'HelloWorld'
|
24
|
+
wdoc.operations[:hello_world][:input].should match /HelloWorld$/
|
36
25
|
end
|
37
|
-
it "should describe services with basic parameters and return values"
|
38
|
-
it "should describe services with array parameters"
|
39
26
|
end
|
40
27
|
|
41
28
|
describe "complex types DSL" do
|
42
|
-
it "should allow definition of complex types using class introspection"
|
43
|
-
it "should allow definition of complex types using a builder-like DSL"
|
44
29
|
it "should accept complex types as input"
|
45
30
|
it "should accept complex types as output"
|
31
|
+
it "should accept arrays as input"
|
32
|
+
it "should accept arrays as output"
|
33
|
+
it "should allow definition of complex types using class introspection"
|
34
|
+
it "should allow definition of complex types using a DSL"
|
46
35
|
end
|
47
36
|
|
48
37
|
describe "WSDL customization" do
|
49
|
-
it "should allow customization of namespace"
|
38
|
+
it "should allow customization of target namespace"
|
39
|
+
it "should allow customization of schema namespace"
|
50
40
|
end
|
51
41
|
|
52
42
|
describe "existing WSDL" do
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Shapewear do
|
4
|
+
describe "usage with SOAP clients" do
|
5
|
+
before do
|
6
|
+
stub_request(:get, "http://services.example.com/complete/soap/wsdl") \
|
7
|
+
.to_return :body => CompleteService.to_wsdl, :headers => {'Content-Type' => 'application/xml'}
|
8
|
+
|
9
|
+
stub_request(:post, "http://services.example.com/complete/soap") \
|
10
|
+
.to_return :body => lambda { |r| CompleteService.serve(r) }, :headers => {'Content-Type' => 'application/xml'}
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should work with Savon" do
|
14
|
+
client = Savon::Client.new 'http://services.example.com/complete/soap/wsdl'
|
15
|
+
response = client.request :echo_in_uppercase, :xmlns => 'http://services.example.com/v1' do
|
16
|
+
soap.body = {:text => 'uppercase text'}
|
17
|
+
end
|
18
|
+
|
19
|
+
puts response.inspect
|
20
|
+
puts response.body.inspect
|
21
|
+
|
22
|
+
response.body[:echo_in_uppercase_response][:body].should == 'UPPERCASE TEXT'
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# This class represents a fully customized service.
|
2
|
+
# It is used to test the extensiveness of the Shapewear DSL.
|
3
|
+
class CompleteService
|
4
|
+
include Shapewear
|
5
|
+
|
6
|
+
wsdl_namespace 'http://services.example.com/v1'
|
7
|
+
schema_namespace 'http://schemas.example.com/v1'
|
8
|
+
|
9
|
+
endpoint_url 'http://services.example.com/complete/soap'
|
10
|
+
|
11
|
+
operation :echo_in_uppercase, :documentation => 'Echoes back the parameter, in uppercase',
|
12
|
+
:parameters => [[:text, String]], :returns => String
|
13
|
+
|
14
|
+
operation :sum, :documentation => 'Adds two numbers',
|
15
|
+
:parameters => [[:x, Fixnum], [:y, Fixnum]],
|
16
|
+
:returns => Fixnum
|
17
|
+
|
18
|
+
operation :get_structured_data, :documentation => 'Returns structured data. 0 uses a Hash, 1 uses a struct, any other value raises a fault',
|
19
|
+
:parameters => [[:id, Fixnum]],
|
20
|
+
:returns => {:text => String, :random_value => Fixnum, :created_at => DateTime}
|
21
|
+
|
22
|
+
def echo_in_uppercase(text)
|
23
|
+
text.upcase
|
24
|
+
end
|
25
|
+
|
26
|
+
def sum(x, y)
|
27
|
+
x + y
|
28
|
+
end
|
29
|
+
|
30
|
+
def get_structured_data(id)
|
31
|
+
case id
|
32
|
+
when 0 then
|
33
|
+
Structured.new('text from the struct')
|
34
|
+
when 1 then
|
35
|
+
{:text => 'text from a hash', :random_value => rand(999), @created_at => DateTime.now}
|
36
|
+
else
|
37
|
+
raise "ID must be 0 or 1"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def reset(chave)
|
42
|
+
raise "Operação não permitida" if ::Rails.env.production?
|
43
|
+
c = Conector::Registro.find_by_chave_registro(chave)
|
44
|
+
c.reset!
|
45
|
+
|
46
|
+
'ok'
|
47
|
+
end
|
48
|
+
|
49
|
+
class Structured < Struct.new(:text, :random_value, :created_at)
|
50
|
+
def initialize(text)
|
51
|
+
@text = text
|
52
|
+
@random_value = rand(999)
|
53
|
+
@created_at = DateTime.now
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
# This class represents a minimal working service, without the use of any of the Shapewear specific DSL.
|
2
|
+
# It is used to test the Convention-over-Configuration-ness of Shapewear.
|
3
|
+
class MinimalWorkingService
|
4
|
+
include Shapewear
|
5
|
+
|
6
|
+
def hello_world
|
7
|
+
"hello"
|
8
|
+
end
|
9
|
+
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shapewear
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 3
|
10
|
+
version: 0.0.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- "F\xC3\xA1bio Batista"
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-01-
|
18
|
+
date: 2012-01-05 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: builder
|
@@ -81,6 +81,62 @@ dependencies:
|
|
81
81
|
version: 2.7.0
|
82
82
|
type: :development
|
83
83
|
version_requirements: *id004
|
84
|
+
- !ruby/object:Gem::Dependency
|
85
|
+
name: rack-test
|
86
|
+
prerelease: false
|
87
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
88
|
+
none: false
|
89
|
+
requirements:
|
90
|
+
- - ">="
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
hash: 3
|
93
|
+
segments:
|
94
|
+
- 0
|
95
|
+
version: "0"
|
96
|
+
type: :development
|
97
|
+
version_requirements: *id005
|
98
|
+
- !ruby/object:Gem::Dependency
|
99
|
+
name: savon
|
100
|
+
prerelease: false
|
101
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
102
|
+
none: false
|
103
|
+
requirements:
|
104
|
+
- - ">="
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
hash: 3
|
107
|
+
segments:
|
108
|
+
- 0
|
109
|
+
version: "0"
|
110
|
+
type: :development
|
111
|
+
version_requirements: *id006
|
112
|
+
- !ruby/object:Gem::Dependency
|
113
|
+
name: wasabi
|
114
|
+
prerelease: false
|
115
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
116
|
+
none: false
|
117
|
+
requirements:
|
118
|
+
- - ">="
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
hash: 3
|
121
|
+
segments:
|
122
|
+
- 0
|
123
|
+
version: "0"
|
124
|
+
type: :development
|
125
|
+
version_requirements: *id007
|
126
|
+
- !ruby/object:Gem::Dependency
|
127
|
+
name: webmock
|
128
|
+
prerelease: false
|
129
|
+
requirement: &id008 !ruby/object:Gem::Requirement
|
130
|
+
none: false
|
131
|
+
requirements:
|
132
|
+
- - ">="
|
133
|
+
- !ruby/object:Gem::Version
|
134
|
+
hash: 3
|
135
|
+
segments:
|
136
|
+
- 0
|
137
|
+
version: "0"
|
138
|
+
type: :development
|
139
|
+
version_requirements: *id008
|
84
140
|
description: Shapewear is a Ruby library for handling SOAP requests from within your Rails or Sinatra application. It makes your fat services look skinny.
|
85
141
|
email: fabio@elementarsistemas.com.br
|
86
142
|
executables: []
|
@@ -101,10 +157,15 @@ files:
|
|
101
157
|
- Rakefile
|
102
158
|
- lib/shapewear.rb
|
103
159
|
- lib/shapewear/dsl.rb
|
160
|
+
- lib/shapewear/logging.rb
|
161
|
+
- lib/shapewear/request.rb
|
104
162
|
- lib/shapewear/version.rb
|
105
163
|
- lib/shapewear/wsdl.rb
|
106
164
|
- shapewear.gemspec
|
107
165
|
- spec/shapewear/dsl_spec.rb
|
166
|
+
- spec/shapewear/savon_usage_spec.rb
|
167
|
+
- spec/shapewear/service_definitions/complete_service.rb
|
168
|
+
- spec/shapewear/service_definitions/minimal_working_service.rb
|
108
169
|
- spec/spec_helper.rb
|
109
170
|
homepage: https://github.com/elementar/shapewear
|
110
171
|
licenses: []
|