chinese_permalink 1.1.1 → 1.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.textile CHANGED
@@ -62,7 +62,7 @@ Or
62
62
  <pre><code>
63
63
  class Post < ActiveRecord::Base
64
64
  def to_param
65
- permalink
65
+ "#{id}-#{permalink}"
66
66
  end
67
67
  end
68
68
  </code></pre>
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.1
1
+ 1.1.2
@@ -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.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
@@ -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
- permalink = id.to_s + '-' + english_permalink
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 "#{post.id}-chinese", post.permalink
67
+ assert_equal "chinese", post.permalink
68
68
 
69
69
  post = Post.create(:title => '我是中国人')
70
- assert_equal "#{post.id}-i-am-a-chinese", post.permalink
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 "#{post.id}-i-am-a-chinese-shanghai", post.permalink
75
+ assert_equal "i-am-a-chinese-shanghai", post.permalink
76
76
 
77
77
  post = Post.create(:title => '我是中国人──上海')
78
- assert_equal "#{post.id}-i-am-a-chinese-shanghai", post.permalink
78
+ assert_equal "i-am-a-chinese-shanghai", post.permalink
79
79
 
80
80
  post = Post.create(:title => '上海+中国')
81
- assert_equal "#{post.id}-shanghai-china", post.permalink
81
+ assert_equal "shanghai-china", post.permalink
82
82
 
83
83
  post = Post.create(:title => '上海/中国')
84
- assert_equal "#{post.id}-shanghai-china", post.permalink
84
+ assert_equal "shanghai-china", post.permalink
85
85
 
86
86
  post = Post.create(:title => '“工作”')
87
- assert_equal "#{post.id}-work", post.permalink
87
+ assert_equal "work", post.permalink
88
88
 
89
89
  post = Post.create(:title => '妈妈的礼物')
90
- assert_equal "#{post.id}-moms-gift", post.permalink
90
+ assert_equal "moms-gift", post.permalink
91
91
 
92
92
  post = Post.create(:title => '宝洁')
93
- assert_equal "#{post.id}-procter-gamble", post.permalink
93
+ assert_equal "procter-gamble", post.permalink
94
94
 
95
95
  post = Post.create(:title => '自我介绍')
96
- assert_equal "#{post.id}-self-introduction", post.permalink
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 "#{post.id}-introduction-i-am-a-chinese", post.permalink
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 "#{post.id}-c-sharp-language", post.permalink
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 "#{post.id}-pg", post.permalink
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.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