Skip to content

Commit

Permalink
Add basic running instructions to README
Browse files Browse the repository at this point in the history
  • Loading branch information
adambeynon committed Oct 28, 2013
1 parent 30e704d commit aae051b
Showing 1 changed file with 68 additions and 2 deletions.
70 changes: 68 additions & 2 deletions README.md
@@ -1,6 +1,72 @@
# opal-sprockets
# Opal Sprockets

Adds sprockets support for Opal
_Adds sprockets support for [Opal](http://opalrb.org)._

## Installation

Add to your `Gemfile`:

```ruby
gem "opal-sprockets"
```

## Usage

Sprockets uses a load path for code files, so make a simple `app/` directory
with some code inside `app/application.rb`:

```ruby
# app/application.rb

require "opal"

puts "hello, world"
```

The opal corelib and runtime can be included in your app simply by adding
`require "opal"`. We also need an html file to test the application with,
so add `index.html`:

```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<script src="/assets/application.js"></script>
</head>
<body>
</body>
</html>
```

## Running Application

`opal-sprockets` comes with a simple `Server` class that can be used to easily
configure applications inside `config.ru`:

```ruby
# config.ru

require 'bundler'
Bundler.require

run Opal::Server.new { |s|
s.append_path 'app'

s.main = 'application'
}
```

This just adds the `app/` directory to the load path, and tells sprockets that
`application.rb` will be the main file to load.

Now just run the rack app:

```
$ bundle exec rackup
```

And then visit `http://127.0.0.1:9292` in any browser.

## License

Expand Down

0 comments on commit aae051b

Please sign in to comment.