rakutenusa-friendly_id 2.0.8 → 2.0.9
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +5 -0
- data/History.txt +7 -0
- data/MIT-LICENSE +19 -0
- data/Rakefile +45 -0
- data/VERSION.yml +2 -2
- data/config/website.yml +2 -0
- data/friendly_id.gemspec +93 -0
- data/generators/friendly_id/templates/create_slugs.rb +2 -2
- data/generators/friendly_id_20_upgrade/friendly_id_20_upgrade_generator.rb +1 -0
- data/generators/friendly_id_20_upgrade/templates/upgrade_friendly_id_to_20.rb +1 -1
- data/init.rb +3 -0
- data/lib/friendly_id/sluggable_class_methods.rb +5 -3
- data/test/slugged_model_test.rb +15 -2
- metadata +32 -17
data/History.txt
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
== 2.1.4 2009-09-01
|
2
|
+
|
3
|
+
* 3 minor enhancements:
|
4
|
+
* Fixed upgrade generator not installing rake tasks (Harry Love)
|
5
|
+
* Fixed handling of very large id's (Nathan Phelps)
|
6
|
+
* Fixed long index name on migration (Rob Ingram)
|
7
|
+
|
1
8
|
== 2.1.3 2009-06-03
|
2
9
|
|
3
10
|
* 1 minor enhancement:
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (c) 2008 Norman Clarke and Adrian Mugnolo.
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
5
|
+
in the Software without restriction, including without limitation the rights
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in all
|
11
|
+
copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
19
|
+
SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'lib/friendly_id/version'
|
2
|
+
|
3
|
+
desc "Run RCov"
|
4
|
+
task :rcov do
|
5
|
+
run_coverage Dir["test/**/*_test.rb"]
|
6
|
+
end
|
7
|
+
|
8
|
+
def run_coverage(files)
|
9
|
+
rm_f "coverage"
|
10
|
+
rm_f "coverage.data"
|
11
|
+
if files.length == 0
|
12
|
+
puts "No files were specified for testing"
|
13
|
+
return
|
14
|
+
end
|
15
|
+
files = files.join(" ")
|
16
|
+
# if RUBY_PLATFORM =~ /darwin/
|
17
|
+
# exclude = '--exclude "gems/"'
|
18
|
+
# else
|
19
|
+
# exclude = '--exclude "rubygems"'
|
20
|
+
# end
|
21
|
+
rcov = ENV["RCOV"] ? ENV["RCOV"] : "rcov"
|
22
|
+
sh "#{rcov} -Ilib:test --sort coverage --text-report #{files}"
|
23
|
+
end
|
24
|
+
|
25
|
+
desc 'Publish RDoc to RubyForge.'
|
26
|
+
task :publish_docs => [:clean, :docs] do
|
27
|
+
host = "compay@rubyforge.org"
|
28
|
+
remote_dir = "/var/www/gforge-projects/friendly-id"
|
29
|
+
local_dir = 'doc'
|
30
|
+
sh %{rsync -av --delete #{local_dir}/ #{host}:#{remote_dir}}
|
31
|
+
end
|
32
|
+
|
33
|
+
begin
|
34
|
+
require 'jeweler'
|
35
|
+
Jeweler::Tasks.new do |gemspec|
|
36
|
+
gemspec.name = "friendly_id"
|
37
|
+
gemspec.summary = "TODO"
|
38
|
+
gemspec.email = "dev@rakutenusa.com"
|
39
|
+
gemspec.homepage = "http://github.com/rakutenusa/friendly_id"
|
40
|
+
gemspec.description = "TODO"
|
41
|
+
gemspec.authors = ["RakutenUSA"]
|
42
|
+
end
|
43
|
+
rescue LoadError
|
44
|
+
puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
|
45
|
+
end
|
data/VERSION.yml
CHANGED
data/config/website.yml
ADDED
data/friendly_id.gemspec
ADDED
@@ -0,0 +1,93 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{friendly_id}
|
5
|
+
s.version = "2.0.9"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["RakutenUSA"]
|
9
|
+
s.date = %q{2009-09-06}
|
10
|
+
s.description = %q{TODO}
|
11
|
+
s.email = %q{dev@rakutenusa.com}
|
12
|
+
s.extra_rdoc_files = [
|
13
|
+
"README.rdoc"
|
14
|
+
]
|
15
|
+
s.files = [
|
16
|
+
".gitignore",
|
17
|
+
"History.txt",
|
18
|
+
"MIT-LICENSE",
|
19
|
+
"Manifest.txt",
|
20
|
+
"README.rdoc",
|
21
|
+
"Rakefile",
|
22
|
+
"VERSION.yml",
|
23
|
+
"config/website.yml",
|
24
|
+
"friendly_id.gemspec",
|
25
|
+
"generators/friendly_id/friendly_id_generator.rb",
|
26
|
+
"generators/friendly_id/templates/create_slugs.rb",
|
27
|
+
"generators/friendly_id_20_upgrade/friendly_id_20_upgrade_generator.rb",
|
28
|
+
"generators/friendly_id_20_upgrade/templates/upgrade_friendly_id_to_20.rb",
|
29
|
+
"init.rb",
|
30
|
+
"lib/friendly_id.rb",
|
31
|
+
"lib/friendly_id/helpers.rb",
|
32
|
+
"lib/friendly_id/non_sluggable_class_methods.rb",
|
33
|
+
"lib/friendly_id/non_sluggable_instance_methods.rb",
|
34
|
+
"lib/friendly_id/slug.rb",
|
35
|
+
"lib/friendly_id/sluggable_class_methods.rb",
|
36
|
+
"lib/friendly_id/sluggable_instance_methods.rb",
|
37
|
+
"lib/friendly_id/version.rb",
|
38
|
+
"lib/tasks/friendly_id.rake",
|
39
|
+
"lib/tasks/friendly_id.rb",
|
40
|
+
"test/contest.rb",
|
41
|
+
"test/custom_slug_normalizer_test.rb",
|
42
|
+
"test/models/book.rb",
|
43
|
+
"test/models/country.rb",
|
44
|
+
"test/models/event.rb",
|
45
|
+
"test/models/novel.rb",
|
46
|
+
"test/models/person.rb",
|
47
|
+
"test/models/post.rb",
|
48
|
+
"test/models/thing.rb",
|
49
|
+
"test/models/user.rb",
|
50
|
+
"test/non_slugged_test.rb",
|
51
|
+
"test/schema.rb",
|
52
|
+
"test/scoped_model_test.rb",
|
53
|
+
"test/slug_test.rb",
|
54
|
+
"test/slugged_model_test.rb",
|
55
|
+
"test/sti_test.rb",
|
56
|
+
"test/test_helper.rb"
|
57
|
+
]
|
58
|
+
s.has_rdoc = true
|
59
|
+
s.homepage = %q{http://github.com/rakutenusa/friendly_id}
|
60
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
61
|
+
s.require_paths = ["lib"]
|
62
|
+
s.rubygems_version = %q{1.3.2}
|
63
|
+
s.summary = %q{TODO}
|
64
|
+
s.test_files = [
|
65
|
+
"test/contest.rb",
|
66
|
+
"test/custom_slug_normalizer_test.rb",
|
67
|
+
"test/models/book.rb",
|
68
|
+
"test/models/country.rb",
|
69
|
+
"test/models/event.rb",
|
70
|
+
"test/models/novel.rb",
|
71
|
+
"test/models/person.rb",
|
72
|
+
"test/models/post.rb",
|
73
|
+
"test/models/thing.rb",
|
74
|
+
"test/models/user.rb",
|
75
|
+
"test/non_slugged_test.rb",
|
76
|
+
"test/schema.rb",
|
77
|
+
"test/scoped_model_test.rb",
|
78
|
+
"test/slug_test.rb",
|
79
|
+
"test/slugged_model_test.rb",
|
80
|
+
"test/sti_test.rb",
|
81
|
+
"test/test_helper.rb"
|
82
|
+
]
|
83
|
+
|
84
|
+
if s.respond_to? :specification_version then
|
85
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
86
|
+
s.specification_version = 3
|
87
|
+
|
88
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
89
|
+
else
|
90
|
+
end
|
91
|
+
else
|
92
|
+
end
|
93
|
+
end
|
@@ -8,11 +8,11 @@ class CreateSlugs < ActiveRecord::Migration
|
|
8
8
|
t.string :scope, :limit => 40
|
9
9
|
t.datetime :created_at
|
10
10
|
end
|
11
|
-
add_index :slugs, [:name, :sluggable_type, :scope, :sequence], :unique => true
|
11
|
+
add_index :slugs, [:name, :sluggable_type, :scope, :sequence], :name => "index_slugs_on_n_s_s_and_s", :unique => true
|
12
12
|
add_index :slugs, :sluggable_id
|
13
13
|
end
|
14
14
|
|
15
15
|
def self.down
|
16
16
|
drop_table :slugs
|
17
17
|
end
|
18
|
-
end
|
18
|
+
end
|
@@ -5,6 +5,7 @@ class FriendlyId20UpgradeGenerator < Rails::Generator::Base
|
|
5
5
|
m.migration_template(
|
6
6
|
'upgrade_friendly_id_to_20.rb', 'db/migrate', :migration_file_name => 'upgrade_friendly_id_to_20'
|
7
7
|
)
|
8
|
+
m.file "/../../../lib/tasks/friendly_id.rake", "lib/tasks/friendly_id.rake"
|
8
9
|
end
|
9
10
|
end
|
10
11
|
end
|
data/init.rb
ADDED
@@ -3,7 +3,7 @@
|
|
3
3
|
module FriendlyId::SluggableClassMethods
|
4
4
|
|
5
5
|
include FriendlyId::Helpers
|
6
|
-
|
6
|
+
|
7
7
|
def self.extended(base) #:nodoc:#
|
8
8
|
|
9
9
|
class << base
|
@@ -18,7 +18,7 @@ module FriendlyId::SluggableClassMethods
|
|
18
18
|
def find_one_with_friendly(id_or_name, options) #:nodoc:#
|
19
19
|
|
20
20
|
scope = options.delete(:scope)
|
21
|
-
return find_one_without_friendly(id_or_name, options) if id_or_name.is_a?(
|
21
|
+
return find_one_without_friendly(id_or_name, options) if id_or_name.is_a?(Integer)
|
22
22
|
|
23
23
|
find_options = {:select => "#{self.table_name}.*"}
|
24
24
|
find_options[:joins] = :slugs unless options[:include] && [*options[:include]].flatten.include?(:slugs)
|
@@ -35,6 +35,8 @@ module FriendlyId::SluggableClassMethods
|
|
35
35
|
|
36
36
|
if result
|
37
37
|
result.finder_slug_name = id_or_name
|
38
|
+
elsif id_or_name.to_i.to_s != id_or_name
|
39
|
+
raise ActiveRecord::RecordNotFound
|
38
40
|
else
|
39
41
|
result = find_one_without_friendly id_or_name, options
|
40
42
|
end
|
@@ -113,4 +115,4 @@ module FriendlyId::SluggableClassMethods
|
|
113
115
|
return slugs, ids
|
114
116
|
end
|
115
117
|
|
116
|
-
end
|
118
|
+
end
|
data/test/slugged_model_test.rb
CHANGED
@@ -11,6 +11,7 @@ class SluggedModelTest < Test::Unit::TestCase
|
|
11
11
|
Post.delete_all
|
12
12
|
Person.delete_all
|
13
13
|
Slug.delete_all
|
14
|
+
Thing.delete_all
|
14
15
|
@post = Post.new :title => "Test post", :content => "Test content", :published => true
|
15
16
|
@post.save!
|
16
17
|
end
|
@@ -31,6 +32,12 @@ class SluggedModelTest < Test::Unit::TestCase
|
|
31
32
|
assert Post.find(@post.id)
|
32
33
|
end
|
33
34
|
|
35
|
+
should "not be findable by its id if looking for something else" do
|
36
|
+
assert_raises ActiveRecord::RecordNotFound do
|
37
|
+
Post.find("#{@post.id}-i-dont-exists")
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
34
41
|
should "generate slug text" do
|
35
42
|
post = Post.new :title => "Test post", :content => "Test content"
|
36
43
|
assert_not_nil @post.slug_text
|
@@ -131,6 +138,12 @@ class SluggedModelTest < Test::Unit::TestCase
|
|
131
138
|
assert_equal true, @post.new_slug_needed?
|
132
139
|
end
|
133
140
|
|
141
|
+
# This emulates a fairly common issue where id's generated by fixtures are very high.
|
142
|
+
should "continue to admit very large ids" do
|
143
|
+
Thing.connection.execute("INSERT INTO things (id, name) VALUES (2147483647, 'big')")
|
144
|
+
assert Thing.find(2147483647)
|
145
|
+
end
|
146
|
+
|
134
147
|
context "and configured to strip diacritics" do
|
135
148
|
setup do
|
136
149
|
Post.friendly_id_options = Post.friendly_id_options.merge(:strip_diacritics => true)
|
@@ -251,7 +264,7 @@ class SluggedModelTest < Test::Unit::TestCase
|
|
251
264
|
should "return results when passed an array of friendly ids" do
|
252
265
|
assert_equal 2, Post.find([@post.friendly_id, @post2.friendly_id]).size
|
253
266
|
end
|
254
|
-
|
267
|
+
|
255
268
|
should "return results when searching using a named scope" do
|
256
269
|
assert_equal 2, Post.published.find([@post.id, @post2.id]).size
|
257
270
|
end
|
@@ -305,4 +318,4 @@ class SluggedModelTest < Test::Unit::TestCase
|
|
305
318
|
|
306
319
|
end
|
307
320
|
|
308
|
-
end
|
321
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rakutenusa-friendly_id
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- RakutenUSA
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-09-06 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -19,22 +19,24 @@ executables: []
|
|
19
19
|
|
20
20
|
extensions: []
|
21
21
|
|
22
|
-
extra_rdoc_files:
|
23
|
-
|
22
|
+
extra_rdoc_files:
|
23
|
+
- README.rdoc
|
24
24
|
files:
|
25
|
+
- .gitignore
|
25
26
|
- History.txt
|
27
|
+
- MIT-LICENSE
|
26
28
|
- Manifest.txt
|
27
29
|
- README.rdoc
|
30
|
+
- Rakefile
|
28
31
|
- VERSION.yml
|
29
|
-
-
|
32
|
+
- config/website.yml
|
33
|
+
- friendly_id.gemspec
|
30
34
|
- generators/friendly_id/friendly_id_generator.rb
|
31
|
-
- generators/friendly_id/templates
|
32
35
|
- generators/friendly_id/templates/create_slugs.rb
|
33
|
-
- generators/friendly_id_20_upgrade
|
34
36
|
- generators/friendly_id_20_upgrade/friendly_id_20_upgrade_generator.rb
|
35
|
-
- generators/friendly_id_20_upgrade/templates
|
36
37
|
- generators/friendly_id_20_upgrade/templates/upgrade_friendly_id_to_20.rb
|
37
|
-
-
|
38
|
+
- init.rb
|
39
|
+
- lib/friendly_id.rb
|
38
40
|
- lib/friendly_id/helpers.rb
|
39
41
|
- lib/friendly_id/non_sluggable_class_methods.rb
|
40
42
|
- lib/friendly_id/non_sluggable_instance_methods.rb
|
@@ -42,13 +44,10 @@ files:
|
|
42
44
|
- lib/friendly_id/sluggable_class_methods.rb
|
43
45
|
- lib/friendly_id/sluggable_instance_methods.rb
|
44
46
|
- lib/friendly_id/version.rb
|
45
|
-
- lib/friendly_id.rb
|
46
|
-
- lib/tasks
|
47
47
|
- lib/tasks/friendly_id.rake
|
48
48
|
- lib/tasks/friendly_id.rb
|
49
49
|
- test/contest.rb
|
50
50
|
- test/custom_slug_normalizer_test.rb
|
51
|
-
- test/models
|
52
51
|
- test/models/book.rb
|
53
52
|
- test/models/country.rb
|
54
53
|
- test/models/event.rb
|
@@ -66,9 +65,9 @@ files:
|
|
66
65
|
- test/test_helper.rb
|
67
66
|
has_rdoc: true
|
68
67
|
homepage: http://github.com/rakutenusa/friendly_id
|
68
|
+
licenses:
|
69
69
|
post_install_message:
|
70
70
|
rdoc_options:
|
71
|
-
- --inline-source
|
72
71
|
- --charset=UTF-8
|
73
72
|
require_paths:
|
74
73
|
- lib
|
@@ -87,9 +86,25 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
87
86
|
requirements: []
|
88
87
|
|
89
88
|
rubyforge_project:
|
90
|
-
rubygems_version: 1.
|
89
|
+
rubygems_version: 1.3.5
|
91
90
|
signing_key:
|
92
|
-
specification_version:
|
91
|
+
specification_version: 3
|
93
92
|
summary: TODO
|
94
|
-
test_files:
|
95
|
-
|
93
|
+
test_files:
|
94
|
+
- test/contest.rb
|
95
|
+
- test/custom_slug_normalizer_test.rb
|
96
|
+
- test/models/book.rb
|
97
|
+
- test/models/country.rb
|
98
|
+
- test/models/event.rb
|
99
|
+
- test/models/novel.rb
|
100
|
+
- test/models/person.rb
|
101
|
+
- test/models/post.rb
|
102
|
+
- test/models/thing.rb
|
103
|
+
- test/models/user.rb
|
104
|
+
- test/non_slugged_test.rb
|
105
|
+
- test/schema.rb
|
106
|
+
- test/scoped_model_test.rb
|
107
|
+
- test/slug_test.rb
|
108
|
+
- test/slugged_model_test.rb
|
109
|
+
- test/sti_test.rb
|
110
|
+
- test/test_helper.rb
|