merb_app_config 1.0.2 → 1.0.3
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 +11 -0
- data/Rakefile +1 -1
- data/lib/application_config/view_helpers.rb +11 -1
- data/lib/merb_app_config.rb +11 -7
- metadata +2 -2
data/README
CHANGED
@@ -8,6 +8,17 @@ Modified from Original Project (AppConfig by Christopher J. Bottaro)
|
|
8
8
|
=== Compatibility
|
9
9
|
Rails 2.1/2.2 and Merb 1.0
|
10
10
|
|
11
|
+
=== Installing on Merb
|
12
|
+
add this to your config: dependencies.rb and run thor merb:gem:install
|
13
|
+
|
14
|
+
dependency "merb_app_config"
|
15
|
+
|
16
|
+
|
17
|
+
=== Installing on Rails
|
18
|
+
|
19
|
+
script/plugin install git://github.com/merbjedi/app_config.git
|
20
|
+
|
21
|
+
|
11
22
|
=== Accessing the AppConfig object
|
12
23
|
After installing this plugin, the AppConfig object will be global available. Entries are accessed via object member notation:
|
13
24
|
AppConfig.my_config_entry
|
data/Rakefile
CHANGED
@@ -2,6 +2,7 @@ module ApplicationConfig
|
|
2
2
|
module ViewHelpers
|
3
3
|
def javascripts_from_config(options = {})
|
4
4
|
html = ""
|
5
|
+
only = [options.delete(:only)].flatten.compact
|
5
6
|
if defined?(AppConfig) and AppConfig.javascripts
|
6
7
|
AppConfig.javascripts.each do |javascript|
|
7
8
|
if javascript.is_a?(OpenStruct)
|
@@ -10,6 +11,8 @@ module ApplicationConfig
|
|
10
11
|
|
11
12
|
if javascript.is_a? Hash
|
12
13
|
javascript.each do |key, val|
|
14
|
+
next unless only.empty? || only.include?(key)
|
15
|
+
|
13
16
|
args = [val].flatten
|
14
17
|
args = args.map{|s| s.gsub("javascripts/", AppConfig.javascript_path)} if AppConfig.javascript_path
|
15
18
|
if defined?(Merb)
|
@@ -38,6 +41,7 @@ module ApplicationConfig
|
|
38
41
|
|
39
42
|
def stylesheets_from_config(options = {})
|
40
43
|
html = ""
|
44
|
+
only = [options.delete(:only)].flatten.compact
|
41
45
|
if defined?(AppConfig) and AppConfig.stylesheets
|
42
46
|
AppConfig.stylesheets.each do |stylesheet|
|
43
47
|
if stylesheet.is_a?(OpenStruct)
|
@@ -46,6 +50,8 @@ module ApplicationConfig
|
|
46
50
|
|
47
51
|
if stylesheet.is_a? Hash
|
48
52
|
stylesheet.each do |key, val|
|
53
|
+
next unless only.empty? || only.include?(key)
|
54
|
+
|
49
55
|
args = [val].flatten
|
50
56
|
args = args.map{|s| s.gsub("stylesheets/", AppConfig.stylesheet_path)} if AppConfig.stylesheet_path
|
51
57
|
if defined?(Merb)
|
@@ -60,7 +66,11 @@ module ApplicationConfig
|
|
60
66
|
args = [stylesheet].flatten
|
61
67
|
args = args.map{|s| s.gsub("stylesheets/", AppConfig.stylesheet_path)} if AppConfig.stylesheet_path
|
62
68
|
args << options
|
63
|
-
|
69
|
+
if defined?(Merb)
|
70
|
+
html << css_include_tag(*args)
|
71
|
+
elsif defined?(Rails)
|
72
|
+
html << stylesheet_link_tag(*args)
|
73
|
+
end
|
64
74
|
end
|
65
75
|
html << "\n"
|
66
76
|
end
|
data/lib/merb_app_config.rb
CHANGED
@@ -5,7 +5,7 @@ require 'application_config/view_helpers'
|
|
5
5
|
if defined?(Merb::Plugins)
|
6
6
|
# Merb gives you a Merb::Plugins.config hash...feel free to put your stuff in your piece of it
|
7
7
|
Merb::Plugins.config[:app_config] = {
|
8
|
-
:auto_reload =>
|
8
|
+
:auto_reload => Merb.env?(:development),
|
9
9
|
:view_helpers => true,
|
10
10
|
:paths => [
|
11
11
|
"#{Merb.root}/config/app_config.yml",
|
@@ -32,16 +32,20 @@ if defined?(Merb::Plugins)
|
|
32
32
|
if Merb::Plugins.config[:app_config][:view_helpers]
|
33
33
|
Merb::Controller.send(:include, ApplicationConfig::ViewHelpers)
|
34
34
|
end
|
35
|
-
|
36
|
-
|
37
|
-
Merb::BootLoader.after_app_loads do
|
35
|
+
|
38
36
|
if Merb::Plugins.config[:app_config][:auto_reload]
|
39
|
-
Merb.logger.info "[AppConfig] Auto reloading AppConfig on
|
37
|
+
Merb.logger.info "[AppConfig] Auto reloading AppConfig on every request."
|
40
38
|
Merb.logger.info "[AppConfig] Set via Merb::Plugins.config[:app_config][:auto_reload]"
|
41
|
-
|
42
|
-
|
39
|
+
|
40
|
+
# add before filter
|
41
|
+
::Merb::Controller.before do
|
42
|
+
AppConfig.reload!
|
43
|
+
end
|
43
44
|
end
|
44
45
|
end
|
45
46
|
|
47
|
+
Merb::BootLoader.after_app_loads do
|
48
|
+
end
|
49
|
+
|
46
50
|
Merb::Plugins.add_rakefiles "merbtasks"
|
47
51
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: merb_app_config
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jacques Crocker
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date:
|
12
|
+
date: 2009-03-31 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|