washout_builder 0.14.1 → 0.15.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 (85) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -2
  3. data/.rubocop.yml +68 -0
  4. data/.travis.yml +1 -1
  5. data/Appraisals +9 -1
  6. data/Gemfile +2 -3
  7. data/Rakefile +17 -20
  8. data/app/controllers/washout_builder/washout_builder_controller.rb +79 -79
  9. data/app/helpers/washout_builder_complex_type_helper.rb +16 -23
  10. data/app/helpers/washout_builder_fault_type_helper.rb +12 -13
  11. data/app/helpers/washout_builder_method_arguments_helper.rb +24 -26
  12. data/app/helpers/washout_builder_method_list_helper.rb +16 -11
  13. data/app/helpers/washout_builder_method_return_type_helper.rb +14 -12
  14. data/app/views/wash_with_html/doc.builder +2 -2
  15. data/bin/appraisal +16 -0
  16. data/bin/autospec +16 -0
  17. data/bin/bundler +16 -0
  18. data/bin/cdiff +16 -0
  19. data/bin/coderay +16 -0
  20. data/bin/colortab +16 -0
  21. data/bin/coveralls +16 -0
  22. data/bin/decolor +16 -0
  23. data/bin/erubis +16 -0
  24. data/bin/guard +16 -0
  25. data/bin/htmldiff +16 -0
  26. data/bin/ldiff +16 -0
  27. data/bin/listen +16 -0
  28. data/bin/nokogiri +16 -0
  29. data/bin/phare +16 -0
  30. data/bin/pry +16 -0
  31. data/bin/rackup +16 -0
  32. data/bin/rails +16 -0
  33. data/bin/rake +16 -0
  34. data/bin/restclient +16 -0
  35. data/bin/rspec +16 -0
  36. data/bin/rubocop +16 -0
  37. data/bin/ruby-parse +16 -0
  38. data/bin/ruby-rewrite +16 -0
  39. data/bin/sass +16 -0
  40. data/bin/sass-convert +16 -0
  41. data/bin/scss +16 -0
  42. data/bin/scss-lint +16 -0
  43. data/bin/term_display +16 -0
  44. data/bin/term_mandel +16 -0
  45. data/bin/thor +16 -0
  46. data/bin/uuid +16 -0
  47. data/config/routes.rb +3 -3
  48. data/init.rb +1 -1
  49. data/lib/washout_builder.rb +20 -29
  50. data/lib/washout_builder/document/complex_type.rb +70 -75
  51. data/lib/washout_builder/document/exception_model.rb +46 -51
  52. data/lib/washout_builder/document/generator.rb +56 -66
  53. data/lib/washout_builder/document/shared_complex_type.rb +2 -4
  54. data/lib/washout_builder/engine.rb +1 -2
  55. data/lib/washout_builder/soap.rb +6 -10
  56. data/lib/washout_builder/type.rb +9 -23
  57. data/lib/washout_builder/version.rb +5 -5
  58. data/spec/app/controllers/washout_builder_controller_spec.rb +26 -28
  59. data/spec/app/helpers/washout_builder_complex_type_helper_spec.rb +37 -45
  60. data/spec/app/helpers/washout_builder_fault_type_helper_spec.rb +65 -77
  61. data/spec/app/helpers/washout_builder_method_arguments_helper_spec.rb +65 -76
  62. data/spec/app/helpers/washout_builder_method_list_helper_spec.rb +30 -35
  63. data/spec/app/helpers/washout_builder_method_return_type_helper_spec.rb +25 -27
  64. data/spec/dummy/config/application.rb +4 -4
  65. data/spec/dummy/config/boot.rb +1 -1
  66. data/spec/dummy/config/environments/development.rb +2 -3
  67. data/spec/dummy/config/environments/test.rb +3 -3
  68. data/spec/dummy/config/initializers/secret_token.rb +1 -1
  69. data/spec/dummy/config/initializers/session_store.rb +1 -1
  70. data/spec/dummy/config/routes.rb +0 -1
  71. data/spec/dummy/script/rails +2 -2
  72. data/spec/integration/washout_builder_all_services_spec.rb +2 -5
  73. data/spec/integration/washout_builder_service_spec.rb +2 -5
  74. data/spec/lib/washout_builder/document/complex_type_spec.rb +98 -118
  75. data/spec/lib/washout_builder/document/exception_model_spec.rb +49 -54
  76. data/spec/lib/washout_builder/document/generator_spec.rb +93 -118
  77. data/spec/lib/washout_builder/type_spec.rb +17 -29
  78. data/spec/lib/washout_builder_spec.rb +293 -308
  79. data/spec/spec_helper.rb +24 -30
  80. data/spec/support/complex_types/fluffy.rb +3 -3
  81. data/spec/support/complex_types/fluffy_container.rb +3 -3
  82. data/spec/support/complex_types/project_type.rb +4 -5
  83. data/spec/support/complex_types/test_type.rb +4 -4
  84. data/washout_builder.gemspec +5 -2
  85. metadata +78 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 802bd845220cba1431d3e914c831885a808f409b
