Sha256: 9bcd685c8aafd317fcccf698e3049bbe1a1488325403da6fd110aa0b9b06f850

Contents?: true

Size: 1.06 KB

Versions: 9

Compression:

Stored size: 1.06 KB

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', 'events.rb')
        template 'websocket_rails.rb', File.join('config', 'initializers', 'websocket_rails.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

9 entries across 9 versions & 3 rubygems

Version Path
hkroger-websocket-rails-0.7.1 lib/generators/websocket_rails/install/install_generator.rb
wwl-websocket-rails-0.7.3 lib/generators/websocket_rails/install/install_generator.rb
wwl-websocket-rails-0.7.2 lib/generators/websocket_rails/install/install_generator.rb
wwl-websocket-rails-0.7.1 lib/generators/websocket_rails/install/install_generator.rb
websocket-rails-0.7.0 lib/generators/websocket_rails/install/install_generator.rb
websocket-rails-0.6.2 lib/generators/websocket_rails/install/install_generator.rb
websocket-rails-0.6.1 lib/generators/websocket_rails/install/install_generator.rb
websocket-rails-0.6.0 lib/generators/websocket_rails/install/install_generator.rb
websocket-rails-0.5.0 lib/generators/websocket_rails/install/install_generator.rb