Skip to content

Instantly share code, notes, and snippets.

@netzpirat
Created April 14, 2010 19:32
Show Gist options
  • Save netzpirat/366219 to your computer and use it in GitHub Desktop.
Save netzpirat/366219 to your computer and use it in GitHub Desktop.
Minimal Rails 3 support for RubyMine: Creates the old Rails 2 scripts that simply executes Rails 3 'rails' command.
#!/usr/bin/env ruby
#
# Helper script to temporary fix some RubyMine 2.0.2 functionality by
# creating old-style Rails 2 scripts. This enables me actually to
# run & debug apps and use the Rails console.
#
# On my machine I have to increase the debugger timeout to connect to a
# Rails 3 app on Ruby 1.9.1. This is done for OS X by modify the Info.plist
# to increase the timeout.
#
# The defaults are '/Applications/RubyMine 2.0.2.app/Contents/Info.plist'
# for the plist and 30 for the timeout. You can pass these settings to
# the script as parameters:
#
# ./rubymine.rb /Users/John/Applications/RubyMine 2.0.2.app/Contents/Info.plist 45
#
# To use the feature you have to install the 'plist' gem:
#
# gem install plist
#
# Optinally you may want also to tweak the memory and parallel garbage collector threads
# to increase the RubyMine performance.
#
require 'FileUtils'
# Create Rails 2 style scripts
[ 'script/console',
'script/dbconsole',
'script/destroy',
'script/generate',
'script/performance/benchmarker',
'script/performance/profiler',
'script/plugin',
'script/runner',
'script/server'
].each do |script|
FileUtils.mkdir_p 'script/performance'
File.open(script, 'w') do |file|
file.write <<SCRIPT
#!/usr/bin/env ruby
exec 'script/rails #{ script.split('/').last }'
SCRIPT
file.chmod(0755)
end
end
# RubyMine configuration tuning
if File.exist?('/Applications/RubyMine 2.0.2.app/Contents/Info.plist')
begin
require 'plist'
config = ARGV[0] || '/Applications/RubyMine 2.0.2.app/Contents/Info.plist'
info = Plist::parse_xml(config)
#info['Java']['VMOptions'] = '-Xms256m -Xmx1024m -XX:MaxPermSize=256m -XX:+UseParallelGC -XX:ParallelGCThreads=4 -XX:+UseAdaptiveSizePolicy -Xbootclasspath/a:../lib/boot.jar -ea'
info['Java']['Properties']['ruby.debug.timeout'] = ARGV[1] || '30'
File.open(config, 'w') {|f| f.write(info.to_plist) }
rescue LoadError
puts 'Install the \'plist\' gem to increase debugger timeout automatically.'
end
end
@netzpirat
Copy link
Author

Works fine here on Ruby 1.9.1. Is there something special in your ~/.irbrc?

@jacquescrocker
Copy link

Seeing an error at the moment (on rev 5393f1): uninitialized constant Plist (NameError)

netzpirat: Thanks a ton for your help with this!

@netzpirat
Copy link
Author

Sorry, I forgot to require plist. This is mainly needed to increase the debugger timeout... Optionally it tunes the garbage collector for RubyMine, but you may have to modify the memory and thread amount to match you dev machine specs.

@jacquescrocker
Copy link

Now getting: no such file to load -- plist (LoadError)

Is plist a macruby thing?

@netzpirat
Copy link
Author

You have to install the plist gem

@jacquescrocker
Copy link

Just tried it in Ruby 1.9.1 and it also has the same error

/Users/jc/.rvm/rubies/ruby-1.9.1-p378/lib/ruby/1.9.1/irb.rb:278:in `dup': can't dup NilClass (TypeError)

I cleared out my .irbrc, same error. No idea whats going on. Ah well, was worth a shot. But it looks like RubyMine is still a no-go for me. 2.5 should fix it though

@netzpirat
Copy link
Author

Yep. I also hope we're getting an early EAP to test Rails 3 integration as soon as possible. We're now at Rails Beta 3 and still no support in RubyMine!

@jcarnegie
Copy link

Works for me. Thanks!

@netzpirat
Copy link
Author

Forget this gist! EAP with Rails 3 support is available: http://confluence.jetbrains.net/display/RUBYDEV/RubyMine+EAP

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment