washout_builder 1.7.4 → 2.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +15 -14
  3. data/Appraisals +8 -2
  4. data/README.md +22 -1
  5. data/Rakefile +3 -3
  6. data/app/controllers/washout_builder/washout_builder_controller.rb +9 -9
  7. data/app/helpers/washout_builder_complex_type_helper.rb +4 -2
  8. data/app/helpers/washout_builder_method_arguments_helper.rb +4 -2
  9. data/app/helpers/washout_builder_method_list_helper.rb +4 -2
  10. data/app/helpers/washout_builder_method_return_type_helper.rb +6 -4
  11. data/app/helpers/washout_builder_shared_helper.rb +29 -0
  12. data/app/views/wash_with_html/doc.builder +6 -6
  13. data/gemfiles/rails_6.1.3.gemfile +8 -0
  14. data/install-travis-bundler.sh +12 -10
  15. data/lib/washout_builder.rb +0 -1
  16. data/lib/washout_builder/document/complex_type.rb +35 -54
  17. data/lib/washout_builder/document/exception_model.rb +17 -18
  18. data/lib/washout_builder/document/generator.rb +6 -6
  19. data/lib/washout_builder/engine.rb +1 -0
  20. data/lib/washout_builder/env_checker.rb +2 -2
  21. data/lib/washout_builder/soap.rb +2 -2
  22. data/lib/washout_builder/version.rb +2 -2
  23. data/spec/app/controllers/washout_builder_controller_spec.rb +4 -4
  24. data/spec/dummy/app/views/layouts/application.html.erb +1 -1
  25. data/spec/dummy/public/404.html +1 -1
  26. data/spec/dummy/public/422.html +1 -1
  27. data/spec/dummy/public/500.html +1 -1
  28. data/spec/lib/washout_builder/document/complex_type_spec.rb +32 -36
  29. data/spec/lib/washout_builder/document/exception_model_spec.rb +5 -5
  30. data/spec/spec_helper.rb +37 -2
  31. data/spec/support/complex_types/test_type.rb +1 -2
  32. data/washout_builder.gemspec +3 -2
  33. metadata +55 -60
  34. data/lib/washout_builder/param.rb +0 -50
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c096f4d12d0323f4e903fc0b9a062a9994d0d8378aa8d596ddc9e485a63d66f8
4
- data.tar.gz: cc4083f364a1b75ebdf184967a07c8529f26fb3958200d3aa3b2c9f26c2a285b
3
+ metadata.gz: 31e9ca2912acbfe0b0abde89e74ae2f2c5b7f89bcdf9a9a92054e6e7ed3d7017
4
+ data.tar.gz: 0f9eb779de5e243f47d6464f9d6e0c45790c64053b3f4b75f94431ef328ee8dd
5
5
  SHA512:
6
- metadata.gz: 0230faa4b0fc98e3ad5390ec0e5b42320cda08c3c76751136cc76c85d14f02d430b5d63d11d836257bf8e4d047415ce034c8bf5c47f17fdf2b05bded1cbe7aca
7
- data.tar.gz: 384c3ae8f533fe710a7470905827a4d4f292b772dddd4049c261b9c6973d0c39e67df9cccc4813a2d3954a86094a907b748ff27f84a7d36732365ef14b748839
6
+ metadata.gz: 6c95a39a250f9fa4bb7d4e0d276f69b8bbf3a02441698f93214d56d32110cb26366897198c7b1da78665a34148ef9062fa07872add72222bc6203cd6d2ca11b3
7
+ data.tar.gz: 2e40ae1202131d8bdec1f30a91107be0477c7636d53be584f6bf4a6eec46ec996aa2f637d090b259126050e6d589ad83274dc6b5bf2121f334fda01dc1c3919d
data/.travis.yml CHANGED
@@ -1,30 +1,29 @@
1
1
  language: ruby
2
- sudo: false
3
2
 
4
3
  cache: bundler
5
4
 
6
5
  bundler_args: --no-deployment --binstubs=./bin
7
6
 
8
7
  before_install:
9
- -"echo 'gem: --no-ri --no-rdoc' > ~/.gemrc"
10
- - gem update --system
8
+ - "echo 'gem: --no-ri --no-rdoc' > ~/.gemrc"
9
+ - rvm rubygems current
10
+ - gem update --system || true
11
11
  - gem --version
12
- - bash ./install-travis-bundler.sh
13
- - bundle --version
12
+ - source ./install-travis-bundler.sh
13
+ - bundle ${MY_BUNDLER_VERSION} --version
14
14
 
15
15
  install:
