scotch-app_config 1.3 → 1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.rdoc +48 -29
- data/app_config.gemspec +2 -2
- data/rails/init.rb +4 -4
- metadata +2 -2
data/README.rdoc
CHANGED
|
@@ -1,56 +1,75 @@
|
|
|
1
|
-
|
|
1
|
+
Conf## Summary
|
|
2
|
+
|
|
2
3
|
Application level configuration.
|
|
3
4
|
|
|
4
|
-
|
|
5
|
+
## Author
|
|
6
|
+
|
|
5
7
|
Christopher J. Bottaro
|
|
6
8
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
9
|
+
### Accessing the Conf object
|
|
10
|
+
|
|
11
|
+
After installing this plugin, the Conf object will be global available. Entries are accessed via object member notation:
|
|
12
|
+
|
|
13
|
+
Conf.my_config_entry
|
|
14
|
+
|
|
10
15
|
Nested entries are supported:
|
|
11
|
-
AppConfig.my_section.some_entry
|
|
12
16
|
|
|
13
|
-
|
|
17
|
+
Conf.my_section.some_entry
|
|
18
|
+
|
|
19
|
+
### Common config file
|
|
20
|
+
|
|
14
21
|
Config entries defined in
|
|
15
|
-
|
|
22
|
+
|
|
23
|
+
RAILS_ROOT/config/app_config.yml
|
|
24
|
+
|
|
16
25
|
will be available to all environments.
|
|
17
26
|
|
|
18
|
-
|
|
27
|
+
### Environment specific config files
|
|
28
|
+
|
|
19
29
|
You can have environment specific config files. Environment specific config entries take precedence over common config entries.
|
|
30
|
+
Example development environment config f=ile:
|
|
20
31
|
|
|
21
|
-
|
|
22
|
-
RAILS_ROOT/config/environments/development.yml
|
|
32
|
+
RAILS_ROOT/config/environments/development.yml
|
|
23
33
|
|
|
24
34
|
Example production environment config file:
|
|
25
|
-
RAILS_ROOT/config/environments/production.yml
|
|
26
35
|
|
|
27
|
-
|
|
28
|
-
|
|
36
|
+
RAILS_ROOT/config/environments/production.yml
|
|
37
|
+
|
|
38
|
+
### Embedded Ruby (ERB)
|
|
39
|
+
|
|
40
|
+
Embedded Ruby is allowed in the configuration files. See examples below.
|
|
41
|
+
|
|
42
|
+
### Examples
|
|
29
43
|
|
|
30
|
-
=== Examples
|
|
31
44
|
Consider the two following config files.
|
|
32
45
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
46
|
+
RAILS\_ROOT/config/app\_config.yml:
|
|
47
|
+
|
|
48
|
+
size: 1
|
|
49
|
+
server: google.com
|
|
36
50
|
|
|
37
51
|
RAILS_ROOT/config/environments/development.yml:
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
52
|
+
|
|
53
|
+
size: 2
|
|
54
|
+
computed: <%= 1 + 2 + 3 %>
|
|
55
|
+
section:
|
|
56
|
+
size: 3
|
|
57
|
+
servers: [ {name: yahoo.com}, {name: amazon.com} ]
|
|
43
58
|
|
|
44
59
|
Notice that the environment specific config entries overwrite the common entries.
|
|
45
|
-
|
|
46
|
-
|
|
60
|
+
|
|
61
|
+
Conf.size -> 2
|
|
62
|
+
Conf.server -> google.com
|
|
47
63
|
|
|
48
64
|
Notice the embedded Ruby.
|
|
49
|
-
|
|
65
|
+
|
|
66
|
+
Conf.computed -> 6
|
|
50
67
|
|
|
51
68
|
Notice that object member notation is maintained even in nested entries.
|
|
52
|
-
|
|
69
|
+
|
|
70
|
+
Conf.section.size -> 3
|
|
53
71
|
|
|
54
72
|
Notice array notation and object member notation is maintained.
|
|
55
|
-
|
|
56
|
-
|
|
73
|
+
|
|
74
|
+
Conf.section.servers[0].name -> yahoo.com
|
|
75
|
+
Conf.section.servers[1].name -> amazon.com
|
data/app_config.gemspec
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Gem::Specification.new do |s|
|
|
2
2
|
s.name = 'app_config'
|
|
3
|
-
s.version = '1.
|
|
4
|
-
s.date = '2008-09-
|
|
3
|
+
s.version = '1.4'
|
|
4
|
+
s.date = '2008-09-03'
|
|
5
5
|
|
|
6
6
|
s.summary = "Application level configuration"
|
|
7
7
|
s.description = "Allow application wide configuration settings via YML files"
|
data/rails/init.rb
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
require 'app_config'
|
|
2
2
|
|
|
3
|
-
::
|
|
3
|
+
::Conf = ApplicationConfig.load_files(RAILS_ROOT+"/config/app_config.yml",
|
|
4
4
|
RAILS_ROOT+"/config/environments/#{RAILS_ENV}.yml")
|
|
5
5
|
|
|
6
|
-
def
|
|
7
|
-
|
|
8
|
-
return
|
|
6
|
+
def Conf.reload!
|
|
7
|
+
Conf.marshal_load(ApplicationConfig.reload.marshal_dump)
|
|
8
|
+
return Conf
|
|
9
9
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: scotch-app_config
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: "1.
|
|
4
|
+
version: "1.4"
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- RailsJedi
|
|
@@ -10,7 +10,7 @@ autorequire:
|
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
12
|
|
|
13
|
-
date: 2008-09-
|
|
13
|
+
date: 2008-09-03 00:00:00 -07:00
|
|
14
14
|
default_executable:
|
|
15
15
|
dependencies:
|
|
16
16
|
- !ruby/object:Gem::Dependency
|