./README.md in helios-0.3.0 vs ./README.md in helios-0.4.0

- old
+ new

@@ -12,42 +12,52 @@ --- ## Requirements -- Ruby 1.9 -- PostgreSQL 9.1 _([Postgres.app](http://postgresapp.com) is the easiest way to get a Postgres server running on your Mac)_ +- Ruby 2.0+ with [Bundler](http://bundler.io) installed +- PostgreSQL 9.2+ _([Postgres.app](http://postgresapp.com) is the easiest way to get a Postgres server running on your Mac)_ ## Getting Started on OS X 1. Verify Ruby Installation: - `$ ruby -v` +``` +$ ruby -v +``` -> If you do not see `ruby 1.9.x` printed, we suggest installing [RVM](http://rvm.io) to manage Ruby versions. +2. Install Helios, Bundler, and at the command prompt: -2. Install Helios at the command prompt: +``` +$ gem install helios +``` - `$ gem install helios` - 3. Create a new Helios application: - `$ helios new myapp` +``` +$ helios new myapp +``` 3. Create a Postgres database at the command prompt: - `$ createdb -h localhost myapp` +``` +$ createdb -h localhost myapp +``` > Database credentials are read from the `.env` file generated by Helios, as the variable `DATABASE_URL`. By default, this will point to a database with the name of the generated app. 4. Change directory to `myapp` - `$ cd myapp` +``` +$ cd myapp +``` 5. Start the web server: - `$ helios server` +``` +$ helios server +``` 6. Go to [http://localhost:5000/admin](http://localhost:5000/admin) and you’ll see your app's Web UI Read on for instructions on the following: @@ -84,18 +94,22 @@ ### Rails To create a Rails app that uses Postgres as its database, pass the `-d postgresql` argument to the `rails new` command: - $ rails new APP_PATH -d postgresql +``` +$ rails new APP_PATH -d postgresql +``` If you're adding Helios to an existing Rails project, be sure to specify a PostgreSQL database in `config/database.yml` and check that the `pg` gem is included in your `Gemfile`: #### Gemfile - gem 'helios' - gem 'pg' +```ruby +gem 'helios' +gem 'pg' +``` Helios can be run as Rails middleware by adding this to the configuration block in `config/application.rb` #### config/application.rb @@ -120,182 +134,202 @@ **Associated Classes** Each entity in the specified data model will have a `Sequel::Model` subclass created for it under the `Rack::CoreData::Models` namespace. -<table> - <caption>Endpoints</caption> - <tr> - <td><tt>GET /:resources</tt></td> - <td>Get list of all of the specified resources</td> - </tr> - <tr> - <td><tt>POST /:resources</tt></td> - <td>Create a new instance of the specified resource</td> - </tr> - <tr> - <td><tt>GET /:resources/:id</tt></td> - <td>Get the specified resource instance</td> - </tr> - <tr> - <td><tt>PUT /:resources/:id</tt></td> - <td>Update the specified resource instance</td> - </tr> - <tr> - <td><tt>DELETE /:resources/:id</tt></td> - <td>Delete the specified resource instance</td> - </tr> -</table> +| | | +|---------------------------|----------------------------------------------------| +| `GET /:resources` | Get list of all of the specified resources | +| `POST /:resources` | Create a new instance of the specified resource | +| `GET /:resources/:id` | Get the specified resource instance | +| `PUT /:resources/:id` | Update the specified resource instance | +| `DELETE /:resources/:id` | Delete the specified resource instance | --- `push_notification`: Adds iOS push notification registration / unregistration endpoints. **Associated Classes** - `Rack::PushNotification::Device` -<table> - <caption>Endpoints</caption> - <tr> - <td><tt>PUT /devices/:token</tt></td> - <td>Register or update existing device for push notifications</td> - </tr> - <tr> - <td><tt>DELETE /devices/:token</tt></td> - <td>Unregister a device from receiving push notifications</td> - </tr> - <tr> - <td><tt>POST /message</tt></td> - <td>Send out a push notification to some devices</td> - </tr> -</table> +| | | +|---------------------------|-----------------------------------------------------------| +| `PUT /push_notification/devices/:token` | Register or update existing device for push notifications | +| `DELETE /push_notification/devices/:token` | Unregister a device from receiving push notifications | +| `POST /push_notification/message` | Send out a push notification to some devices | --- `in_app_purchase`: Adds an endpoint for iOS in-app purchase receipt verification endpoints, as well one for returning product identifiers. **Associated Classes** - `Rack::InAppPurchase::Receipt` - `Rack::InAppPurchase::Product` -<table> - <caption>Endpoints</caption> - <tr> - <td><tt>POST /receipts/verify</tt></td> - <td>Decode the associated Base64-encoded <tt>receipt-data</tt>, recording the receipt data and verifying the information with Apple</td> - </tr> - <tr> - <td><tt>GET /products/identifiers</tt></td> - <td>Return an array of valid product identifiers</td> - </tr> -</table> +| | | +|------------------------------|-----------------------------------------------------------| +| `POST /in_app_purchase/receipts/verify` | Decode the associated Base64-encoded `receipt-data`, recording the receipt data and verifying the information with Apple | +| `GET /in_app_purchase/products/identifiers` | Get an array of valid product identifiers | --- `passbook`: Adds endpoints for the [web service protocol](https://developer.apple.com/library/prerelease/ios/#documentation/PassKit/Reference/PassKit_WebService/WebService.html) for communicating with Passbook **Associated Classes** - `Rack::Passbook::Pass` - `Rack::Passbook::Registration` -<table> - <caption>Endpoints</caption> - <tr> - <td><tt>GET /v1/passes/:passTypeIdentifier/:serialNumber</tt></td> - <td>Get the Latest Version of a Pass</td> - </tr> - <tr> - <td><tt>GET /v1/devices/:deviceLibraryIdentifier/registrations/:passTypeIdentifier[?passesUpdatedSince=tag]</tt></td> - <td>Get the Serial Numbers for Passes Associated with a Device</td> - </tr> - <tr> - <td><tt>POST /v1/devices/:deviceLibraryIdentifier/registrations/:passTypeIdentifier/:serialNumber</tt></td> - <td>Register a Device to Receive Push Notifications for a Pass</td> - </tr> - <tr> - <td><tt>DELETE /v1/devices/:deviceLibraryIdentifier/registrations/:passTypeIdentifier/:serialNumber</tt></td> - <td>Unregister a Device</td> - </tr> -</table> +| | | +|---------------------------|----------------------------------------------------| +| `GET /passbook/v1/passes/:passTypeIdentifier/:serialNumber` | Get the Latest Version of a Pass | +| `GET /passbook/v1/devices/:deviceLibraryIdentifier/registrations/:passTypeIdentifier[?passesUpdatedSince=tag]` | Get the Serial Numbers for Passes Associated with a Device | +| `POST /passbook/v1/devices/:deviceLibraryIdentifier/registrations/:passTypeIdentifier/:serialNumber` | Register a Device to Receive Push Notifications for a Pass | +| `DELETE /passbook/v1/devices/:deviceLibraryIdentifier/registrations/:passTypeIdentifier/:serialNumber` | Unregister a Device | +--- + +`newsstand`: Adds endpoints for Newsstand. Offers complete management of issues, covers, and assets, with plist-based web services and Atom feeds. + +**Associated Classes** + +- `Rack::Newsstand::Issue` + +| | | +|-------------------------------|-------------------------| +| `GET /newsstand/issues` | Get list of all issues | +| `GET /newsstand/issues/:name` | Get a specific issue | +| `POST /newsstand/issues` | Add a new issue | + ## Command-Line Interface Helios comes with a CLI to help create and manage your application. After you `$ gem install helios`, you'll have the `helios` binary available. - $ helios --help - helios +``` +$ helios --help +helios - A command-line interface for building mobile infrastructures +A command-line interface for building mobile infrastructures - Commands: - console Open IRB session with Helios environment - help Display global or [command] help documentation. - link Links a Core Data model - new Creates a new Helios project - server Start running Helios locally +Commands: + console Open IRB session with Helios environment + help Display global or [command] help documentation. + link Links a Core Data model + new Creates a new Helios project + server Start running Helios locally +``` ### Creating an Application The first step to using Helios is to create a new application. This can be done with the `$ helios new` command, which should be familiar if you've ever used Rails. - $ helios new --help +``` +$ helios new --help - Usage: helios new path/to/app +Usage: helios new path/to/app - The `helios new` command creates a new Helios application with a default - directory structure and configuration at the path you specify. + The `helios new` command creates a new Helios application with a default +directory structure and configuration at the path you specify. - Options: - --skip-gemfile Don't create a Gemfile - -B, --skip-bundle Don't run bundle install - -G, --skip-git Don't create a git repository - --edge Setup the application with Gemfile pointing to Helios repository - -f, --force Overwrite files that already exist - -p, --pretend Run but do not make any changes - -s, --skip Skip files that already exist +Options: + --skip-gemfile Don't create a Gemfile + -B, --skip-bundle Don't run bundle install + -G, --skip-git Don't create a git repository + --edge Setup the application with Gemfile pointing to Helios repository + -f, --force Overwrite files that already exist + -p, --pretend Run but do not make any changes + -s, --skip Skip files that already exist +``` ### Linking a Core Data Model In order to keep your data model and REST webservices in sync, you can link it to your helios application: - $ helios link path/to/DataModel.xcdatamodel +``` +$ helios link path/to/DataModel.xcdatamodel +``` This creates a hard link between the data model file in your Xcode and Helios projects—any changes made to either file will affect both. The next time you start the server, Helios will automatically migrate the database to create tables and insert columns to accomodate any new entities or attributes. +> If you are using OS X, do not attempt to delete your Helios application directory using `rm -r` if you have linked a Core Data model. Doing so will result in the removal of the Xcode data model itself. Instead use the finder to move the Helios application directory to trash. + ### Starting the Application Locally To run Helios in development mode on `localhost`, run the `server` command: - $ helios server +``` +$ helios server +``` ### Testing Push Notifications Once you have registered a device and set up your certificate, try this: - $ curl -X POST -d 'payload={"aps": {"alert":"Blastoff!"}}' http://localhost:5000/message +``` +$ curl -X POST -d 'payload={"aps": {"alert":"Blastoff!"}}' http://localhost:5000/push_notification/message +``` +### Setting Up Storage for Newsstand + +In order to set up storage for Newsstand, you will need an account with one of the following cloud storage providers: + +- [Amazon AWS S3](http://aws.amazon.com/s3/) +- [Google Cloud Storage](https://cloud.google.com/products/cloud-storage/) +- [Rackspace Cloud Files](http://www.rackspace.com/cloud/files/) + +In your application directory, edit the `config.ru` with your credentials for the cloud storage provider of your choice. Here is an example configuration using AWS. + +```ruby +require 'bundler' +Bundler.require + +app = Helios::Application.new { + service :data, model: Dir['*.xcdatamodel*'].first if Dir['*.xcdatamodel*'].any? + service :push_notification + service :in_app_purchase + service :passbook + service :newsstand, { + storage: { + provider: 'AWS', + aws_access_key_id: 'YOUR_ACCESS_KEY_ID', + aws_secret_access_key: 'YOUR_SECRET_ACCESS_KEY' + } + } +} + +run app +``` + +For other configuration options, see [fog.io](http://fog.io/storage/). + ### Running the Helios Console You can start an IRB session with the runtime environment of the Helios application with the `console` command: - $ helios console +``` +$ helios console +``` This command activates the services as configured by your Helios application, including any generated Core Data models. The `rack` module is automatically included on launch, allowing you to access everything more directly: - > Passbook::Passes.all # => [...] +```ruby +> Passbook::Passes.all # => [...] +``` ## Deploying to Heroku [Heroku](http://www.heroku.com) is the easiest way to get your app up and running. For full instructions on how to get started, check out ["Getting Started with Ruby on Heroku"](https://devcenter.heroku.com/articles/ruby). Once you've installed the [Heroku Toolbelt](https://toolbelt.heroku.com), and have a Heroku account, enter the following commands from the project directory: - $ heroku create - $ git push heroku master +``` +$ heroku create +$ git add . +$ git push heroku master +``` ## Integrating with an iOS Application ### Core Data Synchronization @@ -326,38 +360,27 @@ > These instructions come from the [APN on Rails](https://github.com/PRX/apn_on_rails) project. Once you have the certificate from Apple for your application, export your key and the apple certificate as p12 files. Here is a quick walkthrough on how to do this: -1. Click the disclosure arrow next to your certificate in Keychain Access and select the certificate and the key. -2. Right click and choose `Export 2 items…`. +1. Click the disclosure arrow next to your certificate in Keychain Access and select the certificate and the key. +2. Right click and choose `Export 2 items…`. 3. Choose the p12 format from the drop down and name it `cert.p12`. Now covert the p12 file to a pem file: - $ openssl pkcs12 -in cert.p12 -out apple_push_notification.pem -nodes -clcerts +``` +$ openssl pkcs12 -in cert.p12 -out apple_push_notification.pem -nodes -clcerts +``` -## Coming Attractions - -There's still a lot to do to make Helios even better. Here are some ideas that are at the top of the list: - -- Test coverage -- More documentation -- More example projects -- Better RubyMotion integration -- Support for multiple schema definitions (not just Core Data) -- Send push notifications from the UI -- Support for additional platforms (Android, WP7) - --- ## Contact Mattt Thompson - http://github.com/mattt - http://twitter.com/mattt -- <mattt@heroku.com> ## License -Helios is released under the [MIT](http://opensource.org/licenses/MIT) license. +Helios is released under the [MIT License](http://opensource.org/licenses/MIT).