Sha256: 9c66a90b23fe216f5e4e4d78e14958c06765f28efe12c917c2250a611f88495c
Contents?: true
Size: 1018 Bytes
Versions: 5
Compression:
Stored size: 1018 Bytes
Contents
module Onoma module Migration class Base def self.parse(file) f = File.open(file, 'rb') document = Nokogiri::XML(f) do |config| config.strict.nonet.noblanks.noent end f.close root = document.root number = file.basename.to_s.split('_').first.to_i new(number, root['name'], root) end attr_reader :number, :name def initialize(number, name, element = nil) @number = number @name = name @actions = [] if element element.children.each do |child| next unless child.is_a? Nokogiri::XML::Element @actions << "Onoma::Migration::Actions::#{child.name.underscore.classify}".constantize.new(child) end end end def each_action(&block) @actions.each(&block) end def inspect "#<#{self.class.name}:#{format('%#x', object_id)} ##{number} #{name.inspect} (#{@actions.size} actions)>" end end end end
Version data entries
5 entries across 5 versions & 1 rubygems