a9n 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +9 -4
- data/lib/a9n.rb +13 -6
- data/lib/a9n/{store.rb → struct.rb} +5 -1
- data/lib/a9n/version.rb +1 -1
- data/spec/a9n_spec.rb +4 -5
- data/spec/spec_helper.rb +2 -1
- data/spec/{store_spec.rb → struct_spec.rb} +1 -1
- metadata +5 -5
data/README.md
CHANGED
@@ -14,13 +14,18 @@ And then execute:
|
|
14
14
|
|
15
15
|
$ bundle
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
A9n.load
|
17
|
+
Add `configuration.yml.example` and/or `configuration.yml` file to config directory.
|
20
18
|
|
21
19
|
## Usage
|
22
20
|
|
23
|
-
|
21
|
+
You can access any variable defined in `configuration.yml` file but delegating it to A9n. E.g:
|
22
|
+
|
23
|
+
production:
|
24
|
+
app_host: 'http://knapo.net'
|
25
|
+
|
26
|
+
is accessible by
|
27
|
+
|
28
|
+
A9n.app_host
|
24
29
|
|
25
30
|
## Contributing
|
26
31
|
|
data/lib/a9n.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
require 'a9n/version'
|
2
|
-
require 'a9n/
|
2
|
+
require 'a9n/struct'
|
3
3
|
|
4
4
|
module A9n
|
5
5
|
class ConfigurationNotLoaded < StandardError; end
|
@@ -10,10 +10,8 @@ module A9n
|
|
10
10
|
|
11
11
|
class << self
|
12
12
|
|
13
|
-
def
|
14
|
-
@@configuration
|
15
|
-
rescue NameError
|
16
|
-
raise ConfigurationNotLoaded.new("Configuration does not seem to be loaded. Plase call `A9n.load`.")
|
13
|
+
def config
|
14
|
+
@@configuration ||= load
|
17
15
|
end
|
18
16
|
|
19
17
|
def env
|
@@ -40,7 +38,7 @@ module A9n
|
|
40
38
|
verify!(base, local)
|
41
39
|
end
|
42
40
|
|
43
|
-
@@configuration =
|
41
|
+
@@configuration = Struct.new(local || base)
|
44
42
|
end
|
45
43
|
|
46
44
|
def load_yml(file)
|
@@ -55,6 +53,15 @@ module A9n
|
|
55
53
|
end
|
56
54
|
end
|
57
55
|
|
56
|
+
# Fixes rspec issue
|
57
|
+
def to_ary
|
58
|
+
nil
|
59
|
+
end
|
60
|
+
|
61
|
+
def method_missing(name, *args)
|
62
|
+
config.send(name, *args)
|
63
|
+
end
|
64
|
+
|
58
65
|
private
|
59
66
|
|
60
67
|
def verify!(base, local)
|
data/lib/a9n/version.rb
CHANGED
data/spec/a9n_spec.rb
CHANGED
@@ -27,7 +27,7 @@ describe A9n do
|
|
27
27
|
let(:local_sample_config){
|
28
28
|
{ :app_host => '127.0.0.1:3000' }
|
29
29
|
}
|
30
|
-
subject { described_class
|
30
|
+
subject { described_class }
|
31
31
|
|
32
32
|
context 'when no configuration file exists' do
|
33
33
|
before do
|
@@ -49,7 +49,7 @@ describe A9n do
|
|
49
49
|
described_class.should_receive(:verify!).never
|
50
50
|
described_class.load
|
51
51
|
end
|
52
|
-
|
52
|
+
|
53
53
|
its(:app_url) { should_not be_nil }
|
54
54
|
specify {
|
55
55
|
expect { subject.app_host }.to raise_error(described_class::NoSuchConfigurationVariable)
|
@@ -63,8 +63,7 @@ describe A9n do
|
|
63
63
|
described_class.should_receive(:verify!).never
|
64
64
|
described_class.load
|
65
65
|
end
|
66
|
-
|
67
|
-
it { should_not be_nil }
|
66
|
+
|
68
67
|
its(:app_host) { should_not be_nil }
|
69
68
|
specify {
|
70
69
|
expect { subject.app_url }.to raise_error(described_class::NoSuchConfigurationVariable)
|
@@ -78,7 +77,7 @@ describe A9n do
|
|
78
77
|
described_class.should_receive(:load_yml).with('config/configuration.yml').and_return(base_sample_config)
|
79
78
|
described_class.load
|
80
79
|
end
|
81
|
-
|
80
|
+
|
82
81
|
its(:app_url) { should_not be_nil }
|
83
82
|
specify {
|
84
83
|
expect { subject.app_host }.to raise_error(described_class::NoSuchConfigurationVariable)
|
data/spec/spec_helper.rb
CHANGED
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.
|
4
|
+
version: 0.0.4
|
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-
|
12
|
+
date: 2012-12-07 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Simple tool for managing app configuration
|
15
15
|
email:
|
@@ -26,12 +26,12 @@ files:
|
|
26
26
|
- Rakefile
|
27
27
|
- a9n.gemspec
|
28
28
|
- lib/a9n.rb
|
29
|
-
- lib/a9n/
|
29
|
+
- lib/a9n/struct.rb
|
30
30
|
- lib/a9n/version.rb
|
31
31
|
- spec/a9n_spec.rb
|
32
32
|
- spec/fixtures/configuration.yml
|
33
33
|
- spec/spec_helper.rb
|
34
|
-
- spec/
|
34
|
+
- spec/struct_spec.rb
|
35
35
|
homepage: https://github.com/knapo/a9n
|
36
36
|
licenses: []
|
37
37
|
post_install_message:
|
@@ -60,4 +60,4 @@ test_files:
|
|
60
60
|
- spec/a9n_spec.rb
|
61
61
|
- spec/fixtures/configuration.yml
|
62
62
|
- spec/spec_helper.rb
|
63
|
-
- spec/
|
63
|
+
- spec/struct_spec.rb
|