Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
c787bfdf
R
rails
项目概览
张重言
/
rails
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rails
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
c787bfdf
编写于
6月 23, 2010
作者:
P
Piotr Sarnacki
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Engine can now load its own plugins
上级
ad6be087
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
62 addition
and
16 deletion
+62
-16
railties/lib/rails/application/configuration.rb
railties/lib/rails/application/configuration.rb
+1
-3
railties/lib/rails/application/railties.rb
railties/lib/rails/application/railties.rb
+12
-12
railties/lib/rails/engine.rb
railties/lib/rails/engine.rb
+5
-0
railties/lib/rails/engine/configuration.rb
railties/lib/rails/engine/configuration.rb
+3
-1
railties/lib/rails/engine/railties.rb
railties/lib/rails/engine/railties.rb
+23
-0
railties/test/railties/engine_test.rb
railties/test/railties/engine_test.rb
+18
-0
未找到文件。
railties/lib/rails/application/configuration.rb
浏览文件 @
c787bfdf
...
...
@@ -10,7 +10,7 @@ class Configuration < ::Rails::Engine::Configuration
attr_accessor
:allow_concurrency
,
:cache_classes
,
:cache_store
,
:encoding
,
:consider_all_requests_local
,
:dependency_loading
,
:filter_parameters
,
:log_level
,
:logger
,
:p
lugins
,
:p
reload_frameworks
,
:reload_plugins
,
:preload_frameworks
,
:reload_plugins
,
:secret_token
,
:serve_static_assets
,
:session_options
,
:time_zone
,
:whiny_nils
...
...
@@ -53,8 +53,6 @@ def paths
paths
.
log
"log/
#{
Rails
.
env
}
.log"
paths
.
tmp
"tmp"
paths
.
tmp
.
cache
"tmp/cache"
paths
.
vendor
"vendor"
,
:load_path
=>
true
paths
.
vendor
.
plugins
"vendor/plugins"
if
File
.
exists?
(
"
#{
root
}
/test/mocks/
#{
Rails
.
env
}
"
)
ActiveSupport
::
Deprecation
.
warn
"
\"
Rails.root/test/mocks/
#{
Rails
.
env
}
\"
won't be added "
<<
...
...
railties/lib/rails/application/railties.rb
浏览文件 @
c787bfdf
module
Rails
class
Application
class
Railties
# TODO Write tests for this behavior extracted from Application
def
initialize
(
config
)
@config
=
config
end
require
'rails/engine/railties'
module
Rails
class
Application
<
Engine
class
Railties
<
Rails
::
Engine
::
Railties
def
all
(
&
block
)
@all
||=
railties
+
engines
+
plugins
@all
||=
railties
+
engines
+
super
@all
.
each
(
&
block
)
if
block
@all
end
...
...
@@ -21,10 +18,13 @@ def engines
end
def
plugins
@plugins
||=
begin
plugin_names
=
(
@config
.
plugins
||
[
:all
]).
map
{
|
p
|
p
.
to_sym
}
Plugin
.
all
(
plugin_names
,
@config
.
paths
.
vendor
.
plugins
)
end
@plugins
||=
super
+
plugins_for_engines
end
def
plugins_for_engines
engines
.
map
{
|
e
|
e
.
railties
.
plugins
}.
flatten
end
end
end
...
...
railties/lib/rails/engine.rb
浏览文件 @
c787bfdf
...
...
@@ -2,6 +2,7 @@
require
'active_support/core_ext/module/delegation'
require
'pathname'
require
'rbconfig'
require
'rails/engine/railties'
module
Rails
# Rails::Engine allows you to wrap a specific Rails application and share it accross
...
...
@@ -140,6 +141,10 @@ def eager_load!
end
end
def
railties
@railties
||=
Railties
.
new
(
config
)
end
def
app
raise
"You can't use Engine as rack application without providing valid rack endpoint"
unless
endpoint
@app
||=
config
.
middleware
.
build
(
endpoint
)
...
...
railties/lib/rails/engine/configuration.rb
浏览文件 @
c787bfdf
...
...
@@ -5,7 +5,7 @@ class Engine
class
Configuration
<
::
Rails
::
Railtie
::
Configuration
attr_reader
:root
attr_writer
:eager_load_paths
,
:autoload_once_paths
,
:autoload_paths
attr_accessor
:middleware
attr_accessor
:middleware
,
:plugins
def
initialize
(
root
=
nil
)
super
()
...
...
@@ -31,6 +31,8 @@ def paths
paths
.
public
"public"
paths
.
public
.
javascripts
"public/javascripts"
paths
.
public
.
stylesheets
"public/stylesheets"
paths
.
vendor
"vendor"
,
:load_path
=>
true
paths
.
vendor
.
plugins
"vendor/plugins"
paths
end
end
...
...
railties/lib/rails/engine/railties.rb
0 → 100644
浏览文件 @
c787bfdf
module
Rails
class
Engine
<
Railtie
class
Railties
# TODO Write tests for this behavior extracted from Application
def
initialize
(
config
)
@config
=
config
end
def
all
(
&
block
)
@all
||=
plugins
@all
.
each
(
&
block
)
if
block
@all
end
def
plugins
@plugins
||=
begin
plugin_names
=
(
@config
.
plugins
||
[
:all
]).
map
{
|
p
|
p
.
to_sym
}
Plugin
.
all
(
plugin_names
,
@config
.
paths
.
vendor
.
plugins
)
end
end
end
end
end
railties/test/railties/engine_test.rb
浏览文件 @
c787bfdf
...
...
@@ -85,5 +85,23 @@ class Engine < ::Rails::Engine
assert_equal
"HELLO WORLD"
,
response
[
2
]
end
test
"engine can load its own plugins"
do
@plugin
.
write
"lib/bukkits.rb"
,
<<-
RUBY
class Bukkits
class Engine < ::Rails::Engine
config.paths.vendor.plugins = "
#{
File
.
join
(
@plugin
.
path
,
"lib/bukkits/plugins"
)
}
"
end
end
RUBY
@plugin
.
write
"lib/bukkits/plugins/yaffle/init.rb"
,
<<-
RUBY
Bukkits::Engine.config.yaffle_loaded = true
RUBY
boot_rails
assert
Bukkits
::
Engine
.
config
.
yaffle_loaded
end
end
end
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录