All export classes inherit from Taxonifi::Export::Base
# File lib/export/format/base.rb, line 8 def initialize(options = {}) opts = { :base_export_path => EXPORT_BASE, :export_folder => '.' }.merge!(options) @base_export_path = opts[:base_export_path] @export_folder = opts[:export_folder] end
Recursively (over)write the the export path.
# File lib/export/format/base.rb, line 30 def configure_folders FileUtils.mkdir_p export_path end
Subclassed models expand on this method, typically writing files to the folders created here.
# File lib/export/format/base.rb, line 25 def export configure_folders end
Return the path to which exported files will be written.
# File lib/export/format/base.rb, line 19 def export_path File.expand_path(File.join(@base_export_path, @export_folder)) end
Write the string to a file in the export path.
# File lib/export/format/base.rb, line 35 def write_file(filename = 'foo', string = nil) raise ExportError, 'Nothing to export for #{filename}.' if string.nil? || string == "" f = File.new( File.expand_path(File.join(export_path, filename)), 'w+') f.puts string f.close end