4
- data.tar.gz: 01217f8a74c7d265fa154f92ae9935331676448a
3
+ metadata.gz: 3bf03886cb1c9afca96b057708fef231782db00a
4
+ data.tar.gz: 432614b7d5788c094053614d678c530e33520bc9
5
5
  SHA512:
6
- metadata.gz: 893d39b63b0a4c07d84437b1962a6490cc83e361d528fb67e7f4e1ae8550f6fc8b137b9c3a45db6d68cbb033e58e06119b6f857231b9d77e90f4349416e18bbe
7
- data.tar.gz: 5fc32ae9c7b33126937e4793169effa58f0d9ec9f842e49e6c528a508f569f7d12614dc56cdd26c35f91e9ec5bc9818914126b9019335a0293706664cac61d6e
6
+ metadata.gz: 5f82065358b685fd0be21b39209f538a62094727d2a21426445fea15df6007524dec39e34f47dab97caeb3b7bd94fb827586f5453e9cafa285257630ed94d603
7
+ data.tar.gz: 8fc71e4d273114de1552e743ce6a3c8f6cd242d5256eee671597a3579d56f9986dccb2886912d719681e5369a3f0947b05f47dd28f7cf422a23037635d547e52
data/.gitignore CHANGED
@@ -9,9 +9,8 @@ pkg/
9
9
  spec/dummy/db/*.sqlite3
10
10
  spec/dummy/log/*.log
11
11
  spec/dummy/tmp/
12
- gemfiles
13
12
  coverage
14
13
  tags
15
14
  Gemfile.lock
16
15
  /nbproject/
17
- /.git-rewrite/
16
+ /.git-rewrite/
@@ -0,0 +1,68 @@
1
+ AllCops:
2
+ Exclude:
3
+ - washout_builder.gemspec
4
+ - bin/**/*
5
+ - Guardfile
6
+
7
+ Documentation:
8
+ Enabled: false
9
+
10
+ Encoding:
11
+ Enabled: false
12
+
13
+ LineLength:
14
+ Max: 200
15
+
16
+ AccessModifierIndentation:
17
+ EnforcedStyle: outdent
18
+
19
+ IfUnlessModifier:
20
+ Enabled: false
21
+
22
+ CaseIndentation:
23
+ IndentWhenRelativeTo: case
24
+ IndentOneStep: true
25
+
26
+ MethodLength:
27
+ CountComments: false
28
+ Max: 20
29
+
30
+ SignalException:
31
+ Enabled: false
32
+
33
+ ColonMethodCall:
34
+ Enabled: false
35
+
36
+ AsciiComments:
37
+ Enabled: false
38
+
39
+ RegexpLiteral:
40
+ Enabled: false
41
+
42
+ AssignmentInCondition:
43
+ Enabled: false
44
+
45
+ ParameterLists:
46
+ CountKeywordArgs: false
47
+
48
+ SingleLineBlockParams:
49
+ Methods:
50
+ - reduce:
51
+ - memo
52
+ - item
53
+
54
+ Metrics/AbcSize:
55
+ Enabled: false
56
+
57
+ Style/CollectionMethods:
58
+ Enabled: true
59
+
60
+ Style/SymbolArray:
61
+ Enabled: true
62
+
63
+ Style/ExtraSpacing:
64
+ Enabled: true
65
+
66
+ Style/FileName:
67
+ Enabled: false
68
+
@@ -9,4 +9,4 @@ rvm:
9
9
  env:
