Sha256: e818d23cf419a8e6a089216c3750850a3534fa18e54774774d91ab9e2de74a89

Contents?: true

Size: 1.15 KB

Versions: 3

Compression:

Stored size: 1.15 KB

Contents

require 'generators/happy_seed/devise/devise_generator'

module HappySeed
  module Generators
    class DeviseInvitableGenerator < HappySeedGenerator
      source_root File.expand_path('../templates', __FILE__)

      def self.fingerprint
        gem_available? 'devise_invitable'
      end

      def install_device_invitable
        return if already_installed

        require_generator DeviseGenerator

        gem 'devise_invitable'

        Bundler.with_clean_env do
          run "bundle install --without production"
          run 'rake db:migrate'
        end

        run 'rails generate devise_invitable:install'
        run 'rails generate devise_invitable User'
        run 'rails generate devise_invitable:views'
        
        directory '.'

        if gem_available?( "haml-rails" )
          remove_file 'app/views/devise/invitations/new.html.erb'
          remove_file 'app/views/devise/invitations/edit.html.erb'
        end
      end

      private
        def gem_available?(name)
          Gem::Specification.find_by_name(name)
        rescue Gem::LoadError
          false
        rescue
          Gem.available?(name)
        end

    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
happy_seed-0.0.19 lib/generators/happy_seed/devise_invitable/devise_invitable_generator.rb
happy_seed-0.0.18 lib/generators/happy_seed/devise_invitable/devise_invitable_generator.rb
happy_seed-0.0.17 lib/generators/happy_seed/devise_invitable/devise_invitable_generator.rb