Pivotal Labs

Main menu

Skip to primary content
Skip to secondary content
  • About
  • Case Studies
  • Team
    • Executives
    • Locations
      • San Francisco (HQ)
      • Boston
      • Boulder
      • Denver
      • London
      • Los Angeles
      • New York
  • Community
    • Blogs
    • Tech Talks
    • Events
  • Careers
    • Lifestyle
    • Principles & Practices
    • Benefits
    • FAQ
    • Apply
  • Tools
  • Contact
    • Press Room
    • Press Releases
    • In The News
    • Press Kit
  • All
  • Labs
  • Standup
  • Tracker
Jared Carroll

Everyday Git Commands in RubyMine

Jared Carroll
Sunday, June 16, 2013

As a long-time command-line Git user, I was hesitant to adopt RubyMine’s version control tools. But I decided to give them a try, and I’m glad I did. RubyMine’s version control tools make common Git commands more accessible and easier to execute. The addition of a GUI is great for tasks such as diffing a file, or viewing commit logs. In this post, we’ll look at performing everyday Git commands in RubyMine on OS X.

git-diff

You can view a diff of all your changes from the Changes tool window.

changes-tool-window

Press command + 9 to open the Changes tool window. Then press command + D to view a diff of all your changes.

view-diff

You can diff a single file by selecting “Compare with the Same Repository Version” from the VCS Operations popup. Press control + V to open the VCS Operations popup.

compare-vcs-operations-popup

git-commit

Press command + K to commit changes.

commit-changes

git-push

Select “Push…” from the VCS Operations popup, control + V, to push your local changes.

push-vcs-operations-popup

git-pull

Press command + T to pull in the latest changes.

update-project

git-log

To view the Git log, open the Changes tool window, command + 9, then navigate to the Log tab with command + shift + ].

git-log-changes-tool-window

To see the log of a single file, select “Show History” from the VCS Operations popup, control + V.

show-history-vcs-operations-popup

This will open the log in the Version Control tool window.

show-history

git-checkout

Revert changes by selecting “Revert” from the VCS Operations popup, control + V.

revert-vcs-operations-popup

git-blame

Determine who changed a file by selecting “Annotate” from the VCS Operations popup, control + V.

annotate-vcs-operations-popup

The committers will be displayed to the left of the editor gutter.

annotate

Don’t Abandon the Command-line

In this post, I focused on the most commonly used Git commands. RubyMine also includes support for more powerful Git commands, such as git-reset and git-rebase. However, I find their RubyMine GUI-based implementations slow and clumsy. As much as I want to stay in RubyMine, I find the best version control strategy is to use RubyMine for common Git commands, but turn to the command-line for the hard stuff.

  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Jared Carroll

Working with RubyMine’s Tabs and Splits

Jared Carroll
Sunday, June 9, 2013

RubyMine’s editor is tab-based. When you open a file, it’s opened in a new tab. The editor can also be split vertically or horizontally; allowing you to edit multiple files simultaneously. In this post, we’ll look at managing and navigating these basic RubyMine concepts on OS X.

Navigating Between Tabs

Move between multiple tabs with command + shift + [/] or control + Left/Right.

tabs.png

Closing Tabs

Close a tab with command + W.

There are several other useful tab closing commands that don’t have keyboard shortcuts. I add the following shortcuts for them:

  • command + shift + W – close all other tabs
  • command + option + W – close all tabs
  • command + option + control + W – close all unmodified tabs

Splitting the Editor

Edit multiple files simultaneously by splitting the editor using the “Split Vertically” or “Split Horizontally” commands (find these commands quickly with command + shift + A, “Find Action”).

split-editor.png

I add command + option + control + Up/Down shortcuts to split vertically and horizontally.

Navigating Between Splits

Move the cursor to the next split with option + Tab. Move to the previous split with option + shift + Tab.

The Switcher can also be used to move between splits. Use control + Tab to open the Switcher, continue holding down control, and then use Tab to select an open file to navigate to.

Moving Tabs Between Splits

Use the “Move To Opposite Group” command (find this command quickly with command + shift + A, “Find Action”) to move tabs between splits.

I add command + option + control + Left/Right shortcuts for this command.

Closing Splits

Close a single split by closing all of its tabs.

Close all splits with option + shift + X.

Master the Basics

In RubyMine, you’ll use tabs and splits all the time. Don’t hesitate to create custom shortcuts for tab and split commands that don’t have them. Efficiently managing and navigating tabs and splits from the keyboard is a fundamental, must learn RubyMine skill.

  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Jared Carroll

Code Generation in RubyMine