10
10
  - RAILS_ENV=test RACK_ENV=test
11
11
  notifications:
12
- email: false
12
+ email: false
data/Appraisals CHANGED
@@ -20,4 +20,12 @@ end
20
20
 
21
21
  appraise "rails-4.1.4" do
22
22
  gem "rails", "4.1.4"
23
- end
23
+ end
24
+
25
+ appraise "rails-4.1.9" do
26
+ gem "rails", "4.1.9"
27
+ end
28
+
29
+ appraise "rails-4.2.0" do
30
+ gem "rails", "4.2.0"
31
+ end
data/Gemfile CHANGED
@@ -1,6 +1,5 @@
1
- source "http://rubygems.org"
1
+ source 'http://rubygems.org'
2
2
 
3
3
  gemspec
4
4
 
5
-
6
- gem 'wash_out', git: 'git://github.com/inossidabile/wash_out.git'
5
+ gem 'wash_out', git: 'git://github.com/inossidabile/wash_out.git'
data/Rakefile CHANGED
@@ -6,41 +6,38 @@ require 'coveralls/rake/task'
6
6
  Coveralls::RakeTask.new
7
7
 
8
8
  RSpec::Core::RakeTask.new(:spec) do |spec|
9
- # spec.rspec_opts = ['--backtrace ']
9
+ spec.rspec_opts = ['--backtrace '] if ENV['DEBUG']
10
10
  end
11
11
 
12
- #desc "Prepare dummy application"
13
- #task :prepare do
12
+ # desc "Prepare dummy application"
13
+ # task :prepare do
14
14
  # ENV["RAILS_ENV"] ||= 'test'
15
- #
16
15
  # require File.expand_path("./spec/dummy/config/environment", File.dirname(__FILE__))
17
16
  # Dummy::Application.load_tasks
18
- #
19
17
  # Rake::Task["db:test:prepare"].invoke
20
- #end
18
+ # end
21
19
 
22
- unless ENV["TRAVIS"]
20
+ unless ENV['TRAVIS']
23
21
  require 'rvm-tester'
24
22
  RVM::Tester::TesterTask.new(:suite) do |t|
25
23
  t.rubies = %w(1.9.3 2.0.0 2.1.0) # which versions to test (required!)
26
- t.bundle_install = true # updates Gemfile.lock, default is true
27
- t.use_travis = true # looks for Rubies in .travis.yml (on by default)
28
- t.command = "bundle exec rake" # runs plain "rake" by default
29
- t.env = {"VERBOSE" => "1", "RAILS_ENV"=>"test", "RACK_ENV"=> "test" } # set any ENV vars
30
- t.num_workers = 5 # defaults to 3
31
- t.verbose = true # shows more output, off by default
24
+ t.bundle_install = true # updates Gemfile.lock, default is true
25
+ t.use_travis = true # looks for Rubies in .travis.yml (on by default)
26
+ t.command = 'bundle exec rake' # runs plain "rake" by default
27
+ t.env = { 'VERBOSE' => '1', 'RAILS_ENV' => 'test', 'RACK_ENV' => 'test' } # set any ENV vars
28
+ t.num_workers = 5 # defaults to 3
29
+ t.verbose = true # shows more output, off by default
32
30
  end
33
31
  end
34
32
 
35
-
36
- desc "Default: run the unit tests."
37
- task :default => [:all]
33
+ desc 'Default: run the unit tests.'
34
+ task default: [:all]
38
35
 
39
36
  desc 'Test the plugin under all supported Rails versions.'
40
- task :all do |t|
41
- if ENV["TRAVIS"]
42
- exec(' bundle exec appraisal install && bundle exec rake appraisal spec && bundle exec rake coveralls:push')
37
+ task :all do |_t|
38
+ if ENV['TRAVIS']
39
+ exec(' bundle exec phare && bundle exec appraisal install && bundle exec rake appraisal spec && bundle exec rake coveralls:push')
43
40
  else
44
- exec(' bundle exec appraisal install && bundle exec rake appraisal spec')
41
+ exec(' bundle exec phare && bundle exec appraisal install && bundle exec rake appraisal spec')
45
42
  end
