Sha256: ff35c71e3163de551eea8cd3d1111bc19db6346fc2fc399e1fda27d534c82d23

Contents?: true

Size: 1.32 KB

Versions: 1

Compression:

Stored size: 1.32 KB

Contents

module Npush
  class ToherokuGenerator < Rails::Generators::Base
    def clone_npush_repo
      @appname = Rails.application.class.parent_name
      @reponame = 'npush' + @appname.to_s.downcase
      @npush_secret = SecureRandom.base64
      @npush_server = 'http://' + @reponame + '.herokuapp.com'
      @listen_port = "80";
      
      in_root do
        git :clone => "git://github.com/skycocker/npush.git"
        inside "npush" do
          system 'heroku create ' + @reponame
          system 'git push heroku master'
          system 'heroku config:add TECHNIQUE="long-polling" SECRET=' + @npush_secret
        end
        
        inside "config/initializers" do
          create_file 'npush.rb' do
            "unless Rails.env.production?\n"+
            "  ENV['npush_server'] = '" + @npush_server + ':' + @listen_port + "'\n"+
            "  ENV['npush_secret'] = '" + @npush_secret + "'\n"+
            "end\n"
          end
        end
        
        inside "app/assets/javascripts" do
          create_file 'npush.js' do
            "window.npush = io.connect('" + @npush_server + ':' + @listen_port + "');\n"
          end
        end
        
        prepend_file 'app/assets/javascripts/application.js', "//= require socket.io.min.js\n"
        append_file '.gitignore', "config/initializers/npush.rb"
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
npush-rails-0.1 lib/generators/npush/toheroku_generator.rb~