1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/railties/lib/rails/dev_caching.rb
Xavier Noria 0caf8ffd7d revises fileutils dependencies in railties
With the exception of what is loaded in active_support/rails,
each file is responsible for its own dependencies. You cannot
rely on runtime order of execution.
2016-04-11 13:16:17 +02:00

43 lines
900 B
Ruby

require 'fileutils'
module Rails
module DevCaching # :nodoc:
class << self
FILE = 'tmp/caching-dev.txt'
def enable_by_file
FileUtils.mkdir_p('tmp')
if File.exist?(FILE)
delete_cache_file
puts 'Development mode is no longer being cached.'
else
create_cache_file
puts 'Development mode is now being cached.'
end
FileUtils.touch 'tmp/restart.txt'
FileUtils.rm_f('tmp/pids/server.pid')
end
def enable_by_argument(caching)
FileUtils.mkdir_p('tmp')
if caching
create_cache_file
elsif caching == false && File.exist?(FILE)
delete_cache_file
end
end
private
def create_cache_file
FileUtils.touch FILE
end
def delete_cache_file
File.delete FILE
end
end
end
end