Sha256: b9b7e497ddefb20398de43e274deb6da8b9ba8e192c394d74f13c9e59a4a6db9
Contents?: true
Size: 648 Bytes
Versions: 1
Compression:
Stored size: 648 Bytes
Contents
require 'yarf' require 'fileutils' module Yarf class Dumper attr_reader :config def initialize(config) @config = config end def dump(dest_dir) config.target_model_configs.each do |mc| columns = mc.selected_columns.map(&:name) rows = mc.model_class.connection.select("select * from #{mc.model_class.table_name}").to_hash.map do |r| columns.each_with_object({}){|c,d| d[c] = r[c]} end path = File.expand_path(mc.name.underscore + ".yml", dest_dir) FileUtils.mkdir_p(File.dirname(path)) open(path, "w"){|f| f.puts(YAML.dump(rows))} end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
yarf-0.1.0 | lib/yarf/dumper.rb |