wash_out 0.10.0.beta.1 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +3 -1
  3. data/.travis.yml +23 -3
  4. data/Appraisals +11 -5
  5. data/Gemfile +2 -2
  6. data/README.md +66 -2
  7. data/Rakefile +6 -7
  8. data/app/helpers/wash_out_helper.rb +49 -18
  9. data/app/views/{wash_with_soap → wash_out}/document/error.builder +0 -0
  10. data/app/views/{wash_with_soap → wash_out}/document/response.builder +1 -3
  11. data/app/views/{wash_with_soap → wash_out}/document/wsdl.builder +15 -15
  12. data/app/views/{wash_with_soap → wash_out}/rpc/error.builder +0 -0
  13. data/app/views/{wash_with_soap → wash_out}/rpc/response.builder +1 -3
  14. data/app/views/{wash_with_soap → wash_out}/rpc/wsdl.builder +16 -16
  15. data/gemfiles/rails_3.1.3.gemfile +20 -0
  16. data/gemfiles/rails_3.2.12.gemfile +20 -0
  17. data/gemfiles/rails_4.0.0.gemfile +19 -0
  18. data/gemfiles/rails_4.1.0.gemfile +19 -0
  19. data/gemfiles/rails_4.2.0.gemfile +19 -0
  20. data/lib/wash_out.rb +48 -16
  21. data/lib/wash_out/configurable.rb +41 -0
  22. data/lib/wash_out/dispatcher.rb +212 -0
  23. data/lib/wash_out/engine.rb +12 -0
  24. data/lib/wash_out/middleware.rb +41 -0
  25. data/lib/wash_out/model.rb +29 -0
  26. data/lib/wash_out/param.rb +43 -16
  27. data/lib/wash_out/router.rb +95 -0
  28. data/lib/wash_out/soap.rb +48 -0
  29. data/lib/wash_out/soap_config.rb +93 -0
  30. data/lib/wash_out/type.rb +20 -13
  31. data/lib/wash_out/version.rb +1 -1
  32. data/lib/wash_out/wsse.rb +29 -10
  33. data/spec/dummy/config/environments/test.rb +1 -0
  34. data/spec/lib/wash_out/dispatcher_spec.rb +28 -13
  35. data/spec/lib/wash_out/middleware_spec.rb +33 -0
  36. data/spec/lib/wash_out/param_spec.rb +47 -17
  37. data/spec/lib/wash_out/router_spec.rb +22 -0
  38. data/spec/lib/wash_out/type_spec.rb +9 -9
  39. data/spec/lib/wash_out_spec.rb +139 -87
  40. data/spec/spec_helper.rb +7 -1
  41. metadata +32 -25
  42. data/lib/wash_out/exceptions/programmer_error.rb +0 -10
  43. data/lib/wash_out/exceptions/soap_error.rb +0 -19
  44. data/lib/wash_out/middlewares/catcher.rb +0 -42
  45. data/lib/wash_out/middlewares/router.rb +0 -132
  46. data/lib/wash_out/rails/active_record.rb +0 -27
  47. data/lib/wash_out/rails/controller.rb +0 -201
  48. data/lib/wash_out/rails/engine.rb +0 -74
  49. data/spec/lib/wash_out/rack_spec.rb +0 -55