46
43
  end
@@ -1,89 +1,89 @@
1
- require_relative "../../../lib/washout_builder/document/generator"
2
- class WashoutBuilder::WashoutBuilderController < ActionController::Base
3
- protect_from_forgery
1
+ require_relative '../../../lib/washout_builder/document/generator'
2
+ module WashoutBuilder
3
+ class WashoutBuilderController < ActionController::Base
4
+ protect_from_forgery
4
5
 
5
- # Will show all api services if no name parameter is receiverd
6
- # If a name parameter is present wiill try to use that and find a controller
7
- # that was that name by camelcasing the name .
8
- # IF a name is provided will show the documentation page for that controller
9
- def all
10
- route = params[:name].present? ? controller_is_a_service?(params[:name]) : nil
11
- if route.present?
12
- @document = WashoutBuilder::Document::Generator.new(route.defaults[:controller])
13
- render :template => "wash_with_html/doc", :layout => false,
14
- :content_type => 'text/html'
15
- else
16
- all_services
6
+ # Will show all api services if no name parameter is receiverd
7
+ # If a name parameter is present wiill try to use that and find a controller
8
+ # that was that name by camelcasing the name .
9
+ # IF a name is provided will show the documentation page for that controller
10
+ def all
11
+ route = params[:name].present? ? controller_is_a_service?(params[:name]) : nil
12
+ if route.present?
13
+ @document = WashoutBuilder::Document::Generator.new(route.defaults[:controller])
14
+ render template: 'wash_with_html/doc', layout: false,
15
+ content_type: 'text/html'
16
+ else
17
+ all_services
18
+ end
17
19
  end
18
- end
19
-
20
-
20
+
21
21
  private
22
-
23
- # tries to find all services by searching through the rails controller
24
- # and returns their namespace, endpoint and a documentation url
25
- def all_services
26
- @map_controllers = map_controllers do |route| route.defaults[:controller] end
27
- @services = @map_controllers.blank? ? [] : @map_controllers.map do |controller_name|
28
- {
29
- 'service_name' => controller_naming(controller_name) ,
30
- 'namespace' => service_namespace(controller_name),
31
- 'endpoint' => service_endpoint(controller_name),
32
- 'documentation_url' => service_documentation_url(controller_name),
33
- }
22
+
23
+ # tries to find all services by searching through the rails controller
24
+ # and returns their namespace, endpoint and a documentation url
25
+ def all_services
26
+ @map_controllers = map_controllers { |route| route.defaults[:controller] }
27
+ @services = @map_controllers.blank? ? [] : @map_controllers.map do |controller_name|
28
+ {
29
+ 'service_name' => controller_naming(controller_name),
30
+ 'namespace' => service_namespace(controller_name),
31
+ 'endpoint' => service_endpoint(controller_name),
32
+ 'documentation_url' => service_documentation_url(controller_name)
33
+ }
34
+ end
35
+
36
+ render template: 'wash_with_html/all_services', layout: false,
37
+ content_type: 'text/html'
34
38
  end
35
-
36
- render :template => "wash_with_html/all_services", :layout => false,
37
- :content_type => 'text/html'
38
- end
39
-
40
- # the way of converting from controller string in downcase in camelcase
41
- def controller_naming(controller)
42
- controller.camelize
43
- end
44
-
45
- # checking if a route has the action for generating WSDL
46
- def route_can_generate_wsdl?(route)
47
- route.defaults[:action] == "_generate_wsdl"
48
- end
49
-
50
- # method for getting all controllers that have the generate wsdl action or finding out
51
- # if a single controller is a soap service
52
- def map_controllers(action = "map")
53
- res = Rails.application.routes.routes.send(action) do |route|
54
- if route_can_generate_wsdl?(route)
55
- yield route if block_given?
39
+
40
+ # the way of converting from controller string in downcase in camelcase
41
+ def controller_naming(controller)
42
+ controller.camelize
43
+ end
44
+
45
+ # checking if a route has the action for generating WSDL
46
+ def route_can_generate_wsdl?(route)
47
+ route.defaults[:action] == '_generate_wsdl'
48
+ end
49
+
50
+ # method for getting all controllers that have the generate wsdl action or finding out
51
+ # if a single controller is a soap service
52
+ def map_controllers(action = 'map')
53
+ res = Rails.application.routes.routes.send(action) do |route|
54
+ if route_can_generate_wsdl?(route)
55
+ yield route if block_given?
56
+ end
56
57
  end
