Sha256: db064445cf98efdebef00525e46c5b6e9cab22d6ac33b317d2ee858224bfef0c

Contents?: true

Size: 1.6 KB

Versions: 2

Compression:

Stored size: 1.6 KB

Contents

require 'rails/generators'
module Hyperloop
  class InstallGenerator < Rails::Generators::Base

    def inject_react_file_js
      append_file 'app/assets/javascripts/application.js' do
        <<-'JS'
//= require hyperloop-loader
        JS
      end
    end

    def inject_engine_to_routes
        route 'mount Hyperloop::Engine => \'/rr\''
    end

    def create_hyperloop_directories
      create_file 'app/hyperloop/components/.keep', ''
      create_file 'app/hyperloop/operations/.keep', ''
      create_file 'app/hyperloop/stores/.keep', ''
      create_file 'app/hyperloop/models/.keep', ''
    end

    def create_policies_directory
      create_file 'app/policies/application_policy.rb', <<-RUBY
        # app/policies/application_policy

        # Policies regulate access to your public models
        # The following policy will open up full access (but only in development)
        # The policy system is very flexible and powerful.  See the documentation
        # for complete details.
class Hyperloop::ApplicationPolicy
  # Allow any session to connect:
  always_allow_connection
  # Send all attributes from all public models
  regulate_all_broadcasts { |policy| policy.send_all }
  # Allow all changes to public models
  allow_change(to: :all, on: [:create, :update, :destroy]) { true }
end unless Rails.env.production?
        RUBY
    end

    def create_initializer
      create_file 'config/initializers/hyperloop.rb', <<-RUBY
        
Hyperloop.configuration do |config|
  config.transport = :simple_poller
  config.import 'reactrb/auto-import'
end

        RUBY

    end

    def add_gems
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
hyperloop-0.5.5 lib/generators/hyperloop/install_generator.rb
hyperloop-0.5.4 lib/generators/hyperloop/install_generator.rb