require 'rails/generators' module KurentoRails module Generators class InstallGenerator < Rails::Generators::Base include Rails::Generators::Migration source_root File.expand_path("../templates", __FILE__) desc "This generator copies and modifies the files necessary for integration with Kurento" def run_websocket_rails_installer generate "websocket_rails:install" # we don't want their version of the events config, so we should just delete it File.delete("config/events.rb") if File.exists?("config/events.rb") end # run 'rails g websocket_rails:install' def disable_rack_lock_in_dev inject_into_file 'config/environments/development.rb', " config.middleware.delete Rack::Lock\n", after: /Rails.application.configure do.*\n/ end def self.next_migration_number(path) sleep 1 Time.now.utc.strftime("%Y%m%d%H%M%S") end def copy_assets directory "javascript", "app/assets/javascripts" directory "config", "config" directory "controllers", "app/controllers" directory "models", "app/models" directory "views", "app/views" end def create_migrations Dir["#{self.class.source_root}/migrations/*.rb"].sort.each do |filepath| name = File.basename(filepath) migration_template "migrations/#{name}", "db/migrate/#{name}" end end end end end