mongoid_permalink_extension 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 50a73110b4c60f539ba49ee24786498c8e4c879c
|
4
|
+
data.tar.gz: de6931f7d654086fbdbec9763ee8814054d3dc80
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 071a03b9ee041e7e36046f4bb5b8b531f71caeaf867ae73f9797621d7085ab6f96e36d552cc03eb4e400c0eff5f53d7aa76df7cb3169ebf0557a4762fdc69c77
|
7
|
+
data.tar.gz: 1406ed2c917d9d6e03aea3a696cf77dd633c9991a461b97c2357ad822de33b54f80a359f7fb2ae414e3d620d8fb837c43db447327b6d1cb72971c1f81fd956f9
|
@@ -14,9 +14,9 @@ module MongoidPermalinkExtension
|
|
14
14
|
def mongoize value
|
15
15
|
return if value.nil?
|
16
16
|
value.to_s.
|
17
|
-
|
17
|
+
gsub(/([\w^_](?=[[:upper:]]))|([a-z](?=\d+))/, '\1\2-').
|
18
18
|
gsub(/\//, '-').
|
19
|
-
gsub(/[
|
19
|
+
gsub(/[-–—]+/, '-').
|
20
20
|
gsub(/[^\p{Alnum} -]/, '').
|
21
21
|
gsub(/\s+/, '-').
|
22
22
|
gsub(/\b\w/){ $&.upcase }.
|
@@ -42,13 +42,20 @@ describe MongoidPermalinkExtension::Permalink do
|
|
42
42
|
end
|
43
43
|
it 'converts to camel case' do
|
44
44
|
MongoidPermalinkExtension::Permalink.mongoize("hello hello").wont_include 'h'
|
45
|
+
MongoidPermalinkExtension::Permalink.mongoize("hello hello").must_equal 'Hello-Hello'
|
45
46
|
end
|
46
47
|
it 'adds spaces to camel case' do
|
47
48
|
MongoidPermalinkExtension::Permalink.mongoize("CamelCase").must_equal 'Camel-Case'
|
48
49
|
end
|
50
|
+
it 'preserves dashes as separators' do
|
51
|
+
MongoidPermalinkExtension::Permalink.mongoize("Camel-Case").must_equal 'Camel-Case'
|
52
|
+
MongoidPermalinkExtension::Permalink.mongoize("Camel--Case").must_equal 'Camel-Case'
|
53
|
+
end
|
49
54
|
it 'converts all dashes to hyphens' do
|
50
55
|
MongoidPermalinkExtension::Permalink.mongoize("–").must_equal '-'
|
56
|
+
MongoidPermalinkExtension::Permalink.mongoize("----–").must_equal '-'
|
51
57
|
MongoidPermalinkExtension::Permalink.mongoize("—").must_equal '-'
|
58
|
+
MongoidPermalinkExtension::Permalink.mongoize("—––––––").must_equal '-'
|
52
59
|
end
|
53
60
|
it 'remove non-alphanumeric characters' do
|
54
61
|
%w(?!@#$%^&*()+=.,;<>[]).shuffle.each do |i|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mongoid_permalink_extension
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tomas Celizna
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-07-
|
11
|
+
date: 2015-07-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mongoid
|