16
- - bundle config --local path vendor/bundle
17
- - bundle config --local jobs 3
18
- - bundle config --local retry 3
19
- - bundle config --local binstubs ./bin
20
- - bundle config --local bin ./bin
21
- - bundle install
16
+ - bundle ${MY_BUNDLER_VERSION} config --local jobs 3
17
+ - bundle ${MY_BUNDLER_VERSION} config --local retry 3
18
+ - bundle ${MY_BUNDLER_VERSION} config --local binstubs ./bin
19
+ - bundle ${MY_BUNDLER_VERSION} config --local bin ./bin
20
+ - bundle ${MY_BUNDLER_VERSION} install
22
21
  - gem env
23
- - bundle env
22
+ - bundle ${MY_BUNDLER_VERSION} env
24
23
 
25
24
  script:
26
25
  - echo $BUNDLE_GEMFILE
27
- - bundle exec rake
26
+ - bundle ${MY_BUNDLER_VERSION} exec rake
28
27
 
29
28
  gemfile:
30
29
  - gemfiles/rails_4.0.0.gemfile
@@ -59,7 +58,7 @@ matrix:
59
58
  - rvm: 2.6.5
60
59
  gemfile: gemfiles/rails_4.1.1.gemfile
61
60
  - rvm: 2.6.5
62
- gemfile: gemfiles/rails_4.2.0.gemfile
61
+ gemfile: gemfiles/rails_4.2.0.gemfile
63
62
  rvm:
64
63
  - 2.2.5
65
64
  - 2.3.1
@@ -68,5 +67,7 @@ rvm:
68
67
  - 2.4.7
69
68
  - 2.5.6
70
69
  - 2.6.5
70
+ - 2.7.1
71
+ - 3.0.0
71
72
  notifications:
72
73
  email: false
data/Appraisals CHANGED
@@ -17,7 +17,7 @@ if RUBY_VERSION <= "2.4.0"
17
17
  gem 'actionpack' , '4.2.7.1'
18
18
  end
19
19
  end
20
- if RUBY_VERSION >= '2.2.0' && ENV['BUNDLER_VERSION'].to_s <= '2.0'
20
+ if RUBY_VERSION >= '2.2.0' && RUBY_VERSION < '3.0.0' && ENV['BUNDLER_VERSION'].to_s <= '2.0'
21
21
  appraise "rails-5.0.0" do
22
22
  gem "rails", "5.0.0"
23
23
  end
@@ -40,7 +40,7 @@ if RUBY_VERSION >= '2.2.0' && ENV['BUNDLER_VERSION'].to_s <= '2.0'
40
40
  end
41
41
  end
42
42
 
43
- if RUBY_VERSION >= '2.2.0' && ENV['BUNDLER_VERSION'].to_s >= '2.0'
43
+ if RUBY_VERSION >= '2.2.0' && RUBY_VERSION < '3.0.0' && ENV['BUNDLER_VERSION'].to_s >= '2.0'
44
44
  appraise "rails-5.2.0" do
45
45
  gem "rails", "5.2.0"
46
46
  end
@@ -57,3 +57,9 @@ if RUBY_VERSION >= '2.2.0' && ENV['BUNDLER_VERSION'].to_s >= '2.0'
57
57
  gem "rails", "6.0.1"
58
58
  end
59
59
  end
60
+
61
+ if RUBY_VERSION >= '3.0.0' && ENV['BUNDLER_VERSION'].to_s >= '2.0'
62
+ appraise "rails-6.1.3" do
63
+ gem "rails", "6.1.3"
64
+ end
65
+ end
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  washout_builder
2
2
  ===============
3
3
 
