Some newbie questions while evaluating RubyMine

Hi all,

Newbie here. I've used RubyMine a bit in the last 2 weeks in order to evaluate it, seeking refuge from Oracle's recent smart decision about NetBeans. I like RubyMine so far, I only have a few of questions.

None of these questions are Rails-related, because we don't have Rails projects => our typical work in ruby is not related to web development, but rather processing log files, parsing queries for CSV reports and stuff like that. We are mainly a Java shop (we use Eclipse for all our Java development).

1) We have a few projects configured for NetBeans, with specs following the typical NetBeans structure

  • All ruby files are under project directory "lib"
  • All specs are under project directory "spec"

Is there any specific advice on how to import NetBeans projects?

When I've tried executing the specs of one of these projects I've got some errors, while I had none under NetBeans. It appears that, while under NetBeans the path of the "lib" folder is automatically added to the load path, that's not the case in RubyMine.

So, is it enough to just add the "lib" folder to the load path under File > Settings > Project Structure > Load Path? See also question #3 below.

2) One of those projects is based on JRuby. How do I configure a JRuby SDK so that it recognizes all existing gems and paths based on the interpreter?

I've tried adding JRuby as an SDK but it seems that it keeps the existing gems configuration.

3) I've created a project on my own with unit tests. I like the convention of keeping source files under "lib" and tests under "test". I've marked the directory "test" as a Test Source. Everything is fine if I execute all tests and I keep referring to library classes as "lib/something" in every test, but as I start trying to run an individual test file I get into errors. For example, event_parser_test.rb has the following requires:

require "test/unit"

require 'lib/event_parser'

require 'lib/event_type_recognizer'

When I try to execute it by itself I get:

/usr/bin/ruby -e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift) /Users/xxx/Workspaces/RubyMine/PerformanceReporting/test/event_parser_test.rb

Testing started at 9:14 AM ...

/Users/xxx/Workspaces/RubyMine/PerformanceReporting/test/event_parser_test.rb:2:in `require': no such file to load -- lib/event_parser (LoadError)

 

from /Users/xxx/Workspaces/RubyMine/PerformanceReporting/test/event_parser_test.rb:2

 

from -e:1:in `load'

 

from -e:1

Process finished with exit code 1

Empty test suite.

Note that I've tried configuring both /Users/xxx/Workspaces/RubyMine/PerformanceReporting and its lib subdirectory in the Load Path, but nothing changes.

4) I love keyboard shortcuts. The most important ones are related to navigation, IMO. It seems to me that there are basically 2 options in RubyMine:

  • Use cmd+[, cmd+] to go back and forth in navigation history
  • Use cmd+shift+[, cmd+shift+] to go to the previous/next file in the order in which the tabs are displayed

Is there anything like cmd+F6 and cmd+e in Eclipse, which present also the list of currently open files? In addition, is there anything like cmd+F6 that allows you to go through all files, resorting all the times based on most recently visited file? cmd+n is nice BTW, a bit like cmd+e in Eclipse (but it works on all files, not only on already opened ones).

Thanks

MM

3 comments
Comment actions Permalink

Hi Manlio,

1) We have a few projects configured for NetBeans, with specs following the typical NetBeans structure

  • All ruby files are under project directory "lib"
  • All specs are under project directory "spec"

Is there any specific advice on how to import NetBeans projects?


When I've tried executing the specs of one of these projects I've got some errors, while I had none under NetBeans. It appears that, while under NetBeans the path of the "lib" folder is automatically added to the load path, that's not the case in RubyMine.

So, is it enough to just add the "lib" folder to the load path under File > Settings > Project Structure > Load Path? See also question #3 below.


Please add "lib" folder to load path for our Code Insight Engine - RubyMine | File | Settings | Project Structure | Load Path tab. This setting is only for our code insight. RubyMine doesn't change application load path. So for launching from console or Continuous Integration Server you will need also to change load path manually. For this just add before require calls line like this:

$: << (File.dirname(__FILE__) + '/..')

or

$: << (File.dirname(__FILE__) + '/../lib')


in your main ruby script.

Also in RubyMine project settings you need specify which gems does your application use (See File | Settings | Ruby SDK and Gems dialog). We call it "to attach" gem. It is only a setting for code insight engine and allows RubyMine to enable/disable support for some gems, testing frameworks, etc. + parse and index only gems which are used in application. If you use bundler RubyMine will do it automatically.


2) One of those projects is based on JRuby. How do I configure a JRuby SDK so that it recognizes all existing gems and paths based on the interpreter?

I've tried adding JRuby as an SDK but it seems that it keeps the existing gems configuration.


Should work. Select interpreter in File | Settings | Ruby SDK and Gems dialog and apply changes. Attach necessary gems.


3) I've created a project on my own with unit tests. I like the convention of keeping source files under "lib" and tests under "test". I've marked the directory "test" as a Test Source. Everything is fine if I execute all tests and I keep referring to library classes as "lib/something" in every test, but as I start trying to run an individual test file I get into errors. For example, event_parser_test.rb has the following requires:

require "test/unit"

require 'lib/event_parser'

require 'lib/event_type_recognizer'

When I try to execute it by itself I get:

/usr/bin/ruby -e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift) /Users/xxx/Workspaces/RubyMine/PerformanceReporting/test/event_parser_test.rb

Testing started at 9:14 AM ...

/Users/xxx/Workspaces/RubyMine/PerformanceReporting/test/event_parser_test.rb:2:in `require': no such file to load -- lib/event_parser (LoadError)

from /Users/xxx/Workspaces/RubyMine/PerformanceReporting/test/event_parser_test.rb:2

from -e:1:in `load'

from -e:1

Process finished with exit code 1

Empty test suite.


You will get the same error in console or other non NetBeans environment. We've already discussed it in the first part of this post.

4) I love keyboard shortcuts. The most important ones are related to navigation, IMO. It seems to me that there are basically 2 options in RubyMine:

  • Use cmd+[, cmd+] to go back and forth in navigation history
  • Use cmd+shift+[, cmd+shift+] to go to the previous/next file in the order in which the tabs are displayed

Is there anything like cmd+F6 and cmd+e in Eclipse, which present also the list of currently open files? In addition, is there anything like cmd+F6 that allows you to go through all files, resorting all the times based on most recently visited file? cmd+n is nice BTW, a bit like cmd+e in Eclipse (but it works on all files, not only on already opened ones).

Thanks

MM

Please look at "RubyMine | Help | Default Keymap Reference" pdf file. Or File | Settings | Keymap.

In "Default MacOS X" keymap:
cmd+e - recent files
^+tab - is switcher among open editor tabs and tool windows.

0
Comment actions Permalink

Thanks Roman, I'll use the following trick for test/spec that are in subfolders.

$: << (File.dirname(__FILE__) + '/..')

Is this standard practice?

Please look at "RubyMine | Help | Default Keymap Reference" pdf file. Or File | Settings | Keymap.

In "Default MacOS X" keymap:
cmd+e - recent files
^+tab - is switcher among open editor tabs and tool windows.


Oh super, just what I needed.

Thanks again,
MM

0
Comment actions Permalink

$: << (File.dirname(__FILE__) + '/..')

Is this standard practice?

AFAIK yes

0

Please sign in to leave a comment.