figaro 0.6.1 → 0.6.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ MmQ0NjAyZmU3NWMzNTZkY2UzNDAyNTA0NTZjMjkwYTRiZDU3ZGU5ZA==
5
+ data.tar.gz: !binary |-
6
+ NmNkMTFlM2UwYzdmZTkxMWRmYTczZjI5NjM4M2Y2ZTY5N2QzY2E3NA==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ YWU3YTgzZmVhYzc2NjhjNTk4YTIyYzdkNzQwZDRiMWU4MzVlYWRiZmIwMDU4
10
+ OWU2ZTA5ZWQ4Y2RkODI2MmU3NzVmOGUwZTc2MjkyZmI5ODRjYjBkMmVlNDQ1
11
+ MmNjODFiM2FkNzc2ZjdiMjFjN2RlMmRiODMwNGFkYmRjN2RhODI=
12
+ data.tar.gz: !binary |-
13
+ MjczZTlkNmI2NTgwNjZjZTkxMTYxODY1MDI2ZWNjNjViZDkyODU3MzMyZTY1
14
+ MWRlZWM2ODJhZTMyZDI1NmQxYmUyZTBiYjM1NGMzNjVlMDE1ZWJkMDllNWNm
15
+ OGZhMzcwOGE3YTI1ZGYzZjIwYzkyMTE0MDU4MTAxNjY4YWU2ZDc=
@@ -21,3 +21,7 @@ matrix:
21
21
  rvm: 1.8.7
22
22
  - gemfile: gemfiles/rails40.gemfile
23
23
  rvm: 1.9.2
24
+ include:
25
+ - gemfile: Gemfile
26
+ rvm: 1.9.3
27
+ env: COVERAGE=true
data/Gemfile CHANGED
@@ -4,7 +4,11 @@ gemspec
4
4
 
5
5
  gem "rails", ">= 3.0.2", "< 5"
6
6
 
