diff --git a/crowbar_framework/lib/tasks/assets.rake b/crowbar_framework/lib/tasks/assets.rake new file mode 100644 index 000000000..add0f0d00 --- /dev/null +++ b/crowbar_framework/lib/tasks/assets.rake @@ -0,0 +1,31 @@ +# +# Copyright 2015, SUSE LINUX Products GmbH +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +namespace :assets do + task non_digested: :environment do + assets = Dir.glob(File.join(Rails.root, 'public/assets/**/*')) + regex = /(-{1}[a-z0-9]{32}*\.{1}){1}/ + assets.each do |file| + next if File.directory?(file) || file !~ regex + + source = file.split('/') + source.push(source.pop.gsub(regex, '.')) + + non_digested = File.join(source) + FileUtils.symlink(file, non_digested, :force => true) + end + end +end