figaro 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .rvmrc
6
+ .yardoc
7
+ Gemfile.lock
8
+ InstalledFiles
9
+ _yardoc
10
+ coverage
11
+ doc/
12
+ lib/bundler/man
13
+ pkg
14
+ rdoc
15
+ spec/reports
16
+ test/tmp
17
+ test/version_tmp
18
+ tmp
@@ -0,0 +1,7 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.8.7
4
+ - 1.9.2
5
+ - 1.9.3
6
+ - ruby-head
7
+ branches: master
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Steve Richert
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,71 @@
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)
2
+
3
+ Simple Rails app configuration
4
+
5
+ ## What is this for?
6
+
7
+ Figaro is for configuring Rails 3 apps, especially open source Rails apps.
8
+
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?
10
+
11
+ Figaro provides a clean and simple way to configure your app and keep the private stuff… private.
12
+
13
+ ## How does it work?
14
+
15
+ It works really well.
16
+
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`!
18
+
19
+ `ENV` is a collection of simple string key/value pairs and it works just great for application configuration.
20
+
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.
22
+
23
+ ## Give me an example.
24
+
25
+ Okay. Add Figaro to your bundle:
26
+
27
+ ```ruby
28
+ gem "figaro"
29
+ ```
30
+
31
+ Next up, create your application's configuration file in `config/application.yml`:
32
+
33
+ ```yaml
34
+ PUSHER_APP_ID: "2954"
35
+ PUSHER_KEY: 7381a978f7dd7f9a1117
36
+ PUSHER_SECRET: abdc3b896a0ffb85d373
37
+ STRIPE_API_KEY: EdAvEPVEC3LuaTg5Q3z6WbDVqZlcBQ8Z
38
+ STRIPE_PUBLIC_KEY: pk_BRgD57O8fHja9HxduJUszhef6jCyS
39
+ ```
40
+
41
+ Now, just add `config/application.yml` to your `.gitignore` and you're done! Your configuration will be available as key/value pairs in `ENV`. For example, here's `config/initializers/pusher.rb`:
42
+
43
+ ```ruby
44
+ Pusher.app_id = ENV["PUSHER_APP_ID"]
45
+ Pusher.key = ENV["PUSHER_KEY"]
46
+ Pusher.secret = ENV["PUSHER_SECRET"]
47
+ ```
48
+
49
+ ## How does it work with Heroku?
50
+
51
+ Heroku's beautifully simple application configuration was the [inspiration](http://laserlemon.com/blog/2011/03/08/heroku-friendly-application-configuration/) for Figaro.
52
+
53
+ 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.
54
+
55
+ ```bash
56
+ heroku config:add PUSHER_APP_ID=8926
57
+ heroku config:add PUSHER_KEY=0463644d89a340ff1132
58
+ heroku config:add PUSHER_SECRET=0eadfd9847769f94367b
59
+ heroku config:add STRIPE_API_KEY=jHXKPPE0dUW84xJNYzn6CdWM2JfrCbPE
60
+ heroku config:add STRIPE_PUBLIC_KEY=pk_HHtUKJwlN7USCT6nE5jiXgoduiNl3
61
+ ```
62
+
63
+ ## What if I'm not using Heroku?
64
+
65
+ No problem. Just add `config/application.yml` on your server for the production app.
66
+
67
+ ## This sucks. How can I make it better?
68
+
69
+ 1. Fork it.
70
+ 2. Make it better.
71
+ 3. Send me a pull request.
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env rake
2
+
3
+ require "bundler/gem_tasks"
4
+ require "cucumber/rake/task"
5
+
6
+ Cucumber::Rake::Task.new(:cucumber)
7
+
8
+ task :default => :cucumber
@@ -0,0 +1,31 @@
1
+ Feature: Rails
2
+ Background:
3
+ Given a new Rails app
4
+ And I add figaro as a dependency
5
+ And I bundle
6
+ And I create "lib/tasks/hello.rake" with:
7
+ """
8
+ task :hello => :environment do
9
+ puts ["Hello", ENV["HELLO"]].compact.join(", ") << "!"
10
+ end
11
+ """
12
+
13
+ Scenario: Has no application.yml
14
+ When I run "bundle exec rake hello"
15
+ Then the output should be "Hello!"
16
+
17
+ Scenario: Has application.yml without requested key
18
+ When I create "config/application.yml" with:
19
+ """
20
+ GOODBYE: Ruby Tuesday
21
+ """
22
+ And I run "bundle exec rake hello"
23
+ Then the output should be "Hello!"
24
+
25
+ Scenario: Has application.yml with requested key
26
+ When I create "config/application.yml" with:
27
+ """
28
+ HELLO: world
29
+ """
30
+ And I run "bundle exec rake hello"
31
+ Then the output should be "Hello, world!"
@@ -0,0 +1,7 @@
1
+ When "I add figaro as a dependency" do
2
+ append_to_file("Gemfile", %(gem "figaro", path: "#{ROOT}"))
3
+ end
4
+
5
+ When "I bundle" do
6
+ run_simple("bundle install")
7
+ end
@@ -0,0 +1,11 @@
1
+ When /^I create "([^"]+)" with:$/ do |path, content|
2
+ write_file(path, content)
3
+ end
4
+
5
+ When /^I run "([^"]+)"$/ do |command|
6
+ run_simple(command)
7
+ end
8
+
9
+ Then /^the output should be "([^"]*)"$/ do |output|
10
+ assert_exact_output(output, output_from(@commands.last).strip)
11
+ end
@@ -0,0 +1,4 @@
1
+ Given "a new Rails app" do
2
+ run_simple("bundle exec rails new example --skip-bundle --skip-git --skip-active-record --skip-sprockets --skip-javascript --skip-test-unit")
3
+ cd("example")
4
+ end
@@ -0,0 +1,8 @@
1
+ require "aruba/api"
2
+ require "aruba/cucumber/hooks"
3
+
4
+ World(Aruba::Api)
5
+
6
+ Before do
7
+ @aruba_timeout_seconds = 10
8
+ end
@@ -0,0 +1 @@
1
+ ROOT = File.expand_path("../../..", __FILE__)
@@ -0,0 +1,23 @@
1
+ # encoding: utf-8
2
+
3
+ Gem::Specification.new do |gem|
4
+ gem.name = "figaro"
5
+ gem.version = "0.1.0"
6
+
7
+ gem.authors = ["Steve Richert"]
8
+ gem.email = ["steve.richert@gmail.com"]
9
+ gem.summary = "Simple Rails app configuration"
10
+ gem.description = "Simple, Heroku-friendly Rails app configuration using ENV and a single YAML file"
11
+ gem.homepage = "https://github.com/laserlemon/figaro"
12
+
13
+ gem.add_dependency "rails", "~> 3.0"
14
+
15
+ gem.add_development_dependency "aruba", "~> 0.4"
16
+ gem.add_development_dependency "cucumber", "~> 1.0"
17
+ gem.add_development_dependency "rake", ">= 0.8.7"
18
+ gem.add_development_dependency "rspec", "~> 2.0"
19
+
20
+ gem.files = `git ls-files`.split($\)
21
+ gem.test_files = gem.files.grep(/^spec\//)
22
+ gem.require_paths = ["lib"]
23
+ end
@@ -0,0 +1,4 @@
1
+ require "figaro/railtie"
2
+
3
+ module Figaro
4
+ end
@@ -0,0 +1,11 @@
1
+ require "rails"
2
+ require "yaml"
3
+
4
+ module Figaro
5
+ class Railtie < ::Rails::Railtie
6
+ config.before_configuration do
7
+ path = Rails.root.join("config/application.yml")
8
+ ENV.update(YAML.load_file(path)) if File.exist?(path)
9
+ end
10
+ end
11
+ end
metadata ADDED
@@ -0,0 +1,155 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: figaro
3
+ version: !ruby/object:Gem::Version
4
+ hash: 27
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 0
10
+ version: 0.1.0
11
+ platform: ruby
12
+ authors:
13
+ - Steve Richert
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2012-04-02 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: rails
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ~>
27
+ - !ruby/object:Gem::Version
28
+ hash: 7
29
+ segments:
30
+ - 3
31
+ - 0
32
+ version: "3.0"
33
+ type: :runtime
34
+ version_requirements: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ name: aruba
37
+ prerelease: false
38
+ requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ hash: 3
44
+ segments:
45
+ - 0
46
+ - 4
47
+ version: "0.4"
48
+ type: :development
49
+ version_requirements: *id002
50
+ - !ruby/object:Gem::Dependency
51
+ name: cucumber
52
+ prerelease: false
53
+ requirement: &id003 !ruby/object:Gem::Requirement
54
+ none: false
55
+ requirements:
56
+ - - ~>
57
+ - !ruby/object:Gem::Version
58
+ hash: 15
59
+ segments:
60
+ - 1
61
+ - 0
62
+ version: "1.0"
63
+ type: :development
64
+ version_requirements: *id003
65
+ - !ruby/object:Gem::Dependency
66
+ name: rake
67
+ prerelease: false
68
+ requirement: &id004 !ruby/object:Gem::Requirement
69
+ none: false
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ hash: 49
74
+ segments:
75
+ - 0
76
+ - 8
77
+ - 7
78
+ version: 0.8.7
79
+ type: :development
80
+ version_requirements: *id004
81
+ - !ruby/object:Gem::Dependency
82
+ name: rspec
83
+ prerelease: false
84
+ requirement: &id005 !ruby/object:Gem::Requirement
85
+ none: false
86
+ requirements:
87
+ - - ~>
88
+ - !ruby/object:Gem::Version
89
+ hash: 3
90
+ segments:
91
+ - 2
92
+ - 0
93
+ version: "2.0"
94
+ type: :development
95
+ version_requirements: *id005
96
+ description: Simple, Heroku-friendly Rails app configuration using ENV and a single YAML file
97
+ email:
98
+ - steve.richert@gmail.com
99
+ executables: []
100
+
101
+ extensions: []
102
+
103
+ extra_rdoc_files: []
104
+
105
+ files:
106
+ - .gitignore
107
+ - .travis.yml
108
+ - Gemfile
109
+ - LICENSE
110
+ - README.md
111
+ - Rakefile
112
+ - features/rails.feature
113
+ - features/step_definitions/bundler_steps.rb
114
+ - features/step_definitions/common_steps.rb
115
+ - features/step_definitions/rails_steps.rb
116
+ - features/support/aruba.rb
117
+ - features/support/env.rb
118
+ - figaro.gemspec
119
+ - lib/figaro.rb
120
+ - lib/figaro/railtie.rb
121
+ homepage: https://github.com/laserlemon/figaro
122
+ licenses: []
123
+
124
+ post_install_message:
125
+ rdoc_options: []
126
+
127
+ require_paths:
128
+ - lib
129
+ required_ruby_version: !ruby/object:Gem::Requirement
130
+ none: false
131
+ requirements:
132
+ - - ">="
133
+ - !ruby/object:Gem::Version
134
+ hash: 3
135
+ segments:
136
+ - 0
137
+ version: "0"
138
+ required_rubygems_version: !ruby/object:Gem::Requirement
139
+ none: false
140
+ requirements:
141
+ - - ">="
142
+ - !ruby/object:Gem::Version
143
+ hash: 3
144
+ segments:
145
+ - 0
146
+ version: "0"
147
+ requirements: []
148
+
149
+ rubyforge_project:
150
+ rubygems_version: 1.8.21
151
+ signing_key:
152
+ specification_version: 3
153
+ summary: Simple Rails app configuration
154
+ test_files: []
155
+