Module: LocalConfig::Rake

Extended by:
Rake::DSL
Defined in:
lib/localconfig/rake.rb

Overview

rake tasks

Class Method Summary collapse

Class Method Details

.define_tasks(opts = {}) ⇒ Object

define rake tasks <namespace>:{exists,create} that use LocalConfig[name].admin_{exists,create}_from_env

Parameters:

  • opts (Hash) (defaults to: {})

    a customizable set of options

Options Hash (opts):

  • :name (String) — default: 'rails'
  • :namespace (String) — default: 'admin'


28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/localconfig/rake.rb', line 28

def self.define_tasks(opts = {})
  name = opts[:name]      || 'rails'
  ns   = opts[:namespace] || 'admin'

  desc 'exit w/ status 2 if the admin user does not exist'
  task "#{ns}:exists" => :environment do
    exit 2 unless LocalConfig[name].admin_exists_from_env
  end

  desc 'create the admin user'
  task "#{ns}:create" => :environment do
    LocalConfig[name].admin_create_from_env
  end
end