Module: ScaffoldParser

Defined in:
lib/scaffold_parser.rb,
lib/scaffold_parser/scaffolders/xsd.rb,
lib/scaffold_parser/scaffolders/xsd/parser.rb,
lib/scaffold_parser/scaffolders/xsd/parser/stack.rb,
lib/scaffold_parser/scaffolders/xsd/parser/handlers/all.rb,
lib/scaffold_parser/scaffolders/xsd/parser/handlers/blank.rb,
lib/scaffold_parser/scaffolders/xsd/parser/handlers/klass.rb,
lib/scaffold_parser/scaffolders/xsd/parser/handlers/utils.rb,
lib/scaffold_parser/scaffolders/xsd/parser/handlers/choice.rb,
lib/scaffold_parser/scaffolders/xsd/parser/handlers/import.rb,
lib/scaffold_parser/scaffolders/xsd/parser/handlers/module.rb,
lib/scaffold_parser/scaffolders/xsd/parser/module_template.rb,
lib/scaffold_parser/scaffolders/xsd/parser/handlers/include.rb,
lib/scaffold_parser/scaffolders/xsd/parser/handlers/elements.rb,
lib/scaffold_parser/scaffolders/xsd/parser/handlers/sequence.rb,
lib/scaffold_parser/scaffolders/xsd/parser/handlers/at_method.rb,
lib/scaffold_parser/scaffolders/xsd/parser/handlers/extension.rb,
lib/scaffold_parser/scaffolders/xsd/parser/handlers/base_method.rb,
lib/scaffold_parser/scaffolders/xsd/parser/handlers/element_ref.rb,
lib/scaffold_parser/scaffolders/xsd/parser/handlers/list_method.rb,
lib/scaffold_parser/scaffolders/xsd/parser/handlers/complex_type.rb,
lib/scaffold_parser/scaffolders/xsd/parser/handlers/class_inherit.rb,
lib/scaffold_parser/scaffolders/xsd/parser/handlers/module_include.rb,
lib/scaffold_parser/scaffolders/xsd/parser/handlers/order_elements.rb,
lib/scaffold_parser/scaffolders/xsd/parser/handlers/submodel_method.rb,
lib/scaffold_parser/scaffolders/xsd/parser/handlers/proxy_list_method.rb

Defined Under Namespace

Modules: Scaffolders

Class Method Summary collapse

Class Method Details

.scaffold(path, options = {}) ⇒ Object



7
8
9
10
11
12
13
14
15
16
# File 'lib/scaffold_parser.rb', line 7

def self.scaffold(path, options = {})
  scaffold_to_string(File.read(path), options).each do |path, content|
    complete_path = path.prepend('./tmp/')
    ensure_dir_exists(complete_path, options)

    puts "Writing out #{complete_path}" if options[:verbose]

    File.open(complete_path, 'wb') { |f| f.write content }
  end
end

.scaffold_to_string(schema, options = {}) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/scaffold_parser.rb', line 18

def self.scaffold_to_string(schema, options = {})
  parse_options = { collect_only: [:element,
                                   :complex_type,
                                   :sequence,
                                   :all,
                                   :choice,
                                   :schema,
                                   :include,
                                   :import,
                                   :group,
                                   :extension] }
  doc = XsdModel.parse(schema, parse_options)

  Scaffolders::XSD.call(doc, options, parse_options)
end