58
+ res = res.uniq.compact if action == 'map'
59
+ res
57
60
  end
58
- res = res.uniq.compact if action == "map"
59
- return res
60
- end
61
-
62
- # checking if a controller is a soap service
63
- def controller_is_a_service?(controller)
64
- map_controllers("detect") do |route|
65
- controller_naming(route.defaults[:controller]) == controller_naming(controller)
61
+
62
+ # checking if a controller is a soap service
63
+ def controller_is_a_service?(controller)
64
+ map_controllers('detect') do |route|
65
+ controller_naming(route.defaults[:controller]) == controller_naming(controller)
66
+ end
66
67
  end
67
- end
68
68
 
69
- # getting the controller class from the controller string
70
- def controller_class(controller)
71
- controller_naming("#{controller}_controller").constantize
72
- end
73
-
74
- # retrieves the service namespace
75
- def service_namespace(controller_name)
76
- controller_class(controller_name).soap_config.namespace
77
- end
78
-
79
- # the endpoint is based on the namespace followed by /action suffix
80
- def service_endpoint(controller_name)
81
- service_namespace(controller_name).gsub("/wsdl", "/action")
82
- end
83
-
84
- # constructs the documentation url for a specific web service
85
- def service_documentation_url(controller_name)
86
- "#{washout_builder.root_url}#{controller_naming(controller_name)}"
87
- end
69
+ # getting the controller class from the controller string
70
+ def controller_class(controller)
71
+ controller_naming("#{controller}_controller").constantize
72
+ end
73
+
74
+ # retrieves the service namespace
75
+ def service_namespace(controller_name)
76
+ controller_class(controller_name).soap_config.namespace
77
+ end
88
78
 
79
+ # the endpoint is based on the namespace followed by /action suffix
80
+ def service_endpoint(controller_name)
81
+ service_namespace(controller_name).gsub('/wsdl', '/action')
82
+ end
83
+
84
+ # constructs the documentation url for a specific web service
85
+ def service_documentation_url(controller_name)
86
+ "#{washout_builder.root_url}#{controller_naming(controller_name)}"
87
+ end
88
+ end
89
89
  end
@@ -1,30 +1,23 @@
1
1
  module WashoutBuilderComplexTypeHelper
2
-
3
- # this method is for printing the attributes of a complex type
4
- # if the attributes are primitives this will show the attributes with blue color
5
- # otherwise will call another method for printing the complex attribute
2
+ # this method is for printing the attributes of a complex type
3
+ # if the attributes are primitives this will show the attributes with blue color
4
+ # otherwise will call another method for printing the complex attribute
6
5
  def create_element_type_html(pre, element)
7
- element.type = "string" if element.type == "text"
8
- element.type = "integer" if element.type == "int"
9
- if WashoutBuilder::Type::BASIC_TYPES.include?(element.type)
10
- pre << "<span class='blue'>#{element.type}</span>&nbsp;<span class='bold'>#{element.name}</span>"
11
- else
12
- create_complex_element_type_html(pre, element)
13
- end
6
+ element.type = 'string' if element.type == 'text'
7
+ element.type = 'integer' if element.type == 'int'
8
+ if WashoutBuilder::Type::BASIC_TYPES.include?(element.type)
9
+ pre << "<span class='blue'>#{element.type}</span>&nbsp;<span class='bold'>#{element.name}</span>"
10
+ else
11
+ create_complex_element_type_html(pre, element)
12
+ end
14
13
  end
15
-
16
-
14
+
17
15
  # checks if a complex attribute of a complex type is a array or not
18
- # and retrieves the complex class name of the attribute and prints it
16
+ # and retrieves the complex class name of the attribute and prints it
19
17
  def create_complex_element_type_html(pre, element)
