Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
2c43a642
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,发现更多精彩内容 >>
提交
2c43a642
编写于
11月 26, 2008
作者:
J
Jeremy Kemper
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Ruby 1.9 compat: no Unicode normalization support yet
上级
51e15a60
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
27 addition
and
3 deletion
+27
-3
activesupport/lib/active_support/inflector.rb
activesupport/lib/active_support/inflector.rb
+8
-1
activesupport/test/inflector_test.rb
activesupport/test/inflector_test.rb
+6
-0
activesupport/test/inflector_test_cases.rb
activesupport/test/inflector_test_cases.rb
+13
-2
未找到文件。
activesupport/lib/active_support/inflector.rb
浏览文件 @
2c43a642
...
...
@@ -275,9 +275,16 @@ def transliterate(string)
Iconv
.
iconv
(
'ascii//ignore//translit'
,
'utf-8'
,
string
).
to_s
end
if
RUBY_VERSION
>=
'1.9'
undef_method
:transliterate
def
transliterate
(
string
)
warn
"Ruby 1.9 doesn't support Unicode normalization yet"
string
.
dup
end
# The iconv transliteration code doesn't function correctly
# on some platforms, but it's very fast where it does function.
if
"foo"
!=
Inflector
.
transliterate
(
"föö"
)
els
if
"foo"
!=
Inflector
.
transliterate
(
"föö"
)
undef_method
:transliterate
def
transliterate
(
string
)
string
.
mb_chars
.
normalize
(
:kd
)
.
# Decompose accented characters
...
...
activesupport/test/inflector_test.rb
浏览文件 @
2c43a642
...
...
@@ -104,6 +104,12 @@ def test_parameterize
end
end
def
test_parameterize_and_normalize
StringToParameterizedAndNormalized
.
each
do
|
some_string
,
parameterized_string
|
assert_equal
(
parameterized_string
,
ActiveSupport
::
Inflector
.
parameterize
(
some_string
))
end
end
def
test_parameterize_with_custom_separator
StringToParameterized
.
each
do
|
some_string
,
parameterized_string
|
assert_equal
(
parameterized_string
.
gsub
(
'-'
,
'_'
),
ActiveSupport
::
Inflector
.
parameterize
(
some_string
,
'_'
))
...
...
activesupport/test/inflector_test_cases.rb
浏览文件 @
2c43a642
...
...
@@ -147,14 +147,25 @@ module InflectorTestCases
StringToParameterized
=
{
"Donald E. Knuth"
=>
"donald-e-knuth"
,
"Random text with *(bad)* characters"
=>
"random-text-with-bad-characters"
,
"Malmö"
=>
"malmo"
,
"Garçons"
=>
"garcons"
,
"Allow_Under_Scores"
=>
"allow_under_scores"
,
"Trailing bad characters!@#"
=>
"trailing-bad-characters"
,
"!@#Leading bad characters"
=>
"leading-bad-characters"
,
"Squeeze separators"
=>
"squeeze-separators"
}
# Ruby 1.9 doesn't do Unicode normalization yet.
if
RUBY_VERSION
>=
'1.9'
StringToParameterizedAndNormalized
=
{
"Malmö"
=>
"malm"
,
"Garçons"
=>
"gar-ons"
}
else
StringToParameterizedAndNormalized
=
{
"Malmö"
=>
"malmo"
,
"Garçons"
=>
"garcons"
}
end
UnderscoreToHuman
=
{
"employee_salary"
=>
"Employee salary"
,
"employee_id"
=>
"Employee"
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录