shapewear 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/.travis.yml CHANGED
@@ -1,4 +1,5 @@
1
1
  # https://github.com/travis-ci/travis-ci/wiki/.travis.yml-options
2
+ language: ruby
2
3
  script: "bundle exec rake"
3
4
  rvm:
4
5
  - 1.8.7
data/README.md CHANGED
@@ -1,15 +1,21 @@
1
- shapewear [![Build Status](https://secure.travis-ci.org/elementar/shapewear.png)](http://travis-ci.org/elementar/shapewear)
2
- =========
1
+ # shapewear [![Build Status](https://secure.travis-ci.org/elementar/shapewear.png)](http://travis-ci.org/elementar/shapewear)
3
2
 
4
- Make your fat service look skinny.
3
+ Shapewear make your fat service look skinny.
5
4
 
6
- Work in Progress
7
- ----------------
5
+ Most of the inspiration for this gem came from [Savon](http://savonrb.com/) and [HTTParty](http://httparty.rubyforge.org/),
6
+ thanks Daniel Harrington (a.k.a. rubiii) and John Nunemaker!
8
7
 
9
- This gem is still in early development, and it's not yet yet ready for use. Any contribution and feedback is welcome.
8
+ ## Work in Progress
10
9
 
11
- Installation
12
- ------------
10
+ This gem is still in early development. It's only working for some very basic cases. Any contribution and feedback is welcome.
11
+
12
+ ### Roadmap
13
+
14
+ * Add more tests;
15
+ * Add support for SOAP 1.2;
16
+ * Add cleaner integration on Rails and Sinatra (Rack middleware?).
17
+
18
+ ## Installation
13
19
 
14
20
  Shapewear is available through [Rubygems](http://rubygems.org/gems/shapewear) and can be installed via:
15
21
 
@@ -62,7 +68,7 @@ class MyFirstServiceController < ApplicationController
62
68
  end
63
69
 
64
70
  def serve
65
- render :xml => MyHelloService.serve(params)
71
+ render :xml => MyHelloService.serve(request)
66
72
  end
67
73
  end
68
74
  ```
@@ -78,7 +84,7 @@ class MySinatraApp < Sinatra::App
78
84
 
79
85
  post "my_first_service" do
80
86
  content_type "application/xml"
81
- MyHelloService.serve(params)
87
+ MyHelloService.serve(request)
82
88
  end
83
89
  end
84
90
  ```
data/lib/shapewear.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # encoding: UTF-8
2
+
1
3
  require 'nokogiri'
2
4
 
3
5
  require 'shapewear/version'
data/lib/shapewear/dsl.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # encoding: UTF-8
2
+
1
3
  require 'builder'
2
4
 
3
5
  module Shapewear::DSL
@@ -18,7 +20,7 @@ module Shapewear::DSL
18
20
  'xsd1' => "http://schema.example.com/#{self.name}",
19
21
  'wsdl' => 'http://schemas.xmlsoap.org/wsdl/',
20
22
  'soap' => 'http://schemas.xmlsoap.org/wsdl/soap/',
21
- 'xsd' => 'http://www.w3.org/2000/10/XMLSchema',
23
+ 'xsd' => 'http://www.w3.org/2001/XMLSchema',
22
24
  'env' => 'http://schemas.xmlsoap.org/soap/envelope/'
23
25
  end
24
26
 
@@ -1,3 +1,5 @@
1
+ # encoding: UTF-8
2
+
1
3
  module Shapewear::Logging
2
4
  def logger
3
5
  @logger ||= (::Rails.logger rescue Logger.new(STDOUT))
@@ -1,3 +1,5 @@
1
+ # encoding: UTF-8
2
+
1
3
  module Shapewear::Request
2
4
  # @param request [Rack::Request, Hash]
3
5
  def serve(request)
@@ -1,5 +1,7 @@
1
+ # encoding: UTF-8
2
+
1
3
  module Shapewear
2
4
 
3
- Version = "0.0.3"
5
+ Version = "0.0.4"
4
6
 
5
7
  end
@@ -1,3 +1,5 @@
1
+ # encoding: UTF-8
2
+
1
3
  require 'builder'
2
4
 
3
5
  #noinspection RubyArgCount,RubyResolve
@@ -10,6 +12,7 @@ module Shapewear::WSDL
10
12
  xm.definitions :name => self.name, 'targetNamespace' => namespaces['tns'],
11
13
  'xmlns' => namespaces['wsdl'],
12
14
  'xmlns:soap' => namespaces['soap'],
15
+ 'xmlns:xsd' => namespaces['xsd'],
13
16
  'xmlns:xsd1' => namespaces['xsd1'],
14
17
  'xmlns:tns' => namespaces['tns'] do |xdef|
15
18
 
@@ -17,39 +20,39 @@ module Shapewear::WSDL
17
20
  xtypes.schema 'xmlns' => namespaces['xsd'], 'targetNamespace' => namespaces['xsd1'] do |xschema|
18
21
 
19
22
  # define elements for each defined method
20
- instance_methods(false).each do |m|
21
- build_type_elements_for_method(m, xschema)
23
+ operations.each do |m, op_opts|
24
+ build_type_elements_for_method(m, op_opts, xschema)
22
25
  end
23
26
  end
24
27
  end
25
28
 
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
+ operations.each do |m, op_opts|
30
+ xdef.message :name => "#{op_opts[:public_name]}Input" do |xmsg|
31
+ xmsg.part :name => :body, :element => "xsd1:#{op_opts[:public_name]}Request"
29
32
  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"
33
+ xdef.message :name => "#{op_opts[:public_name]}Output" do |xmsg|
34
+ xmsg.part :name => :body, :element => "xsd1:#{op_opts[:public_name]}Response"
32
35
  end
33
36
  end
34
37
 
35
38
  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"
39
+ operations.each do |m, op_opts|
40
+ xpt.operation :name => op_opts[:public_name] do |xop|
41
+ xop.input :message => "tns:#{op_opts[:public_name]}Input" unless instance_method(m).arity == 0
42
+ xop.output :message => "tns:#{op_opts[:public_name]}Output"
40
43
  end
41
44
  end
42
45
  end
43
46
 
44
47
  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'
48
+ xbind.tag! 'soap:binding', :style => 'rpc', :transport => 'http://schemas.xmlsoap.org/soap/http'
46
49
  operations.each do |op, op_opts|
47
50
  xbind.operation :name => op_opts[:public_name] do |xop|
48
51
  doc = op_opts[:documentation] rescue nil
49
52
  xop.documentation doc unless doc.nil?
50
53
  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' }
54
+ xop.input { |xin| xin.tag! 'soap:body', :use => 'literal', :namespace => namespaces['tns'] } unless instance_method(op).arity == 0
55
+ xop.output { |xin| xin.tag! 'soap:body', :use => 'literal', :namespace => namespaces['tns'] }
53
56
  end
54
57
  end
55
58
  end
@@ -63,10 +66,9 @@ module Shapewear::WSDL
63
66
  end
64
67
  end
65
68
 
66
- def build_type_elements_for_method(m, xschema)
69
+ def build_type_elements_for_method(m, op_options, xschema)
67
70
  # element for method arguments
68
71
  um = instance_method(m)
69
- op_options = options[:operations][m.to_sym] rescue nil
70
72
 
71
73
  if um.arity > 0
72
74
  xschema.element :name => "#{op_options[:public_name]}Request" do |xreq|
@@ -106,7 +108,7 @@ module Shapewear::WSDL
106
108
  end
107
109
 
108
110
  # element for method result
109
- xschema.element :name => "#{op_options[:public_name]}" do |xreq|
111
+ xschema.element :name => "#{op_options[:public_name]}Response" do |xreq|
110
112
  xreq.complexType do |xct|
111
113
  xct.all do |xall|
112
114
  ret = op_options[:returns] rescue nil
data/shapewear.gemspec CHANGED
@@ -1,3 +1,5 @@
1
+ # encoding: UTF-8
2
+
1
3
  lib = File.expand_path("../lib", __FILE__)
2
4
  $:.unshift lib unless $:.include? lib
3
5
 
@@ -1,3 +1,5 @@
1
+ # encoding: UTF-8
2
+
1
3
  require "spec_helper"
2
4
 
3
5
  describe Shapewear::DSL do
@@ -1,3 +1,5 @@
1
+ # encoding: UTF-8
2
+
1
3
  require "spec_helper"
2
4
 
3
5
  describe Shapewear do
@@ -1,3 +1,5 @@
1
+ # encoding: UTF-8
2
+
1
3
  # This class represents a fully customized service.
2
4
  # It is used to test the extensiveness of the Shapewear DSL.
3
5
  class CompleteService
@@ -1,3 +1,5 @@
1
+ # encoding: UTF-8
2
+
1
3
  # This class represents a minimal working service, without the use of any of the Shapewear specific DSL.
2
4
  # It is used to test the Convention-over-Configuration-ness of Shapewear.
3
5
  class MinimalWorkingService
data/spec/spec_helper.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # encoding: UTF-8
2
+
1
3
  require "bundler"
2
4
  Bundler.require :default, :development
3
5
 
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: 25
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 3
10
- version: 0.0.3
9
+ - 4
10
+ version: 0.0.4
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-05 00:00:00 Z
18
+ date: 2012-01-06 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: builder