Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
1a50d2e6
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,发现更多精彩内容 >>
提交
1a50d2e6
编写于
1月 19, 2010
作者:
Y
Yehuda Katz
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Stop overriding LoadError.new to return a MissingSourceError (and sometimes nil!)
上级
5ebfa624
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
36 addition
and
33 deletion
+36
-33
actionpack/lib/action_controller/metal/helpers.rb
actionpack/lib/action_controller/metal/helpers.rb
+1
-1
actionpack/test/controller/new_base/base_test.rb
actionpack/test/controller/new_base/base_test.rb
+1
-1
activemodel/lib/active_model/lint.rb
activemodel/lib/active_model/lint.rb
+2
-0
activesupport/lib/active_support/core_ext/load_error.rb
activesupport/lib/active_support/core_ext/load_error.rb
+16
-30
activesupport/lib/active_support/dependencies.rb
activesupport/lib/active_support/dependencies.rb
+1
-1
activesupport/test/core_ext/load_error_test.rb
activesupport/test/core_ext/load_error_test.rb
+15
-0
未找到文件。
actionpack/lib/action_controller/metal/helpers.rb
浏览文件 @
1a50d2e6
...
...
@@ -100,7 +100,7 @@ def default_helper_module!
module_path
=
module_name
.
underscore
helper
module_path
rescue
MissingSourceFile
=>
e
raise
e
unless
e
.
is_missing?
"
#{
module_path
}
_helper"
raise
e
unless
e
.
is_missing?
"
helpers/
#{
module_path
}
_helper"
rescue
NameError
=>
e
raise
e
unless
e
.
missing_name?
"
#{
module_name
}
Helper"
end
...
...
actionpack/test/controller/new_base/base_test.rb
浏览文件 @
1a50d2e6
...
...
@@ -22,7 +22,7 @@ def modify_response_headers
end
def
show_actions
render
:text
=>
"actions:
#{
action_methods
.
to_a
.
join
(
', '
)
}
"
render
:text
=>
"actions:
#{
action_methods
.
to_a
.
sort
.
join
(
', '
)
}
"
end
protected
...
...
activemodel/lib/active_model/lint.rb
浏览文件 @
1a50d2e6
...
...
@@ -53,6 +53,8 @@ def test_model_naming
assert_kind_of
String
,
model_name
assert_kind_of
String
,
model_name
.
human
assert_kind_of
String
,
model_name
.
partial_path
assert_kind_of
String
,
model_name
.
singular
assert_kind_of
String
,
model_name
.
plural
end
# errors
...
...
activesupport/lib/active_support/core_ext/load_error.rb
浏览文件 @
1a50d2e6
class
MissingSourceFile
<
LoadError
#:nodoc:
attr_reader
:path
def
initialize
(
message
,
path
)
super
(
message
)
@path
=
path
end
def
is_missing?
(
path
)
path
.
gsub
(
/\.rb$/
,
''
)
==
self
.
path
.
gsub
(
/\.rb$/
,
''
)
end
class
LoadError
REGEXPS
=
[
/^no such file to load -- (.+)$/i
,
/^Missing \w+ (?:file\s*)?([^\s]+.rb)$/i
,
/^Missing API definition file in (.+)$/i
,
]
def
self
.
from_message
(
message
)
REGEXPS
.
each
do
|
regexp
,
capture
|
match
=
regexp
.
match
(
message
)
return
MissingSourceFile
.
new
(
message
,
match
[
capture
])
unless
match
.
nil?
def
path
@path
||=
begin
REGEXPS
.
find
do
|
regex
|
message
=~
regex
end
$1
end
nil
end
REGEXPS
=
[
[
/^no such file to load -- (.+)$/i
,
1
],
[
/^Missing \w+ (file\s*)?([^\s]+.rb)$/i
,
2
],
[
/^Missing API definition file in (.+)$/i
,
1
],
[
/win32/
,
0
]
]
unless
defined?
(
REGEXPS
)
end
class
LoadError
def
self
.
new
(
*
args
)
if
self
==
LoadError
MissingSourceFile
.
from_message
(
args
.
first
)
else
super
end
def
is_missing?
(
location
)
location
.
sub
(
/\.rb$/
,
''
)
==
path
.
sub
(
/\.rb$/
,
''
)
end
end
MissingSourceFile
=
LoadError
\ No newline at end of file
activesupport/lib/active_support/dependencies.rb
浏览文件 @
1a50d2e6
...
...
@@ -236,7 +236,7 @@ def depend_on(file_name, swallow_load_errors = false, message = "No such file to
rescue
LoadError
=>
load_error
unless
swallow_load_errors
if
file_name
=
load_error
.
message
[
/ -- (.*?)(\.rb)?$/
,
1
]
raise
MissingSourceFile
.
new
(
message
%
file_name
,
load_error
.
path
).
copy_blame!
(
load_error
)
raise
LoadError
.
new
(
message
%
file_name
).
copy_blame!
(
load_error
)
end
raise
end
...
...
activesupport/test/core_ext/load_error_test.rb
浏览文件 @
1a50d2e6
...
...
@@ -15,3 +15,18 @@ def test_path
end
end
end
class
TestLoadError
<
Test
::
Unit
::
TestCase
def
test_with_require
assert_raise
(
LoadError
)
{
require
'no_this_file_don\'t_exist'
}
end
def
test_with_load
assert_raise
(
LoadError
)
{
load
'nor_does_this_one'
}
end
def
test_path
begin
load
'nor/this/one.rb'
rescue
LoadError
=>
e
assert_equal
'nor/this/one.rb'
,
e
.
path
end
end
end
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录