Book Image

Instant RubyMine Assimilation

By : David L. Jones
Book Image

Instant RubyMine Assimilation

By: David L. Jones

Overview of this book

Ruby and Ruby on Rails applications can become very complex very quickly, with hundreds of different files to contend with during a typical day of development. With RubyMine, you can become much more productive and let the IDE take care of the menial tasks while you concentrate on the details and structure of your applications. Instant RubyMine Assimilation shows you how to integrate the RubyMine development environment into your everyday development process. With step-by-step instructions and practical examples, you will learn how to customize the environment precisely to suit your needs, debug and test your code, and get the most out of many other features of RubyMine. Starting with the installation of RubyMine on your preferred platform, this guide will walk you through creating your first program. You will be taken through everything from the development and testing process all the way to deploying your website for the world to enjoy. You will learn how to manage your project in RubyMine including integrating version control, testing, and debugging your projects. Furthermore, you will learn how to navigate complex projects, view database tables, and utilize the built-in console and deployment tools of RubyMine, all of which will help you become an expert developer This book will also teach you how to install and use Gems, change Ruby environments, and use code coverage and reports to enhance your testing. By the end of this book, you will be able to confidently deploy your Rails application to a server, all within the inviting environment that is RubyMine.
Table of Contents (7 chapters)

Ensuring your legacy (Become an expert)


There is nothing worse than losing code that you have spent eons writing. RubyMine has some nice built-in tools to manage your version control systems including Subversion and GIT repositories.

Getting ready

Open your Progeny Rails project in RubyMine.

Depending on your OS, download and install Subversion and GIT as follows:

  • For the Mac OS, subversion is already installed on the Mac OS X versions.

  • Git can be installed by downloading the installer for your version of OS X. The images can be found at https://code.google.com/p/git-osx-installer/.

  • Follow the instructions for the installer.

  • For Windows, Subversion can be downloaded and installed by running the appropriate installer for your system from http://tortoisesvn.net/downloads.html.

  • Git can be installed through the installer http://msysgit.github.io/.

  • Follow the instructions for the installer.

  • For Linux OS, subversion can be installed by opening a terminal window and typing:

    sudo apt-get install subversion
    
  • Git can be installed by typing the following command in a terminal window:

    sudo apt-get install git
    

How to do it...

Now that we have subversion and Git installed, we can tell RubyMine which version control system that we want to use for our project. Let's start with Git:

  1. Navigate to VCS | Enable Version Control System...

    This will bring up a little window that will let us choose which VCS to use for this particular project. We can have different VCSs for each project that we have in RubyMine, as shown in the following screenshot:

  2. Select OK. This will initiate the Git system and automatically issue the command git init on your project.

  3. Expand some folders. You will see that all of the files are now color coded in red. This means that the files are not yet under version control, so we need to add them to our local Git repository. This takes two steps: Adding the files and committing the files.

  4. To add the entire project, click on the frame panel button at the bottom of the project called 9: Changes.

  5. Click on the link Click to Browse which is next to Unversioned Files. A new window will open with a list of files in the project.

  6. Select the top-level folder and hit the green + button on the left of this window. This will add all of the files and folders to the project under the Git staging system. As shown in the following screenshot, the project window will now show all the files with a green color, which means the files are added to the local Git repository, but they have not yet been committed:

Now all we need to do is commit the directory using the following steps:

  1. Right-click on the project folder in the project list and navigate to Git | Commit Folder. This will bring up a window like the following:

    From this window, we can select many options, but the most important is to add a comment in the bottom text box. This comment will follow this commit forever.

  2. Type Initial Project Commit in this box.

  3. Hit the button Commit in the bottom-right corner. This will add the files to the Git repository and we can now see that all the files have returned to a black color in the project window. This means that all the files are now under version control. If we make a change to a file, the color will change appropriately. From now on, we can add single files and commit them either individually or as a group, just like the initial commit.

Now let's see how to view changes from different files versus our committed repository changes:

  1. Add the following comment line to our species.rb file from app | models above the method that we created earlier:

    # Return a status string of a particular species
  2. Save the file.

  3. Right-click on the opened file and navigate to Git | Compare with Latest Repository Version. This will show us a window with both versions of the file shown next to each other with insertion and deletions from both versions to show exactly what is different between the two files, as you can see in the following screenshot:

There's more…

The subversion and other version control systems that RubyMine integrates with are basically the same in operation. Explore the subversion system or any other VCS systems that you might be familiar with. Just remember to use one of them to maintain your legacy and not lose your best work.

There are many more controls that you can use with your VCS including comparing full directories, pushing your changes to a remote repository, creating patches, viewing and creating branches, and even integration with GitHub. Feel free to explore all these options on your own.