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 ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ InstalledFiles
7
+ _yardoc
8
+ coverage
9
+ doc/
10
+ lib/bundler/man
11
+ pkg
12
+ rdoc
13
+ spec/reports
14
+ test/tmp
15
+ test/version_tmp
16
+ tmp
17
+ .DS_Store
data/Gemfile CHANGED
@@ -1,3 +1,4 @@
1
1
  source "https://rubygems.org"
2
+ gemspec
2
3
 
3
4
  gem "rspec"
data/Gemfile.lock CHANGED
@@ -1,3 +1,8 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ config_yml (0.0.1)
5
+
1
6
  GEM
2
7
  remote: https://rubygems.org/
3
8
  specs:
@@ -15,4 +20,5 @@ PLATFORMS
15
20
  ruby
16
21
 
17
22
  DEPENDENCIES
23
+ config_yml!
18
24
  rspec
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/russian_doll.yml
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.russian_doll[:foo][:bar][:baz] # => { :array => [:red, :green, :blue] }
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
- $:.unshift(File.expand_path("../lib", __FILE__))
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 = `git ls-files`.split("\n")
16
- spec.test_files = `git ls-files -- spec/*`.split("\n")
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,11 @@
1
+ module Configuration
2
+ module Syntax
3
+ module Conf
4
+ def self.method_missing(method, *args)
5
+ Configuration.method_missing(method, args)
6
+ end
7
+ end
8
+ end
9
+ end
10
+
11
+ include Configuration::Syntax
@@ -0,0 +1 @@
1
+ require "configuration/syntax/conf"
@@ -1,3 +1,3 @@
1
1
  module Configuration
2
- VERSION = "0.0.1".freeze
2
+ VERSION = "0.0.2".freeze
3
3
  end
data/lib/configuration.rb CHANGED
@@ -1,5 +1,8 @@
1
1
  require "yaml"
2
2
 
3
+ require "configuration/syntax"
4
+ require "configuration/version"
5
+
3
6
  module Configuration
4
7
  # Returns a hash with configuration for the given class method
5
8
  # called. The configuration is loaded from the file config/+method_called+.yml.
@@ -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
@@ -14,7 +14,6 @@ describe Configuration do
14
14
  let(:file_b) { double }
15
15
 
16
16
  it "loads all config files" do
17
- Configuration.file_a
18
17
  Configuration.files.should be_eql files
19
18
  end
20
19
  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.1
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-27 00:00:00.000000000 Z
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