Sha256: c791592b3edac1f1b016b82716e9d331b573866b0947da8c7bcc69f5554ad9ec
Contents?: true
Size: 1.43 KB
Versions: 49
Compression:
Stored size: 1.43 KB
Contents
module Challah module Task require 'fileutils' def self.unpack_file(source, destination = nil) destination = source if destination.nil? unless defined?(Rails) raise "Rails could not be found. Are you sure you are in a Rails project?" end from = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', source)) to = File.expand_path(File.join(Rails.root, destination)) if File.exists?(from) if File.exists?(to) puts "exists #{destination}" else FileUtils.mkdir_p(File.dirname(to)) FileUtils.cp(from, to) puts "created #{destination}" end end end end end namespace :challah do namespace :unpack do desc "Unpack the User model, Role model, Sessions controller and sign in views to the app" task :all => [ :user, :signin, :views ] desc "Copy the sign in and access denied views into the app" task :signin do Challah::Task.unpack_file('app/controllers/sessions_controller.rb') end desc "Copy the default User model into the app" task :user do Challah::Task.unpack_file('app/models/user.rb') end desc "Copy the sign in and access denied views into the app" task :views do Challah::Task.unpack_file('app/views/sessions/new.html.erb') Challah::Task.unpack_file('app/views/sessions/access_denied.html.erb') end end task :unpack => 'unpack:all' end
Version data entries
49 entries across 48 versions & 2 rubygems