figaro 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -1,5 +1,6 @@
1
1
  *.gem
2
2
  *.rbc
3
+ .DS_Store
3
4
  .bundle
4
5
  .config
5
6
  .rvmrc
@@ -9,6 +10,7 @@ InstalledFiles
9
10
  _yardoc
10
11
  coverage
11
12
  doc/
13
+ gemfiles/*.gemfile.lock
12
14
  lib/bundler/man
13
15
  pkg
14
16
  rdoc
@@ -1,7 +1,11 @@
1
+ branches: master
2
+ gemfile:
3
+ - gemfiles/rails30.gemfile
4
+ - gemfiles/rails31.gemfile
5
+ - gemfiles/rails32.gemfile
1
6
  language: ruby
2
7
  rvm:
3
8
  - 1.8.7
4
9
  - 1.9.2
5
10
  - 1.9.3
6
11
  - ruby-head
7
- branches: master
@@ -0,0 +1,11 @@
1
+ appraise "rails30" do
2
+ gem "rails", "~> 3.0.0"
3
+ end
4
+
5
+ appraise "rails31" do
6
+ gem "rails", "~> 3.1.0"
7
+ end
8
+
9
+ appraise "rails32" do
10
+ gem "rails", "~> 3.2.0"
11
+ end
data/README.md CHANGED
@@ -28,17 +28,15 @@ Okay. Add Figaro to your bundle:
28
28
  gem "figaro"
29
29
  ```
30
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
31
+ Next up, install Figaro:
32
+
33
+ ```bash
34
+ rails generate figaro:install
39
35
  ```
40
36
 
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`:
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`:
42
40
 
43
41
  ```ruby
44
42
  Pusher.app_id = ENV["PUSHER_APP_ID"]
data/Rakefile CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  require "bundler/gem_tasks"
4
4
  require "cucumber/rake/task"
5
+ require "appraisal"
5
6
 
6
7
  Cucumber::Rake::Task.new(:cucumber)
7
8
 
@@ -22,6 +22,21 @@ Feature: Rails
22
22
  And I run "bundle exec rake hello"
23
23
  Then the output should be "Hello!"
24
24
 
25
+ Scenario: Has blank application.yml
26
+ When I create "config/application.yml" with:
27
+ """
28
+ """
29
+ And I run "bundle exec rake hello"
30
+ Then the output should be "Hello!"
31
+
32
+ Scenario: Has commented application.yml
33
+ When I create "config/application.yml" with:
34
+ """
35
+ # Comment
36
+ """
37
+ And I run "bundle exec rake hello"
38
+ Then the output should be "Hello!"
39
+
25
40
  Scenario: Has application.yml with requested key
26
41
  When I create "config/application.yml" with:
27
42
  """
@@ -29,3 +44,14 @@ Feature: Rails
29
44
  """
30
45
  And I run "bundle exec rake hello"
31
46
  Then the output should be "Hello, world!"
47
+
48
+ Scenario: Generator creates and ignores application.yml file
49
+ When I run "bundle exec rails generate figaro:install"
50
+ Then "config/application.yml" should exist
51
+ And ".gitignore" should contain "/config/application.yml"
52
+
53
+ Scenario: Generator only creates application.yml if not using Git
54
+ Given I run "rm .gitignore"
55
+ When I run "bundle exec rails generate figaro:install"
56
+ Then "config/application.yml" should exist
57
+ But ".gitignore" should not exist
@@ -9,3 +9,11 @@ end
9
9
  Then /^the output should be "([^"]*)"$/ do |output|
10
10
  assert_exact_output(output, output_from(@commands.last).strip)
11
11
  end
12
+
13
+ Then /^"([^"]+)" should ?(not)? exist$/ do |path, negative|
14
+ check_file_presence([path], !negative)
15
+ end
16
+
17
+ Then /^"([^"]+)" should contain "([^"]*)"$/ do |path, content|
18
+ check_file_content(path, content, true)
19
+ end
@@ -1,4 +1,5 @@
1
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")
2
+ in_current_dir{ FileUtils.rm_rf("example") }
3
+ run_simple("bundle exec rails new example --skip-bundle --skip-active-record --skip-sprockets --skip-javascript --skip-test-unit")
3
4
  cd("example")
4
5
  end
@@ -4,5 +4,9 @@ require "aruba/cucumber/hooks"
4
4
  World(Aruba::Api)
5
5
 
6
6
  Before do
7
- @aruba_timeout_seconds = 10
7
+ @aruba_timeout_seconds = 60
8
+ end
9
+
10
+ After "~@no-clobber" do
11
+ FileUtils.rm_rf(current_dir)
8
12
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |gem|
4
4
  gem.name = "figaro"
5
- gem.version = "0.1.1"
5
+ gem.version = "0.2.0"
6
6
 
7
7
  gem.authors = ["Steve Richert"]
8
8
  gem.email = ["steve.richert@gmail.com"]
@@ -12,6 +12,7 @@ Gem::Specification.new do |gem|
12
12
 
13
13
  gem.add_dependency "rails", "~> 3.0"
14
14
 
15
+ gem.add_development_dependency "appraisal", "~> 0.4"
15
16
  gem.add_development_dependency "aruba", "~> 0.4"
16
17
  gem.add_development_dependency "cucumber", "~> 1.0"
17
18
  gem.add_development_dependency "rake", ">= 0.8.7"
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rails", "~> 3.0.0"
6
+
7
+ gemspec :path=>"../"
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rails", "~> 3.1.0"
6
+
7
+ gemspec :path=>"../"
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rails", "~> 3.2.0"
6
+
7
+ gemspec :path=>"../"
@@ -5,7 +5,7 @@ module Figaro
5
5
  class Railtie < ::Rails::Railtie
6
6
  config.before_configuration do
7
7
  path = Rails.root.join("config/application.yml")
8
- ENV.update(YAML.load_file(path)) if File.exist?(path)
8
+ ENV.update(YAML.load(File.read(path)) || {}) if File.exist?(path)
9
9
  end
10
10
  end
11
11
  end
@@ -0,0 +1,23 @@
1
+ module Figaro
2
+ module Generators
3
+ class InstallGenerator < Rails::Generators::Base
4
+ source_root File.expand_path("../templates", __FILE__)
5
+
6
+ def create_configuration
7
+ copy_file "application.yml", "config/application.yml"
8
+ end
9
+
10
+ def ignore_configuration
11
+ if File.exists?(".gitignore")
12
+ append_to_file ".gitignore" do
13
+ <<-EOF.strip_heredoc
14
+
15
+ # Ignore application configuration
16
+ /config/application.yml
17
+ EOF
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,7 @@
1
+ # Add application configuration variables here, as shown below.
2
+ #
3
+ # PUSHER_APP_ID: "2954"
4
+ # PUSHER_KEY: 7381a978f7dd7f9a1117
5
+ # PUSHER_SECRET: abdc3b896a0ffb85d373
6
+ # STRIPE_API_KEY: EdAvEPVEC3LuaTg5Q3z6WbDVqZlcBQ8Z
7
+ # STRIPE_PUBLIC_KEY: pk_BRgD57O8fHja9HxduJUszhef6jCyS
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: figaro
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-04-02 00:00:00.000000000 Z
12
+ date: 2012-04-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -27,6 +27,22 @@ dependencies:
27
27
  - - ~>
28
28
  - !ruby/object:Gem::Version
29
29
  version: '3.0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: appraisal
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: '0.4'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: '0.4'
30
46
  - !ruby/object:Gem::Dependency
31
47
  name: aruba
32
48
  requirement: !ruby/object:Gem::Requirement
@@ -85,6 +101,7 @@ extra_rdoc_files: []
85
101
  files:
86
102
  - .gitignore
87
103
  - .travis.yml
104
+ - Appraisals
88
105
  - Gemfile
89
106
  - LICENSE
90
107
  - README.md
@@ -96,8 +113,13 @@ files:
96
113
  - features/support/aruba.rb
97
114
  - features/support/env.rb
98
115
  - figaro.gemspec
116
+ - gemfiles/rails30.gemfile
117
+ - gemfiles/rails31.gemfile
118
+ - gemfiles/rails32.gemfile
99
119
  - lib/figaro.rb
100
120
  - lib/figaro/railtie.rb
121
+ - lib/generators/figaro/install/install_generator.rb
122
+ - lib/generators/figaro/install/templates/application.yml
101
123
  homepage: https://github.com/laserlemon/figaro
102
124
  licenses: []
103
125
  post_install_message: