chinese_permalink 1.1.1 → 1.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.textile +1 -1
- data/VERSION +1 -1
- data/chinese_permalink.gemspec +2 -1
- data/init.rb +1 -0
- data/lib/chinese_permalink.rb +1 -2
- data/test/chines_permalink_test.rb +13 -13
- metadata +2 -1
data/README.textile
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.1.
|
1
|
+
1.1.2
|
data/chinese_permalink.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{chinese_permalink}
|
8
|
-
s.version = "1.1.
|
8
|
+
s.version = "1.1.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Richard Huang"]
|
@@ -24,6 +24,7 @@ Gem::Specification.new do |s|
|
|
24
24
|
"chinese_permalink.gemspec",
|
25
25
|
"generators/chinese_permalink_migration/chinese_permalink_migration_generator.rb",
|
26
26
|
"generators/chinese_permalink_migration/templates/migration.rb",
|
27
|
+
"init.rb",
|
27
28
|
"lib/chinese_permalink.rb",
|
28
29
|
"rails/init.rb",
|
29
30
|
"test/chines_permalink_test.rb"
|
data/init.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ActiveRecord::Base.send :include, ChinesePermalink
|
data/lib/chinese_permalink.rb
CHANGED
@@ -30,8 +30,7 @@ module ChinesePermalink
|
|
30
30
|
end
|
31
31
|
|
32
32
|
english_permalink = remove_duplicate_dash(remove_tailing_dash(remove_non_ascii(remove_space(remove_punctuation(english_permalink))))).downcase
|
33
|
-
|
34
|
-
self.update_attribute(self.class.permalink_field, permalink)
|
33
|
+
self.update_attribute(self.class.permalink_field, english_permalink)
|
35
34
|
end
|
36
35
|
end
|
37
36
|
|
@@ -64,50 +64,50 @@ class ChinesePermalinkTest < Test::Unit::TestCase
|
|
64
64
|
|
65
65
|
def test_simple_chinese_title
|
66
66
|
post = Post.create(:title => '中国人')
|
67
|
-
assert_equal "
|
67
|
+
assert_equal "chinese", post.permalink
|
68
68
|
|
69
69
|
post = Post.create(:title => '我是中国人')
|
70
|
-
assert_equal "
|
70
|
+
assert_equal "i-am-a-chinese", post.permalink
|
71
71
|
end
|
72
72
|
|
73
73
|
def test_chinese_title_with_dash
|
74
74
|
post = Post.create(:title => '我是中国人——上海')
|
75
|
-
assert_equal "
|
75
|
+
assert_equal "i-am-a-chinese-shanghai", post.permalink
|
76
76
|
|
77
77
|
post = Post.create(:title => '我是中国人──上海')
|
78
|
-
assert_equal "
|
78
|
+
assert_equal "i-am-a-chinese-shanghai", post.permalink
|
79
79
|
|
80
80
|
post = Post.create(:title => '上海+中国')
|
81
|
-
assert_equal "
|
81
|
+
assert_equal "shanghai-china", post.permalink
|
82
82
|
|
83
83
|
post = Post.create(:title => '上海/中国')
|
84
|
-
assert_equal "
|
84
|
+
assert_equal "shanghai-china", post.permalink
|
85
85
|
|
86
86
|
post = Post.create(:title => '“工作”')
|
87
|
-
assert_equal "
|
87
|
+
assert_equal "work", post.permalink
|
88
88
|
|
89
89
|
post = Post.create(:title => '妈妈的礼物')
|
90
|
-
assert_equal "
|
90
|
+
assert_equal "moms-gift", post.permalink
|
91
91
|
|
92
92
|
post = Post.create(:title => '宝洁')
|
93
|
-
assert_equal "
|
93
|
+
assert_equal "procter-gamble", post.permalink
|
94
94
|
|
95
95
|
post = Post.create(:title => '自我介绍')
|
96
|
-
assert_equal "
|
96
|
+
assert_equal "self-introduction", post.permalink
|
97
97
|
end
|
98
98
|
|
99
99
|
def test_chinese_category_and_title
|
100
100
|
post = CategoryPost.create(:title => '我是中国人', :category => '介绍')
|
101
|
-
assert_equal "
|
101
|
+
assert_equal "introduction-i-am-a-chinese", post.permalink
|
102
102
|
end
|
103
103
|
|
104
104
|
def test_complicated_title_with_before_methods
|
105
105
|
post = ComplicatedBeforePost.create(:title => 'C#语言')
|
106
|
-
assert_equal "
|
106
|
+
assert_equal "c-sharp-language", post.permalink
|
107
107
|
end
|
108
108
|
|
109
109
|
def test_complicated_title_with_after_methods
|
110
110
|
post = ComplicatedAfterPost.create(:title => '宝洁')
|
111
|
-
assert_equal "
|
111
|
+
assert_equal "pg", post.permalink
|
112
112
|
end
|
113
113
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chinese_permalink
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Richard Huang
|
@@ -39,6 +39,7 @@ files:
|
|
39
39
|
- chinese_permalink.gemspec
|
40
40
|
- generators/chinese_permalink_migration/chinese_permalink_migration_generator.rb
|
41
41
|
- generators/chinese_permalink_migration/templates/migration.rb
|
42
|
+
- init.rb
|
42
43
|
- lib/chinese_permalink.rb
|
43
44
|
- rails/init.rb
|
44
45
|
- test/chines_permalink_test.rb
|