4
- [![Gem Version](https://badge.fury.io/rb/washout_builder.svg)](http://badge.fury.io/rb/washout_builder) [![Build Status](https://travis-ci.org/bogdanRada/washout_builder.png?branch=master,develop)](https://travis-ci.org/bogdanRada/washout_builder) [![Dependency Status](https://gemnasium.com/bogdanRada/washout_builder.svg)](https://gemnasium.com/bogdanRada/washout_builder) [![Documentation Status](http://inch-ci.org/github/bogdanRada/washout_builder.svg?branch=master)](http://inch-ci.org/github/bogdanRada/washout_builder) [![Coverage Status](https://coveralls.io/repos/bogdanRada/washout_builder/badge.svg?branch=master)](https://coveralls.io/r/bogdanRada/washout_builder?branch=master) [![Code Climate](https://codeclimate.com/github/bogdanRada/washout_builder/badges/gpa.svg)](https://codeclimate.com/github/bogdanRada/washout_builder) [![Repo Size](https://reposs.herokuapp.com/?path=bogdanRada/washout_builder)](https://github.com/bogdanRada/washout_builder) [![Gem Downloads](https://ruby-gem-downloads-badge.herokuapp.com/washout_builder?type=total)](https://github.com/bogdanRada/washout_builder) [![Analytics](https://ga-beacon.appspot.com/UA-72570203-1/bogdanRada/washout_builder)](https://github.com/bogdanRada/washout_builder)
4
+ [![Gem Version](https://badge.fury.io/rb/washout_builder.svg)](http://badge.fury.io/rb/washout_builder) [![Build Status](https://travis-ci.org/bogdanRada/washout_builder.png?branch=master,develop)](https://travis-ci.org/bogdanRada/washout_builder) [![Documentation Status](http://inch-ci.org/github/bogdanRada/washout_builder.svg?branch=master)](http://inch-ci.org/github/bogdanRada/washout_builder) [![Coverage Status](https://coveralls.io/repos/bogdanRada/washout_builder/badge.svg?branch=master)](https://coveralls.io/r/bogdanRada/washout_builder?branch=master) [![Code Climate](https://codeclimate.com/github/bogdanRada/washout_builder/badges/gpa.svg)](https://codeclimate.com/github/bogdanRada/washout_builder) [![Repo Size](https://reposs.herokuapp.com/?path=bogdanRada/washout_builder)](https://github.com/bogdanRada/washout_builder) [![Gem Downloads](https://ruby-gem-downloads-badge.herokuapp.com/washout_builder?type=total)](https://github.com/bogdanRada/washout_builder)
5
5
 
6
6
  Overview
7
7
  --------
@@ -10,6 +10,27 @@ WashOutBuilder is a Soap Service Documentation generator (extends [WashOut](http
10
10
 
11
11
  The way [WashOut](https://github.com/inossidabile/wash_out) is used is not modified, it just extends its functionality by generating html documentation to your services that you write
12
12
 
13
+ NEW Improvements in version 2.0.1
14
+ ---------------------------------
15
+ - Fix issue when trying to re-use same complex type (with same structure) multiple times inside same controller
16
+
17
+ NEW Improvements in version 2.0.0
18
+ ---------------------------------
19
+
20
+ This release tries to fix some major bugs and introduces backward incompatible changes.
21
+ - The complex type list will contain now exactly same types used when doing an actual SOAP request
22
+ - Same for when listing the soap actions ( the return type and parameters ).
23
+
24
+ Initially the way the complex types were shown on the page was not correct, because it was not reflecting
25
+ the actual way the SOAP action receives its arguments when doing an actual SOAP request to that controller
26
+
27
+ The main issue was not handling correctly the classes that are inheriting from WashOut::Type.
28
+
29
+ This release tries to fix those issues.
30
+
31
+ Note: Only internal methods have been changed. The configuration has not changed.
32
+ So in order to upgrade to this new version, just update the version in your Gemfile/gemspec file
33
+
13
34
  NEW Improvements in version 1.5.1
14
35
  ---------------------------------
15
36
 
data/Rakefile CHANGED
@@ -21,7 +21,7 @@ task :all do |_t|
21
21
  # require 'json'
22
22
  # puts JSON.pretty_generate(ENV.to_hash)
23
23
  if ENV['BUNDLE_GEMFILE'] =~ /gemfiles/
24
- appraisal_name = ENV['BUNDLE_GEMFILE'].scan(/rails\_(.*)\.gemfile/).flatten.first
24
+ appraisal_name = ENV['BUNDLE_GEMFILE'].scan(/rails_(.*)\.gemfile/).flatten.first
25
25
  command_prefix = "appraisal rails-#{appraisal_name}"
26
26
  exec ("#{command_prefix} bundle install && #{command_prefix} bundle exec rspec && bundle exec rake coveralls:push ")
27
27
  else
@@ -40,8 +40,8 @@ YARD::Config.load_plugins
40
40
  end
41
41
 
42
42
  YARD::Rake::YardocTask.new do |t|
43
- t.files = ['lib/**/*.rb', 'spec/**/*_spec.rb'] # optional
44
- t.options = ['--any', '--extra', '--opts', '--markup-provider=redcarpet', '--markup=markdown', '--debug'] # optional
43
+ t.files = %w(lib/**/*.rb spec/**/*_spec.rb) # optional
44
+ t.options = %w(--any --extra --opts --markup-provider=redcarpet --markup=markdown --debug) # optional
45
45
  t.stats_options = ['--list-undoc'] # optional
46
46
  end
47
47
 
@@ -23,7 +23,7 @@ module WashoutBuilder
23
23
  @document = WashoutBuilder::Document::Generator.new(route_details, controller_class(params[:name]).controller_path)
24
24
  @file_to_serve = 'wash_with_html/doc'
25
25
  render_html(@file_to_serve)
26
- elsif
26
+ else
27
27
  @services = all_services
28
28
  @file_to_serve = 'wash_with_html/all_services'
29
29
  render_html(@file_to_serve)
@@ -71,10 +71,10 @@ module WashoutBuilder
71
71
  controller_name = hash[:route].present? && hash[:route].respond_to?(:defaults) ? hash[:route].defaults[:controller] : nil
72
72
  if controller_name.present?
73
73
  {
74
- 'service_name' => controller_naming(controller_name),
75
- 'namespace' => service_namespace(hash, controller_name),
76
- 'endpoint' => service_endpoint(hash, controller_name),
77
- 'documentation_url' => service_documentation_url(hash, controller_name)
74
+ 'service_name' => controller_naming(controller_name),
75
+ 'namespace' => service_namespace(hash, controller_name),
76
+ 'endpoint' => service_endpoint(hash, controller_name),
77
+ 'documentation_url' => service_documentation_url(hash, controller_name)
78
78
  }
79
79
  end
80
80
  end.uniq{|hash| hash['service_name'] }
@@ -113,10 +113,10 @@ module WashoutBuilder
113
113
  engine_route = Rails.application.routes.named_routes[engine.engine_name]
114
114
  routes_hash_array = engine.routes.routes.map { |route|
115
115
  {
116
- engine: engine,
117
- route_set: engine.routes,
118
- route: route,
119
- mounted_at: engine_route.blank? ? nil : engine_route.path.spec.to_s
116
+ engine: engine,
117
+ route_set: engine.routes,
118
+ route: route,
119
+ mounted_at: engine_route.blank? ? nil : engine_route.path.spec.to_s
120
120
  }
121
121
  }
122
122
 
@@ -1,5 +1,6 @@
1
1
  # module that is used for constructing complex types in HTML-Documentation
2
2
  module WashoutBuilderComplexTypeHelper
3
+ include WashoutBuilderSharedHelper
3
4
  # this method is for printing the attributes of a complex type
4
5
  # if the attributes are primitives this will show the attributes with blue color
5
6
  # otherwise will call another method for printing the complex attribute
@@ -49,8 +50,9 @@ module WashoutBuilderComplexTypeHelper
49
50
  def create_complex_element_type_html(pre, element, element_description)
50
51
  complex_class = element.find_complex_class_name
51
52
  return if complex_class.nil?
52
- complex_class_content = element.multiplied == false ? "#{complex_class}" : "Array of #{complex_class}"
53
- pre << "<a href='##{complex_class}'><span class='lightBlue'>#{complex_class_content}</span></a>&nbsp;<span class='bold'>#{element.name}</span>"
53
+ real_class = find_correct_complex_type(complex_class)
54
+ complex_class_content = element.multiplied ? "Array of #{real_class}" : "#{real_class}"
55
+ pre << "<a href='##{real_class}'><span class='lightBlue'>#{complex_class_content}</span></a>&nbsp;<span class='bold'>#{element.name}</span>"
54
56
  pre << "&#8194;<span>#{html_safe(element_description)}</span>" unless element_description.blank?
55
57
  pre
56
58
  end
@@ -1,5 +1,6 @@
1
1
  # helper that is used to show the arguments of a method with their types in HTML documentation
2
2
  module WashoutBuilderMethodArgumentsHelper
3
+ include WashoutBuilderSharedHelper
3
4
  # displays the parameter of a method as argument and determines if the parameter is basic type or complex type
4
5
  #
5
6
  # @see WashoutBuilder::Document::ComplexType#find_complex_class_name
@@ -37,8 +38,9 @@ module WashoutBuilderMethodArgumentsHelper
37
38
  # @api public
38
39
  def create_method_argument_complex_element(pre, param, use_spacer, spacer, complex_class)
39
40
  return if complex_class.nil?
40
- argument_content = param.multiplied == false ? "#{complex_class}" : "Array of #{complex_class}"
41
- pre << "#{use_spacer ? spacer : ''}<a href='##{complex_class}'><span class='lightBlue'>#{argument_content}</span></a>&nbsp;<span class='bold'>#{param.name}</span>"
41
+ real_class = find_correct_complex_type(complex_class)
42
+ argument_content = param.multiplied ? "Array of #{real_class}" : "#{real_class}"
43
+ pre << "#{use_spacer ? spacer : ''}<a href='##{real_class}'><span class='lightBlue'>#{argument_content}</span></a>&nbsp;<span class='bold'>#{param.name}</span>"
42
44
  end
43
45
 
44
46
  # this method will check if the current index of the argument is not last, will insert a comma then a break if the argument is followed by other arguments,
@@ -1,5 +1,6 @@
1
1
  # helper that is used to list the method's return tyep as a LI element in HTML documentation
2
2
  module WashoutBuilderMethodListHelper
3
+ include WashoutBuilderSharedHelper
3
4
  # this method will create the return type of the method and check if the type is basic or complex type or array of types
4
5
  #
5
6
  # @param [Builder::XmlMarkup] xml the markup builder that is used to insert HTML line breaks or span elements
@@ -10,9 +11,10 @@ module WashoutBuilderMethodListHelper
10
11
  #
11
12
  # @api public
12
13
  def create_return_complex_type_list_html(xml, complex_class, builder_out)
13
- return_content = builder_out[0].multiplied == false ? "#{complex_class}" : "Array of #{complex_class}"
14
+ real_class = find_correct_complex_type(complex_class)
15
+ return_content = builder_out[0].multiplied ? "Array of #{real_class}" : "#{real_class}"
14
16
  xml.span('class' => 'pre') do
15
- xml.a('href' => "##{complex_class}") do |inner_xml|
17
+ xml.a('href' => "##{real_class}") do |inner_xml|
16
18
  inner_xml.span('class' => 'lightBlue') do |y|
17
19
  y << "#{return_content}"
18
20
  end
@@ -1,5 +1,6 @@
1
1
  # helper that is used to create the return types of methods in HTML documentation
2
2
  module WashoutBuilderMethodReturnTypeHelper
3
+ include WashoutBuilderSharedHelper
3
4
  # this method will print the return type next to the method name
4
5
  # @see WashoutBuilder::Document::ComplexType#find_complex_class_name
5
6
  # @see WashoutBuilder::Type::BASIC_TYPES
@@ -37,11 +38,12 @@ module WashoutBuilderMethodReturnTypeHelper
37
38
  # @api public
38
39
  def html_public_method_complex_type(pre, output, complex_class)
39
40
  return if complex_class.nil?
40
- if output[0].multiplied == false
41
- complex_return_type = "#{complex_class}"
41
+ real_class = find_correct_complex_type(complex_class)
42
+ if output[0].multiplied
43
+ complex_return_type = "Array of #{real_class}"
42
44
  else
43
- complex_return_type = "Array of #{complex_class}"
45
+ complex_return_type = "#{real_class}"
44
46
  end
45
- pre << "<a href='##{complex_class}'><span class='lightBlue'>#{complex_return_type}</span></a>"
47
+ pre << "<a href='##{real_class}'><span class='lightBlue'>#{complex_return_type}</span></a>"
46
48
  end
47
49
  end
@@ -0,0 +1,29 @@
1
+ module WashoutBuilderSharedHelper
2
+ # When displaying a complex type that inherits from WashOut::Type
3
+ # we must use its descendant name to properly show the correct Type
4
+ # that can we used to make the actual request to the action
5
+ #
6
+ # @param [Class, String] complex_class the name of the complex type either as a string or a class
7
+ # @return [Class, String]
8
+ # @api public
9
+ def find_correct_complex_type(complex_class)
10
+ real_class = find_class_from_string(complex_class)
11
+ if real_class.present? && real_class.ancestors.include?( WashoutBuilder::Type.base_type_class)
12
+ descendant = WashoutBuilder::Type.base_param_class.parse_def(config, real_class.wash_out_param_map)[0]
13
+ descendant.find_complex_class_name
14
+ else
15
+ complex_class
16
+ end
17
+ end
18
+
19
+ # Tries to constantize a string or a class to return the class
20
+ #
21
+ # @param [String] complex_class A string that contains the name of a class
22
+ # @return [Class, nil] returns the class if it is classes_defined otherwise nil
23
+ # @api public
24
+ def find_class_from_string(complex_class)
25
+ complex_class.is_a?(Class) ? complex_class : complex_class.constantize
26
+ rescue
27
+ nil
28
+ end
29
+ end
@@ -33,16 +33,16 @@ xml.html( "xmlns" => "http://www.w3.org/1999/xhtml" ) {
33
33
 
34
34
  xml.h1 "#{ @document.service} Soap WebService interface description"
35
35
 
36
- xml.p{ |y| y << "Endpoint URI:";
36
+ xml.p{ |y| y << "Endpoint URI:"
37
37
  xml.span( "class" => "pre") {
38
- xml.a( "href" => "#{@document.endpoint}") { |y| y << "#{@document.endpoint}" }
39
- };
38
+ xml.a( "href" => "#{@document.endpoint}") { |out| out << "#{@document.endpoint}" }
39
+ }
40
40
  }
41
41
 
42
- xml.p{ |y| y << "WSDL URI:";
42
+ xml.p{ |y| y << "WSDL URI:"
43
43
  xml.span( "class" => "pre") {
44
- xml.a( "href" => "#{@document.namespace}") { |y| y << "#{@document.namespace}" }
45
- };
44
+ xml.a( "href" => "#{@document.namespace}") { |out| out << "#{@document.namespace}" }
45
+ }
46
46
  }
47
47
  xml.p ""
48
48
  unless @document.service_description.blank?
@@ -0,0 +1,8 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "http://rubygems.org"
4
+
5
+ gem "wash_out", git: "https://github.com/inossidabile/wash_out.git"
6
+ gem "rails", "6.1.3"
7
+
8
+ gemspec path: "../"
@@ -1,21 +1,23 @@
1
1
  #!/usr/bin/env bash
2
2
 
3
- set -o errexit
4
- set -o pipefail
5
- set -o nounset
3
+ # set -o errexit
4
+ # set -o pipefail
5
+ # set -o nounset
6
6
 
7
- rails_version="$(echo "$(basename $BUNDLE_GEMFILE .gemfile)" | sed 's/[^0-9.]*\([0-9.]*\).*/\1/')"
7
+ rails_version="$(basename "${BUNDLE_GEMFILE:="$(pwd)/Gemfile"}" .gemfile | sed 's/[^0-9.]*\([0-9.]*\).*/\1/')"
8
8
 
9
- echo "Trying to compare rails ${rails_version} with 5.1"
9
+ echo "Trying to compare rails ${rails_version:="1"} with 5.2"
10
10
 
11
- if (( $(echo "${rails_version%.*} >= 5.1" |bc -l) )); then
11
+ if (( $(echo "${rails_version%.*} >= 5.2" |bc -l) )); then
12
12
  echo "Installing Bundler v2"
13
- gem uninstall -v '< 2.0' -i $(rvm gemdir)@global -ax bundler --force || true
14
- gem install bundler -v '2.0.1'
13
+ gem uninstall -v '< 2.0' -i "$(rvm gemdir)"@global -ax bundler --force || true
14
+ gem install bundler -v '2.2.11'
15
+ export MY_BUNDLER_VERSION="_2.2.11_"
15
16
  else
16
17
  echo "Installing Bundler v1"
17
- gem uninstall -v '>= 2' -i $(rvm gemdir)@global -ax bundler --force || true
18
+ gem uninstall -v '>= 2' -i "$(rvm gemdir)"@global -ax bundler --force || true
18
19
  gem install bundler -v '1.17.3'
20
+ export MY_BUNDLER_VERSION="_1.17.3_"
19
21
  fi
20
22
 
21
- unset rails_version
23
+ unset rails_version
@@ -52,7 +52,6 @@ end
52
52
  base_param_class = WashoutBuilder::Type.base_param_class
53
53
  if base_param_class.present?
54
54
  base_param_class.class_eval do
55
- extend WashoutBuilder::Param
56
55
  include WashoutBuilder::Document::ComplexType
57
56
  end
58
57
  end
@@ -10,27 +10,27 @@ module WashoutBuilder
10
10
  # finds the complex class name of the current Washout::Param object and checks if is a duplicate
11
11
  # @see #check_duplicate_complex_class
12
12
  #
13
- # @param [Array] defined Array that is used for when iterating through descendants and ancestors
13
+ # @param [Array] classes_defined Array that is used for when iterating through descendants and ancestors
14
14
  #
15
15
  # @return [Class] the complex type name of the current object
16
16
  #
17
17
  # @api public
18
- def find_complex_class_name(defined = [])
18
+ def find_complex_class_name(classes_defined = [])
19
19
  complex_class = struct? ? basic_type.tr('.', '/').camelize : nil
20
- check_duplicate_complex_class(defined, complex_class) unless complex_class.nil? || defined.blank?
20
+ check_duplicate_complex_class(classes_defined, complex_class) unless complex_class.nil? || classes_defined.blank?
21
21
  complex_class
22
22
  end
23
23
 
24
24
  # checks if the complex class appears in the array of complex types
25
25
  #
26
- # @param [Array<Hash>] defined Array that is used for checking if a complex type is already defined
26
+ # @param [Array<Hash>] classes_defined Array that is used for checking if a complex type is already classes_defined
27
27
  # @param [Class] complex_class the complex type name used for searching
28
28
  #
29
29
  # @return [Boolean] returns true or false if the complex type is found inside the array
30
30
  # @raise [RuntimeError] Raises a runtime error if is detected a duplicate use of the complex type
31
31
  # @api public
32
- def check_duplicate_complex_class(defined, complex_class)
33
- complex_obj_found = defined.find { |hash| hash[:class] == complex_class }
32
+ def check_duplicate_complex_class(classes_defined, complex_class)
33
+ complex_obj_found = classes_defined.find { |hash| hash if hash[:class] == complex_class && hash[:obj].find_param_structure.keys != self.find_param_structure.keys }
34
34
  raise "Duplicate use of `#{basic_type}` type name. Consider using classified types." if !complex_obj_found.nil? && struct? && !classified?
35
35
  end
36
36
 
@@ -40,13 +40,13 @@ module WashoutBuilder
40
40
  #
41
41
  # @param [WashOut::SoapConfig] config the configuration of the soap service
42
42
  # @param [Clas] complex_class the complex type name of the object
43
- # @param [Array<Hash>] defined An array that holds all the complex types found so far
43
+ # @param [Array<Hash>] classes_defined An array that holds all the complex types found so far
44
44
  #
45
45
  # @return [Array<Class>, nil] returns nil if object not classified othewise an array of classes that are ancestors to curent object
46
46
  #
47
47
  # @api public
48
- def complex_type_ancestors(config, complex_class, defined)
49
- classified? ? get_class_ancestors(config, complex_class, defined) : nil
48
+ def complex_type_ancestors(config, complex_class, classes_defined)
49
+ classified? ? get_class_ancestors(config, complex_class, classes_defined) : nil
50
50
  end
51
51
 
52
52
  # iterates through all the elements of the current object
@@ -71,30 +71,11 @@ module WashoutBuilder
71
71
  self.map = map.delete_if { |element| keys.include?(element.name) }
72
72
  end
73
73
 
74
- # Dirty hack to fix the first washout param type.
75
- # This only applies if the first complex type is inheriting WashOutType
76
- # its name should be set to its descendant and the map of the current object will be set to its descendant
77
- # @see WashOut::Param#parse_builder_def
78
- #
79
- # @param [WashOut::SoapConfig] config an object that holds the soap configuration
80
- # @param [Class, String] complex_class the name of the complex type either as a string or a class
81
- # @return [void]
82
- # @api public
83
- def fix_descendant_wash_out_type(config, complex_class)
84
- param_class = find_class_from_string(complex_class)
85
- base_param_class = WashoutBuilder::Type.base_param_class
86
- base_type_class = WashoutBuilder::Type.base_type_class
87
- return if base_param_class.blank? || base_type_class.blank?
88
- return unless param_class.present? && param_class.ancestors.include?(base_type_class) && map[0].present?
89
- descendant = base_param_class.parse_builder_def(config, param_class.wash_out_param_map)[0]
90
- self.name = descendant.name
91
- self.map = descendant.map
92
- end
93
74
 
94
75
  # Description of method
95
76
  #
96
77
  # @param [String] complex_class A string that contains the name of a class
97
- # @return [Class, nil] returns the class if it is defined otherwise nil
78
+ # @return [Class, nil] returns the class if it is classes_defined otherwise nil
98
79
  # @api public
99
80
  def find_class_from_string(complex_class)
100
81
  complex_class.is_a?(Class) ? complex_class : complex_class.constantize
@@ -114,10 +95,10 @@ module WashoutBuilder
114
95
  param_structure = find_param_structure
115
96
  ancestor_structure = ancestor.find_param_structure
116
97
  if param_structure.keys == ancestor_structure.keys
117
- return true
98
+ true
118
99
  else
119
100
  remove_type_inheritable_elements(ancestor_structure.keys)
120
- return false
101
+ false
121
102
  end
122
103
  end
123
104
 
@@ -132,10 +113,10 @@ module WashoutBuilder
132
113
  def get_ancestors(class_name)
133
114
  param_class = find_class_from_string(class_name)
134
115
  if param_class.nil?
135
- return nil
116
+ nil
136
117
  else
137
118
  base_type_class = WashoutBuilder::Type.base_type_class
138
- filtered_classes = ['ActiveRecord::Base', 'Object', 'BasicObject']
119
+ filtered_classes = %w(ActiveRecord::Base Object BasicObject)
139
120
  filtered_classes << base_type_class.to_s if base_type_class.present?
140
121
  get_complex_type_ancestors(param_class, filtered_classes)
141
122
  end
@@ -146,16 +127,16 @@ module WashoutBuilder
146
127
  # @see WashOutParam#struct?
147
128
  #
148
129
  # @param [WashOut::SoapConfig] config an object that holds the soap configuration
149
- # @param [Array<Hash>] defined An Array with all the complex types that have been detected till now
130
+ # @param [Array<Hash>] classes_defined An Array with all the complex types that have been detected till now
150
131
  # @return [Array<Hash>] An array with all the complex types that
151
132
  # @api public
152
- def complex_type_descendants(config, defined)
133
+ def complex_type_descendants(config, classes_defined)
153
134
  if struct?
154
135
  c_names = []
155
- map.each { |obj| c_names.concat(obj.get_nested_complex_types(config, defined)) }
156
- defined.concat(c_names)
136
+ map.each { |obj| c_names.concat(obj.get_nested_complex_types(config, classes_defined)) }
137
+ classes_defined.concat(c_names)
157
138
  end
158
- defined
139
+ classes_defined
159
140
  end
160
141
 
161
142
  # Recursive method that tries to identify all the nested descendants of the current object
@@ -166,18 +147,18 @@ module WashoutBuilder
166
147
  # @see #complex_type_descendants
167
148
  #
168
149
  # @param [WashOut::SoapConfig] config holds the soap configuration
169
- # @param [Array<Hash>] defined An array with all the complex type structures that have been detected so far
150
+ # @param [Array<Hash>] classes_defined An array with all the complex type structures that have been detected so far
170
151
  # @return [Array<Hash>] An array with all the complex type that have been detected while iterating to all the descendants of the current object and also contains the previous ones
171
152
  # @api public
172
- def get_nested_complex_types(config, defined)
173
- defined = [] if defined.blank?
174
- complex_class = find_complex_class_name(defined)
175
- fix_descendant_wash_out_type(config, complex_class)
176
- unless complex_class.nil?
177
- defined << complex_type_hash(complex_class, self, complex_type_ancestors(config, complex_class, defined))
153
+ def get_nested_complex_types(config, classes_defined)
154
+ classes_defined = [] if classes_defined.blank?
155
+ complex_class = find_complex_class_name(classes_defined)
156
+ real_class = find_class_from_string(complex_class)
157
+ if complex_class.present? && (real_class.blank? || (real_class.present? && !real_class.ancestors.include?( WashoutBuilder::Type.base_type_class)))
158
+ classes_defined << complex_type_hash(complex_class, self, complex_type_ancestors(config, complex_class, classes_defined))
178
159
  end
179
- defined = complex_type_descendants(config, defined)
180
- defined.blank? ? [] : defined.sort_by { |hash| hash[:class].to_s.downcase }.uniq
160
+ classes_defined = complex_type_descendants(config, classes_defined)
161
+ classes_defined.blank? ? [] : classes_defined.sort_by { |hash| hash[:class].to_s.downcase }.uniq
181
162
  end
182
163
 
183
164
  # method that constructs the a hash with the name of the ancestor ( the class name) and as value its elemen structure
@@ -199,9 +180,9 @@ module WashoutBuilder
199
180
  # @api public
200
181
  def complex_type_hash(class_name, object, ancestors)
201
182
  {
202
- class: class_name,
203
- obj: object,
204
- ancestors: ancestors
183
+ class: class_name,
184
+ obj: object,
185
+ ancestors: ancestors
205
186
  }
206
187
  end
207
188
 
@@ -213,10 +194,10 @@ module WashoutBuilder
213
194
  #
214
195
  # @param [WashOut::SoapConfig] config holds the soap configuration
215
196
  # @param [Class] class_name The name of the class that is used for fetching the ancestors
216
- # @param [Array<Hash>] defined An Array with all the complex types that have been detected so far
197
+ # @param [Array<Hash>] classes_defined An Array with all the complex types that have been detected so far
217
198
  # @return [Array<Class>] An Array of classes from which the class that is sent as parameter inherits from
218
199
  # @api public
219
- def get_class_ancestors(config, class_name, defined)
200
+ def get_class_ancestors(config, class_name, classes_defined)
220
201
  ancestors = get_ancestors(class_name)
221
202
  return if ancestors.blank?
222
203
  base_param_class = WashoutBuilder::Type.base_param_class
@@ -224,8 +205,8 @@ module WashoutBuilder
224
205
  ancestor_object = base_param_class.parse_def(config, ancestor_structure(ancestors))[0]
225
206
  bool_the_same = same_structure_as_ancestor?(ancestor_object)
226
207
  unless bool_the_same
227
- top_ancestors = get_class_ancestors(config, ancestors[0], defined)
228
- defined << complex_type_hash(ancestors[0], ancestor_object, top_ancestors)
208
+ top_ancestors = get_class_ancestors(config, ancestors[0], classes_defined)
209
+ classes_defined << complex_type_hash(ancestors[0], ancestor_object, top_ancestors)
229
210
  end
230
211
  ancestors unless bool_the_same
231
212
  end