Sha256: 6063e88b8db51c43a3116862a64f50cd7e75177c46ce02827da2296b6ee77287

Contents?: true

Size: 1.95 KB

Versions: 15

Compression:

Stored size: 1.95 KB

Contents

#!/usr/bin/env ruby
# encoding: ASCII-8BIT
$:.unshift File.join(File.dirname(__FILE__),'../lib') if ENV['DEBUG_SOAP4R']

require 'getoptlong'
require 'logger'
require 'wsdl/xmlSchema/xsd2ruby'

class XSD2RubyApp < Logger::Application
private

  OptSet = [
    ['--xsd','-x', GetoptLong::REQUIRED_ARGUMENT],
    ['--module_path','-m', GetoptLong::REQUIRED_ARGUMENT],
    ['--classdef','-e', GetoptLong::OPTIONAL_ARGUMENT],
    ['--mapping_registry','-r', GetoptLong::NO_ARGUMENT],
    ['--mapper','-p', GetoptLong::NO_ARGUMENT],
    ['--force','-f', GetoptLong::NO_ARGUMENT],
    ['--quiet','-q', GetoptLong::NO_ARGUMENT],
  ]

  def initialize
    super('app')
    STDERR.sync = true
    self.level = Logger::FATAL
  end

  def run
    @worker = WSDL::XMLSchema::XSD2Ruby.new
    @worker.logger = @log
    location, opt = parse_opt(GetoptLong.new(*OptSet))
    usage_exit unless location
    @worker.location = location
    if opt['quiet']
      self.level = Logger::FATAL
    else
      self.level = Logger::INFO
    end
    @worker.opt.update(opt)
    @worker.run
    0
  end

  def usage_exit
    puts <<__EOU__
Usage: #{ $0 } --xsd xsd_location [options]
  xsd_location: filename or URL

Example:
  #{ $0 } --xsd myapp.xsd --classdef foo

Options:
  --xsd xsd_location
  --classdef [filenameprefix]
  --mapping_registry
  --mapper
  --module_path [Module::Path::Name]
  --force
  --quiet
__EOU__
    exit 1
  end

  def parse_opt(getoptlong)
    opt = {}
    xsd = nil
    begin
      getoptlong.each do |name, arg|
       	case name
	when "--xsd"
	  xsd = arg
        when "--module_path"
          opt['module_path'] = arg
	when "--classdef", "--mapping_registry", "--mapper"
  	  opt[name.sub(/^--/, '')] = arg.empty? ? nil : arg
	when "--force"
	  opt['force'] = true
        when "--quiet"
          opt['quiet'] = true
   	else
  	  raise ArgumentError.new("Unknown type #{ arg }")
   	end
      end
    rescue
      usage_exit
    end
    return xsd, opt
  end
end

XSD2RubyApp.new.start

Version data entries

15 entries across 15 versions & 9 rubygems

Version Path
malagant-soap4r-1.5.8.20141127181857 bin/xsd2ruby.rb
rtiss_soap4r-1.6.1 bin/xsd2ruby.rb
rtiss_soap4r-1.6.0 bin/xsd2ruby.rb
eSpace_soap4r-1.5.8 bin/xsd2ruby.rb
soap4r-ruby19-1.5.9 bin/xsd2ruby.rb
tomdz-soap4r-1.5.8.20120202093209 bin/xsd2ruby.rb
soap5r-2.0.3 bin/xsd2ruby.rb
soap5r-2.0.2 bin/xsd2ruby.rb
soap5r-2.0.1 bin/xsd2ruby.rb
soap5r-2.0.0 bin/xsd2ruby.rb
soap5r-2.0.0.20120130130121 bin/xsd2ruby.rb
soap4r-sgonyea-1.5.9 bin/xsd2ruby.rb
sunteya-soap4r-1.5.8.0 bin/xsd2ruby.rb
tomdz-soap4r-1.5.8.20111103171510 bin/xsd2ruby.rb
rubyjedi-soap4r-1.5.8.20100619003610 bin/xsd2ruby.rb