app/controllers/morion/morion_controller.rb in morion-0.0.4 vs app/controllers/morion/morion_controller.rb in morion-0.0.5

- old
+ new

@@ -1,33 +1,10 @@ require_dependency "morion/application_controller" module Morion class MorionController < ApplicationController def index - root = Rails.root.to_s - regex = /.*(\.jpg|\.jpeg|\.png|\.svg)/ - app_assets_paths = Rails.application.assets.paths. - select {|path| path =~ /#{root}/}. - map {|path| Pathname.new(path).cleanpath } - - files_data = Find.find(*app_assets_paths).select {|path| path =~ regex } - - files_data = files_data.map do |path| - filename = path.match(/(?:.+\/)([^#?]+)/)[1] - extension = filename.match(/(\.[^\\]+)$/)[1] - asset_path = path - folder_path = path.gsub(root, "") - - app_assets_paths.each do |rails_path| - asset_path.gsub!("#{rails_path}/", "") - end - - {filename: filename, asset_path: asset_path, path: folder_path, extension: extension} - end - - # binding.pry - - @folders = files_data.group_by {|file| file[:path].match(/(.*\/).*/)[1] } + @folders = FoldersAndFilesFinder.new.files_by_folders end protected end end