washout_builder 0.14.0 → 0.14.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 28e063d6a4b5eaf6ddbfa719878fb79cd1fd97a2
4
- data.tar.gz: 2bf44c71f0a33cd2835eca1cd03dc1eab968d074
3
+ metadata.gz: 802bd845220cba1431d3e914c831885a808f409b
4
+ data.tar.gz: 01217f8a74c7d265fa154f92ae9935331676448a
5
5
  SHA512:
6
- metadata.gz: 6537d2449d4d330dca6a4d1b8c2820dd9d47d5d7c1df3bd5e21a80a85e99f093350c743f4ee7540e5118155b3a2513cc878d60b3cda0d65051a466218eff8154
7
- data.tar.gz: d3a9fbb41c8f68c7ea3cd828d862110ef28207ba3a09bdf1f6449a0fac2fe95b024d4c5fb4869e52639f6379f83d964f38aa68de8fe27b4cd59a05f18d0cb7ff
6
+ metadata.gz: 893d39b63b0a4c07d84437b1962a6490cc83e361d528fb67e7f4e1ae8550f6fc8b137b9c3a45db6d68cbb033e58e06119b6f857231b9d77e90f4349416e18bbe
7
+ data.tar.gz: 5fc32ae9c7b33126937e4793169effa58f0d9ec9f842e49e6c528a508f569f7d12614dc56cdd26c35f91e9ec5bc9818914126b9019335a0293706664cac61d6e
data/.coveralls.yml CHANGED
@@ -1,2 +1,2 @@
1
1
  service_name: travis-ci
