config_for 0.1.0 → 0.1.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1fd11626cc268c38c80c2ce643e41c9847ad84a9
4
- data.tar.gz: 76f6e604d374d722d459633e8fb5102457aab546
3
+ metadata.gz: cc898ae1ac1904265206e188a2dc17f22ad46ab3
4
+ data.tar.gz: 9cb5eb13f46f7fdcbb51d718c6d1c8e1bdf34b47
5
5
  SHA512:
6
- metadata.gz: 72d4e91b471a64b6094f58cd33d5deb9414d90eb6e3aa46f577b08dac6b2f91591d5462b5f9f327da80cc856bd1ea4eae5d089a2620d01922690688613aadd3e
7
- data.tar.gz: c6b63b3189ca204869a7b51d10dbb929ad25644f319b7260685676a736475df85ae47ad542ade94e1deefec7038861a83ad0df203caddef6d28a78453bff70bf
6
+ metadata.gz: 0250747aafc96cd7debac2d674a3e668d832b40bb08f97e4cd4e2550a6b622eb6b9740bbc1a4b798a05735f463977a3885670653f661333f13d87ae1b3771682
7
+ data.tar.gz: 7191805275b3302a4b267d6871a96f624ca8a8cd1a79e8e55dafc56f65274b8021f311d48d2ba622ced6f80381b9621139f9e36ffcaccdd7e57471930cf05af7
data/CHANGELOG.md CHANGED
@@ -3,6 +3,12 @@ All notable changes to this project will be documented in this file.
3
3
 
4
4
  ## master - unreleased
5
5
 
6
+ ## 0.1.1 - 2014-10-29
7
+
8
+ ### Changed
9
+ - Passing a Symbol as env works
10
+ - Loads indifferent_access core extension
11
+
6
12
  ## 0.1.0 - 2014-10-03
7
13
 
8
14
  ### Added
data/README.md CHANGED
@@ -107,6 +107,19 @@ So the last think you have to do is add `config/database.yml` to `linked_files`
107
107
  set :linked_files, %w[ config/database.yml ]
108
108
  ```
109
109
 
110
+ ### PORO
111
+
112
+ If you have your own framework. You need to create your own `config_for` method. But don't worry. It is easy:
113
+
114
+ ```ruby
115
+ require 'config_for'
116
+ module MyApp
117
+ def self.config_for(name)
118
+ ConfigFor.load_config(MyApp.root.join('config'), name, MyApp.env)
119
+ end
120
+ end
121
+ ```
122
+
110
123
  ## Contributing
111
124
 
112
125
  1. Fork it ( https://github.com/3scale/config_for/fork )
data/lib/config_for.rb CHANGED
@@ -3,7 +3,10 @@ require 'pathname'
3
3
 
4
4
  require 'yaml'
5
5
  require 'erb'
6
+
6
7
  require 'active_support/hash_with_indifferent_access'
8
+ # HashWithIndifferentAccess needs this core extension to be loaded
9
+ require 'active_support/core_ext/hash/indifferent_access'
7
10
 
8
11
  module ConfigFor
9
12
  if defined?(::Rails)
@@ -33,8 +36,8 @@ module ConfigFor
33
36
  yaml = File.join(path, "#{name}.yml")
34
37
 
35
38
  if File.readable?(yaml)
36
- config = parse_yaml(yaml)[env]
37
- ActiveSupport::HashWithIndifferentAccess.new(config)
39
+ config = parse_yaml(yaml)
40
+ ActiveSupport::HashWithIndifferentAccess.new(config).fetch(env)
38
41
  else
39
42
  raise "Could not load configuration. Can't read #{yaml}"
40
43
  end
@@ -1,3 +1,3 @@
1
1
  module ConfigFor
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.1'
3
3
  end
@@ -20,4 +20,12 @@ RSpec.describe ConfigFor do
20
20
  'Could not load configuration. Can\'t read spec/fixtures/unknown.yml')
21
21
  end
22
22
  end
23
+
24
+ context 'with symbol as env' do
25
+ let(:env) { :production }
26
+
27
+ context 'database' do
28
+ it { is_expected.to_not be_empty }
29
+ end
30
+ end
23
31
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: config_for
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michal Cichra
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-03 00:00:00.000000000 Z
11
+ date: 2014-10-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler