Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 76 lines (46 sloc) 2.978 kB
dbaacdb @laserlemon Write the README
laserlemon authored
1 # Figaro [![Build Status](https://secure.travis-ci.org/laserlemon/figaro.png)](http://travis-ci.org/laserlemon/figaro) [![Dependency Status](https://gemnasium.com/laserlemon/figaro.png)](https://gemnasium.com/laserlemon/figaro)
0e57f51 @laserlemon Initial commit
laserlemon authored
2
dbaacdb @laserlemon Write the README
laserlemon authored
3 Simple Rails app configuration
0e57f51 @laserlemon Initial commit
laserlemon authored
4
dbaacdb @laserlemon Write the README
laserlemon authored
5 ## What is this for?
0e57f51 @laserlemon Initial commit
laserlemon authored
6
dbaacdb @laserlemon Write the README
laserlemon authored
7 Figaro is for configuring Rails 3 apps, especially open source Rails apps.
0e57f51 @laserlemon Initial commit
laserlemon authored
8
dbaacdb @laserlemon Write the README
laserlemon authored
9 Open sourcing a Rails app can be a little tricky when it comes to sensitive configuration information like [Pusher](http://pusher.com/) or [Stripe](https://stripe.com/) credentials. You don't want to check private credentials into the repo but what other choice is there?
0e57f51 @laserlemon Initial commit
laserlemon authored
10
dbaacdb @laserlemon Write the README
laserlemon authored
11 Figaro provides a clean and simple way to configure your app and keep the private stuff… private.
0e57f51 @laserlemon Initial commit
laserlemon authored
12
dbaacdb @laserlemon Write the README
laserlemon authored
13 ## How does it work?
0e57f51 @laserlemon Initial commit
laserlemon authored
14
dbaacdb @laserlemon Write the README
laserlemon authored
15 It works really well.
0e57f51 @laserlemon Initial commit
laserlemon authored
16
dbaacdb @laserlemon Write the README
laserlemon authored
17 There are a few similar solutions out there, and a lot of homegrown attempts. Most namespace your configuration under a `Config` (or similar) namespace. That's fine, but there's already a place to describe the application environment… `ENV`!
0e57f51 @laserlemon Initial commit
laserlemon authored
18
dbaacdb @laserlemon Write the README
laserlemon authored
19 `ENV` is a collection of simple string key/value pairs and it works just great for application configuration.
0e57f51 @laserlemon Initial commit
laserlemon authored
20
dbaacdb @laserlemon Write the README
laserlemon authored
21 As an added bonus, this is exactly how apps on [Heroku](http://www.heroku.com/) are configured. So if you configure your Rails app using `ENV`, you're already set to deploy to Heroku.
0e57f51 @laserlemon Initial commit
laserlemon authored
22
dbaacdb @laserlemon Write the README
laserlemon authored
23 ## Give me an example.
0e57f51 @laserlemon Initial commit
laserlemon authored
24
dbaacdb @laserlemon Write the README
laserlemon authored
25 Okay. Add Figaro to your bundle:
26
27 ```ruby
28 gem "figaro"
29 ```
30
27f6e0a @laserlemon Update README with new installation instructions
laserlemon authored
31 Next up, install Figaro:
32
33 ```bash
34 rails generate figaro:install
dbaacdb @laserlemon Write the README
laserlemon authored
35 ```
36
27f6e0a @laserlemon Update README with new installation instructions
laserlemon authored
37 This generates a commented `config/application.yml` file and ignores it in your `.gitignore`. Add your own configuration to this file and you're done!
38
39 Your configuration will be available as key/value pairs in `ENV`. For example, here's `config/initializers/pusher.rb`:
dbaacdb @laserlemon Write the README
laserlemon authored
40
41 ```ruby
42 Pusher.app_id = ENV["PUSHER_APP_ID"]
43 Pusher.key = ENV["PUSHER_KEY"]
44 Pusher.secret = ENV["PUSHER_SECRET"]
45 ```
46
47 ## How does it work with Heroku?
48
49 Heroku's beautifully simple application configuration was the [inspiration](http://laserlemon.com/blog/2011/03/08/heroku-friendly-application-configuration/) for Figaro.
50
51 To configure your application `ENV` on Heroku, you can do the following from the command line using the `heroku` gem and your production configuration information.
52
53 ```bash
54 heroku config:add PUSHER_APP_ID=8926
55 heroku config:add PUSHER_KEY=0463644d89a340ff1132
56 heroku config:add PUSHER_SECRET=0eadfd9847769f94367b
57 heroku config:add STRIPE_API_KEY=jHXKPPE0dUW84xJNYzn6CdWM2JfrCbPE
58 heroku config:add STRIPE_PUBLIC_KEY=pk_HHtUKJwlN7USCT6nE5jiXgoduiNl3
59 ```
60
61 ## What if I'm not using Heroku?
62
4c7c460 @laserlemon Include the mascot
laserlemon authored
63 No problem. Just add `config/application.yml` to your production app on the server.
dbaacdb @laserlemon Write the README
laserlemon authored
64
65 ## This sucks. How can I make it better?
66
67 1. Fork it.
68 2. Make it better.
69 3. Send me a pull request.
4c7c460 @laserlemon Include the mascot
laserlemon authored
70
71 ## Does Figaro have a mascot?
72
73 Yes.
74
75 [![Figaro](http://images2.wikia.nocookie.net/__cb20100628192722/disney/images/5/53/Pinocchio-pinocchio-4947890-960-720.jpg "Figaro's mascot: Figaro")](http://en.wikipedia.org/wiki/Figaro_(Disney\))
Something went wrong with that request. Please try again.