washout_builder 0.12.4 → 0.13.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- M2JhN2Y4NzUzNWRkMmRmMTFiZGZiZTlkNzkxMjA3YzhjYWUwOGZjNg==
4
+ ZDQ2OGJiMzYxM2FkYWM5ZjZlNWViOWU1MjA3NWZiNGFlNDUyYjAyNQ==
5
5
  data.tar.gz: !binary |-
6
- NjFkM2ZmZGYxZjU5M2Y3ODJmYzVjZGM4OTI2M2I2ODg4OTJmMDNmNw==
6
+ ZDlhOTM3MGFmNTEwZjk1YTM3NTlkYzM5MDE1ODBmMjlhMTcyYTU0OA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MWU0Mzc2ZDc3Mzg3NTRjODJmNGQ1YTY0YTg5NGVhOWJhZWVmNDhhMDA0NjUw
10
- ZDU4YWRkYmE0MjllZjM1YWU4ZjhjMGNkMzM3MjFkMzIxNTcwMzM4YzhjODZl
11
- NDFjZmM1OTNhZDc4MGM2YmFhMTQ2Mzc2YWZjMDFlYWU3NjE5ZDU=
9
+ OGVhM2QzYTVmNzMyMjM4ZGJkN2RjY2EyNmQ4YzViMTZhYTBiNDUxOWQ3MzE2
10
+ ZGQ1Zjc1ZmIzNWU1NjFhOGRmZDIyOTIzNDQ2N2YxYzgwOTRmMjU1ZWFlOWEz
11
+ MjlkMDBkY2UzMzUzNmU5OTE3ZDQwMzRlMmE2YTZkMmMwNGMwZTE=
12
12
  data.tar.gz: !binary |-
13
- MzM0MjI0MDhlOTdiZjY1YjE4YjY3ODNlYTg1N2E1MTY2MmRjZjJkZWZjYWQx
14
- YjQ3MmMyNWQ0ZTVlODc1ODVhMGIyYjZkMDIxYWVhNGZjMzNmNThmMmEyMjBi
15
- MDQ4NzRiNzExNjZhNTcwZmViZWFlZmQ1ODM1ZjM2ZGM4YmJkNWI=
13
+ YjhkZDU3YTAyNmE2MDFkMWUzODk2NzJlMmJmZWI0NmZhZjI5YTU1YjRhNzc3
14
+ OWZiMWVlNzAyMWEyNWI2MzY4NWNhYTdlNjdhNTRlNWM4YjkwYTI4NGE3YTNh
15
+ ZDY4ZDQ1ZjkxNTIwM2JhNTJlMjI4NmZmNDRhZmRlNjhhMGE0ODA=
data/Gemfile CHANGED
@@ -4,7 +4,6 @@ gemspec
4
4
 
5
5
 
6
6
  gem 'wash_out', git: 'git://github.com/inossidabile/wash_out.git'
7
- gem 'virtus'
8
7
  gem 'wasabi'
9
8
  gem 'savon'
10
9
  gem 'httpi'
