Sha256: 7fe70dac8be28612dc473a04ac86ae13ca167b55f2daccf0802bc2082dfea7ae

Contents?: true

Size: 1006 Bytes

Versions: 19

Compression:

Stored size: 1006 Bytes

Contents

require 'rails'

module WebsocketRails
  module Generators
    class InstallGenerator < Rails::Generators::Base
      source_root File.expand_path("../templates", __FILE__)

      desc "Create the events.rb initializer and require the JS client in the application.js manifest."

      class_option :manifest, :type => :string, :aliases => "-m", :default => 'application.js',
                   :desc => "Javascript manifest file to modify (or create)"

      def create_events_initializer_file
        template 'events.rb', File.join('config', 'initializers', 'events.rb')
      end

      def inject_websocket_rails_client
        manifest = options[:manifest]
        js_path  = "app/assets/javascripts"

        create_file("#{js_path}/#{manifest}") unless File.exists?("#{js_path}/#{manifest}")

        append_to_file "#{js_path}/#{manifest}" do
          out = ""
          out << "//= require websocket_rails/main"
          out << "\n"
          out << "\n"
        end
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
websocket-rails-0.4.9 lib/generators/websocket_rails/install/install_generator.rb
websocket-rails-0.4.8 lib/generators/websocket_rails/install/install_generator.rb
websocket-rails-0.4.7 lib/generators/websocket_rails/install/install_generator.rb
websocket-rails-0.4.6 lib/generators/websocket_rails/install/install_generator.rb
websocket-rails-0.4.5 lib/generators/websocket_rails/install/install_generator.rb
websocket-rails-0.4.4 lib/generators/websocket_rails/install/install_generator.rb
websocket-rails-0.4.3 lib/generators/websocket_rails/install/install_generator.rb
websocket-rails-0.4.2 lib/generators/websocket_rails/install/install_generator.rb
websocket-rails-0.4.1 lib/generators/websocket_rails/install/install_generator.rb
websocket-rails-0.4.0 lib/generators/websocket_rails/install/install_generator.rb
websocket-rails-0.3.0 lib/generators/websocket_rails/install/install_generator.rb
websocket-rails-0.2.1 lib/generators/websocket_rails/install/install_generator.rb
websocket-rails-0.2.0 lib/generators/websocket_rails/install/install_generator.rb
websocket-rails-0.1.9 lib/generators/websocket_rails/install/install_generator.rb
websocket-rails-0.1.8 lib/generators/websocket_rails/install/install_generator.rb
websocket-rails-0.1.7 lib/generators/websocket_rails/install/install_generator.rb
websocket-rails-0.1.6 lib/generators/websocket_rails/install/install_generator.rb
websocket-rails-0.1.5 lib/generators/websocket_rails/install/install_generator.rb
websocket-rails-0.1.4 lib/generators/websocket_rails/install/install_generator.rb