exe/soaspec in soaspec-0.2.8 vs exe/soaspec in soaspec-0.2.9
- old
+ new
@@ -1,18 +1,15 @@
#!/usr/bin/env ruby
-
require 'thor'
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')
require 'savon'
require 'soaspec'
module Soaspec
-
# Common executable for Soaspec
class Exe < Thor
-
include Soaspec::ExeHelpers
include Soaspec::WsdlGenerator
long_desc <<-LONGDESC
`soaspec new` will generate the initial files and folders for starting a testing project using soaspec
@@ -52,10 +49,11 @@
LONGDESC
desc 'add [type] [name]', 'Add new ExchangeHandler'
def add(type = 'rest', name = 'TestService')
raise "Type '#{type}' is not available" unless %w[rest soap].include? type
+
@name = name # Use instance variable for ERB
create_file filename: File.join('lib', "#{name.snakecase}.rb"),
content: retrieve_contents(File.join('lib', "new_#{type}_service.rb"))
end
@@ -85,34 +83,31 @@
savon_options[:basic_auth] = [@auth_name, @auth_password] if options[:auth] == 'basic'
@wsdl_doc = Savon.client(**savon_options).wsdl
@wsdl_schemas = @wsdl_doc.parser.schemas
- create_file filename: 'Rakefile', ignore_if_present: true
- create_file filename: 'Gemfile', ignore_if_present: true
+ create_files %w[Rakefile Gemfile README.md spec/spec_helper.rb], ignore_if_present: true
create_file(filename: '.rspec')
create_file(filename: '.travis.yml') if options[:ci] == 'travis'
- create_file filename: 'README.md', ignore_if_present: true
- create_file filename: 'spec/spec_helper.rb', ignore_if_present: true
create_folder 'logs'
create_file filename: "lib/#{options[:name].snakecase}.rb", content: class_content
# Files according to WSDL
- @wsdl_doc.operations.each do |operation, details|
+ @wsdl_doc.operations.each do |operation, op_details|
puts "Creating files for operation: #{operation}"
@content = "default:\n"
@use_camel_case = false
- puts 'Message params: ' + details.to_s
+ puts 'Message params: ' + op_details.to_s
# From namespace identifier, find namespace, and for that find schemaLocation xsd and use that to build request
- if details[:parameters]
- details[:parameters].each do |element, details|
- @use_camel_case = true if /[[:upper:]]/.match(element.to_s[0]) != nil
+ if op_details[:parameters]
+ op_details[:parameters].each do |element, details|
+ @use_camel_case = true unless /[[:upper:]]/.match(element.to_s[0]).nil?
@content += " #{element.to_s.snakecase}: #{fill_in_field_from_type(details[:type])} # #{details[:type]} \n"
# TODO: If details is a Hash need to loop again
end
end
- wsdl_to_yaml_for root_elements_for(details)
+ wsdl_to_yaml_for root_elements_for(op_details)
params = []
params << 'convert_request_keys_to: :camelcase' if @use_camel_case
params_string = params == [] ? '' : ', ' + params.join(', ')
@class_params = "'#{camel_case(operation)}'#{params_string}"
@@ -131,6 +126,6 @@
Soaspec::VirtualServer.run!(Port: port)
end
end
end
-Soaspec::Exe.start(ARGV)
\ No newline at end of file
+Soaspec::Exe.start(ARGV)