Jared Carroll
Sunday, June 2, 2013

When learning how to program, you were probably taught not to copy and paste code. Typing it out manually improved your understanding of its syntax and structure. However, after learning a particular concept, repeatedly typing it becomes boring and tedious. An IDE can help you automate this process by intelligently generating boilerplate code. In this post, we’ll take a look at code generation in RubyMine on OS X.

Generating Getters and Setters

If a class has instance variables, press command + N in the editor to generate getters, setters, or both.

generate-method-type.png

After selecting what type of method to generate, RubyMine will prompt you for the instance variable to generate it for.

choose-instance-varibles.png

Generating Overridden Methods

Use control + O to view a list of overridable methods.

overriding-methods.png

Select a method from this dialog to generate a stub for it.

Generating Surrounding Code

Surround code with conditionals and other language constructs using command + alt/option + T.

surround.png

Remove surrounding code with command + shift + delete.

unwrap.png

Intentions

RubyMine’s intentions offer many different ways for generating and modifying code. A yellow lightbulb icon in the editor indicates that intentions are available.

intention-icon.png

Press alt/option + enter to view the intention. Press enter to execute it.

create-method-intention.png

Intentions can even create classes.

create-class-intention.png

Use intentions to modify code e.g., converting from Ruby 1.8 to 1.9 Hash syntax or converting a string from double to single quotes.

convert-hash-intention.png

convert-string-intention.png

Live Templates

RubyMine’s live templates are commonly known as snippets in other editors. Press command + J to view the list of available live templates.

live-templates.png

Live templates are more commonly inserted by typing an abbreviation and then pressing tab.

Here’s some of my favorite live templates:

  • def – create an instance method
  • defs – create a class (singleton) method
  • do – create a do...end block
  • doo – create a do |object| ...end block that expects an argument
  • dest – RSpec describe a type
  • des – RSpec describe a method
  • it – create an RSpec example
  • p – access a Rails controller’s params object
  • s – access a Rails controller’s session object

Automate It

Once you understand a particular concept, Ruby or Rails, as a programmer, your goal should be to automate it. If you’re beginning Ruby or Rails, then I would avoid code generation in order to better familiarize yourself with the language and framework. However, if you’re a veteran Rubyist, then I see nothing wrong with automating what you already know.

  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Jared Carroll

Better Project Integration with RubyMine’s Tool Windows

Jared Carroll
Monday, May 27, 2013

RubyMine’s tool windows integrate common development tasks such as searching, debugging, and version control, into the IDE. This eliminates context switching to external tools, providing a more fluid development experience. In this post, we’ll look at some common commands for managing tool windows in RubyMine on OS X.

Opening and Closing Tool Windows

Each tool window is given a number. They can be opened or closed with command + <number>, e.g., by default, the Project tool window is given command + 1.

tool window shortcuts

Opened tool windows are located on the bottom and sides of the IDE.

Navigating Between Tool Windows

To navigate between opened tool windows, first open the Switcher with control + tab. Then continue holding down control and press the number of a specific tool window.

switcher

While holding down control, use option to move between the Switcher’s two columns.

Navigating Between Tool Windows and the Editor

Press esc in a tool window to move focus to the editor. Use F12 to move focus back to the tool window.

Closing Tool Windows

Close tool windows with command + w. Use shift + esc in a tool window to close it and move focus to the editor.

Close all opened tool windows and move focus to the editor with command + shift + F12. Press it again to re-open the tool windows.

Don’t Sell Your IDE Short

Many developers insist of performing certain tasks outside their IDE. Perhaps they fear losing skills they’ve heavily invested in. For certain exceptional situations, e.g., debugging production, it’s important to know how to do these tasks without an IDE. But when it comes to day-to-day development, embrace your IDE and experiment with a new way of doing old things.

  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Jared Carroll

Debugging in RubyMine

Jared Carroll
Monday, May 20, 2013

Before using RubyMine, my debugging workflow went something like this:

Why isn’t this test passing?. It should’ve passed. Let me add a few Kernel#puts calls to see what’s going on. Hmmm, ok, it’s still failing. I’m going to need some more output. Man, these tests take forever to run. Syntax error?!. Ugh, typo…

Debugging like this isn’t fun; especially when pairing. Fortunately, RubyMine can help. RubyMine includes a standard debugger that has minimal setup and works out of the box. I still don’t enjoy debugging, but RubyMine has made it much less painful. In this post, we’ll look at debugging in RubyMine on OS X.

Setting Breakpoints

Add or remove breakpoints with command + F8.

breakpoint.png

View existing breakpoints with command + shift + F8.

