RubyMine 7.0.0 Web Help

RubyMine supports development in projects structured in compliance with the Compass framework. This framework uses SASS and SCSS extensions of CSS.

On this page:

Preparing for Compass development

The Compass framework is installed through the Ruby Gem manager, therefore you need to install Ruby first.

  1. Download and install Ruby.
  2. Specify a path variable for the folder where the Ruby executable file and the gem.bat file are stored. This lets you launch Ruby and Gem Manager from any folder and ensures that Ruby is successfully launched during transpilation.
  3. Install and enable the SASS Support repository plugin.

    The plugin is not bundled with RubyMine, but it is available from the RubyMine plugin repository. Once enabled, the plugin is available at the IDE level, that is, you can use it in all your RubyMine projects. See Installing, Updating and Uninstalling Repository Plugins and Enabling and Disabling Plugins for details.

  4. Install Compass.
    1. The installation is performed in the command line mode. To start the built-in Terminal, hover your mouse pointer over show_tool_window_bars in the lower left corner of the IDE, then choose Terminal from the menu (see Working with Embedded Local Terminal for details).
    2. Type the following command at the command line prompt:
      gem install compass
                              

      The tool is installed to the folder where Ruby executable file and the gem.bat file are stored.

Setting up a Compass project

You can have a project set up according to the Compass requirements in two ways: create a new Compass project or create an empty project and introduce a Compass-specific structure in it. In either case, a project is set up through command line commands. Of course, you can set up a Compass project externally and then open it in RubyMine.

During project set-up, a conf.rb configuration file is generated. You will need to specify the location of this file when integrating Compass with RubyMine.

  • To set up the Compass-specific structure in an existing project:
    1. Open the desired project in RubyMine.
    2. Open the built-in Terminal by hovering your mouse pointer over show_tool_window_bars in the lower left corner of RubyMine and choosing Terminal from the menu.
    3. At the command line prompt, type:
      compass init
                              
  • To create a Compass project from scratch:
    1. Open the desired project in RubyMine.
    2. Open the built-in Terminal by hovering your mouse pointer over show_tool_window_bars in the lower left corner of RubyMine and choosing Terminal from the menu.
    3. Switch to the folder that will be the parent for the new project folder. Type the following command:
      cd <parent folder name>
                              
    4. At the command line prompt, type:
      compass create <the name of the project to be created>
                              
Integrating Compass with RubyMine

To develop a Compass-specific project in RubyMine, you need to specify the Compass executable file compass and the project configuration file config.rb. You can do it either through the Compass Support page of the Settings dialog box or on the fly using an intention action that opens the Compass Support dialog box.

  1. Open the Compass Support page or dialog box by doing one of the following:
    • Open the project settings by choosing File | Settings | Project Settings . For details, see Accessing Project Settings. Then click Compass Support. The Compass Support page opens.
      1. In a .sass or .scss file, type the following import statement:
        @import 'compass'
                                        
      2. Click the red bulb icon or press Alt+EnterAlt+EnterAlt+EnterAlt+EnterAlt+EnterAlt+EnterAlt+EnterAlt+Enter, Shift+Alt+J or Ctrl+Shift+MAlt+EnterAlt EnterAlt EnterCommand 1Alt Enter. Then choose Configure Compass from the suggestion list.
      The Compass Support dialog box opens.
  2. To activate Compass support, select the Enable Compass support check box.
  3. In the Compass executable file text box, specify the location of the compass executable file under the Ruby installation. Type the path manually, for example, C:\Ruby200-x64\bin\compass, or choose it from the drop-down list, or click the Browse button browseButton and choose the location of the compass file in the dialog box that opens.
  4. In the Config path field, specify the location of the project Compass configuration file config.rb. Type the path manually, for example, C:\my_projects\\compass_project\config.rb, or choose it from the drop-down list, or click the Browse button browseButton and choose the location of the compass file int he dialog box that opens.

    The Compass configuration file config.rb is generated during project set-up through compass create or compass init commands.

Transpiling SASS or SCSS code into CSS

SASS and SCSS are not processed by browsers that work with CSS code. Therefore to be executed, SASS or SCSS code has to be translated into CSS. This operation is referred to as transpilation and the tools that perform it are called transpilers.

RubyMine supports integration with a transpiler tool that translates SASS and SCSS code from a Compass project without changing the Compass-specific project structure.

In RubyMine, transpiler configurations are called File Watchers. For each supported transpiler, RubyMine provides a predefined File Watcher template. Predefined File Watcher templates are available at the RubyMine level. To run a transpiler against your project files, you need to create a project-specific File Watcher based on the relevant template, at least, specify the path to the transpiler to use on your machine.

RubyMine provides a common procedure and user interface for creating File Watchers of all types. The only difference is in the predefined templates you choose in each case.

Creating a Compass SASS or Compass SCSS transpiler
  1. Install and enable the File Watchers repository plugin.

    The plugin is not bundled with RubyMine, but it is available from the RubyMine plugin repository. Once enabled, the plugin is available at the IDE level, that is, you can use it in all your RubyMine projects. See Installing, Updating and Uninstalling Repository Plugins and Enabling and Disabling Plugins for details.

  2. To start creating a File Watcher, open the Project Settings by choosing File | Settings on the main menu, and then click File Watchers. The File Watchers page that opens, shows the list of File Watchers that are already configured in the project.
  3. Click the Add button new.png or press Alt+InsertAlt+InsertAlt+InsertAlt+InsertAlt+InsertAlt+InsertAlt+Insert or Ctrl+NAlt+InsertShift+Meta+N, Ctrl+N or Ctrl+EnterCommand N or Control EnterControl N or Control EnterCommand N or Control EnterControl N or Control Enter and choose the compass sass or compass scss predefined template from the pop-up list.
  4. In the Program text box, specify the path to the executable file:
    • compass.bat for Windows
    • compass for Unix and OS X
    Type the path manually or click the Browse button browseButton.png and choose the file location in the dialog box that opens.
  5. In the Arguments text box, type one of the following depending on the operating system used:
    • For OS X and Unix
      compile $FileDir$ $FilePath$
                              
    • For Windows
      compile $FileDir$ $UnixSeparators($FilePath$)$
                              
  6. Proceed as described on page Using File Watchers.

Running a Compass SASS or Compass SCSS transpiler

When you open a SASS or SCSS file, RubyMine checks whether an applicable file watcher is available in the current project. If such file watcher is configured but disabled, RubyMine displays a pop-up window that informs you about the configured file watcher and suggests to enable it.

If an applicable file watcher is configured and enabled in the current project, RubyMine starts it automatically upon the event specified in the New Watcher dialog.

  • If the Immediate file synchronization check box is selected, the File Watcher is invoked as soon as any changes are made to the source code.
  • If the Immediate file synchronization check box is cleared, the File Watcher is started upon save (File | Save All, Ctrl+SCtrl+SCtrl+SCtrl+SCtrl+X, Ctrl+SCtrl+SCtrl+S or Ctrl+Shift+SCtrl+SMeta+S, Alt+Meta+S or Ctrl+Meta+SCommand SCommand SCommand SCommand S) or when you move focus from RubyMine (upon frame deactivation).

RubyMine creates a separate file with the generated output. The file has the name of the source SASS or SCSS file and the extension css. The location of the generated files is defined in the Output paths to refresh text box of the New Watcher dialog. However, in the Project Tree, they are shown under the source file which is now displayed as a node.

See Also

Procedures:

Reference:

Web Resources: