Sha256: 51e36435884020858c509b35d3c9d24f0217e1a2f4f50a09414b95ed85f370dc
Contents?: true
Size: 862 Bytes
Versions: 15
Compression:
Stored size: 862 Bytes
Contents
# frozen_string_literal: true require 'alchemy/upgrader' module Alchemy::Upgrader::Tasks class ElementViewsUpdater < Thor include Thor::Actions no_tasks do def rename_element_views puts "-- Removing '_view' suffix from element views" Dir.glob("#{elements_view_folder}/*_view.*").each do |file| FileUtils.mv(file, file.to_s.sub(/_view/, '')) end end def update_local_variable puts "-- Updating element views local variable to element name" Alchemy::Element.definitions.map { |e| e['name'] }.each do |name| view = Dir.glob("#{elements_view_folder}/_#{name}.*").last gsub_file(view, /\b#{name}_view\b/, name) end end end private def elements_view_folder Rails.root.join('app', 'views', 'alchemy', 'elements') end end end
Version data entries
15 entries across 15 versions & 1 rubygems