view-breakpoints.png

Starting the Debugger

Debug the current program with control + shift + D. This will automatically open the Debug tool window (command + 5).

debug-tool-window.png

Use control + D to re-run the last debug session. View recent debug sessions with control + alt/option + D.

debug-menu.png

Examining a Program

Examine variables in the Debug tool window’s variables pane.

variables.png

Use command + N in the Debug tool window’s Watches pane to watch a specific variable. backspace will delete a watch.

watches.png

Use alt/option + F8 to evaluate arbitrary expressions. control + space triggers autocompletion.

evaluate-expression.png

Instead of using the Debug tool window, examine a variable inline by placing your cursor on it and pressing command + alt/option + F8.

quick-evaluate-expression.png

Stepping through a Program

Step into a method with F7. Step over a method with F8. Step out of a method with shift + F8.

Use your cursor as a temporary breakpoint with alt/option + F9. Continue your debug session with F9.

Stop #puts’ing

If you’re using an IDE, take time to learn its debugger. Don’t litter your code with Kernel#puts and friends. Instead, set a breakpoint, start the debugger, examine some objects, and slowly step through your problems.

  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Jared Carroll

File Management in RubyMine

Jared Carroll
Sunday, May 12, 2013

As developers, we create, update, and delete files all day long. Managing files from the command-line is one of the first skills we learned. However, constantly switching from your editor to the command-line to execute a simple file command, a command you’ve probably executed thousands of times before, is tedious and slow. Instead, stay in your editor, and let it take care of the boring stuff. In this post, we’ll look at RubyMine’s file commands on OS X.

Creating Files

To create a new file or directory, press control + alt/option + N within the editor or Project tool window.

new in current directory dialog

Copying Files

Use F5 within the editor or Project tool window to copy the current file.

copy dialog

F5 can also be used in the Project tool window to copy directories.

Cloning Files

To create a copy of a file or directory in the current directory, press shift + F5.

clone dialog

Moving Files

Move files and directories with F6.

move dialog

Like the previous file commands, this command works both within the editor and Project tool window.

Renaming Files

Files and directories can be renamed in the Project tool window with shift + F6.

rename dialog

Deleting Files

Delete files and directories in the Project tool window with delete.

safe delete dialog

Locating Files

To locate a file in the Project tool window, press alt/option + F1 in the editor, and then select the Project View option, the default option, from the Select Target dialog.

select target dialog

Select Reveal in Finder to open the file in a new OS X Finder window.

Working with File Paths

Use command + alt/option + F12 to view the complete file path.

file path dialog

Selecting a directory will open the directory in a new OS X Finder window.

Copy the current file path to the clipboard with command + shift + C. Copy a reference, the current relative file path and line with command + alt/option + shift + C.

paste from history dialog

These commands are useful for when you need to work with a file on the command-line.

Relying on Abstractions

A common developer fear is that overreliance on a particular IDE’s features will cause you to forget, or maybe never learn, the underlying commands. I agree that in some cases, e.g., version control, it’s important to know what’s going on under the hood. However, these situations are rare. And when it comes to everyday commands, I’d much rather use higher-level abstractions to free me from the mundane.

  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Jared Carroll

Running Programs in RubyMine

Jared Carroll
Sunday, May 5, 2013

A typical Rails development environment includes an editor, a terminal for running a web server, and a utility terminal for managing files, using version control, running tests, etc. During development, you’re constantly switching between your editor and these external terminals. RubyMine, an Integrated Development Environment, can eliminate this tedious back and forth workflow. In this post, we’ll learn how to run programs in RubyMine on OS X; allowing you to stay in RubyMine all day long.

Running Files

To run a file, open the file in the editor or select the file in the project tool window, then press control + shift + R. Rerun a file with control + R.

These commands are commonly used to run test files, but they could also be used to run a simple Ruby script.

Run Tool Window

All running programs are displayed in the Run tool window. Press command + 4 to open the Run tool window.

run tool window

Stop a running program with command + F2. Use command + shift + [ and command + shift + ] to navigate between multiple running programs.

Running Tests

In a test file, press control + shift + R outside of any individual test to run all the tests in the file. Press control + shift + R within an individual test to run just that test.

Run Dialog

Open the run dialog with control + alt/option + R. The run dialog lists recently run programs. This is useful for when you want to rerun a test you ran several tests ago.

run dialog

By default, this dialog also includes commands to run a development server, and your entire test suite.

Ruby/Rails Quick List

Use command + option + R to open the Ruby/Rails quick list. The Ruby/Rails quick list includes several useful commands such as, starting a Rails console, and starting an IRB session.

