Sha256: 9603a4f3326f7016663b851e096509bad6596070cd9fd8b21483c61da1fcc726

Contents?: true

Size: 1.51 KB

Versions: 3

Compression:

Stored size: 1.51 KB

Contents

module HappySeed
  module Generators
    class AdminGenerator < Rails::Generators::Base
      source_root File.expand_path('../templates', __FILE__)

      def install_landing_page
        gem 'devise'
        gem 'activeadmin', github: 'gregbell/active_admin'
        gem 'dateslices'

        Bundler.with_clean_env do
          run "bundle install"
        end

        generate 'active_admin:install'

        remove_file "app/admin/dashboard.rb"
        remove_file "spec/factories/admin_users.rb"

        directory 'app'
        directory "docs"
        directory "spec"
        directory "vendor"

        insert_into_file "config/initializers/active_admin.rb", "  config.register_javascript '//www.google.com/jsapi'\n  config.register_javascript 'chartkick.js'\n", :after => "To load a javascript file:\n"
        append_to_file "config/initializers/assets.rb", "\nRails.application.config.assets.precompile += %w( chartkick.js )\n"

        inject_into_file 'config/application.rb', after: "config.generators do |g|\n" do <<-'RUBY'
      g.scaffold_controller "scaffold_controller"
RUBY
        end

        route <<-'ROUTE'
namespace :admin do
    # get "/stats" => "stats#stats"
    devise_scope :admin_user do
      get '/stats/:scope' => "stats#stats", as: :admin_stats
    end
  end
ROUTE

      
      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.11 lib/generators/happy_seed/admin/admin_generator.rb
happy_seed-0.0.10 lib/generators/happy_seed/admin/admin_generator.rb
happy_seed-0.0.9 lib/generators/happy_seed/admin/admin_generator.rb