soybean 1.0.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/bin/xsd2ruby DELETED
@@ -1,90 +0,0 @@
1
- #!/usr/bin/env ruby
2
- $:.unshift File.absolute_path('.')
3
- require 'getoptlong'
4
- require 'logger'
5
- require 'vendor/wsdl/xmlSchema/xsd2ruby'
6
-
7
- class XSD2RubyApp < Logger::Application
8
- private
9
-
10
- OptSet = [
11
- ['--xsd', '-x', GetoptLong::REQUIRED_ARGUMENT],
12
- ['--module_path', '-m', GetoptLong::REQUIRED_ARGUMENT],
13
- ['--classdef', '-e', GetoptLong::OPTIONAL_ARGUMENT],
14
- ['--mapping_registry', '-r', GetoptLong::NO_ARGUMENT],
15
- ['--mapper', '-p', GetoptLong::NO_ARGUMENT],
16
- ['--force', '-f', GetoptLong::NO_ARGUMENT],
17
- ['--quiet', '-q', GetoptLong::NO_ARGUMENT],
18
- ]
19
-
20
- def initialize
21
- super('app')
22
- STDERR.sync = true
23
- WSDL::SOAP::ClassNameCreator
24
- self.level = Logger::FATAL
25
- end
26
-
27
- def run
28
- @worker = WSDL::XMLSchema::XSD2Ruby.new
29
- @worker.logger = @log
30
- location, opt = parse_opt(GetoptLong.new(*OptSet))
31
- usage_exit unless location
32
- @worker.location = location
33
- if opt['quiet']
34
- self.level = Logger::FATAL
35
- else
36
- self.level = Logger::INFO
37
- end
38
- @worker.opt.update(opt)
39
- @worker.run
40
- 0
41
- end
42
-
43
- def usage_exit
44
- puts <<__EOU__
45
- Usage: #{ $0 } --xsd xsd_location [options]
46
- xsd_location: filename or URL
47
-
48
- Example:
49
- #{ $0 } --xsd myapp.xsd --classdef foo
50
-
51
- Options:
52
- --xsd xsd_location
53
- --classdef [filenameprefix]
54
- --mapping_registry
55
- --mapper
56
- --module_path [Module::Path::Name]
57
- --force
58
- --quiet
59
- __EOU__
60
- exit 1
61
- end
62
-
63
- def parse_opt(getoptlong)
64
- opt = {}
65
- xsd = nil
66
- begin
67
- getoptlong.each do |name, arg|
68
- case name
69
- when "--xsd"
70
- xsd = arg
71
- when "--module_path"
72
- opt['module_path'] = arg
73
- when "--classdef", "--mapping_registry", "--mapper"
74
- opt[name.sub(/^--/, '')] = arg.empty? ? nil : arg
75
- when "--force"
76
- opt['force'] = true
77
- when "--quiet"
78
- opt['quiet'] = true
79
- else
80
- raise ArgumentError.new("Unknown type #{ arg }")
81
- end
82
- end
83
- rescue
84
- usage_exit
85
- end
86
- return xsd, opt
87
- end
88
- end
89
-
90
- XSD2RubyApp.new.start
@@ -1,33 +0,0 @@
1
- require 'active_support/core_ext/string/inflections'
2
-
3
- module Soybean
4
- module Actions
5
-
6
- class GenerateClasses < Thor::Actions::CreateFile
7
-
8
- # @param base [Thor::Base] A Thor::Base instance
9
- # @param location [String|Pathname] Path to xsd file
10
- # @param destination [String|Pathname] Path to generated file with ruby classes
11
- # @param config [Hash] config
12
- # @option config [Boolean] :force Override destination file
13
- # @option config [Boolean] :verbose Be verbosely
14
- def initialize(base, location, destination, config={})
15
- @location = location
16
- super(base, "#{destination}.rb", class_definitions, config)
17
- end
18
-
19
- protected
20
-
21
- # @return [WSDL::SOAP::ClassDefCreator] Generate ruby classes from xsd
22
- def class_definitions
23
- @definitions ||= WSDL::SOAP::ClassDefCreator.new(xsd, WSDL::SOAP::ClassNameCreator.new).dump
24
- end
25
-
26
- # @return [WSDL::XMLSchema::Importer] Parse xsd
27
- def xsd
28
- @xsd ||= WSDL::XMLSchema::Importer.import(@location)
29
- end
30
-
31
- end
32
- end
33
- end