Class: Eatr::Xml::SchemaGenerator
- Inherits:
-
Object
- Object
- Eatr::Xml::SchemaGenerator
- Defined in:
- lib/eatr/xml/schema_generator.rb
Instance Method Summary collapse
-
#initialize(xml_path) ⇒ SchemaGenerator
constructor
A new instance of SchemaGenerator.
- #schema(starting_point) ⇒ Object
Constructor Details
#initialize(xml_path) ⇒ SchemaGenerator
Returns a new instance of SchemaGenerator.
4 5 6 |
# File 'lib/eatr/xml/schema_generator.rb', line 4 def initialize(xml_path) @xml_path = xml_path end |
Instance Method Details
#schema(starting_point) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/eatr/xml/schema_generator.rb', line 8 def schema(starting_point) doc = Nokogiri::XML(File.open(@xml_path)) do |config| config.strict.nonet end doc.remove_namespaces! fields = doc.at_xpath(starting_point).element_children.flat_map do |child| field_def(child) end schema = { 'name' => '', 'remove_namespaces' => true, 'fields' => fields } YAML.dump(schema) end |