Sha256: a7850db774ecd53a76ee8b21e594e7ee389a79e230837ef5b498ef050ef15de4

Contents?: true

Size: 1.56 KB

Versions: 5

Compression:

Stored size: 1.56 KB

Contents

class Recipes::AngularAdmin < Rails::AppBuilder
  def ask
    if selected?(:admin_mode)
      angular_admin = answer(:"angular-admin") do
        Ask.confirm "Do you want Angular support for ActiveAdmin?"
      end
      set(:angular_admin, angular_admin)
    end
  end

  def create
    recipe = self
    if selected?(:angular_admin)
      after(:admin_install) do
        recipe.add_angular_admin
      end
    end
  end

  def install
    active_admin = load_recipe(:admin)
    if active_admin.installed?
      add_angular_admin
    else
      info "ActiveAdmin can't be installed because Active Admin isn't installed."
    end
  end

  def installed?
    dir_exist?("app/assets/javascripts/admin")
  end

  def add_angular_admin
    copy_file '../assets/active_admin/init_activeadmin_angular.rb',
      'config/initializers/init_activeadmin_angular.rb'

    create_file 'app/assets/javascripts/admin_app.js', "angular.module('ActiveAdmin', []);"

    copy_file '../assets/active_admin/active_admin.js.coffee',
      'app/assets/javascripts/active_admin.js.coffee',
      force: true

    empty_directory 'app/assets/javascripts/admin'
    empty_directory 'app/assets/javascripts/admin/controllers'
    empty_directory 'app/assets/javascripts/admin/services'
    empty_directory 'app/assets/javascripts/admin/directives'

    create_file 'app/assets/javascripts/admin/controllers/.keep'
    create_file 'app/assets/javascripts/admin/services/.keep'
    create_file 'app/assets/javascripts/admin/directives/.keep'

    inside('.') do
      run('bower install angular --save')
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
potassium-3.0.0 lib/potassium/recipes/angular_admin.rb
potassium-2.3.0 lib/potassium/recipes/angular_admin.rb
potassium-2.2.0 lib/potassium/recipes/angular_admin.rb
potassium-2.1.0 lib/potassium/recipes/angular_admin.rb
potassium-2.0.0 lib/potassium/recipes/angular_admin.rb