app_config 0.3.1 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README +13 -12
- data/lib/app_config.rb +1 -1
- data/lib/app_config/base.rb +9 -6
- metadata +2 -2
data/README
CHANGED
@@ -9,7 +9,9 @@ An easy to use, customizable library to easily store and retrieve application
|
|
9
9
|
Usage is simple. Just pass either a hash of options, or a block, to
|
10
10
|
AppConfig.setup. See AppConfig::Base for a list of valid storage methods.
|
11
11
|
|
12
|
-
|
12
|
+
== AppConfig::Storage::YAML
|
13
|
+
|
14
|
+
Given this YAML file:
|
13
15
|
|
14
16
|
---
|
15
17
|
admin_email: 'admin@example.com'
|
@@ -33,7 +35,7 @@ Use it like so:
|
|
33
35
|
AppConfig[:api_name] # => 'Supr Webz 2.0'
|
34
36
|
AppConfig[:api_key] # => 'SUPERAWESOMESERVICE'
|
35
37
|
|
36
|
-
|
38
|
+
== AppConfig::Storage::Sqlite
|
37
39
|
|
38
40
|
AppConfig.setup do |config|
|
39
41
|
config[:storage_method] = :sqlite
|
@@ -47,25 +49,24 @@ Want SQLite3? No problem!
|
|
47
49
|
AppConfig[:column] # => 'value'
|
48
50
|
|
49
51
|
|
50
|
-
==
|
52
|
+
== Environment Mode
|
51
53
|
|
52
|
-
As of version 0.
|
54
|
+
As of version 0.4.0, there's an 'environment mode' where you can organize
|
53
55
|
the config file sort of like Rails' database config.
|
54
56
|
|
55
|
-
|
56
|
-
|
57
|
+
# config/app_config.yml
|
57
58
|
development:
|
58
|
-
|
59
|
+
title: 'Development Mode'
|
59
60
|
|
60
61
|
production:
|
61
|
-
|
62
|
+
title: 'Production Mode'
|
62
63
|
|
63
|
-
Then set the <tt>:
|
64
|
+
Then set the <tt>:env</tt> option to your desired environment.
|
64
65
|
|
65
66
|
AppConfig.setup do |config|
|
66
|
-
config[:
|
67
|
+
config[:env] = Rails.env # or any string.
|
67
68
|
config[:uri] = 'yaml://path/to/app_config.yml'
|
68
69
|
end
|
69
70
|
|
70
|
-
#
|
71
|
-
AppConfig[:
|
71
|
+
# Uses the given environment section of the config.
|
72
|
+
AppConfig[:title] = 'Production Mode'
|
data/lib/app_config.rb
CHANGED
data/lib/app_config/base.rb
CHANGED
@@ -25,13 +25,20 @@ module AppConfig
|
|
25
25
|
@storage = initialize_storage
|
26
26
|
end
|
27
27
|
|
28
|
-
# Access the <tt>key</tt>'s value in
|
28
|
+
# Access the <tt>key</tt>'s value in storage.
|
29
29
|
def [](key)
|
30
30
|
storage[key]
|
31
31
|
end
|
32
32
|
|
33
|
+
def environment
|
34
|
+
(@options[:environment] || @options[:env]) || nil
|
35
|
+
end
|
36
|
+
alias_method :env, :environment
|
37
|
+
|
38
|
+
# Returns the <tt>@storage</tt> contents, which is what is exposed
|
39
|
+
# as the configuration.
|
33
40
|
def storage
|
34
|
-
|
41
|
+
environment ? @storage[environment] : @storage
|
35
42
|
end
|
36
43
|
|
37
44
|
def to_hash
|
@@ -66,9 +73,5 @@ module AppConfig
|
|
66
73
|
end
|
67
74
|
end
|
68
75
|
|
69
|
-
def rails_enabled?
|
70
|
-
@options[:rails] || false
|
71
|
-
end
|
72
|
-
|
73
76
|
end # Base
|
74
77
|
end # AppConfig
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: app_config
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dale Campbell
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-10-
|
12
|
+
date: 2009-10-02 00:00:00 -05:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|