a9n 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -14,13 +14,31 @@ And then execute:
14
14
 
15
15
  $ bundle
16
16
 
17
- Add `configuration.yml.example` and/or `configuration.yml` file into the config directory.
18
- When none fo these files exists, `A9n::MissingConfigurationFile` exception is thrown.
19
- If both file exists, their content is validated and all keys existing in example file must exist in base file.
17
+ Add `configuration.yml.example` and/or `configuration.yml` file into the config
18
+ directory. When none fo these files exists, `A9n::MissingConfigurationFile`
19
+ exception is thrown.
20
+ If both file exist, content of `configuration.yml` is validated. It means that
21
+ all keys existing in example file must exist in base file - in case of missing
22
+ keys`A9n::MissingConfigurationVariables` is thrown with information about
23
+ missing keys.
24
+
25
+ Load configuration by adding to your `application.rb` or `environment.rb` right
26
+ after budler requires:
27
+
28
+ A9n.load
29
+
30
+ This step is not required, but recommended, as it configuration is loaded and
31
+ verified on evironment load.
32
+
33
+ It works with `Rails` by default. If you want to use `A9n` with non-rails app
34
+ you need to tell it A9n:
35
+
36
+ A9n.local_app = MyApp
20
37
 
21
38
  ## Usage
22
39
 
23
- You can access any variable defined in configuration files but delegating it to A9n. E.g:
40
+ You can access any variable defined in configuration files but delegating it to
41
+ `A9n`. E.g:
24
42
 
25
43
  production:
26
44
  app_host: 'http://knapo.net'
data/lib/a9n.rb CHANGED
@@ -59,6 +59,10 @@ module A9n
59
59
  nil
60
60
  end
61
61
 
62
+ def fetch(*args)
63
+ config.fetch(*args)
64
+ end
65
+
62
66
  def method_missing(name, *args)
63
67
  config.send(name, *args)
64
68
  end
data/lib/a9n/struct.rb CHANGED
@@ -5,6 +5,10 @@ module A9n
5
5
  def keys
6
6
  @table.keys
7
7
  end
8
+
9
+ def fetch(name, default = nil)
10
+ @table[name.to_sym] || default
11
+ end
8
12
 
9
13
  def method_missing(name, *args)
10
14
  unless @table.key?(name.to_sym)
data/lib/a9n/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module A9n
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
data/spec/a9n_spec.rb CHANGED
@@ -3,6 +3,9 @@ require 'spec_helper'
3
3
  describe A9n do
4
4
  describe '.local_app' do
5
5
  context 'when rails not found' do
6
+ before {
7
+ described_class.should_receive(:get_rails).and_return(nil)
8
+ }
6
9
  specify {
7
10
  described_class.local_app.should be_nil
8
11
  }
data/spec/struct_spec.rb CHANGED
@@ -36,4 +36,14 @@ describe A9n::Struct do
36
36
  subject.non_existing_dwarf
37
37
  }.to raise_error(A9n::NoSuchConfigurationVariable)
38
38
  end
39
+
40
+ describe '#fetch' do
41
+ it 'return non empty value' do
42
+ subject.fetch(:non_empty_dwarf).should == 'dwarf'
43
+ end
44
+
45
+ it 'not returns nil for non existing value' do
46
+ subject.fetch(:non_existing_dwarf).should == nil
47
+ end
48
+ end
39
49
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: a9n
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
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-12-08 00:00:00.000000000 Z
12
+ date: 2012-12-12 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Simple tool for managing app configuration
15
15
  email: