Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
915f108d
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,体验更适合开发者的 AI 搜索 >>
提交
915f108d
编写于
6月 26, 2009
作者:
J
José Valim
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'master' of
git://github.com/rails/rails
上级
aee63a12
b5dfdc71
变更
24
展开全部
隐藏空白更改
内联
并排
Showing
24 changed file
with
218 addition
and
82 deletion
+218
-82
actionpack/lib/action_controller/base/streaming.rb
actionpack/lib/action_controller/base/streaming.rb
+1
-1
actionpack/lib/action_controller/testing/performance_test.rb
actionpack/lib/action_controller/testing/performance_test.rb
+0
-0
actionpack/lib/action_view/helpers/asset_tag_helper.rb
actionpack/lib/action_view/helpers/asset_tag_helper.rb
+28
-4
actionpack/lib/action_view/render/partials.rb
actionpack/lib/action_view/render/partials.rb
+0
-26
actionpack/lib/action_view/template/handlers/builder.rb
actionpack/lib/action_view/template/handlers/builder.rb
+1
-2
actionpack/lib/action_view/template/handlers/erb.rb
actionpack/lib/action_view/template/handlers/erb.rb
+2
-1
actionpack/test/controller/render_test.rb
actionpack/test/controller/render_test.rb
+0
-7
actionpack/test/controller/send_file_test.rb
actionpack/test/controller/send_file_test.rb
+1
-1
actionpack/test/fixtures/public/.gitignore
actionpack/test/fixtures/public/.gitignore
+1
-0
actionpack/test/fixtures/public/elsewhere/cools.js
actionpack/test/fixtures/public/elsewhere/cools.js
+1
-0
actionpack/test/fixtures/public/elsewhere/file.css
actionpack/test/fixtures/public/elsewhere/file.css
+1
-0
actionpack/test/fixtures/public/javascripts/common.javascript
...onpack/test/fixtures/public/javascripts/common.javascript
+1
-0
actionpack/test/fixtures/public/stylesheets/random.styles
actionpack/test/fixtures/public/stylesheets/random.styles
+1
-0
actionpack/test/template/asset_tag_helper_test.rb
actionpack/test/template/asset_tag_helper_test.rb
+88
-30
activerecord/lib/active_record/base.rb
activerecord/lib/active_record/base.rb
+19
-0
activerecord/lib/active_record/connection_adapters/abstract_adapter.rb
...lib/active_record/connection_adapters/abstract_adapter.rb
+6
-1
activerecord/lib/active_record/connection_adapters/mysql_adapter.rb
...rd/lib/active_record/connection_adapters/mysql_adapter.rb
+13
-0
activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
...b/active_record/connection_adapters/postgresql_adapter.rb
+11
-0
activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb
...d/lib/active_record/connection_adapters/sqlite_adapter.rb
+10
-0
activerecord/test/cases/adapter_test.rb
activerecord/test/cases/adapter_test.rb
+15
-0
activesupport/lib/active_support/cache.rb
activesupport/lib/active_support/cache.rb
+6
-1
railties/lib/initializer.rb
railties/lib/initializer.rb
+11
-6
railties/lib/performance_test_help.rb
railties/lib/performance_test_help.rb
+1
-1
railties/lib/rails/configuration.rb
railties/lib/rails/configuration.rb
+0
-1
未找到文件。
actionpack/lib/action_controller/base/streaming.rb
浏览文件 @
915f108d
...
...
@@ -168,7 +168,7 @@ def send_file_headers!(options)
end
headers
.
merge!
(
'Content-Length'
=>
options
[
:length
],
'Content-Length'
=>
options
[
:length
]
.
to_s
,
'Content-Disposition'
=>
disposition
,
'Content-Transfer-Encoding'
=>
'binary'
)
...
...
actionpack/lib/action_controller/testing/performance.rb
→
actionpack/lib/action_controller/testing/performance
_test
.rb
浏览文件 @
915f108d
文件已移动
actionpack/lib/action_view/helpers/asset_tag_helper.rb
浏览文件 @
915f108d
require
'cgi'
require
'action_view/helpers/url_helper'
require
'action_view/helpers/tag_helper'
require
'active_support/core_ext/file'
module
ActionView
module
Helpers
#:nodoc:
...
...
@@ -285,7 +286,7 @@ def javascript_include_tag(*sources)
end
javascript_src_tag
(
joined_javascript_name
,
options
)
else
e
xpand_javascript_sources
(
sources
,
recursive
).
collect
{
|
source
|
javascript_src_tag
(
source
,
options
)
}.
join
(
"
\n
"
)
e
nsure_javascript_sources!
(
expand_javascript_sources
(
sources
,
recursive
)
).
collect
{
|
source
|
javascript_src_tag
(
source
,
options
)
}.
join
(
"
\n
"
)
end
end
...
...
@@ -434,7 +435,7 @@ def stylesheet_link_tag(*sources)
end
stylesheet_tag
(
joined_stylesheet_name
,
options
)
else
e
xpand_stylesheet_sources
(
sources
,
recursive
).
collect
{
|
source
|
stylesheet_tag
(
source
,
options
)
}.
join
(
"
\n
"
)
e
nsure_stylesheet_sources!
(
expand_stylesheet_sources
(
sources
,
recursive
)
).
collect
{
|
source
|
stylesheet_tag
(
source
,
options
)
}.
join
(
"
\n
"
)
end
end
...
...
@@ -664,13 +665,28 @@ def determine_source(source, collection)
end
end
def
ensure_stylesheet_sources!
(
sources
)
sources
.
each
do
|
source
|
asset_file_path!
(
path_to_stylesheet
(
source
))
end
return
sources
end
def
ensure_javascript_sources!
(
sources
)
sources
.
each
do
|
source
|
asset_file_path!
(
path_to_javascript
(
source
))
end
return
sources
end
def
join_asset_file_contents
(
paths
)
paths
.
collect
{
|
path
|
File
.
read
(
asset_file_path
(
path
))
}.
join
(
"
\n\n
"
)
paths
.
collect
{
|
path
|
File
.
read
(
asset_file_path
!
(
path
))
}.
join
(
"
\n\n
"
)
end
def
write_asset_file_contents
(
joined_asset_path
,
asset_paths
)
FileUtils
.
mkdir_p
(
File
.
dirname
(
joined_asset_path
))
File
.
open
(
joined_asset_path
,
"w+"
)
{
|
cache
|
cache
.
write
(
join_asset_file_contents
(
asset_paths
))
}
File
.
atomic_write
(
joined_asset_path
)
{
|
cache
|
cache
.
write
(
join_asset_file_contents
(
asset_paths
))
}
# Set mtime to the latest of the combined files to allow for
# consistent ETag without a shared filesystem.
...
...
@@ -682,6 +698,14 @@ def asset_file_path(path)
File
.
join
(
ASSETS_DIR
,
path
.
split
(
'?'
).
first
)
end
def
asset_file_path!
(
path
)
unless
path
=~
%r{^[-a-z]+://}
absolute_path
=
asset_file_path
(
path
)
raise
(
Errno
::
ENOENT
,
"Asset file not found at '
#{
absolute_path
}
'"
)
unless
File
.
exist?
(
absolute_path
)
return
absolute_path
end
end
def
collect_asset_files
(
*
path
)
dir
=
path
.
first
...
...
actionpack/lib/action_view/render/partials.rb
浏览文件 @
915f108d
...
...
@@ -232,18 +232,6 @@ def _render_partial_with_block(layout, block, options)
ensure
@_proc_for_layout
=
nil
end
def
_deprecated_ivar_assign
(
template
)
if
respond_to?
(
:controller
)
ivar
=
:"@
#{
template
.
variable_name
}
"
object
=
if
controller
.
instance_variable_defined?
(
ivar
)
ActiveSupport
::
Deprecation
::
DeprecatedObjectProxy
.
new
(
controller
.
instance_variable_get
(
ivar
),
"
#{
ivar
}
will no longer be implicitly assigned to
#{
template
.
variable_name
}
"
)
end
end
end
def
_render_partial_with_layout
(
layout
,
options
)
if
layout
...
...
@@ -253,18 +241,6 @@ def _render_partial_with_layout(layout, options)
content
=
_render_partial
(
options
)
return
_render_content_with_layout
(
content
,
layout
,
options
[
:locals
])
end
def
_deprecated_ivar_assign
(
template
)
if
respond_to?
(
:controller
)
ivar
=
:"@
#{
template
.
variable_name
}
"
object
=
if
controller
.
instance_variable_defined?
(
ivar
)
ActiveSupport
::
Deprecation
::
DeprecatedObjectProxy
.
new
(
controller
.
instance_variable_get
(
ivar
),
"
#{
ivar
}
will no longer be implicitly assigned to
#{
template
.
variable_name
}
"
)
end
end
end
def
_array_like_objects
array_like
=
[
Array
]
...
...
@@ -290,8 +266,6 @@ def _render_partial_object(template, options, object = nil)
end
def
_set_locals
(
object
,
locals
,
template
,
options
)
object
||=
_deprecated_ivar_assign
(
template
)
locals
[
:object
]
=
locals
[
template
.
variable_name
]
=
object
locals
[
options
[
:as
]]
=
object
if
options
[
:as
]
end
...
...
actionpack/lib/action_view/template/handlers/builder.rb
浏览文件 @
915f108d
require
'builder'
module
ActionView
module
TemplateHandlers
class
Builder
<
TemplateHandler
...
...
@@ -8,6 +6,7 @@ class Builder < TemplateHandler
self
.
default_format
=
Mime
::
XML
def
compile
(
template
)
require
'builder'
"xml = ::Builder::XmlMarkup.new(:indent => 2);"
+
"self.output_buffer = xml.target!;"
+
template
.
source
+
...
...
actionpack/lib/action_view/template/handlers/erb.rb
浏览文件 @
915f108d
require
'erb'
require
'active_support/core_ext/class/attribute_accessors'
module
ActionView
...
...
@@ -16,6 +15,8 @@ class ERB < TemplateHandler
self
.
default_format
=
Mime
::
HTML
def
compile
(
template
)
require
'erb'
magic
=
$1
if
template
.
source
=~
/\A(<%#.*coding:\s*(\S+)\s*-?%>)/
erb
=
"
#{
magic
}
<% __in_erb_template=true %>
#{
template
.
source
}
"
::
ERB
.
new
(
erb
,
nil
,
erb_trim_mode
,
'@output_buffer'
).
src
...
...
actionpack/test/controller/render_test.rb
浏览文件 @
915f108d
...
...
@@ -1268,13 +1268,6 @@ def test_partial_hash_collection_with_locals
assert_equal
"Hola: PratikHola: Amy"
,
@response
.
body
end
def
test_partial_with_implicit_local_assignment
assert_deprecated
do
get
:partial_with_implicit_local_assignment
assert_equal
"Hello: Marcel"
,
@response
.
body
end
end
def
test_render_missing_partial_template
assert_raise
(
ActionView
::
MissingTemplate
)
do
get
:missing_partial
...
...
actionpack/test/controller/send_file_test.rb
浏览文件 @
915f108d
...
...
@@ -115,7 +115,7 @@ def test_send_file_headers!
@controller
.
send
(
:send_file_headers!
,
options
)
h
=
@controller
.
headers
assert_equal
1
,
h
[
'Content-Length'
]
assert_equal
'1'
,
h
[
'Content-Length'
]
assert_equal
'image/png'
,
@controller
.
content_type
assert_equal
'disposition; filename="filename"'
,
h
[
'Content-Disposition'
]
assert_equal
'binary'
,
h
[
'Content-Transfer-Encoding'
]
...
...
actionpack/test/fixtures/public/.gitignore
0 → 100644
浏览文件 @
915f108d
absolute
\ No newline at end of file
actionpack/test/fixtures/public/elsewhere/cools.js
0 → 100644
浏览文件 @
915f108d
// cools.js
\ No newline at end of file
actionpack/test/fixtures/public/elsewhere/file.css
0 → 100644
浏览文件 @
915f108d
/*file.css*/
\ No newline at end of file
actionpack/test/fixtures/public/javascripts/common.javascript
0 → 100644
浏览文件 @
915f108d
// common.javascript
\ No newline at end of file
actionpack/test/fixtures/public/stylesheets/random.styles
0 → 100644
浏览文件 @
915f108d
/* random.styles */
\ No newline at end of file
actionpack/test/template/asset_tag_helper_test.rb
浏览文件 @
915f108d
此差异已折叠。
点击以展开。
activerecord/lib/active_record/base.rb
浏览文件 @
915f108d
...
...
@@ -67,6 +67,25 @@ class RecordNotSaved < ActiveRecordError
class
StatementInvalid
<
ActiveRecordError
end
# Parent class for all specific exceptions which wrap database driver exceptions
# provides access to the original exception also.
class
WrappedDatabaseException
<
StatementInvalid
attr_reader
:original_exception
def
initialize
(
message
,
original_exception
)
super
(
message
)
@original_exception
,
=
original_exception
end
end
# Raised when a record cannot be inserted because it would violate a uniqueness constraint.
class
RecordNotUnique
<
WrappedDatabaseException
end
# Raised when a record cannot be inserted or updated because it references a non-existent record.
class
InvalidForeignKey
<
WrappedDatabaseException
end
# Raised when number of bind variables in statement given to <tt>:condition</tt> key (for example, when using +find+ method)
# does not match number of expected variables.
#
...
...
activerecord/lib/active_record/connection_adapters/abstract_adapter.rb
浏览文件 @
915f108d
...
...
@@ -211,9 +211,14 @@ def log(sql, name)
@last_verification
=
0
message
=
"
#{
e
.
class
.
name
}
:
#{
e
.
message
}
:
#{
sql
}
"
log_info
(
message
,
name
,
0
)
raise
ActiveRecord
::
StatementInvalid
,
message
raise
translate_exception
(
e
,
message
)
end
def
translate_exception
(
e
,
message
)
# override in derived class
ActiveRecord
::
StatementInvalid
.
new
(
message
)
end
def
format_log_entry
(
message
,
dump
=
nil
)
if
ActiveRecord
::
Base
.
colorize_logging
if
@@row_even
...
...
activerecord/lib/active_record/connection_adapters/mysql_adapter.rb
浏览文件 @
915f108d
...
...
@@ -563,6 +563,19 @@ def limited_update_conditions(where_sql, quoted_table_name, quoted_primary_key)
where_sql
end
protected
def
translate_exception
(
exception
,
message
)
case
exception
.
errno
when
1062
RecordNotUnique
.
new
(
message
,
exception
)
when
1452
InvalidForeignKey
.
new
(
message
,
exception
)
else
super
end
end
private
def
connect
encoding
=
@config
[
:encoding
]
...
...
activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
浏览文件 @
915f108d
...
...
@@ -941,6 +941,17 @@ def postgresql_version
end
end
def
translate_exception
(
exception
,
message
)
case
exception
.
message
when
/duplicate key value violates unique constraint/
RecordNotUnique
.
new
(
message
,
exception
)
when
/violates foreign key constraint/
InvalidForeignKey
.
new
(
message
,
exception
)
else
super
end
end
private
# The internal PostgreSQL identifier of the money data type.
MONEY_COLUMN_TYPE_OID
=
790
#:nodoc:
...
...
activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb
浏览文件 @
915f108d
...
...
@@ -431,6 +431,16 @@ def default_primary_key_type
'INTEGER PRIMARY KEY NOT NULL'
.
freeze
end
end
def
translate_exception
(
exception
,
message
)
case
exception
.
message
when
/column(s)? .* (is|are) not unique/
RecordNotUnique
.
new
(
message
,
exception
)
else
super
end
end
end
class
SQLite2Adapter
<
SQLiteAdapter
# :nodoc:
...
...
activerecord/test/cases/adapter_test.rb
浏览文件 @
915f108d
...
...
@@ -130,4 +130,19 @@ def test_add_limit_offset_should_sanitize_sql_injection_for_limit_with_comas
assert_equal
" LIMIT 1,7 OFFSET 7"
,
@connection
.
add_limit_offset!
(
""
,
:limit
=>
sql_inject
,
:offset
=>
7
)
end
end
def
test_uniqueness_violations_are_translated_to_specific_exception
@connection
.
execute
"INSERT INTO subscribers(nick) VALUES('me')"
assert_raises
(
ActiveRecord
::
RecordNotUnique
)
do
@connection
.
execute
"INSERT INTO subscribers(nick) VALUES('me')"
end
end
def
test_foreign_key_violations_are_translated_to_specific_exception
unless
@connection
.
adapter_name
==
'SQLite'
assert_raises
(
ActiveRecord
::
InvalidForeignKey
)
do
@connection
.
execute
"INSERT INTO fk_test_has_fk (fk_id) VALUES (0)"
end
end
end
end
activesupport/lib/active_support/cache.rb
浏览文件 @
915f108d
...
...
@@ -2,7 +2,12 @@
require
'active_support/core_ext/benchmark'
require
'active_support/core_ext/exception'
require
'active_support/core_ext/class/attribute_accessors'
require
'active_support/core_ext'
# FIXME: pulling in all to_param extensions
%w(hash nil string time date date_time array big_decimal range object boolean)
.
each
do
|
library
|
require
"active_support/core_ext/
#{
library
}
/conversions"
end
# require 'active_support/core_ext' # FIXME: pulling in all to_param extensions
module
ActiveSupport
# See ActiveSupport::Cache::Store for documentation.
...
...
railties/lib/initializer.rb
浏览文件 @
915f108d
...
...
@@ -101,6 +101,7 @@ def self.default
def
self
.
run
(
initializer
=
nil
,
config
=
nil
)
default
.
config
=
config
if
config
default
.
config
||=
Configuration
.
new
yield
default
.
config
if
block_given?
default
.
run
(
initializer
)
end
end
...
...
@@ -176,7 +177,8 @@ def self.run(initializer = nil, config = nil)
# Action Pack, Action Mailer, and Active Resource) are loaded.
Initializer
.
default
.
add
:require_frameworks
do
begin
require
'active_support/all'
require
'active_support'
require
'active_support/core_ext/kernel/reporting'
configuration
.
frameworks
.
each
{
|
framework
|
require
(
framework
.
to_s
)
}
rescue
LoadError
=>
e
# Re-raise as RuntimeError because Mongrel would swallow LoadError.
...
...
@@ -396,12 +398,15 @@ def self.run(initializer = nil, config = nil)
end
Initializer
.
default
.
add
:initialize_metal
do
Rails
::
Rack
::
Metal
.
requested_metals
=
configuration
.
metals
Rails
::
Rack
::
Metal
.
metal_paths
+=
plugin_loader
.
engine_metal_paths
# TODO: Make Rails and metal work without ActionController
if
defined?
(
ActionController
)
Rails
::
Rack
::
Metal
.
requested_metals
=
configuration
.
metals
Rails
::
Rack
::
Metal
.
metal_paths
+=
plugin_loader
.
engine_metal_paths
configuration
.
middleware
.
insert_before
(
:"ActionDispatch::ParamsParser"
,
Rails
::
Rack
::
Metal
,
:if
=>
Rails
::
Rack
::
Metal
.
metals
.
any?
)
configuration
.
middleware
.
insert_before
(
:"ActionDispatch::ParamsParser"
,
Rails
::
Rack
::
Metal
,
:if
=>
Rails
::
Rack
::
Metal
.
metals
.
any?
)
end
end
# Add the load paths used by support functions such as the info controller
...
...
railties/lib/performance_test_help.rb
浏览文件 @
915f108d
require
'action_controller/performance_test'
require
'action_controller/
testing/
performance_test'
ActionController
::
Base
.
perform_caching
=
true
ActiveSupport
::
Dependencies
.
mechanism
=
:require
...
...
railties/lib/rails/configuration.rb
浏览文件 @
915f108d
...
...
@@ -93,7 +93,6 @@ def framework_root_path
# TODO: Fix this when there is an application object
def
middleware
require
'action_controller'
ActionController
::
Dispatcher
.
middleware
end
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录