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

Version Path
challah-2.0.0.beta2 lib/tasks/unpack.rake
challah-2.0.0.beta1 lib/tasks/unpack.rake
challah-1.6.1 lib/tasks/unpack.rake
challah-1.6.0 lib/tasks/unpack.rake
challah-1.5.0 lib/tasks/unpack.rake
challah-1.4.2 lib/tasks/unpack.rake
challah-1.4.1 lib/tasks/unpack.rake
challah-1.4.0 lib/tasks/unpack.rake
challah-1.3.3 lib/tasks/unpack.rake
challah-1.3.2 lib/tasks/unpack.rake
challah-1.3.1 lib/tasks/unpack.rake
challah-1.3.0 lib/tasks/unpack.rake
challah-1.2.11 lib/tasks/unpack.rake
challah-1.2.10 lib/tasks/unpack.rake
challah-1.2.9 lib/tasks/unpack.rake
challah-1.2.8 lib/tasks/unpack.rake
challah-1.2.7 lib/tasks/unpack.rake
challah-1.2.6 lib/tasks/unpack.rake
challah-1.2.5 lib/tasks/unpack.rake
challah-1.2.5.pre lib/tasks/unpack.rake