Rakefile in adwords4r-13.0.1 vs Rakefile in adwords4r-15.0.1

- old
+ new

@@ -14,11 +14,11 @@ # Determine the current version of the software CLOBBER.include('pkg') -CURRENT_VERSION = '13.0.1' +CURRENT_VERSION = '15.0.1' PKG_VERSION = ENV['REL'] ? ENV['REL'] : CURRENT_VERSION SRC_RB = FileList['lib/**/*.rb'] WSDLDIR = 'wsdl' @@ -26,51 +26,58 @@ GENDIR = LIBDIR + '/adwords4r' logger = Logger.new(STDERR) CLEAN.include(WSDLDIR) -AdWords::Service.getVersions.each do |v| +AdWords::Service.get_versions.each do |v| vname = "v#{v}" CLEAN.include(File.join(GENDIR, vname)) end desc "gets the wsdl and generates the classes" task :default => [:getwsdl, :generate] desc "gets the wsdl files for AdWords services" task :getwsdl do - AdWords::Service.getVersions.each do |v| + AdWords::Service.get_versions.each do |v| vname = "v#{v}" mkdir_p File.join(WSDLDIR, vname) - AdWords::Service.getServices(v).each {|s| - save(getfile("adwords.google.com", - "/api/adwords/#{vname}/#{s}Service?wsdl"), - getWsdlFileName(vname,s))} + AdWords::Service.get_services(v).each do |s| + if v.to_i <= 13 + save(getfile("adwords.google.com", + "/api/adwords/#{vname}/#{s}Service?wsdl"), + get_wsdl_file_name(vname, s)) + else + save(getfile("adwords-sandbox.google.com", + "/api/adwords/cm/#{vname}/#{s}Service?wsdl"), + get_wsdl_file_name(vname, s)) + end + end end end desc "generates AdWords classes from the wsdl files" task :generate do - AdWords::Service.getVersions.each do |v| + AdWords::Service.get_versions.each do |v| vname = "v#{v}" gendir = "#{LIBDIR}/adwords4r/#{vname}" mkdir_p gendir - AdWords::Service.getServices(v).each do |name| + AdWords::Service.get_services(v).each do |name| worker = WSDL::SOAP::WSDL2Ruby.new worker.logger = logger - worker.location = getWsdlFileName(vname,name) + worker.location = get_wsdl_file_name(vname,name) worker.basedir = gendir - worker.opt.update(getWsdlOpt(name)) + worker.opt.update(get_wsdl_opt(vname,name)) worker.run - fixImport(v, File.join(gendir, "#{name}Driver.rb")) - fixImport(v, File.join(gendir, "#{name}MappingRegistry.rb")) - fixImport(v, File.join(gendir, "#{name}.rb")) + fix_import(v, File.join(gendir, "#{name}Driver.rb")) + fix_import(v, File.join(gendir, "#{name}MappingRegistry.rb")) + fix_import(v, File.join(gendir, "#{name}.rb")) end end end -def fixImport(version, file) +def fix_import(version, file) vname = "v#{version}" tempfile = file + '.tmp' outfile = File.new(tempfile,"w") File.open(file, "r") do |infile| infile.each do |l| @@ -84,117 +91,105 @@ end outfile.close File.rename(tempfile, file) end -def getWsdlOpt(s) +def get_wsdl_opt(v,s) optcmd= {} s << "Service" optcmd['classdef'] = s optcmd['force'] = true optcmd['mapping_registry'] = true optcmd['driver'] = nil - + # Causes soap4r to wrap the classes it outputs into the given modules - optcmd['module_path'] = ['AdWords', s] + optcmd['module_path'] = ['AdWords', v.capitalize, s] return optcmd end -def getWsdlFileName(v,s) +def get_wsdl_file_name(v,s) "#{WSDLDIR}/#{v}/#{s}.wsdl" end def getfile(host, path) - puts "getting https//#{host}#{path}" + puts "getting https://#{host}#{path}" https = Net::HTTP.new(host, 443) https.use_ssl = true https.verify_mode = OpenSSL::SSL::VERIFY_NONE https.start { |w| w.get2(path).body } end def fix_attribute(text, name, type) text.gsub!(Regexp.new("#{name}=\"#{type}\""),"#{name}=\"xsd:#{type}\"") end -def fixWsdl(wsdl) - ['type', 'base'].each {|name| +def fix_wsdl(wsdl) + ['type', 'base'].each {|name| ['long', 'string', 'date', 'int', 'boolean'].each {|type| fix_attribute(wsdl, name, type)}} schema_ns = "xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"" if wsdl !~ Regexp.new(schema_ns) wsdl.gsub!(/(<wsdl:definitions[^>]*)>/, '\1 ' + schema_ns + '>') end return wsdl - #wsdl.gsub(/type=\"long\"/, 'type="xsd:long"') end # Saves this document to the specified @var path. -#doesn't create the file if contains markup for google 404 page +# doesn't create the file if contains markup for google 404 page def save(content, path) if content !~ /<H2>Error 404<\/H2>/ - File::open(path, 'w') {|f| f.write(fixWsdl(content))} + File::open(path, 'w') {|f| f.write(fix_wsdl(content))} end end # ==================================================================== # Create a task that will package the Rake software into distributable # gem files. PKG_FILES = FileList[ - '*.*', - 'Rakefile', - 'lib/**/*.rb', - 'examples/**/*.rb', - # 'test/**/*.rb', + '*.*', + 'Rakefile', + 'lib/**/*.rb', + 'examples/**/*.rb', 'scripts/**/*.rb' ] -#puts PKG_FILES - PKG_FILES.exclude(/\._/) if ! defined?(Gem) puts "Package Target requires RubyGems" else spec = Gem::Specification.new do |s| - + #### Basic information. - + s.name = 'adwords4r' s.version = PKG_VERSION s.summary = "Client library for the AdWords API." s.description = %{\ -Adwords4r provides an easy to use way to access the AdWords API in ruby.\ +Adwords4r provides an easy to use way to access the AdWords API in Ruby.\ Currently the following AdWords API versions are supported:\ \ -* V12\ * V13\ +* V200902 (sandbox) } - + s.files = PKG_FILES.to_a s.require_path = 'lib' s.autorequire = 'adwords4r' - - #s.test_files = PKG_FILES.select { |fn| fn =~ /^test\/test/ } - - #s.has_rdoc = true + s.has_rdoc = false - #s.extra_rdoc_files = rd.rdoc_files.reject { |fn| fn =~ /\.rb$/ }.to_a - #s.rdoc_options << - # '--title' << 'Builder -- Easy XML Building' << - # '--main' << 'README' << - # '--line-numbers' - - s.author = "Jeffrey Posnick, Patrick Chanezon, Ryan Leavengood" - s.email = "jeffy@google.com" - s.homepage = "http://rubyforge.org/projects/google4r/" - s.requirements << 'soap4r v1.5.8 or greater' + + s.author = + "Sergio Gomes, Jeffrey Posnick, Patrick Chanezon, Ryan Leavengood" + s.email = "api.sgomes@gmail.com" + s.homepage = "http://code.google.com/p/google-api-adwords-ruby/" + s.requirements << 'soap4r v1.5.8' s.requirements << 'httpclient v2.1.2 or greater' - s.rubyforge_project = 'google4r' - s.add_dependency('soap4r', '>= 1.5.8') + s.add_dependency('soap4r', '= 1.5.8') s.add_dependency('httpclient', '>= 2.1.2') end - + Rake::GemPackageTask.new(spec) do |t| t.need_tar = true end end