lib/task_support.rb in radiant-0.8.2 vs lib/task_support.rb in radiant-0.9.0.rc2
- old
+ new
@@ -27,7 +27,27 @@
puts "Radiant::Config updated from #{path}"
else
puts "No file exists at #{path}"
end
end
+
+ # Write the combined content of files in dir into cache_file in the same dir.
+ #
+ def cache_files(dir, files, cache_file)
+ cache_content = files.collect { |f|
+ File.read(File.join(dir, f)) }.join("\n\n")
+
+ cache_path = File.join(dir, cache_file)
+ rm(cache_path) if File.exists?(cache_path)
+ File.open(cache_path, "w+") { |f| f.write(cache_content) }
+ end
+
+ # Reads through the layout file and returns an array of JS filenames
+ #
+ def find_admin_js
+ layout = File.join(RADIANT_ROOT, 'app', 'views', 'layouts', 'application.html.haml')
+ js_regexp = /javascript_include_tag %w\((.*)\), :cache => 'admin\/all/
+ files = File.open(layout) { |f| f.read.match(js_regexp)[1].split }
+ files.collect { |f| f.split('/').last + '.js' }
+ end
end
-end
\ No newline at end of file
+end