7
- gem "aruba", "~> 0.5.1"
8
- gem "cucumber", "~> 1.2.1"
9
- gem "rake", "~> 10.0.3"
10
- gem "rspec", "~> 2.13.0"
7
+ group :test do
8
+ gem "aruba", "~> 0.5"
9
+ gem "coveralls", "~> 0.6", :require => false
10
+ gem "cucumber", "~> 1.2"
11
+ gem "rake", "~> 10.0"
12
+ gem "rspec", "~> 2.13"
13
+ gem "simplecov", "~> 0.7", :require => false
14
+ end
data/README.md CHANGED
@@ -1,4 +1,9 @@
1
- # Figaro [![Build](https://travis-ci.org/laserlemon/figaro.png?branch=master)](https://travis-ci.org/laserlemon/figaro) [![Code Climate](https://codeclimate.com/github/laserlemon/figaro.png)](https://codeclimate.com/github/laserlemon/figaro)
1
+ # Figaro
2
+ [![Gem Version](https://badge.fury.io/rb/figaro.png)](http://badge.fury.io/rb/figaro)
3
+ [![Build Status](https://travis-ci.org/laserlemon/figaro.png?branch=master)](https://travis-ci.org/laserlemon/figaro)
4
+ [![Code Climate](https://codeclimate.com/github/laserlemon/figaro.png)](https://codeclimate.com/github/laserlemon/figaro)
5
+ [![Coverage Status](https://coveralls.io/repos/laserlemon/figaro/badge.png?branch=master)](https://coveralls.io/r/laserlemon/figaro)
6
+ [![Dependency Status](https://gemnasium.com/laserlemon/figaro.png)](https://gemnasium.com/laserlemon/figaro)
2
7
 
3
8
  Simple Rails app configuration
4
9
 
data/Rakefile CHANGED
@@ -6,3 +6,12 @@ RSpec::Core::RakeTask.new(:spec)
6
6
  Cucumber::Rake::Task.new(:cucumber)
7
7
 
8
8
  task :default => [:spec, :cucumber]
9
+
10
+ if ENV["COVERAGE"]
11
+ Rake::Task[:default].enhance do
12
+ require "simplecov"
13
+ require "coveralls"
14
+
15
+ Coveralls::SimpleCov::Formatter.new.format(SimpleCov.result)
16
+ end
17
+ end
@@ -9,10 +9,6 @@ Feature: Rails
9
9
  puts ["Hello", ENV["HELLO"]].compact.join(", ") << "!"
10
10
  end
11
11
 
12
- task :nena => :environment do
13
- puts [ENV["LUFTBALLOONS"], "Luftballoons"].compact.join(" ")
14
- end
15
-
16
12
  task :greet => :environment do
17
13
  puts ([Figaro.env.greeting] * 3).join(", ") << "!"
18
14
  end
@@ -22,15 +18,7 @@ Feature: Rails
22
18
  When I run "rake hello"
23
19
  Then the output should be "Hello!"
24
20
 
25
- Scenario: Has application.yml without requested key
26
- Given I create "config/application.yml" with:
27
- """
28
- GOODBYE: Ruby Tuesday
29
- """
30
- When I run "rake hello"
31
- Then the output should be "Hello!"
32
-
33
- Scenario: Has blank application.yml
21
+ Scenario: Has blank application.yml
34
22
  Given I create "config/application.yml" with:
35
23
  """
36
24
  """
@@ -45,24 +33,6 @@ Feature: Rails
45
33
  When I run "rake hello"
46
34
  Then the output should be "Hello!"
47
35
 
48
- Scenario: Has application.yml with requested key
49
- Given I create "config/application.yml" with:
50
- """
51
- HELLO: world
52
- """
53
- When I run "rake hello"
54
- Then the output should be "Hello, world!"
55
-
56
- Scenario: Has application.yml with RAILS_ENV defaulting to "development"
57
- Given I create "config/application.yml" with:
58
- """
59
- HELLO: world
60
- development:
61
- HELLO: developers
62
- """
63
- When I run "rake hello"
64
- Then the output should be "Hello, developers!"
65
-
66
36
  Scenario: Has application.yml with RAILS_ENV set
67
37
  Given I create "config/application.yml" with:
68
38
  """
@@ -79,14 +49,6 @@ Feature: Rails
79
49
  When I run "rake hello RAILS_ENV=production"
80
50
  Then the output should be "Hello, users!"
81
51
 
82
- Scenario: Has application.yml with non-string values
83
- Given I create "config/application.yml" with:
84
- """
85
- LUFTBALLOONS: 99
86
- """
87
- When I run "rake nena"
88
- Then the output should be "99 Luftballoons"
89
-
90
52
  Scenario: Generator creates and ignores application.yml file
91
53
  When I run "rails generate figaro:install"
92
54
  Then "config/application.yml" should exist
@@ -1,3 +1,8 @@
1
+ if ENV["COVERAGE"]
2
+ require "simplecov"
3
+ SimpleCov.start { add_filter("features") }
4
+ end
5
+
1
6
  require "pathname"
2
7
 
3
8
  ROOT = Pathname.new(File.expand_path("../../..", __FILE__))
@@ -2,13 +2,14 @@
2
2
 
3
3
  Gem::Specification.new do |gem|
4
4
  gem.name = "figaro"
5
- gem.version = "0.6.1"
5
+ gem.version = "0.6.2"
6
6
 
7
7
  gem.authors = ["Steve Richert"]
8
8
  gem.email = ["steve.richert@gmail.com"]
9
9
  gem.summary = "Simple Rails app configuration"
10
10
  gem.description = "Simple, Heroku-friendly Rails app configuration using ENV and a single YAML file"
11
11
  gem.homepage = "https://github.com/laserlemon/figaro"
12
+ gem.license = "MIT"
12
13
 
13
14
  gem.add_dependency "rails", ">= 3", "< 5"
14
15
 
@@ -4,7 +4,11 @@ gemspec :path => "../"
4
4
 
5
5
  gem "rails", "~> 3.0.2"
6
6
 
7
- gem "aruba", "~> 0.5.1"
8
- gem "cucumber", "~> 1.2.1"
9
- gem "rake", "~> 10.0.3"
10
- gem "rspec", "~> 2.13.0"
7
+ group :test do
8
+ gem "aruba", "~> 0.5"
9
+ gem "coveralls", "~> 0.6", :require => false
10
+ gem "cucumber", "~> 1.2"
11
+ gem "rake", "~> 10.0"
12
+ gem "rspec", "~> 2.13"
13
+ gem "simplecov", "~> 0.7", :require => false
14
+ end
@@ -4,7 +4,11 @@ gemspec :path => "../"
4
4
 
5
5
  gem "rails", "~> 3.1.0"
6
6
 
7
- gem "aruba", "~> 0.5.1"
8
- gem "cucumber", "~> 1.2.1"
9
- gem "rake", "~> 10.0.3"
10
- gem "rspec", "~> 2.13.0"
7
+ group :test do
8
+ gem "aruba", "~> 0.5"
9
+ gem "coveralls", "~> 0.6", :require => false
10
+ gem "cucumber", "~> 1.2"
11
+ gem "rake", "~> 10.0"
12
+ gem "rspec", "~> 2.13"
13
+ gem "simplecov", "~> 0.7", :require => false
14
+ end
@@ -4,7 +4,11 @@ gemspec :path => "../"
4
4
 
5
5
  gem "rails", "~> 3.2.0"
6
6
 
7
- gem "aruba", "~> 0.5.1"
8
- gem "cucumber", "~> 1.2.1"
9
- gem "rake", "~> 10.0.3"
10
- gem "rspec", "~> 2.13.0"
7
+ group :test do
8
+ gem "aruba", "~> 0.5"
9
+ gem "coveralls", "~> 0.6", :require => false
10
+ gem "cucumber", "~> 1.2"
11
+ gem "rake", "~> 10.0"
12
+ gem "rspec", "~> 2.13"
13
+ gem "simplecov", "~> 0.7", :require => false
14
+ end
@@ -4,7 +4,11 @@ gemspec :path => "../"
4
4
 
5
5
  gem "rails", ">= 4.0.0.beta", "< 4.1"
6
6
 
7
- gem "aruba", "~> 0.5.1"
8
- gem "cucumber", "~> 1.2.1"
9
- gem "rake", "~> 10.0.3"
10
- gem "rspec", "~> 2.13.0"
7
+ group :test do
8
+ gem "aruba", "~> 0.5"
9
+ gem "coveralls", "~> 0.6", :require => false
10
+ gem "cucumber", "~> 1.2"
11
+ gem "rake", "~> 10.0"
12
+ gem "rspec", "~> 2.13"
13
+ gem "simplecov", "~> 0.7", :require => false
14
+ end
@@ -1,6 +1,6 @@
1
1
  namespace :figaro do
2
2
  desc "Configure Heroku according to application.yml"
3
3
  task :heroku, [:app] => :environment do |_, args|
4
- Figaro::Tasks.heroku(args[:app])
4
+ Figaro::Tasks::Heroku.new(args[:app]).invoke
5
5
  end
6
6
  end
@@ -1,12 +1,22 @@
1
1
  module Figaro
2
2
  module Tasks
3
- def self.heroku(app = nil)
4
- with_app = app ? " --app #{app}" : ""
3
+ class Heroku < Struct.new(:app)
4
+ def invoke
5
+ heroku("config:set #{vars}")
6
+ end
5
7
 
6
- rails_env = `heroku config:get RAILS_ENV#{with_app}`.chomp
7
- vars = Figaro.vars(rails_env.presence)
8
+ def vars
9
+ Figaro.vars(environment)
10
+ end
8
11
 
9
- `heroku config:add #{vars}#{with_app}`
12
+ def environment
13
+ heroku("run 'echo $RAILS_ENV'").chomp[/(\w+)\z/]
14
+ end
15
+
16
+ def heroku(command)
17
+ with_app = app ? " --app #{app}" : ""
18
+ `heroku #{command}#{with_app}`
19
+ end
10
20
  end
11
21
  end
12
22
  end
@@ -1,61 +1,71 @@
1
1
  require "spec_helper"
2
2
 
3
- describe Figaro::Tasks do
4
- describe ".heroku" do
5
- it "configures Heroku" do
6
- Figaro.stub(:vars => "FOO=bar")
3
+ module Figaro::Tasks
4
+ describe Heroku do
5
+ subject(:heroku) { Heroku.new }
7
6
 
8
- Figaro::Tasks.should_receive(:`).once.with("heroku config:get RAILS_ENV").
9
- and_return("development\n")
10
- Figaro::Tasks.should_receive(:`).once.with("heroku config:add FOO=bar")
7
+ describe "#invoke" do
8
+ it "configures Heroku" do
9
+ heroku.stub(:vars => "FOO=bar")
11
10
 
12
- Figaro::Tasks.heroku
13
- end
11
+ heroku.should_receive(:heroku).once.with("config:set FOO=bar")
14
12
 
15
- it "configures a specific Heroku app" do
16
- Figaro.stub(:vars => "FOO=bar")
13
+ heroku.invoke
14
+ end
15
+ end
17
16
 
18
- Figaro::Tasks.should_receive(:`).once.
19
- with("heroku config:get RAILS_ENV --app my-app").
20
- and_return("development\n")
21
- Figaro::Tasks.should_receive(:`).once.
22
- with("heroku config:add FOO=bar --app my-app")
17
+ describe "#vars" do
18
+ it "returns Figaro's vars for Heroku's environment" do
19
+ heroku.stub(:environment => "staging")
20
+ Figaro.stub(:vars).with("staging").and_return("FOO=bar")
23
21
 
24
- Figaro::Tasks.heroku("my-app")
22
+ expect(heroku.vars).to eq("FOO=bar")
23
+ end
25
24
  end
26
25
 
27
- it "respects the Heroku's remote Rails environment" do
28
- Figaro::Tasks.stub(:`).with("heroku config:get RAILS_ENV").
29
- and_return("production\n")
30
-
31
- Figaro.should_receive(:vars).once.with("production").and_return("FOO=bar")
32
- Figaro::Tasks.should_receive(:`).once.with("heroku config:add FOO=bar")
26
+ describe "#environment" do
27
+ it "returns Heroku's environment" do
28
+ heroku.stub(:heroku).with("run 'echo $RAILS_ENV'").and_return(<<-OUT)
29
+ Running `echo $RAILS_ENV` attached to terminal... up, run.1234
30
+ staging
31
+ OUT
33
32
 
34
- Figaro::Tasks.heroku
33
+ expect(heroku.environment).to eq("staging")
34
+ end
35
35
  end
36
36
 
37
- it "defaults to the local Rails environment if not set remotely" do
38
- Figaro::Tasks.stub(:`).with("heroku config:get RAILS_ENV").
39
- and_return("\n")
37
+ describe "#heroku" do
38
+ it "runs a command on Heroku" do
39
+ heroku.should_receive(:`).once.with("heroku info")
40
40
 
41
- Figaro.should_receive(:vars).once.with(nil).and_return("FOO=bar")
42
- Figaro::Tasks.should_receive(:`).once.with("heroku config:add FOO=bar")
41
+ heroku.heroku("info")
42
+ end
43
43
 
44
- Figaro::Tasks.heroku
45
- end
44
+ it "runs a command on a specific Heroku app" do
45
+ heroku = Heroku.new("my-app")
46
46
 
47
- describe "figaro:heroku", :rake => true do
48
- it "configures Heroku" do
49
- Figaro::Tasks.should_receive(:heroku).once.with(nil)
47
+ heroku.should_receive(:`).once.with("heroku info --app my-app")
50
48
 
51
- task.invoke
49
+ heroku.heroku("info")
52
50
  end
51
+ end
52
+ end
53
53
 
54
- it "configures a specific Heroku app" do
55
- Figaro::Tasks.should_receive(:heroku).once.with("my-app")
54
+ describe "figaro:heroku", :rake => true do
55
+ subject(:heroku) { mock(:heroku) }
56
56
 
57
- task.invoke("my-app")
58
- end
57
+ it "configures Heroku" do
58
+ Figaro::Tasks::Heroku.stub(:new).with(nil).and_return(heroku)
59
+ heroku.should_receive(:invoke).once
60
+
61
+ task.invoke
62
+ end
63
+
64
+ it "configures a specific Heroku app" do
65
+ Figaro::Tasks::Heroku.stub(:new).with("my-app").and_return(heroku)
66
+ heroku.should_receive(:invoke).once
67
+
68
+ task.invoke("my-app")
59
69
  end
60
70
  end
61
71
  end
@@ -1,3 +1,8 @@
1
+ if ENV["COVERAGE"]
2
+ require "simplecov"
3
+ SimpleCov.start { add_filter("spec") }
4
+ end
5
+
1
6
  require "figaro"
2
7
  require "pathname"
3
8
 
metadata CHANGED
@@ -1,20 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: figaro
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
5
- prerelease:
4
+ version: 0.6.2
6
5
  platform: ruby
7
6
  authors:
8
7
  - Steve Richert
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-02-27 00:00:00.000000000 Z
11
+ date: 2013-03-07 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rails
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
17
  - - ! '>='
20
18
  - !ruby/object:Gem::Version
@@ -25,7 +23,6 @@ dependencies:
25
23
  type: :runtime
26
24
  prerelease: false
27
25
  version_requirements: !ruby/object:Gem::Requirement
28
- none: false
29
26
  requirements:
30
27
  - - ! '>='
31
28
  - !ruby/object:Gem::Version
@@ -71,28 +68,28 @@ files:
71
68
  - spec/spec_helper.rb
72
69
  - spec/support/rake.rb
73
70
  homepage: https://github.com/laserlemon/figaro
74
- licenses: []
71
+ licenses:
72
+ - MIT
73
+ metadata: {}
75
74
  post_install_message:
76
75
  rdoc_options: []
77
76
  require_paths:
78
77
  - lib
79
78
  required_ruby_version: !ruby/object:Gem::Requirement
80
- none: false
81
79
  requirements:
82
80
  - - ! '>='
83
81
  - !ruby/object:Gem::Version
84
82
  version: '0'
85
83
  required_rubygems_version: !ruby/object:Gem::Requirement
86
- none: false
87
84
  requirements:
88
85
  - - ! '>='
89
86
  - !ruby/object:Gem::Version
90
87
  version: '0'
91
88
  requirements: []
92
89
  rubyforge_project:
93
- rubygems_version: 1.8.25
90
+ rubygems_version: 2.0.2
94
91
  signing_key:
95
- specification_version: 3
92
+ specification_version: 4
96
93
  summary: Simple Rails app configuration
97
94
  test_files:
98
95
  - features/rails.feature