2
- repo_token: UaUbPHZDlrwJTkU33FqFBf4FaMU4vhBwV
2
+ repo_token: RcokBkjBaFERh6P3aMwGQ5EJStDmHmHQT
data/README.rdoc CHANGED
@@ -1,7 +1,7 @@
1
1
  = washout_builder {<img src="https://badge.fury.io/rb/washout_builder.png" alt="Gem Version" />}[http://badge.fury.io/rb/washout_builder]
2
2
  {<img src="https://travis-ci.org/bogdanRada/washout_builder.png?branch=master,develop" />}[https://travis-ci.org/bogdanRada/washout_builder]
3
- {<img src="https://www.versioneye.com/user/projects/52fc7297ec1375346600007d/badge.png" alt="Dependency Status" />}[https://www.versioneye.com/user/projects/52fc7297ec1375346600007d]{<img src="https://www.versioneye.com/user/projects/52fc7297ec1375346600007d/badge.png" alt="Dependency Status" />}[https://www.versioneye.com/user/projects/52fc7297ec1375346600007d]
4
- {<img src="https://coveralls.io/repos/bogdanRada/washout_builder/badge.png?alt=true" alt="Coveralls Coverage Status" />}[https://coveralls.io/r/bogdanRada/washout_builder]
3
+ {<img src="https://www.versioneye.com/user/projects/52fc7297ec1375346600007d/badge.svg?style=flat" alt="Dependency Status" />}[https://www.versioneye.com/user/projects/52fc7297ec1375346600007d]
4
+ {<img src="https://coveralls.io/repos/bogdanRada/washout_builder/badge.png?branch=master" alt="Coverage Status" />}[https://coveralls.io/r/bogdanRada/washout_builder?branch=master]
5
5
  {<img src="https://codeclimate.com/github/bogdanRada/washout_builder.png" />}[https://codeclimate.com/github/bogdanRada/washout_builder]
6
6
  {<img src="https://reposs.herokuapp.com/?path=bogdanRada/washout_builder" alt="Repo Size"/>}[https://github.com/bogdanRada/washout_builder]
7
7
  {<img src="https://ruby-gem-downloads-badge.herokuapp.com/washout_builder?type=total&style=dynamic" alt="Gem Downloads"/>}[https://rubygems.org/gems/washout_builder]
@@ -2,6 +2,10 @@ require_relative "../../../lib/washout_builder/document/generator"
2
2
  class WashoutBuilder::WashoutBuilderController < ActionController::Base
3
3
  protect_from_forgery
4
4
 
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
5
9
  def all
6
10
  route = params[:name].present? ? controller_is_a_service?(params[:name]) : nil
7
11
  if route.present?
@@ -16,12 +20,13 @@ class WashoutBuilder::WashoutBuilderController < ActionController::Base
16
20
 
17
21
  private
18
22
 
19
-
23
+ # tries to find all services by searching through the rails controller
24
+ # and returns their namespace, endpoint and a documentation url
20
25
  def all_services
21
- @map_controllers = map_controllers
26
+ @map_controllers = map_controllers do |route| route.defaults[:controller] end
22
27
  @services = @map_controllers.blank? ? [] : @map_controllers.map do |controller_name|
23
28
  {
24
- 'service_name' => controller_name.camelize ,
29
+ 'service_name' => controller_naming(controller_name) ,
25
30
  'namespace' => service_namespace(controller_name),
26
31
  'endpoint' => service_endpoint(controller_name),
27
32
  'documentation_url' => service_documentation_url(controller_name),
@@ -32,36 +37,53 @@ class WashoutBuilder::WashoutBuilderController < ActionController::Base
32
37
  :content_type => 'text/html'
33
38
  end
34
39
 
35
- def all_controllers
36
- Rails.application.routes.routes
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"
37
48
  end
38
49
 
39
- def map_controllers
40
- all_controllers.map do |route|
41
- route.defaults[:controller] if route.defaults[:action] == "_generate_wsdl"
42
- end.uniq.compact
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
57
+ end
58
+ res = res.uniq.compact if action == "map"
59
+ return res
43
60
  end
44
61
 
62
+ # checking if a controller is a soap service
45
63
  def controller_is_a_service?(controller)
46
- route = all_controllers.detect do |route|
47
- route.defaults[:controller].camelize == controller.camelize && route.defaults[:action] == "_generate_wsdl"
64
+ map_controllers("detect") do |route|
65
+ controller_naming(route.defaults[:controller]) == controller_naming(controller)
48
66
  end
49
67
  end
50
68
 
69
+ # getting the controller class from the controller string
51
70
  def controller_class(controller)
52
- "#{controller}_controller".camelize.constantize
71
+ controller_naming("#{controller}_controller").constantize
53
72
  end
54
73
 
74
+ # retrieves the service namespace
55
75
  def service_namespace(controller_name)
56
76
  controller_class(controller_name).soap_config.namespace
57
77
  end
58
78
 
79
+ # the endpoint is based on the namespace followed by /action suffix
59
80
  def service_endpoint(controller_name)
60
81
  service_namespace(controller_name).gsub("/wsdl", "/action")
61
82
  end
62
83
 
84
+ # constructs the documentation url for a specific web service
63
85
  def service_documentation_url(controller_name)
64
- "#{washout_builder.root_url}#{controller_name.camelize}"
86
+ "#{washout_builder.root_url}#{controller_naming(controller_name)}"
65
87
  end
66
88
 
67
89
  end
@@ -1,6 +1,8 @@
1
1
  module WashoutBuilderComplexTypeHelper
2
2
 
3
-
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
4
6
  def create_element_type_html(pre, element)
5
7
  element.type = "string" if element.type == "text"
6
8
  element.type = "integer" if element.type == "int"
@@ -11,7 +13,9 @@ module WashoutBuilderComplexTypeHelper
11
13
  end
12
14
  end
13
15
 
14
-
16
+
17
+ # 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
15
19
  def create_complex_element_type_html(pre, element)
16
20
  complex_class = element.get_complex_class_name
17
21
  unless complex_class.nil?
@@ -23,4 +27,4 @@ module WashoutBuilderComplexTypeHelper
23
27
  end
24
28
 
25
29
 
26
-
30
+
@@ -1,27 +1,36 @@
1
1
  module WashoutBuilderFaultTypeHelper
2
2
 
3
+ # checks if a complex attribute of a complex type SoapFault is array or not
4
+ # if the attribute is an array will print also the type of the elements contained in the array
5
+ # otherwise will show the complex class of the attribute
3
6
  def create_fault_model_complex_element_type(pre, attr_primitive, attribute, array)
4
7
  attribute_primitive = array == true ? "Array of #{attr_primitive}" : "#{attr_primitive}"
5
8
  pre << "<a href='##{attr_primitive}'><span class='lightBlue'> #{attribute_primitive}</span></a>&nbsp;<span class='bold'>#{attribute}</span>"
6
9
  end
7
10
 
8
-
11
+ # if the attribute is an array this method is used to identify the type of the elements inside the array
9
12
  def member_type_is_basic?(attr_details)
10
13
  WashoutBuilder::Type::BASIC_TYPES.include?(attr_details[:member_type].to_s.downcase) ? attr_details[:member_type].to_s.downcase : attr_details[:member_type]
11
14
  end
12
-
15
+ # checks is the attribute has a primitive value or a complex value
13
16
  def primitive_type_is_basic?(attr_details)
14
- WashoutBuilder::Type::BASIC_TYPES.include?(attr_details[:primitive].to_s.downcase)
17
+ WashoutBuilder::Type::BASIC_TYPES.include?(attr_details[:primitive].to_s.downcase)
15
18
  end
16
19
 
20
+ # if the attribute value is of type nil the documentation will show string
21
+ # otherwise the primitive value
17
22
  def get_primitive_type_string(attr_details)
18
23
  attr_details[:primitive].to_s.downcase == "nilclass" ? "string" : attr_details[:primitive].to_s.downcase
19
24
  end
20
25
 
26
+ # if the attribute is of type array the method identifies the type of the elements inside the array
21
27
  def get_member_type_string(attr_details)
22
28
  attr_details[:primitive].to_s.downcase == "array" ? member_type_is_basic?(attr_details) : attr_details[:primitive]
23
29
  end
24
30
 
31
+ # this method is used to print all attributes of a SoapFault element
32
+ # 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
25
34
  def create_html_fault_model_element_type(pre, attribute, attr_details)
26
35
  if primitive_type_is_basic?(attr_details) || attr_details[:primitive] == "nilclass"
27
36
  pre << "<span class='blue'>#{get_primitive_type_string(attr_details)}</span>&nbsp;<span class='bold'>#{attribute}</span>"
@@ -29,4 +38,4 @@ module WashoutBuilderFaultTypeHelper
29
38
  create_fault_model_complex_element_type(pre, get_member_type_string(attr_details), attribute, true )
30
39
  end
31
40
  end
32
- end
41
+ end
@@ -1,13 +1,5 @@
1
1
  require 'wash_out'
2
- require 'washout_builder/soap'
3
- require 'washout_builder/engine'
4
- require 'washout_builder/document/shared_complex_type'
5
- require 'washout_builder/document/complex_type'
6
- require 'washout_builder/document/exception_model'
7
- require 'washout_builder/document/generator'
8
- require 'washout_builder/type'
9
- require 'washout_builder/version'
10
-
2
+ Gem.find_files("washout_builder/**/*.rb").each { |path| require path }
11
3
 
12
4
  WashOut::Param.send :include, WashoutBuilder::Document::ComplexType
13
5
 
@@ -51,13 +43,32 @@ end
51
43
 
52
44
 
53
45
  WashOut::Param.class_eval do
54
-
46
+
55
47
  def self.parse_builder_def(soap_config, definition)
56
48
  raise RuntimeError, "[] should not be used in your params. Use nil if you want to mark empty set." if definition == []
57
49
  return [] if definition == nil
58
-
59
- definition = { :value => definition } unless definition.is_a?(Hash)
60
-
50
+
51
+ # the following lines was removed because when generating the documentation
52
+ # the "source_class" attrtibute of the object was not the name of the class of the complex tyoe
53
+ # but instead was the name given in the hash
54
+ # Example :
55
+ # class ProjectType < WashOut::Type
56
+ # map :project => {
57
+ # :name => :string,
58
+ # :description => :string,
59
+ # :users => [{:mail => :string }],
60
+ # }
61
+ #end
62
+ #
63
+ # The name of the complex type should be ProjectType and not "project"
64
+
65
+
66
+ # if definition.is_a?(Class) && definition.ancestors.include?(WashOut::Type)
67
+ # definition = definition.wash_out_param_map
68
+ # end
69
+
70
+ definition = { :value => definition } unless definition.is_a?(Hash) # for arrays and symbols
71
+
61
72
  definition.collect do |name, opt|
62
73
  if opt.is_a? WashOut::Param
63
74
  opt
@@ -65,9 +76,9 @@ WashOut::Param.class_eval do
65
76
  WashOut::Param.new(soap_config, name, opt[0], true)
66
77
  else
67
78
  WashOut::Param.new(soap_config, name, opt)
79
+ end
68
80
  end
69
81
  end
70
- end
71
82
 
72
83
  end
73
84
 
@@ -1,3 +1,4 @@
1
+ require_relative "./shared_complex_type"
1
2
  module WashoutBuilder
2
3
  module Document
3
4
  module ComplexType
@@ -120,4 +121,4 @@ module WashoutBuilder
120
121
 
121
122
  end
122
123
  end
123
- end
124
+ end
@@ -1,3 +1,4 @@
1
+ require_relative "./shared_complex_type"
1
2
  module WashoutBuilder
2
3
  module Document
3
4
  module ExceptionModel
@@ -6,7 +6,7 @@ module WashoutBuilder # Returns the version of the currently loaded Rails as a
6
6
  module VERSION
7
7
  MAJOR = 0
8
8
  MINOR = 14
9
- TINY = 0
9
+ TINY = 1
10
10
  PRE = nil
11
11
 
12
12
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: washout_builder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.14.0
4
+ version: 0.14.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - bogdanRada
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-21 00:00:00.000000000 Z
11
+ date: 2015-01-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: wash_out
@@ -395,8 +395,6 @@ files:
395
395
  - spec/app/helpers/washout_builder_method_arguments_helper_spec.rb
396
396
  - spec/app/helpers/washout_builder_method_list_helper_spec.rb
397
397
  - spec/app/helpers/washout_builder_method_return_type_helper_spec.rb
398
- - spec/app/integration/washout_builder_all_services_spec.rb
399
- - spec/app/integration/washout_builder_service_spec.rb
400
398
  - spec/dummy/Rakefile
401
399
  - spec/dummy/app/controllers/application_controller.rb
402
400
  - spec/dummy/app/helpers/application_helper.rb
@@ -420,6 +418,8 @@ files:
420
418
  - spec/dummy/public/favicon.ico
421
419
  - spec/dummy/public/stylesheets/.gitkeep
422
420
  - spec/dummy/script/rails
421
+ - spec/integration/washout_builder_all_services_spec.rb
422
+ - spec/integration/washout_builder_service_spec.rb
423
423
  - spec/lib/washout_builder/document/complex_type_spec.rb
424
424
  - spec/lib/washout_builder/document/exception_model_spec.rb
425
425
  - spec/lib/washout_builder/document/generator_spec.rb
@@ -462,8 +462,6 @@ test_files:
462
462
  - spec/app/helpers/washout_builder_method_arguments_helper_spec.rb
463
463
  - spec/app/helpers/washout_builder_method_list_helper_spec.rb
464
464
  - spec/app/helpers/washout_builder_method_return_type_helper_spec.rb
465
- - spec/app/integration/washout_builder_all_services_spec.rb
466
- - spec/app/integration/washout_builder_service_spec.rb
467
465
  - spec/dummy/Rakefile
468
466
  - spec/dummy/app/controllers/application_controller.rb
469
467
  - spec/dummy/app/helpers/application_helper.rb
@@ -487,6 +485,8 @@ test_files:
487
485
  - spec/dummy/public/favicon.ico
488
486
  - spec/dummy/public/stylesheets/.gitkeep
489
487
  - spec/dummy/script/rails
488
+ - spec/integration/washout_builder_all_services_spec.rb
489
+ - spec/integration/washout_builder_service_spec.rb
490
490
  - spec/lib/washout_builder/document/complex_type_spec.rb
491
491
  - spec/lib/washout_builder/document/exception_model_spec.rb
492
492
  - spec/lib/washout_builder/document/generator_spec.rb