Sha256: 7c3d36f009c3198ef33fd0f3f72423319c2a888798d1d40f3c2764873415fb42
Contents?: true
Size: 1.37 KB
Versions: 3
Compression:
Stored size: 1.37 KB
Contents
module Eco::API::UseCases::GraphQL::Samples::Location::Service module TreeToList module Output OUT_FOLDER = 'sftp'.freeze OUT_TIME_FORMAT = '%Y%m%dT%H%M%S'.freeze OUT_FILENAME = 'Location_Nodes.csv'.freeze OUT_HEADER = %w[ nodeId name parentId parentName archived archivedToken weight level_reference ].freeze private def generate_live_nodes_file(nodes_list) return unless generate_live_nodes_file? CSV.open(output_filename, "w") do |csv| csv << output_header nodes_list do |item| csv << item.values_at(*output_header) end end log(:info) { "Created file: #{output_filename}" } end def output_header self.class::OUT_HEADER end def generate_live_nodes_file? true end def output_filename @output_filename ||= File.join(output_folder, "#{timestamp}_#{output_file}") end def output_folder "#{config.active_enviro}/#{self.class::OUT_FOLDER}" end def output_file options.dig(:output, :file) || self.class::OUT_FILENAME end def timestamp(date = Time.now) date.strftime(self.class::OUT_TIME_FORMAT) end end end end
Version data entries
3 entries across 3 versions & 1 rubygems