Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
ed77e84c
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,发现更多精彩内容 >>
提交
ed77e84c
编写于
10月 08, 2009
作者:
C
Carl Lerche
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Ported over more initializers
上级
7faa52a4
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
48 addition
and
54 deletion
+48
-54
railties/lib/rails/application.rb
railties/lib/rails/application.rb
+41
-1
railties/lib/rails/initializer.rb
railties/lib/rails/initializer.rb
+0
-42
railties/test/application/initializer_test.rb
railties/test/application/initializer_test.rb
+7
-0
railties/test/initializer_test.rb
railties/test/initializer_test.rb
+0
-11
未找到文件。
railties/lib/rails/application.rb
浏览文件 @
ed77e84c
...
...
@@ -102,7 +102,47 @@ def new
# Create tmp directories
initializer
:ensure_tmp_directories_exist
do
%w(cache pids sessions sockets)
.
each
do
|
dir_to_make
|
FileUtils
.
mkdir_p
(
File
.
join
(
configuration
.
root_path
,
'tmp'
,
dir_to_make
))
FileUtils
.
mkdir_p
(
File
.
join
(
config
.
root_path
,
'tmp'
,
dir_to_make
))
end
end
# Loads the environment specified by Configuration#environment_path, which
# is typically one of development, test, or production.
initializer
:load_environment
do
silence_warnings
do
next
if
@environment_loaded
next
unless
File
.
file?
(
config
.
environment_path
)
@environment_loaded
=
true
constants
=
self
.
class
.
constants
eval
(
IO
.
read
(
configuration
.
environment_path
),
binding
,
configuration
.
environment_path
)
(
self
.
class
.
constants
-
constants
).
each
do
|
const
|
Object
.
const_set
(
const
,
self
.
class
.
const_get
(
const
))
end
end
end
initializer
:add_gem_load_paths
do
require
'rails/gem_dependency'
Rails
::
GemDependency
.
add_frozen_gem_path
unless
config
.
gems
.
empty?
require
"rubygems"
config
.
gems
.
each
{
|
gem
|
gem
.
add_load_paths
}
end
end
# Preload all frameworks specified by the Configuration#frameworks.
# Used by Passenger to ensure everything's loaded before forking and
# to avoid autoload race conditions in JRuby.
initializer
:preload_frameworks
do
if
config
.
preload_frameworks
config
.
frameworks
.
each
do
|
framework
|
# String#classify and #constantize aren't available yet.
toplevel
=
Object
.
const_get
(
framework
.
to_s
.
gsub
(
/(?:^|_)(.)/
)
{
$1
.
upcase
})
toplevel
.
load_all!
if
toplevel
.
respond_to?
(
:load_all!
)
end
end
end
end
...
...
railties/lib/rails/initializer.rb
浏览文件 @
ed77e84c
...
...
@@ -116,48 +116,6 @@ def self.run(initializer = nil, config = nil)
end
end
# Loads the environment specified by Configuration#environment_path, which
# is typically one of development, test, or production.
Initializer
.
default
.
add
:load_environment
do
silence_warnings
do
next
if
@environment_loaded
next
unless
File
.
file?
(
configuration
.
environment_path
)
@environment_loaded
=
true
config
=
configuration
constants
=
self
.
class
.
constants
eval
(
IO
.
read
(
configuration
.
environment_path
),
binding
,
configuration
.
environment_path
)
(
self
.
class
.
constants
-
constants
).
each
do
|
const
|
Object
.
const_set
(
const
,
self
.
class
.
const_get
(
const
))
end
end
end
Initializer
.
default
.
add
:add_gem_load_paths
do
require
'rails/gem_dependency'
Rails
::
GemDependency
.
add_frozen_gem_path
unless
config
.
gems
.
empty?
require
"rubygems"
config
.
gems
.
each
{
|
gem
|
gem
.
add_load_paths
}
end
end
# Preload all frameworks specified by the Configuration#frameworks.
# Used by Passenger to ensure everything's loaded before forking and
# to avoid autoload race conditions in JRuby.
Initializer
.
default
.
add
:preload_frameworks
do
if
configuration
.
preload_frameworks
configuration
.
frameworks
.
each
do
|
framework
|
# String#classify and #constantize aren't available yet.
toplevel
=
Object
.
const_get
(
framework
.
to_s
.
gsub
(
/(?:^|_)(.)/
)
{
$1
.
upcase
})
toplevel
.
load_all!
if
toplevel
.
respond_to?
(
:load_all!
)
end
end
end
# This initialization routine does nothing unless <tt>:active_record</tt>
# is one of the frameworks to load (Configuration#frameworks). If it is,
# this sets the database configuration from Configuration#database_configuration
...
...
railties/test/application/initializer_test.rb
浏览文件 @
ed77e84c
...
...
@@ -54,5 +54,12 @@ module Zoo::ReptileHouse ; end
assert
Zoo
end
test
"load environment with global"
do
app_file
"config/environments/development.rb"
,
"$initialize_test_set_from_env = 'success'"
assert_nil
$initialize_test_set_from_env
Rails
::
Initializer
.
run
{
}
assert_equal
"success"
,
$initialize_test_set_from_env
end
end
end
\ No newline at end of file
railties/test/initializer_test.rb
浏览文件 @
ed77e84c
...
...
@@ -33,17 +33,6 @@ def initialize(envpath)
end
end
class
Initializer_load_environment_Test
<
Test
::
Unit
::
TestCase
def
test_load_environment_with_constant
config
=
ConfigurationMock
.
new
(
"
#{
File
.
dirname
(
__FILE__
)
}
/fixtures/environment_with_constant.rb"
)
assert_nil
$initialize_test_set_from_env
Rails
::
Initializer
.
run
(
:load_environment
,
config
)
assert_equal
"success"
,
$initialize_test_set_from_env
ensure
$initialize_test_set_from_env
=
nil
end
end
class
Initializer_after_initialize_with_blocks_environment_Test
<
Test
::
Unit
::
TestCase
def
setup
config
=
ConfigurationMock
.
new
(
""
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录