Class: DataMapper::Salesforce::SoapWrapper
- Inherits:
-
Object
- Object
- DataMapper::Salesforce::SoapWrapper
- Defined in:
- lib/dm-salesforce/soap_wrapper.rb
Defined Under Namespace
Classes: ClassesFailedToGenerate
Instance Attribute Summary collapse
-
#api_dir ⇒ Object
readonly
Returns the value of attribute api_dir.
-
#driver_name ⇒ Object
readonly
Returns the value of attribute driver_name.
-
#module_name ⇒ Object
readonly
Returns the value of attribute module_name.
-
#wsdl_path ⇒ Object
readonly
Returns the value of attribute wsdl_path.
Instance Method Summary collapse
- #driver ⇒ Object
- #files_exist? ⇒ Boolean
-
#generate_files ⇒ Object
Good candidate for shipping out into a Rakefile.
- #generate_soap_classes ⇒ Object
-
#initialize(module_name, driver_name, wsdl_path, api_dir) ⇒ SoapWrapper
constructor
A new instance of SoapWrapper.
- #wsdl_api_dir ⇒ Object
Constructor Details
#initialize(module_name, driver_name, wsdl_path, api_dir) ⇒ SoapWrapper
Returns a new instance of SoapWrapper.
7 8 9 10 11 |
# File 'lib/dm-salesforce/soap_wrapper.rb', line 7 def initialize(module_name, driver_name, wsdl_path, api_dir) @module_name, @driver_name, @wsdl_path, @api_dir = module_name, driver_name, File.(wsdl_path), File.(api_dir) generate_soap_classes driver end |
Instance Attribute Details
#api_dir ⇒ Object (readonly)
Returns the value of attribute api_dir.
5 6 7 |
# File 'lib/dm-salesforce/soap_wrapper.rb', line 5 def api_dir @api_dir end |
#driver_name ⇒ Object (readonly)
Returns the value of attribute driver_name.
5 6 7 |
# File 'lib/dm-salesforce/soap_wrapper.rb', line 5 def driver_name @driver_name end |
#module_name ⇒ Object (readonly)
Returns the value of attribute module_name.
5 6 7 |
# File 'lib/dm-salesforce/soap_wrapper.rb', line 5 def module_name @module_name end |
#wsdl_path ⇒ Object (readonly)
Returns the value of attribute wsdl_path.
5 6 7 |
# File 'lib/dm-salesforce/soap_wrapper.rb', line 5 def wsdl_path @wsdl_path end |
Instance Method Details
#driver ⇒ Object
13 14 15 |
# File 'lib/dm-salesforce/soap_wrapper.rb', line 13 def driver @driver ||= Object.const_get(module_name).const_get(driver_name).new end |
#files_exist? ⇒ Boolean
55 56 57 58 59 |
# File 'lib/dm-salesforce/soap_wrapper.rb', line 55 def files_exist? ["#{module_name}.rb", "#{module_name}MappingRegistry.rb", "#{module_name}Driver.rb"].all? do |name| File.exist?("#{wsdl_api_dir}/#{name}") end end |
#generate_files ⇒ Object
Good candidate for shipping out into a Rakefile.
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/dm-salesforce/soap_wrapper.rb', line 34 def generate_files require 'wsdl/soap/wsdl2ruby' wsdl2ruby = WSDL::SOAP::WSDL2Ruby.new wsdl2ruby.logger = $LOG if $LOG wsdl2ruby.location = wsdl_path wsdl2ruby.basedir = wsdl_api_dir wsdl2ruby.opt.merge!({ 'classdef' => module_name, 'module_path' => module_name, 'mapping_registry' => nil, 'driver' => nil, 'client_skelton' => nil, }) wsdl2ruby.run raise ClassesFailedToGenerate unless files_exist? end |
#generate_soap_classes ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/dm-salesforce/soap_wrapper.rb', line 17 def generate_soap_classes unless File.file?(wsdl_path) raise Errno::ENOENT, "Could not find the WSDL at #{wsdl_path}" end unless File.directory?(wsdl_api_dir) FileUtils.mkdir_p wsdl_api_dir end generate_files unless files_exist? $:.push wsdl_api_dir require "#{module_name}Driver" $:.delete wsdl_api_dir end |
#wsdl_api_dir ⇒ Object
61 62 63 |
# File 'lib/dm-salesforce/soap_wrapper.rb', line 61 def wsdl_api_dir "#{api_dir}/#{File.basename(wsdl_path)}" end |