config_yml 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/Gemfile +1 -0
- data/Gemfile.lock +6 -0
- data/README.md +29 -2
- data/Rakefile +1 -0
- data/config_yml.gemspec +4 -4
- data/lib/configuration/syntax/conf.rb +11 -0
- data/lib/configuration/syntax.rb +1 -0
- data/lib/configuration/version.rb +1 -1
- data/lib/configuration.rb +3 -0
- data/spec/lib/configuration/syntax_spec.rb +21 -0
- data/spec/lib/configuration_spec.rb +0 -1
- metadata +8 -2
data/.gitignore
ADDED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -8,6 +8,29 @@ Description
|
|
8
8
|
|
9
9
|
config.yml provides a very simple way of configure your ruby applications through yaml files.
|
10
10
|
|
11
|
+
Installation
|
12
|
+
------------
|
13
|
+
|
14
|
+
If you are using Bundler, add the following code to your Gemfile:
|
15
|
+
```ruby
|
16
|
+
gem "config_yml", :require => "configuration"
|
17
|
+
```
|
18
|
+
|
19
|
+
and run:
|
20
|
+
```console
|
21
|
+
$ bundle install
|
22
|
+
```
|
23
|
+
|
24
|
+
If you are not using Bundler:
|
25
|
+
```console
|
26
|
+
$ gem install config_yml
|
27
|
+
```
|
28
|
+
|
29
|
+
then in your Ruby code:
|
30
|
+
```ruby
|
31
|
+
require "configuration"
|
32
|
+
```
|
33
|
+
|
11
34
|
Examples
|
12
35
|
--------
|
13
36
|
|
@@ -28,6 +51,10 @@ end
|
|
28
51
|
ENV["REDIS_URL"] # => "redis://:foo@localhost:6379/bar"
|
29
52
|
```
|
30
53
|
|
54
|
+
You can also use the shorthand:
|
55
|
+
```ruby
|
56
|
+
redis = Conf.redis
|
57
|
+
```
|
31
58
|
|
32
59
|
#### Environment based:
|
33
60
|
|
@@ -66,7 +93,7 @@ Configuration.mysql[:database] # => "myapp_test"
|
|
66
93
|
#### Nested:
|
67
94
|
|
68
95
|
```yaml
|
69
|
-
# config/
|
96
|
+
# config/matryoshka.yml
|
70
97
|
foo:
|
71
98
|
bar:
|
72
99
|
baz:
|
@@ -77,7 +104,7 @@ foo:
|
|
77
104
|
```
|
78
105
|
|
79
106
|
```ruby
|
80
|
-
Configuration.
|
107
|
+
Configuration.matryoshka[:foo][:bar][:baz] # => { :array => [:red, :green, :blue] }
|
81
108
|
```
|
82
109
|
|
83
110
|
License
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/config_yml.gemspec
CHANGED
@@ -1,5 +1,4 @@
|
|
1
|
-
|
2
|
-
require "configuration/version"
|
1
|
+
require File.expand_path("../lib/configuration/version", __FILE__)
|
3
2
|
|
4
3
|
Gem::Specification.new do |spec|
|
5
4
|
spec.name = "config_yml"
|
@@ -12,6 +11,7 @@ Gem::Specification.new do |spec|
|
|
12
11
|
spec.email = "to@vitork.com"
|
13
12
|
spec.homepage = "https://github.com/vitork/config_yml"
|
14
13
|
|
15
|
-
spec.files
|
16
|
-
spec.test_files
|
14
|
+
spec.files = `git ls-files`.split("\n")
|
15
|
+
spec.test_files = `git ls-files -- spec/*`.split("\n")
|
16
|
+
spec.require_paths = ['lib']
|
17
17
|
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require "configuration/syntax/conf"
|
data/lib/configuration.rb
CHANGED
@@ -0,0 +1,21 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Configuration::Syntax::Conf do
|
4
|
+
let(:files) { ["config/file_a.yml", "config/file_b.yml"] }
|
5
|
+
let(:file_a) { { key_a: "value_a" } }
|
6
|
+
let(:file_b) { { key_b: "value_b" } }
|
7
|
+
|
8
|
+
before do
|
9
|
+
Dir.stub(:glob).and_return(files)
|
10
|
+
YAML.stub(:load_file).and_return(file_a, file_b)
|
11
|
+
end
|
12
|
+
|
13
|
+
it "provides an interface for access yml config files" do
|
14
|
+
Conf.file_a[:key_a].should be_eql "value_a"
|
15
|
+
Conf.file_b[:key_b].should be_eql "value_b"
|
16
|
+
end
|
17
|
+
|
18
|
+
it "doesn't provide an interface for access other attributes" do
|
19
|
+
Conf.files.should_not be_eql files
|
20
|
+
end
|
21
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: config_yml
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
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: 2013-04-
|
12
|
+
date: 2013-04-30 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: A very simple way of configure your ruby applications through yaml files.
|
15
15
|
email: to@vitork.com
|
@@ -17,12 +17,17 @@ executables: []
|
|
17
17
|
extensions: []
|
18
18
|
extra_rdoc_files: []
|
19
19
|
files:
|
20
|
+
- .gitignore
|
20
21
|
- Gemfile
|
21
22
|
- Gemfile.lock
|
22
23
|
- README.md
|
24
|
+
- Rakefile
|
23
25
|
- config_yml.gemspec
|
24
26
|
- lib/configuration.rb
|
27
|
+
- lib/configuration/syntax.rb
|
28
|
+
- lib/configuration/syntax/conf.rb
|
25
29
|
- lib/configuration/version.rb
|
30
|
+
- spec/lib/configuration/syntax_spec.rb
|
26
31
|
- spec/lib/configuration_spec.rb
|
27
32
|
- spec/spec_helper.rb
|
28
33
|
homepage: https://github.com/vitork/config_yml
|
@@ -51,5 +56,6 @@ signing_key:
|
|
51
56
|
specification_version: 3
|
52
57
|
summary: Simplify your app configuration.
|
53
58
|
test_files:
|
59
|
+
- spec/lib/configuration/syntax_spec.rb
|
54
60
|
- spec/lib/configuration_spec.rb
|
55
61
|
- spec/spec_helper.rb
|