Sha256: e729a27e7484d1f2a7914d12b78b86ad3662682ba694b42c88a0059c7d34e39f

Contents?: true

Size: 1.11 KB

Versions: 17

Compression:

Stored size: 1.11 KB

Contents

class Eco::API::UseCases::Default::Locations::TagTreePaths < Eco::API::Common::Loaders::UseCase
  name "tagtree-paths"
  type :other

  require_relative 'cli/tagtree_paths_cli'

  OUT_FOLDER      = "sftp".freeze
  OUT_TIME_FORMAT = '%Y%m%dT%H%M%S'.freeze
  OUT_FILENAME    = "tag_paths".freeze

  def main(*_args)
    CSV.open(output_filename, "w") do |csv|
      csv << %w[Tag Path]
      tag_paths.each do |values|
        csv << values
      end
    end

    log(:info) {
      "Generated file '#{output_filename}'"
    }
  end

  private

  def tag_paths
    @tag_paths ||= tagtree.tags.reverse.map do |tag|
      [tag, tagtree.path(tag).join("|")]
    end
  end

  def tagtree
    session.tagtree
  end

  def output_file_format
    'csv'
  end

  def output_filename(name = self.class::OUT_FILENAME)
    File.join(output_folder, "#{timestamp}_#{config.active_enviro}_#{name}.#{output_file_format}")
  end

  def output_folder
    "#{config.active_enviro}/#{self.class::OUT_FOLDER}"
  end

  def timestamp(date = Time.now)
    date.strftime(self.class::OUT_TIME_FORMAT)
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
eco-helpers-3.0.21 lib/eco/api/usecases/default/locations/tagtree_paths_case.rb
eco-helpers-3.0.20 lib/eco/api/usecases/default/locations/tagtree_paths_case.rb
eco-helpers-3.0.19 lib/eco/api/usecases/default/locations/tagtree_paths_case.rb
eco-helpers-3.0.18 lib/eco/api/usecases/default/locations/tagtree_paths_case.rb
eco-helpers-3.0.17 lib/eco/api/usecases/default/locations/tagtree_paths_case.rb
eco-helpers-3.0.16 lib/eco/api/usecases/default/locations/tagtree_paths_case.rb
eco-helpers-3.0.15 lib/eco/api/usecases/default/locations/tagtree_paths_case.rb
eco-helpers-3.0.14 lib/eco/api/usecases/default/locations/tagtree_paths_case.rb
eco-helpers-3.0.13 lib/eco/api/usecases/default/locations/tagtree_paths_case.rb
eco-helpers-3.0.12 lib/eco/api/usecases/default/locations/tagtree_paths_case.rb
eco-helpers-3.0.11 lib/eco/api/usecases/default/locations/tagtree_paths_case.rb
eco-helpers-3.0.10 lib/eco/api/usecases/default/locations/tagtree_paths_case.rb
eco-helpers-3.0.9 lib/eco/api/usecases/default/locations/tagtree_paths_case.rb
eco-helpers-3.0.8 lib/eco/api/usecases/default/locations/tagtree_paths_case.rb
eco-helpers-3.0.7 lib/eco/api/usecases/default/locations/tagtree_paths_case.rb
eco-helpers-3.0.6 lib/eco/api/usecases/default/locations/tagtree_paths_case.rb
eco-helpers-3.0.5 lib/eco/api/usecases/default/locations/tagtree_paths_case.rb