Sha256: 1cc10232fa4860973c72770d230ea102a0641d3853015b91ce19f93c1b3593c4

Contents?: true

Size: 1.19 KB

Versions: 4

Compression:

Stored size: 1.19 KB

Contents

# --                                                            ; {{{1
#
# File        : localconfig/rake.rb
# Maintainer  : Felix C. Stegerman <flx@obfusk.net>
# Date        : 2014-10-21
#
# Copyright   : Copyright (C) 2014  Felix C. Stegerman
# Licence     : LGPLv3+
#
# --                                                            ; }}}1

require 'rake/dsl_definition'

require 'localconfig/admin'

# namespace
module LocalConfig

  # rake tasks
  module Rake
    extend ::Rake::DSL

    # define rake tasks `<namespace>:{exists,create}` that use
    # `LocalConfig[name].admin_{exists,create}_from_env`
    #
    # @option opts [String] :name      ('rails')
    # @option opts [String] :namespace ('admin')
    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

  end

end

# vim: set tw=70 sw=2 sts=2 et fdm=marker :

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
localconfig-0.3.3 lib/localconfig/rake.rb
localconfig-0.3.2 lib/localconfig/rake.rb
localconfig-0.3.1 lib/localconfig/rake.rb
localconfig-0.3.0 lib/localconfig/rake.rb