mongomapper_ext 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/mongomapper_ext/slugizer.rb +12 -10
- data/lib/mongomapper_ext.rb +4 -1
- data/mongomapper_ext.gemspec +2 -2
- data/test/models.rb +1 -1
- data/test/test_slugizer.rb +6 -0
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.5
|
@@ -16,17 +16,19 @@ module MongoMapperExt
|
|
16
16
|
end
|
17
17
|
|
18
18
|
protected
|
19
|
+
|
19
20
|
def generate_slug
|
20
|
-
if self.
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
21
|
+
return false if self[self.class.slug_key].blank?
|
22
|
+
max_length = self.class.slug_options[:max_length]
|
23
|
+
|
24
|
+
slug = self[self.class.slug_key].parameterize.to_s
|
25
|
+
slug = slug[0, max_length] if max_length
|
26
|
+
|
27
|
+
if !self.class.slug_options[:unique]
|
28
|
+
key = UUIDTools::UUID.random_create.hexdigest[0,4] #optimize
|
29
|
+
self.slug = key+"-"+slug
|
30
|
+
else
|
31
|
+
self.slug = slug
|
30
32
|
end
|
31
33
|
end
|
32
34
|
|
data/lib/mongomapper_ext.rb
CHANGED
data/mongomapper_ext.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{mongomapper_ext}
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.5"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["David A. Cuadrado"]
|
12
|
-
s.date = %q{2010-03-
|
12
|
+
s.date = %q{2010-03-08}
|
13
13
|
s.description = %q{MongoMapper extensions}
|
14
14
|
s.email = %q{krawek@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
data/test/models.rb
CHANGED
data/test/test_slugizer.rb
CHANGED
@@ -25,6 +25,12 @@ class TestSlugizer < Test::Unit::TestCase
|
|
25
25
|
@blogpost.slug = nil
|
26
26
|
@blogpost.to_param.should == @blogpost.id
|
27
27
|
end
|
28
|
+
|
29
|
+
should "respect the max length option" do
|
30
|
+
@blogpost = BlogPost.create(:title => "ultimo video/cancion en youtube?",
|
31
|
+
:body => "HeRe is tHe Body of the bLog pOsT")
|
32
|
+
@blogpost.slug.should =~ /\w+-ultimo-video-canci/
|
33
|
+
end
|
28
34
|
end
|
29
35
|
|
30
36
|
context "finding objects" do
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
8
|
+
- 5
|
9
|
+
version: 0.1.5
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- David A. Cuadrado
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-03-
|
17
|
+
date: 2010-03-08 00:00:00 -05:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|