data/README.rdoc CHANGED
@@ -25,7 +25,6 @@ The way WashOut is used is not modified, it just extends its functionality by ge
25
25
  1. {Ruby 1.9.x or Ruby 2.0.x}[http://www.ruby-lang.org]
26
26
  2. {Ruby on Rails}[http://rubyonrails.org].
27
27
  3. {WashOut Gem version >= 0.9.1}[https://github.com/inossidabile/wash_out]
28
- 4. {Virtus Gem}[https://github.com/solnic/virtus]
29
28
 
30
29
  = Compatibility
31
30
 
@@ -105,47 +104,7 @@ Here is an example :
105
104
  :description => "some description about this method to show in the documentation"
106
105
 
107
106
 
108
- The exception classes used <b>must inherit</b> from <tt>WashOut::Dispatcher::SOAPError</tt>, which has by default a error code and a message as attributes but you can extend it by adding more attributes to your own custom class.
109
-
110
- The WashOut::SoapError now includes Virtus.model from +virtus+ gem. This way you can add attributes like this:
111
-
112
- class MyCustomSoapError < WashOut::Dispatcher::SOAPError
113
-
114
- attribute :custom_attribute, String
115
- attribute :other_custom_attribute, Integer
116
-
117
- end
118
-
119
- You can also specify complex types like this:
120
-
121
- class MyCustomSoapError < WashOut::Dispatcher::SOAPError
122
-
123
- attribute :errors,Array[Integer]
124
- attribute :custom, Array[MyCustomModel]
125
- attribute :custom2, MyCustomModel
126
-
127
- end
128
-
129
- <b>The class MyCustomModel must include +Virtus.model+ or +Virtus.value_object+ or it must include at least one module that includes +Virtus.module+ if you want it to show up in the documentation!
130
- Please checkout {Virtus Gem}[https://github.com/solnic/virtus] for further documentation!</b>
131
-
132
- You can also use aggregation with another fault class exception like this:
133
-
134
- class MyCustomSoapError < WashOut::Dispatcher::SOAPError
135
-
136
- attribute :errors, Array[MyOtherCustomSoapError]
137
-
138
- end
139
-
140
- And you can also use inheritance between custom exception classes like this:
141
-
142
- class MySecondCustomSoapError < MyCustomSoapError
143
-
144
- atribute :option , String
145
-
146
- end
147
-
148
- And you will see in the documentation that the class +MySecondCustomSoapError+ will extend +MyCustomSoapError+
107
+ The exception classes used <b>must inherit</b> from <tt>WashOut::Dispatcher::SOAPError</tt>, which has by default a error code and a message as attributes .
149
108
 
150
109
  = Testing
151
110
 
@@ -194,7 +194,6 @@ module WashoutBuilderHelper
194
194
  end
195
195
 
196
196
  def create_html_public_method_arguments(xml, pre, operation, formats)
197
- xml.span("class" => "bold") {|y| y << "#{operation} (" }
198
197
  mlen = formats[:builder_in].size
199
198
  xml.br if mlen > 1
200
199
  spacer = "&nbsp;&nbsp;&nbsp;&nbsp;"
@@ -234,6 +233,7 @@ module WashoutBuilderHelper
234
233
 
235
234
  xml.p("class" => "pre"){ |pre|
236
235
  create_html_public_method_return_type(xml,pre, formats)
236
+ xml.span("class" => "bold") {|y| y << "#{operation} (" }
237
237
  create_html_public_method_arguments(xml, pre, operation, formats)
238
238
  }
239
239
  xml.p "#{formats[:description]}" if !formats[:description].blank?
@@ -1,6 +1,6 @@
1
1
  module WashoutBuilder
2
2
  module Document
3
- module VirtusModel
3
+ module ExceptionModel
4
4
  extend ActiveSupport::Concern
5
5
  include WashoutBuilder::Document::SharedComplexType
6
6
 
@@ -56,22 +56,47 @@ module WashoutBuilder
56
56
  complex_class
57
57
  end
58
58
 
59
-
59
+
60
+ def get_exception_attributes
61
+ attrs = self.instance_methods.find_all do |method|
62
+ method != :== &&
63
+ method != :! &&
64
+ self.instance_methods.include?(:"#{method}=")
65
+ end
66
+ attrs.concat(["message", "backtrace"])
67
+ end
68
+
69
+
60
70
  def get_virtus_model_structure
61
- attribute_set.inject({}) {|h, elem| h["#{elem.name}"]= { :primitive => "#{elem.primitive}", :member_type => elem.options[:member_type].nil? ? nil: elem.options[:member_type].primitive }; h }
71
+ h = {}
72
+ get_exception_attributes.each do |method_name|
73
+ primitive_type = case method_name.to_s.downcase
74
+ when "code"
75
+ "integer"
76
+ when "message", "backtrace"
77
+ "string"
78
+ else
79
+ "string"
80
+ end
81
+ h["#{method_name}"]= {
82
+ :primitive => "#{primitive_type}",
83
+ :member_type => nil
84
+ }
85
+ end
86
+ return h
62
87
  end
63
88
 
64
89
 
65
90
  def self.extract_nested_complex_types(complex_class, complex_types)
66
- unless complex_class.nil?
67
- param_class = complex_class.is_a?(Class) ? complex_class : complex_class.constantize rescue nil
68
- if param_class.present? && param_class.ancestors.include?(Virtus::Model::Core)
69
- param_class.send :extend, WashoutBuilder::Document::VirtusModel
70
- param_class.get_fault_class_ancestors( complex_types)
71
- elsif param_class.present? && !param_class.ancestors.include?(Virtus::Model::Core)
72
- raise RuntimeError, "Non-existent use of `#{param_class}` type name or this class does not use Virtus.model. Consider using classified types that include Virtus.mode for exception atribute types."
73
- end
74
- end
91
+ unless complex_class.nil?
92
+ param_class = complex_class.is_a?(Class) ? complex_class : complex_class.constantize rescue nil
93
+ if param_class.present? && WashoutBuilder::Type.valid_fault_class?(param_class)
94
+ param_class.send :extend, WashoutBuilder::Document::ExceptionModel
95
+ param_class.get_fault_class_ancestors( complex_types)
96
+ elsif param_class.present? && !WashoutBuilder::Type.valid_fault_class?(param_class)
97
+ raise RuntimeError, "Non-existent use of `#{param_class}` type name or this class does not inherit from SoapError. Consider using classified types that include SoapError for exception classes."
98
+ end
99
+ end
75
100
  end
76
101
 
77
102
  end
@@ -1,4 +1,4 @@
1
- require_relative "./virtus_model"
1
+ require_relative "./exception_model"
2
2
  module WashoutBuilder
3
3
  module Document
4
4
  class Generator
@@ -117,7 +117,7 @@ module WashoutBuilder
117
117
  fault_types.each do |hash|
118
118
  hash[:structure].each do |attribute, attr_details|
119
119
  complex_class = hash[:fault].get_virtus_member_type_primitive(attr_details)
120
- WashoutBuilder::Document::VirtusModel.extract_nested_complex_types(complex_class, complex_types)
120
+ WashoutBuilder::Document::ExceptionModel.extract_nested_complex_types(complex_class, complex_types)
121
121
  end
122
122
  end
123
123
  complex_types
@@ -1,3 +1,3 @@
1
1
  module WashoutBuilder
2
- VERSION = "0.12.4"
2
+ VERSION = "0.13.0"
3
3
  end
@@ -1,37 +1,20 @@
1
1
  require 'wash_out'
2
- require 'virtus'
3
2
  require 'washout_builder/soap'
4
3
  require 'washout_builder/engine'
5
4
  require 'washout_builder/document/shared_complex_type'
6
5
  require 'washout_builder/document/complex_type'
7
- require 'washout_builder/document/virtus_model'
6
+ require 'washout_builder/document/exception_model'
8
7
  require 'washout_builder/document/generator'
9
8
  require 'washout_builder/type'
10
9
  require 'washout_builder/version'
11
10
 
12
11
 
13
-
14
- Virtus::InstanceMethods::Constructor.class_eval do
15
- alias_method :original_initialize,:initialize
16
- def initialize(attributes = nil)
17
- if WashoutBuilder::Type.valid_fault_class?(self.class)
18
- attributes = {:message => attributes} unless attributes.is_a?(Hash)
19
- end
20
- original_initialize(attributes)
21
- end
22
- end
23
-
24
-
25
12
  WashOut::Param.send :include, WashoutBuilder::Document::ComplexType
26
13
 
27
14
 
28
15
  WashoutBuilder::Type.get_fault_classes.each do |exception_class|
29
16
  exception_class.class_eval do
30
- extend WashoutBuilder::Document::VirtusModel
31
- include Virtus.model
32
- attribute :code, Integer
33
- attribute :message, String
34
- attribute :backtrace, String
17
+ extend WashoutBuilder::Document::ExceptionModel
35
18
  end
36
19
  end
37
20
 
@@ -5,14 +5,14 @@ class SOAPError < WashOut::Dispatcher::SOAPError
5
5
 
6
6
  end
7
7
 
8
- describe WashoutBuilder::Document::VirtusModel do
8
+ describe WashoutBuilder::Document::ExceptionModel do
9
9
 
10
10
  let(:subject) { SOAPError}
11
11
 
12
12
 
13
13
 
14
14
  it "gets the strcuture" do
15
- subject.get_virtus_model_structure.should eq({"code"=>{:primitive=>"Integer", :member_type=>nil}, "message"=>{:primitive=>"String", :member_type=>nil}, "backtrace"=>{:primitive=>"String", :member_type=>nil}})
15
+ subject.get_virtus_model_structure.should eq({"code"=>{:primitive=>"integer", :member_type=>nil}, "message"=>{:primitive=>"string", :member_type=>nil}, "backtrace"=>{:primitive=>"string", :member_type=>nil}})
16
16
  end
17
17
 
18
18
  it "gets the member type for arrays" do
@@ -29,7 +29,7 @@ describe WashoutBuilder::Document::VirtusModel do
29
29
 
30
30
 
31
31
  it "gets the strcuture" do
32
- subject.remove_fault_type_inheritable_elements(["code"]).should eq({ "message"=>{:primitive=>"String", :member_type=>nil}, "backtrace"=>{:primitive=>"String", :member_type=>nil}})
32
+ subject.remove_fault_type_inheritable_elements(["code"]).should eq({ "message"=>{:primitive=>"string", :member_type=>nil}, "backtrace"=>{:primitive=>"string", :member_type=>nil}})
33
33
  end
34
34
 
35
35
  end
@@ -1,12 +1,14 @@
1
1
  #encoding:utf-8
2
2
  require 'spec_helper'
3
3
  mock_controller do
4
- soap_action 'dispatcher_method', :args => nil, :return => nil
4
+ soap_service namespace: "/api/wsdl", description: "some description"
5
+
6
+ soap_action 'dispatcher_method', :args => nil, :return => nil
5
7
 
6
- def dispatcher_method
7
- #nothing
8
- end
9
- end
8
+ def dispatcher_method
9
+ #nothing
10
+ end
11
+ end
10
12
 
11
13
  describe WashoutBuilder::Document::Generator do
12
14
 
@@ -22,32 +24,12 @@ describe WashoutBuilder::Document::Generator do
22
24
  }
23
25
  }
24
26
  let(:service_class) { ApiController }
25
- let(:attributes) {
26
- {
27
- :config => soap_config,
28
- :service_class => service_class,
29
- :soap_actions => soap_actions
30
- }}
31
-
32
27
  before(:each) do
33
- @document = WashoutBuilder::Document::Generator.new(attributes)
34
- end
35
-
36
- context "initialize" do
37
-
38
- it "sets the config " do
39
- @document.config.should eq(soap_config)
40
- end
41
-
42
- it "sets the service_class " do
43
- @document.service_class.should eq(service_class)
44
- end
45
-
46
- it "sets the soap_actions " do
47
- @document.soap_actions.should eq(soap_actions)
48
- end
28
+ @document = WashoutBuilder::Document::Generator.new("api")
29
+ @document.stubs(:controller_class).returns(service_class)
49
30
 
50
31
  end
32
+
51
33
 
52
34
 
53
35
  context "namespace" do
@@ -595,9 +595,6 @@ describe WashoutBuilder do
595
595
 
596
596
  end
597
597
 
598
- it "intanstiates correctly a custom exception" do
599
- soap_exception.attributes.should eq({:code=>error_code, :message=>error_message, :backtrace=>nil})
600
- end
601
598
  end
602
599
 
603
600
 
@@ -16,5 +16,4 @@ Gem::Specification.new do |s|
16
16
  s.test_files = s.files.grep(/^(spec)/)
17
17
  s.require_paths = ["lib"]
18
18
  s.add_runtime_dependency 'wash_out', '~> 0.9', '>= 0.9.1'
19
- s.add_runtime_dependency 'virtus', '~> 1.0', '>= 1.0.0'
20
19
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: washout_builder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.4
4
+ version: 0.13.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - bogdanRada
@@ -30,26 +30,6 @@ dependencies:
30
30
  - - ! '>='
31
31
  - !ruby/object:Gem::Version
32
32
  version: 0.9.1
33
- - !ruby/object:Gem::Dependency
34
- name: virtus
35
- requirement: !ruby/object:Gem::Requirement
36
- requirements:
37
- - - ~>
38
- - !ruby/object:Gem::Version
39
- version: '1.0'
40
- - - ! '>='
41
- - !ruby/object:Gem::Version
42
- version: 1.0.0
43
- type: :runtime
44
- prerelease: false
45
- version_requirements: !ruby/object:Gem::Requirement
46
- requirements:
47
- - - ~>
48
- - !ruby/object:Gem::Version
49
- version: '1.0'
50
- - - ! '>='
51
- - !ruby/object:Gem::Version
52
- version: 1.0.0
53
33
  description: ! 'WashOut Soap Service HTML-Documentation generator (extends WashOut
54
34
  https://github.com/inossidabile/wash_out/) '
55
35
  email: raoul_ice@yahoo.com
@@ -75,9 +55,9 @@ files:
75
55
  - init.rb
76
56
  - lib/washout_builder.rb
77
57
  - lib/washout_builder/document/complex_type.rb
58
+ - lib/washout_builder/document/exception_model.rb
78
59
  - lib/washout_builder/document/generator.rb
79
60
  - lib/washout_builder/document/shared_complex_type.rb
80
- - lib/washout_builder/document/virtus_model.rb
81
61
  - lib/washout_builder/engine.rb
82
62
  - lib/washout_builder/soap.rb
83
63
  - lib/washout_builder/type.rb
@@ -110,8 +90,8 @@ files:
110
90
  - spec/dummy/public/stylesheets/.gitkeep
111
91
  - spec/dummy/script/rails
112
92
  - spec/lib/washout_builder/document/complex_type_spec.rb
93
+ - spec/lib/washout_builder/document/exception_model_spec.rb
113
94
  - spec/lib/washout_builder/document/generator_spec.rb
114
- - spec/lib/washout_builder/document/virtus_model_spec.rb
115
95
  - spec/lib/washout_builder/type_spec.rb
116
96
  - spec/lib/washout_builder_spec.rb
117
97
  - spec/spec_helper.rb
@@ -119,13 +99,6 @@ files:
119
99
  - spec/support/complex_types/fluffy_container.rb
120
100
  - spec/support/complex_types/project_type.rb
121
101
  - spec/support/complex_types/test_type.rb
122
- - spec/support/exceptions/another_exception.rb
123
- - spec/support/exceptions/base_exception.rb
124
- - spec/support/exceptions/custom2.rb
125
- - spec/support/exceptions/ex_model.rb
126
- - spec/support/exceptions/name_mod.rb
127
- - spec/support/exceptions/name_model.rb
128
- - spec/support/exceptions/value_object_model.rb
129
102
  - washout_builder.gemspec
130
103
  homepage: http://github.com/bogdanRada/washout_builder/
131
104
  licenses:
@@ -180,8 +153,8 @@ test_files:
180
153
  - spec/dummy/public/stylesheets/.gitkeep
181
154
  - spec/dummy/script/rails
182
155
  - spec/lib/washout_builder/document/complex_type_spec.rb
156
+ - spec/lib/washout_builder/document/exception_model_spec.rb
183
157
  - spec/lib/washout_builder/document/generator_spec.rb
184
- - spec/lib/washout_builder/document/virtus_model_spec.rb
185
158
  - spec/lib/washout_builder/type_spec.rb
186
159
  - spec/lib/washout_builder_spec.rb
187
160
  - spec/spec_helper.rb
@@ -189,10 +162,3 @@ test_files:
189
162
  - spec/support/complex_types/fluffy_container.rb
190
163
  - spec/support/complex_types/project_type.rb
191
164
  - spec/support/complex_types/test_type.rb
192
- - spec/support/exceptions/another_exception.rb
193
- - spec/support/exceptions/base_exception.rb
194
- - spec/support/exceptions/custom2.rb
195
- - spec/support/exceptions/ex_model.rb
196
- - spec/support/exceptions/name_mod.rb
197
- - spec/support/exceptions/name_model.rb
198
- - spec/support/exceptions/value_object_model.rb
@@ -1,7 +0,0 @@
1
- class AnotherException < WashOut::Dispatcher::SOAPError
2
-
3
- attribute :ex3_name, String
4
- attribute :ex3_id, Integer
5
-
6
- end
7
-
@@ -1,15 +0,0 @@
1
- Dir["#{File.dirname(__FILE__)}/**/*.rb"].each { |f| require f }
2
- class BaseException < AnotherException
3
-
4
- attribute :custom_attribute, String
5
- attribute :other_custom_attribute, Integer
6
- attribute :errors,Array[Integer]
7
- attribute :custom, Array[ExModel]
8
- attribute :custom2, ExModel
9
- attribute :errors_2, Array[Custom2]
10
- attribute :error, Custom2
11
- attribute :module, NameModel
12
- attribute :geo, ValueObjectModel
13
-
14
- end
15
-
@@ -1,7 +0,0 @@
1
- class Custom2 < WashOut::Dispatcher::SOAPError
2
-
3
- attribute :ex2_name, String
4
- attribute :ex2_id, Integer
5
-
6
- end
7
-
@@ -1,8 +0,0 @@
1
- class ExModel
2
- include Virtus.model
3
-
4
- attribute :name, String
5
- attribute :id, Integer
6
-
7
- end
8
-
@@ -1,5 +0,0 @@
1
- module NameMod
2
- include Virtus.module
3
-
4
- attribute :name, String
5
- end
@@ -1,5 +0,0 @@
1
- require_relative "./name_mod"
2
-
3
- class NameModel
4
- include NameMod
5
- end
@@ -1,8 +0,0 @@
1
- class ValueObjectModel
2
- include Virtus.value_object
3
-
4
- values do
5
- attribute :latitude, Float
6
- attribute :longitude, Float
7
- end
8
- end