Skip to content

Commit

Permalink
Merge branch 'release/v0.11.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
bogdanRada committed Dec 19, 2013
2 parents 1775d2a + af7bfba commit a7cc872
Show file tree
Hide file tree
Showing 9 changed files with 95 additions and 30 deletions.
30 changes: 15 additions & 15 deletions app/helpers/washout_builder_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,19 +90,19 @@ def create_html_public_methods(xml, map)


def create_html_public_method(xml, operation, formats)
# raise YAML::dump(formats[:in])
# raise YAML::dump(formats[:builder_in])
xml.h3 "#{operation}"
xml.a("name" => "#{operation}") {}


xml.p("class" => "pre"){ |pre|
unless formats[:out].nil?
complex_class = formats[:out][0].get_complex_class_name
if WashoutBuilder::Type::BASIC_TYPES.include?(formats[:out][0].type)
xml.span("class" => "blue") { |y| y<< "#{formats[:out][0].type}" }
unless formats[:builder_out].nil?
complex_class = formats[:builder_out][0].get_complex_class_name
if WashoutBuilder::Type::BASIC_TYPES.include?(formats[:builder_out][0].type)
xml.span("class" => "blue") { |y| y<< "#{formats[:builder_out][0].type}" }
else
unless complex_class.nil?
if formats[:out][0].multiplied == false
if formats[:builder_out][0].multiplied == false
pre << "<a href='##{complex_class}'><span class='lightBlue'>#{complex_class}</span></a>"
else
pre << "<a href='##{complex_class}'><span class='lightBlue'>Array of #{complex_class}</span></a>"
Expand All @@ -114,13 +114,13 @@ def create_html_public_method(xml, operation, formats)
end

xml.span("class" => "bold") {|y| y << "#{operation} (" }
mlen = formats[:in].size
mlen = formats[:builder_in].size
xml.br if mlen > 1
spacer = "&nbsp;&nbsp;&nbsp;&nbsp;"
if mlen > 0
j=0
while j<mlen
param = formats[:in][j]
param = formats[:builder_in][j]
complex_class = param.get_complex_class_name
use_spacer = mlen > 1 ? true : false
if WashoutBuilder::Type::BASIC_TYPES.include?(param.type)
Expand Down Expand Up @@ -156,9 +156,9 @@ def create_html_public_method(xml, operation, formats)

xml.ul {
j=0
mlen = formats[:in].size
mlen = formats[:builder_in].size
while j<mlen
param = formats[:in][j]
param = formats[:builder_in][j]
complex_class = param.get_complex_class_name
xml.li("class" => "pre") { |pre|
if WashoutBuilder::Type::BASIC_TYPES.include?(param.type)
Expand All @@ -181,13 +181,13 @@ def create_html_public_method(xml, operation, formats)
xml.p "Return value:"
xml.ul {
xml.li {
unless formats[:out].nil?
complex_class = formats[:out][0].get_complex_class_name
if WashoutBuilder::Type::BASIC_TYPES.include?(formats[:out][0].type)
xml.span("class" => "pre") { |xml| xml.span("class" => "blue") { |sp| sp << "#{formats[:out][0].type}" } }
unless formats[:builder_out].nil?
complex_class = formats[:builder_out][0].get_complex_class_name
if WashoutBuilder::Type::BASIC_TYPES.include?(formats[:builder_out][0].type)
xml.span("class" => "pre") { |xml| xml.span("class" => "blue") { |sp| sp << "#{formats[:builder_out][0].type}" } }
else
unless complex_class.nil?
if formats[:out][0].multiplied == false
if formats[:builder_out][0].multiplied == false
xml.span("class" => "pre") { xml.a("href" => "##{complex_class}") { |xml| xml.span("class" => "lightBlue") { |y| y<<"#{complex_class}" } } }
else
xml.span("class" => "pre") { xml.a("href" => "##{complex_class}") { |xml| xml.span("class" => "lightBlue") { |y| y<<"Array of #{complex_class}" } } }
Expand Down
42 changes: 38 additions & 4 deletions lib/washout_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,50 @@ def initialize(attributes = nil)
[WashOut::SOAPError, SOAPError].each do |exception_class|
exception_class.class_eval do
extend WashoutBuilder::Document::VirtusModel
include Virtus.model
attribute :code, Integer
attribute :message, String
attribute :backtrace, String
include Virtus.model
attribute :code, Integer
attribute :message, String
attribute :backtrace, String
end
end


if defined?(WashOut::SOAP)
WashOut::SOAP::ClassMethods.class_eval do
alias_method :original_soap_action, :soap_action
end
end


if defined?(WashOut::Rails::Controller)
WashOut::Rails::Controller::ClassMethods.class_eval do
alias_method :original_soap_action, :soap_action
end
end



WashOut::Param.class_eval do

def self.parse_builder_def(soap_config, definition)
raise RuntimeError, "[] should not be used in your params. Use nil if you want to mark empty set." if definition == []
return [] if definition == nil

definition = { :value => definition } unless definition.is_a?(Hash)

definition.collect do |name, opt|
if opt.is_a? WashOut::Param
opt
elsif opt.is_a? Array
WashOut::Param.new(soap_config, name, opt[0], true)
else
WashOut::Param.new(soap_config, name, opt)
end
end
end

end

ActionController::Base.class_eval do

# Define a SOAP service. The function has no required +options+:
Expand Down
4 changes: 2 additions & 2 deletions lib/washout_builder/document/generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def input_types
types = []
unless soap_actions.blank?
soap_actions.each do |operation, formats|
(formats[:in]).each do |p|
(formats[:builder_in]).each do |p|
types << p
end
end
Expand All @@ -51,7 +51,7 @@ def output_types
types = []
unless soap_actions.blank?
soap_actions.each do |operation, formats|
(formats[:out]).each do |p|
(formats[:builder_out]).each do |p|
types << p
end
end
Expand Down
34 changes: 32 additions & 2 deletions lib/washout_builder/soap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,43 @@
module WashoutBuilder
module SOAP
extend ActiveSupport::Concern
include WashOut::Rails::Controller
include WashOut::SOAP if defined?(WashOut::SOAP)
include WashOut::Rails::Controller if defined?(WashOut::Rails::Controller)



module ClassMethods
attr_accessor :soap_actions
# Define a SOAP action +action+. The function has two required +options+:
# :args and :return. Each is a type +definition+ of format described in
# WashOut::Param#parse_def.
#
# An optional option :to can be passed to allow for names of SOAP actions
# which are not valid Ruby function names.
def soap_action(action, options={})
original_soap_action(action, options)

if action.is_a?(Symbol)
if soap_config.camelize_wsdl.to_s == 'lower'
action = action.to_s.camelize(:lower)
elsif soap_config.camelize_wsdl
action = action.to_s.camelize
end
end


current_action = self.soap_actions[action]
current_action[:builder_in] = WashOut::Param.parse_builder_def(soap_config, options[:args])
current_action[:builder_out] = WashOut::Param.parse_builder_def(soap_config, options[:return])

end
end


included do
include WashOut::Configurable if defined?(WashOut::Configurable)
include WashOut::Dispatcher if defined?(WashOut::Dispatcher)
include WashoutBuilder::Dispatcher
self.soap_actions = {}
end
end
end
2 changes: 1 addition & 1 deletion lib/washout_builder/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module WashoutBuilder
VERSION = "0.10.4"
VERSION = "0.11.0"
end
2 changes: 1 addition & 1 deletion spec/lib/washout_builder/dispatcher_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def dispatcher_method
:config => ApiController.soap_config,
:service_class => ApiController,
:soap_actions => {'dispatcher_method' =>
{:args => nil, :return => nil, :in => [], :out => [], :to => 'dispatcher_method'}
{:args => nil, :return => nil, :in => [], :out => [],:builder_in => [], :builder_out => [], :to => 'dispatcher_method'}
}
)
get :_generate_doc
Expand Down
6 changes: 3 additions & 3 deletions spec/lib/washout_builder/document/generator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

let(:soap_actions) {
{'dispatcher_method' =>
{:args => nil, :return => nil, :in => [], :out => [], :to => 'dispatcher_method'}
{:args => nil, :return => nil, :in => [], :out => [], :builder_in => [], :builder_out => [], :to => 'dispatcher_method'}
}
}
let(:service_class) { ApiController }
Expand Down Expand Up @@ -68,7 +68,7 @@
context "input types" do
let(:expected) { types = []
soap_actions.each do |operation, formats|
(formats[:in]).each do |p|
(formats[:builder_in]).each do |p|
types << p
end
end
Expand All @@ -81,7 +81,7 @@
context "output types" do
let(:expected) { types = []
soap_actions.each do |operation, formats|
(formats[:out]).each do |p|
(formats[:builder_out]).each do |p|
types << p
end
end
Expand Down
3 changes: 2 additions & 1 deletion spec/lib/washout_builder_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
before(:each) do
WashOut::Rails::Engine.config.wash_out[:wsdl_style] = 'rpc'
WashOut::Rails::Engine.config.wash_out[:parser] = :nokogiri
WashOut::Rails::Engine.config.wash_out[:catch_xml_errors] = true
WashOut::Rails::Engine.config.wash_out[:catch_xml_errors] = true
WashOut::Rails::Engine.config.wash_out[:camelize_wsdl] = "lower"
end

let :nori do
Expand Down
2 changes: 1 addition & 1 deletion washout_builder.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ Gem::Specification.new do |s|
s.files = `git ls-files`.split("\n")
s.test_files = s.files.grep(/^(spec)/)
s.require_paths = ["lib"]
s.add_dependency("wash_out", ">= 0.10.0.beta.1")
s.add_dependency("wash_out", ">= 0.9.0")
s.add_dependency("virtus", ">= 1.0.0")
end

0 comments on commit a7cc872

Please sign in to comment.