Ruby Rails quick list

You can run a file or a code selection in an existing IRB or Rails console with alt/option + shift + L. View IRB history with command + E.

IRB history

Running Rake Tasks

Run a Rake task with alt/option + R.

run Rake task

If a custom Rake task doesn’t appear in the list, reload Rake tasks from this dialog or the Ruby/Rails quick list (command + alt/option + R).

Running Rails Generators

Run a Rails generator with command + alt/option + G.

run Rails generator

If a custom Rails generator task doesn’t appear in the list, reload Rails generators from this dialog or the Ruby/Rails quick list (command + alt/option + R).

Take Advantage of Your IDE

IDEs increase your productivity by combining all of your development tools into one program. Frequent context switching to external tools not only slows you down, but also requires more in-depth knowledge of each tool. Try gradually replacing external tools with their IDE equivalents. Over time, your knowledge of shell command options and obscure Git commands will no longer seem very important to you.

  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Andrew Bruce

Procrastination, considered.

Andrew Bruce
Sunday, May 5, 2013

Last week I blogged about a new project for aiding in the hunt for test pollution, Scrubber. This is a personal side project that I began recently. It’s in the very early stages, like many of my other pet projects. It’s something I’ve worked on entirely alone, though I’d also love to collaborate with others and/or pair on it.

I was going to blog this week about the latest improvements I’d made to the code, and how it was going to improve the end-user’s experience despite being a mere refactor and a minor user interface tweak. I got bored after writing the first few paragraphs, and instead got distracted by the code, refactoring and tweaking it more than was necessary. A couple of hours in, I’d totally gold-plated the code in a way that I might have deemed unacceptable whilst on client time. This made me a little angry with myself: why was I procrastinating from blogging, and was I a bad developer who’d lost the ability to work alone?

Something we’re encouraged to do at Pivotal Labs is reflect on our behavior. Thinking about my boredom and procrastination a little, I realized there was something more interesting going on. The process went a bit like this:

  1. Start blogging about the new features. Paste the visual output of the program into the blog post. Realize that the output didn’t meet the requirement of improving the user experience.
  2. Start to implement the missing parts of the feature. Spend hours enjoying the freedom to refactor, delete and re-implement with no time limit, far more than when pairing on client time.

When we pair, we have a safety net to catch us when we get distracted by neat language features or elegant implementation tricks. Our partner will often remind us that we’ve spent, say, two hours making no discernible feature changes and no improvement to maintainability of the code. When soloing, however, especially on pet projects, we are free to choose a goal for the activity. Sometimes we decide to perform code katas, but other times we don’t consciously choose a goal: the goal could become apparent during the activity itself.

So it seemed that I’d accidentally found validation in what I was doing, and a potentially more interesting blog post at the same time. I’d managed to get some programming exercise in instead of banging out a not-quite-earth-shattering new feature. Specifically, I:

  1. Thought like a user until it became obvious that changes were still needed. Switched to developer mode by accident.
  2. Allowed myself to try out several approaches to the Presenter pattern, applying them to a trivial example that would not need a presenter in ‘real world’ programming.
  3. Used the Introduce Null Object refactor in a situation that didn’t call for it. Yet, it felt good and might even prove useful for the project later.
  4. Practiced several coding techniques that might become useful in the work environment.
  5. Temporarily inverted my work-based insecurities about performance and timeliness, providing stress relief as an unexpected benefit of my brain switching itself off from the task at hand.

Reflection is a useful technique for improving well-being. Your mileage may vary. If you’d have preferred to read about the changes made to Scrubber this week, you can read the commit history!

  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Jared Carroll

Breakdown Your Work in RubyMine with Tasks

Jared Carroll
Sunday, April 28, 2013

In RubyMine, you can create tasks to breakdown and structure your work. A task can be a simple local task, or it can correspond to a feature, bug, or chore, in an issue-tracking system. Each task in RubyMine includes the current state of the editor, allowing you to switch between tasks and resume exactly where you left off. In this post, we’ll explore RubyMine’s tasks on OS X.

Creating Tasks

Press alt/option + shift + N to open the task dialog. Enter the task’s name, then press Enter to create the task.

create task

By default, RubyMine will clear your current context and create a new changelist.

Switching Tasks

A context is a set of opened files. Each task has an associated context. When you switch tasks, its context is automatically loaded.

To switch between tasks, use alt/option + shift + T.

switch task

Isolating Work with Changelists

A changelist is a set of related source code changes. Each task has an associated changelist.

task changelist

