class RakeUnusedRoutes::InsightsFormatter

Public Class Methods

convert_from_insights!() click to toggle source
# File lib/rake_unused_routes/insights_formatter.rb, line 7
def convert_from_insights!
  FileUtils.mkdir_p tmp_dir_path
  File.open("#{tmp_dir_path}/controller_summary.csv", 'w+') do |file|
    file.write csv_file
  end
end

Private Class Methods

actions_from_insights() click to toggle source
# File lib/rake_unused_routes/insights_formatter.rb, line 23
def actions_from_insights
  CSV.read(insights_csv_file_path).
    drop(1).map(&:first).reject{|r| r=~/Middleware/ }.
    map{ |r| r.sub('Controller/', '') }.
    map{|r| "#{r.split('/')[0..-2].
    map{|r| r.camelize}.join('::')}Controller##{r.split('/').last}" }.sort
end
csv_file() click to toggle source
# File lib/rake_unused_routes/insights_formatter.rb, line 16
def csv_file
  CSV.generate do |csv|
    csv << [ 'Action' ]
    actions_from_insights.each{ |action| csv << [ action ] }
  end
end
insights_csv_file_path() click to toggle source
# File lib/rake_unused_routes/insights_formatter.rb, line 35
def insights_csv_file_path
  ENV.fetch('INSIGHTS_CONTROLLERS', './tmp/insights_controllers.csv')
end
tmp_dir_path() click to toggle source
# File lib/rake_unused_routes/insights_formatter.rb, line 31
def tmp_dir_path
  './tmp'
end