20
- complex_class = element.get_complex_class_name
21
- unless complex_class.nil?
22
- complex_class_content = element.multiplied == false ? "#{complex_class}" : "Array of #{complex_class}"
23
- pre << "<a href='##{complex_class}'><span class='lightBlue'>#{complex_class_content}</span></a>&nbsp;<span class='bold'>#{element.name}</span>"
24
- end
18
+ complex_class = element.find_complex_class_name
19
+ return if complex_class.nil?
20
+ complex_class_content = element.multiplied == false ? "#{complex_class}" : "Array of #{complex_class}"
21
+ pre << "<a href='##{complex_class}'><span class='lightBlue'>#{complex_class_content}</span></a>&nbsp;<span class='bold'>#{element.name}</span>"
25
22
  end
26
-
27
23
  end
28
-
29
-
30
-
@@ -1,5 +1,4 @@
1
1
  module WashoutBuilderFaultTypeHelper
2
-
3
2
  # checks if a complex attribute of a complex type SoapFault is array or not
4
3
  # if the attribute is an array will print also the type of the elements contained in the array
5
4
  # otherwise will show the complex class of the attribute
@@ -7,35 +6,35 @@ module WashoutBuilderFaultTypeHelper
7
6
  attribute_primitive = array == true ? "Array of #{attr_primitive}" : "#{attr_primitive}"
8
7
  pre << "<a href='##{attr_primitive}'><span class='lightBlue'> #{attribute_primitive}</span></a>&nbsp;<span class='bold'>#{attribute}</span>"
9
8
  end
10
-
9
+
11
10
  # if the attribute is an array this method is used to identify the type of the elements inside the array
12
11
  def member_type_is_basic?(attr_details)
13
12
  WashoutBuilder::Type::BASIC_TYPES.include?(attr_details[:member_type].to_s.downcase) ? attr_details[:member_type].to_s.downcase : attr_details[:member_type]
14
13
  end
15
14
  # checks is the attribute has a primitive value or a complex value
16
15
  def primitive_type_is_basic?(attr_details)
17
- WashoutBuilder::Type::BASIC_TYPES.include?(attr_details[:primitive].to_s.downcase)
16
+ WashoutBuilder::Type::BASIC_TYPES.include?(attr_details[:primitive].to_s.downcase)
18
17
  end
19
18
 
20
- # if the attribute value is of type nil the documentation will show string
19
+ # if the attribute value is of type nil the documentation will show string
21
20
  # otherwise the primitive value
22
21
  def get_primitive_type_string(attr_details)
23
- attr_details[:primitive].to_s.downcase == "nilclass" ? "string" : attr_details[:primitive].to_s.downcase
24
- end
25
-
22
+ attr_details[:primitive].to_s.downcase == 'nilclass' ? 'string' : attr_details[:primitive].to_s.downcase
23
+ end
24
+
26
25
  # if the attribute is of type array the method identifies the type of the elements inside the array
27
26
  def get_member_type_string(attr_details)
28
- attr_details[:primitive].to_s.downcase == "array" ? member_type_is_basic?(attr_details) : attr_details[:primitive]
27
+ attr_details[:primitive].to_s.downcase == 'array' ? member_type_is_basic?(attr_details) : attr_details[:primitive]
29
28
  end
30
-
31
- # this method is used to print all attributes of a SoapFault element
29
+
30
+ # this method is used to print all attributes of a SoapFault element
32
31
  # if the attribute value is a primitve value it will be shown in blue and will also show the type of the primitive
33
- # if is a complex type will use another method for finding out the complex class
32
+ # if is a complex type will use another method for finding out the complex class
34
33
  def create_html_fault_model_element_type(pre, attribute, attr_details)
35
- if primitive_type_is_basic?(attr_details) || attr_details[:primitive] == "nilclass"
34
+ if primitive_type_is_basic?(attr_details) || attr_details[:primitive] == 'nilclass'
36
35
  pre << "<span class='blue'>#{get_primitive_type_string(attr_details)}</span>&nbsp;<span class='bold'>#{attribute}</span>"
37
36
  else
38
- create_fault_model_complex_element_type(pre, get_member_type_string(attr_details), attribute, true )
37
+ create_fault_model_complex_element_type(pre, get_member_type_string(attr_details), attribute, true)
39
38
  end
40
39
  end
41
40
  end