Changelists allow you to isolate each task’s changes. Use command + K to commit the current task’s changelist. RubyMine will now consider the task closed, and ask if you want to delete its changelist.

Pivotal Tracker Integration

Instead of manually creating tasks, you can configure RubyMine to load tasks from Pivotal Tracker.

In project settings, command + ,, create a new Pivotal Tracker server in the Tasks Servers section. Then add your Pivotal Tracker project id (located in the Pivotal Tracker project’s settings page) and API token.

pivotal tracker settings

Pivotal Tracker stories will now appear in the task dialog.

Pivotal Tracker tasks

Creating a new task from a Pivotal Tracker story allows you to update the story as in-progress. However, it won’t set you as the owner of the story. Also, closing the task won’t finish the story.

Clean Context Switching

RubyMine’s tasks are well-suited for serial development. But if you constantly switch contexts, like most developers, they fall short, because switching tasks brings along committed work. If each task consists of a single commit, then this isn’t a problem. However, I prefer to commit frequently; resulting in many small, granular commits. So, in my opinion, using a distributed version control system, e.g., Git, and a branch-per-feature workflow, is a better development strategy than RubyMine’s tasks. Branches keep your work isolated from the main line of development, and it’s still possible to cleanly switch contexts.

  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Jared Carroll

Searching Code with RubyMine’s Usage Search

Jared Carroll
Sunday, April 21, 2013

When browsing a codebase, you often want to view the definition of a particular class, method, or variable. However, sometimes you want to do the reverse; you want to see where a particular class, method, or variable is used. Typically this involves using your editor’s text search, or a command line tool, such as grep or ack. Unfortunately, text searches may return false positives, such as log file data, or similarly named constructs. The problem is that you want to search code not text.

RubyMine has text search, but it also includes a powerful, code-based usage search. Usage search is smarter than text search, because RubyMine is aware of code constructs such as classes, methods, and variables. This results in a more accurate search; allowing you to quickly view and navigate actual usages. In this post, we’ll explore RubyMine’s usage search on OS X.

Find Usages

To find where a particular class, method, variable (instance or local), or parameter is used, place your cursor on it, and press alt/option + F7. Results will be displayed in the Find tool window.

find usages

command + alt/option + Up/Down navigates the results. Use F4 to jump to the source code of a particular usage.

Recent usage search results can be viewed again with command + E.

recent usages

Find Usages in File

By default, find usages is scoped to the entire project. To scope it to the current file, use command + F7. command + G and command + shift + G navigate the results.

Show Usages

command + alt/option + F7 can be used to show usages inline. Instead of displaying usages in the Find tool window, they appear in a pop-up window.

show usages

Searching Code

RubyMine’s usage search demonstrates an advantage an IDE has over a text editor. By being aware of code constructs, such as classes, methods, and variables, IDEs can offer powerful tools that allow you to quickly and accurately explore a codebase.

  • 0 Shares
  • Share on Facebook
  • Share on Twitter

Topics

  • agile (783)
  • rails (117)
  • testing (90)
  • ruby (85)
  • ruby on rails (71)
  • jobs (62)
  • javascript (59)
  • techtalk (44)
  • ironblogger (42)
  • rspec (39)
  • bloggerdome (34)
  • productivity (34)
  • activerecord (30)
  • rubymine (30)
  • git (29)
  • gogaruco (29)
  • nyc (27)
  • design (24)
  • mobile (23)
  • pivotal tracker (22)
  • process (21)
  • cucumber (21)
  • jasmine (19)
  • ios (18)
  • tracker ecosystem (17)
  • webos (17)
  • objective-c (17)
  • fun (16)
  • android (16)
  • palm (16)
  • ci (16)
  • "soft" ware (16)
  • bdd (15)
  • tdd (15)
  • cedar (15)
  • rails3 (14)
  • performance (14)
  • css (14)
  • gem (13)
  • mouse-free development (12)
  • selenium (12)
  • goruco (12)
  • bundler (12)
  • api (12)
  • keyboard (11)
  • meetup (11)
  • railsconf (11)
  • nyc-standup (11)
  • capybara (10)
  • mac (10)
Subscribe to productivity Feed
  1. 1
  2. 2
  3. 3
  4. 4
  5. →
  • About
  • Case Studies
  • Team
  • Community
  • Careers
  • Tools
  • Contact
  • Labs
  • Events

Contact Us

contact@pivotallabs.com
+1 415-77-PIVOT
TwitterLinkedInFacebook

Pivotal Tracker

Tracker is the award-winning agile project management tool that enables real-time collaboration around a shared, prioritized backlog.
Visit pivotaltracker.com >