<commit_before># Half Pipe

[![Stories in Ready](https://badge.waffle.io/d-i/half-pipe.png?label=ready)](http://waffle.io/d-i/half-pipe)

Gem to replace the Rails asset pipeline with a Grunt.js-based workflow, providing dependencies via Bower.

Half Pipe is a generator to get you up and running quickly with a Grunt setup for building client-side code in Rails apps. We believe that your asset workflow is yours and you should be able to configure it however you need to.

## Who is this For?

This initial release assumes you have been using [Grunt.js](http://www.gruntjs.com) in non-Rails apps and would like to start using it in Rails as well. It uses [Bower](http://bower.io) for dependency management, [RequireJS](http://www.requirejs.org) for Javascript modules and Sass for CSS. If you use alternatives to these tools, we'd love to [hear from you][issue].

## Alpha Version

**NOTE** This README refers to the alpha version of Half Pipe. I highly recommend using the alpha and following this README, but if you are on the 0.2 version please see [the previous README](https://github.com/d-i/half-pipe/blob/4a68659f215f939f7da9d3e5e8756c7f31a86177/README.md).

## We Want Feedback

Half Pipe is still in the early stages of development. The workflow has been extracted from our projects at [D-I](http://d-i.co) with inspiration from [ember-app-kit](http://github.com/stefanpenner/ember-app-kit). We are trying to build an extremely flexible and useful tool for front-end developers who work in Rails apps, while still adhering to good coding principles. If you want to use Half Pipe but feel hesitant for any reason, please feel free to [open up an issue telling us why][issue]. As we progress towards a 1.0 release, we want to hear from you to make this tool the best it can be.

## Getting Started

### Installing

The Half Pipe gem is mostly a vehicle to bring a nice Grunt workflow into your Rails app. To set it up, add the following to your Gemfile:

```
gem 'half-pipe', '~>0.3.0.alpha'
```

After you install the gem, you can run `rails g half\_pipe:install` to setup the Grunt workflow. This will configure your app for node.js, copy over the Grunt setup, install node modules and run `grunt build:public`.

From here you can move your stylesheets from `app/assets/stylesheets` to `app/styles` (make sure you replace [Sprockets directives](https://github.com/sstephenson/sprockets#managing-and-bundling-dependencies) with [Sass imports](http://sass-lang.com/documentation/file.SASS_REFERENCE.html#import).

You can also move JavaScripts into `app/scripts`, but take care to make sure you wrap them in requirejs modules (see http://mikemurry.com/getting-started-with-require-js/ for a quick overview of requirejs) or else you won't be able to build.

### Working on Assets

#### Front-end Developer Workflow

Run `grunt server` and Half Pipe will start up your Rails app with a preview server for your assets. Browse to `http://localhost:3000` and use your app like normal. Grunt will watch assets and recompile automatically when you make changes. It will also restart your Rails app when you change files in `config` or `lib`, and any time you install new gems with Bundler.

#### Back-end Developer Workflow

If you don't need to work on assets, nothing really changes for you. If you've never used grunt before, install it with `npm install -g grunt-cli`. Then run `npm install` to install dependencies and then `grunt build:public` to get the assets into your public folder. Once you've done that, you will only need to use grunt when you need to get the latest changes to assets (this step will go away in the future, see d-i/half-pipe#31).

## Usage

There are built-in helpers for referencing most assets.

- `image\_tag "avatar.png"` will reference /assets/images/avatar.png
- `javascript_include_tag "main"` will reference /assets/scripts/main.js
- `stylesheet_link_tag "main"` will reference /assets/styles/main.css

Half Pipe also provides helpers for Sass:

- `image-url('avatar.png')` compiles to url(/assets/images/avatar.png)
- `image-path('avatar.png')` compiles to /assets/images/avatar.png

#### Usage of the app folder

Only put assets that need to be processed by grunt in the app folder. For example, if you want to use Grunt to sprite your images then you can create an `app/icons` folder and output the sprite to `public/assets/images`. However, you should keep the rest of your images in your repository at `public/assets/images`. That way files that don't need to be processed will never get passed through Grunt, which makes it clear to everyone what is getting compiled and what isn't.<commit_msg>Remove backslash that shows up but causes badness in vim<commit_after># Half Pipe

[![Stories in Ready](https://badge.waffle.io/d-i/half-pipe.png?label=ready)](http://waffle.io/d-i/half-pipe)

Gem to replace the Rails asset pipeline with a Grunt.js-based workflow, providing dependencies via Bower.

Half Pipe is a generator to get you up and running quickly with a Grunt setup for building client-side code in Rails apps. We believe that your asset workflow is yours and you should be able to configure it however you need to.

## Who is this For?

This initial release assumes you have been using [Grunt.js](http://www.gruntjs.com) in non-Rails apps and would like to start using it in Rails as well. It uses [Bower](http://bower.io) for dependency management, [RequireJS](http://www.requirejs.org) for Javascript modules and Sass for CSS. If you use alternatives to these tools, we'd love to [hear from you][issue].

## Alpha Version

**NOTE** This README refers to the alpha version of Half Pipe. I highly recommend using the alpha and following this README, but if you are on the 0.2 version please see [the previous README](https://github.com/d-i/half-pipe/blob/4a68659f215f939f7da9d3e5e8756c7f31a86177/README.md).

## We Want Feedback

Half Pipe is still in the early stages of development. The workflow has been extracted from our projects at [D-I](http://d-i.co) with inspiration from [ember-app-kit](http://github.com/stefanpenner/ember-app-kit). We are trying to build an extremely flexible and useful tool for front-end developers who work in Rails apps, while still adhering to good coding principles. If you want to use Half Pipe but feel hesitant for any reason, please feel free to [open up an issue telling us why][issue]. As we progress towards a 1.0 release, we want to hear from you to make this tool the best it can be.

## Getting Started

### Installing

The Half Pipe gem is mostly a vehicle to bring a nice Grunt workflow into your Rails app. To set it up, add the following to your Gemfile:

```
gem 'half-pipe', '~>0.3.0.alpha'
```

After you install the gem, you can run `rails g half\_pipe:install` to setup the Grunt workflow. This will configure your app for node.js, copy over the Grunt setup, install node modules and run `grunt build:public`.

From here you can move your stylesheets from `app/assets/stylesheets` to `app/styles` (make sure you replace [Sprockets directives](https://github.com/sstephenson/sprockets#managing-and-bundling-dependencies) with [Sass imports](http://sass-lang.com/documentation/file.SASS_REFERENCE.html#import).

You can also move JavaScripts into `app/scripts`, but take care to make sure you wrap them in requirejs modules (see http://mikemurry.com/getting-started-with-require-js/ for a quick overview of requirejs) or else you won't be able to build.

### Working on Assets

#### Front-end Developer Workflow

Run `grunt server` and Half Pipe will start up your Rails app with a preview server for your assets. Browse to `http://localhost:3000` and use your app like normal. Grunt will watch assets and recompile automatically when you make changes. It will also restart your Rails app when you change files in `config` or `lib`, and any time you install new gems with Bundler.

#### Back-end Developer Workflow

If you don't need to work on assets, nothing really changes for you. If you've never used grunt before, install it with `npm install -g grunt-cli`. Then run `npm install` to install dependencies and then `grunt build:public` to get the assets into your public folder. Once you've done that, you will only need to use grunt when you need to get the latest changes to assets (this step will go away in the future, see d-i/half-pipe#31).

## Usage

There are built-in helpers for referencing most assets.

- `image_tag "avatar.png"` will reference /assets/images/avatar.png
- `javascript_include_tag "main"` will reference /assets/scripts/main.js
- `stylesheet_link_tag "main"` will reference /assets/styles/main.css

Half Pipe also provides helpers for Sass:

- `image-url('avatar.png')` compiles to url(/assets/images/avatar.png)
- `image-path('avatar.png')` compiles to /assets/images/avatar.png

#### Usage of the app folder

Only put assets that need to be processed by grunt in the app folder. For example, if you want to use Grunt to sprite your images then you can create an `app/icons` folder and output the sprite to `public/assets/images`. However, you should keep the rest of your images in your repository at `public/assets/images`. That way files that don't need to be processed will never get passed through Grunt, which makes it clear to everyone what is getting compiled and what isn't.
{'fraction_non_alphanumeric': 0.08186695278969958, 'fraction_numerical': 0.008798283261802575, 'mean_word_length': 4.353819643882826, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 6, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1804117', 'n_tokens_mistral': 2724, 'n_tokens_neox': 2585, 'n_words': 1308}