@@ -1,74 +0,0 @@
1
- module WashOut
2
- module Rails
3
- class Engine < ::Rails::Engine
4
-
5
- def self.defaults
6
- {
7
- parser: :rexml,
8
- namespace: 'urn:WashOut',
9
- wsdl_style: 'rpc',
10
- snakecase_input: false,
11
- camelize_wsdl: false,
12
- catch_xml_errors: false,
13
- wsse_username: nil,
14
- wsse_password: nil
15
- }
16
- end
17
-
18
- config.wash_out = ActiveSupport::OrderedOptions.new.merge!(defaults)
19
-
20
- initializer "wash_out.configuration" do |app|
21
- if app.config.wash_out[:catch_xml_errors]
22
- app.config.middleware.insert_after 'ActionDispatch::ShowExceptions', WashOut::Middlewares::Catcher
23
- end
24
- end
25
-
26
- initializer "wash_out.responders" do
27
- Mime::Type.register "application/soap+xml", :soap
28
-
29
- ActionController::Renderers.add :soap do |what, options|
30
- _render_soap(what, options)
31
- end
32
- end
33
- end
34
- end
35
-
36
- ActionDispatch::Routing::Mapper.class_eval do
37
- # Adds the routes for a SOAP endpoint at +controller+.
38
- def wash_out(controller_name, options={})
39
- options.reverse_merge!(@scope) if @scope
40
- controller_path = [options[:module], controller_name].compact.join("/")
41
-
42
- # WSDL Route
43
- match "#{controller_name}/wsdl" => "#{controller_name}#_generate_wsdl",
44
- via: :get,
45
- format: false
46
-
47
- # Responding point
48
- match "#{controller_name}/action" => WashOut::Middlewares::Router.new(controller_path),
49
- via: [:get, :post],
50
- format: false
51
- end
52
- end
53
-
54
- ActionController::Base.class_eval do
55
- # Define a SOAP service. The function has no required +options+:
56
- # but allow any of :parser, :namespace, :wsdl_style, :snakecase_input,
57
- # :camelize_wsdl, :wsse_username, :wsse_password and :catch_xml_errors.
58
- #
59
- # Any of the the params provided allows for overriding the defaults
60
- # (like supporting multiple namespaces instead of application wide such)
61
- #
62
- def self.soap_service(options={})
63
- include WashOut::Rails::Controller
64
- self.soap_config = options
65
- end
66
- end
67
-
68
- if defined?(ActiveRecord)
69
- ActiveRecord::Base.class_eval do
70
- # Turns AR models into WashOut types
71
- extend WashOut::Rails::ActiveRecord
72
- end
73
- end
74
- end
@@ -1,55 +0,0 @@
1
- require 'spec_helper'
2
- require 'wash_out/middlewares/catcher'
3
- require 'rexml/document'
4
-
5
- describe WashOut::Middlewares::Catcher do
6
- context 'catches REXML' do
7
- let(:app) { lambda {|env| REXML::Document.new '<hi>' } }
8
- let(:rack) { WashOut::Middlewares::Catcher.new(app) }
9
- let(:env) { {} }
10
-
11
- it 'passes exceptions through when not in SOAP mode' do
12
- lambda { rack.call(env) }.should raise_exception
13
- end
14
-
15
- context 'intercepts when in SOAP mode' do
16
- subject { rack.call(env) }
17
-
18
- context 'for basic rack servers' do
19
- let(:env) do
20
- {
21
- 'HTTP_SOAPACTION' => 'pretend_action',
22
- 'rack.errors' => double('logger', puts: true),
23
- 'rack.input' => double('basic-rack-input', string: 'hi')
24
- }
25
- end
26
-
27
- it do
28
- subject[0].should == 400
29
- subject[1]['Content-Type'].should == 'text/xml'
30
- subject[2][0].should include 'Error parsing SOAP Request XML'
31
- subject[2][0].should include 'soap:Fault'
32
- subject[2][0].should_not include __FILE__
33
- end
34
- end
35
-
36
- context 'for passenger' do
37
- let(:env) do
38
- {
39
- 'HTTP_SOAPACTION' => 'pretend_action',
40
- 'rack.errors' => double('logger', puts: true),
41
- 'rack.input' => double('basic-rack-input', read: 'hi')
42
- }
43
- end
44
-
45
- it do
46
- subject[0].should == 400
47
- subject[1]['Content-Type'].should == 'text/xml'
48
- subject[2][0].should include 'Error parsing SOAP Request XML'
49
- subject[2][0].should include 'soap:Fault'
50
- subject[2][0].should_not include __FILE__
51
- end
52
- end
53
- end
54
- end
55
- end