mongoid_permalink_extension 0.0.2 → 0.0.3

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: fc0ea8bbe92ca2029b1f68a4c3c79b069224c537
4
- data.tar.gz: 5b10800406a9c8e46de37982af384dbb1ac205b3
3
+ metadata.gz: f13fb1ed216c60973b45afab89fa6ec65a0552ac
4
+ data.tar.gz: d8449c8b1d4751d6ea1b9d5431c2640e9eaf973b
5
5
  SHA512:
6
- metadata.gz: 2617f90afbc0ee4eb3ae4c16829c03f562d723a0c9bb08fb812065774f75c5e722503042e5712a5c1e56516c1170918d4a93a292f1c81e61cb051644d2aa3ab3
7
- data.tar.gz: 0a506ac5f04d984107dc300e8b1c324acb310091c0a654c6faff2b03633b2001a34331d1351dedc85845eb79d2f543e8d9bc9cc5a46b4bcfeeaf78d9f8542330
6
+ metadata.gz: 15fd20bdbdf234afe35eb838ce97070e664b8e2d7ea87cefbea0c593e72f54ac3ae4741e1c0c7f8922d90e7436be4a5def47fc4c2f8279751821fa1c8b121024
7
+ data.tar.gz: efcebe2e00315277a00663433737effe21a29975f899c926a78cbac05ab3ab42b661c44802f15839156f71e735c32db590184dd2c448dc8599f62b88bdaaf060
@@ -14,6 +14,7 @@ module MongoidPermalinkExtension
14
14
  def mongoize value
15
15
  return if value.nil?
16
16
  value.to_s.
17
+ gsub(/\//, '-').
17
18
  gsub(/[–—]/, '-').
18
19
  gsub(/[^\p{Alnum} -]/, '').
19
20
  gsub(/\s+/, '-').
@@ -1,3 +1,3 @@
1
1
  module MongoidPermalinkExtension
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -2,62 +2,63 @@
2
2
 
3
3
  require 'test_helper'
4
4
 
5
- # ---------------------------------------------------------------------
6
-
7
5
  class MongoidPermalinkExtensionTest
8
6
  include Mongoid::Document
9
7
  field :permalink, type: MongoidPermalinkExtension::Permalink
10
8
  end
11
9
 
12
10
  # ---------------------------------------------------------------------
13
-
14
- module MongoidPermalinkExtension
15
- describe Permalink do
16
-
17
- subject { MongoidPermalinkExtensionTest.new }
18
-
19
- describe '.demongoize' do
20
- let(:permalink_value) { 'something stored in the database' }
21
- it 'does not change the value' do
22
- MongoidPermalinkExtension::Permalink.demongoize(permalink_value).must_equal permalink_value
23
- end
11
+
12
+ describe MongoidPermalinkExtension::Permalink do
13
+ subject { MongoidPermalinkExtensionTest.new }
14
+
15
+ # ---------------------------------------------------------------------
16
+
17
+ describe '.demongoize' do
18
+ let(:permalink_value) { 'something stored in the database' }
19
+ it 'does not change the value' do
20
+ MongoidPermalinkExtension::Permalink.demongoize(permalink_value).must_equal permalink_value
24
21
  end
22
+ end
25
23
 
26
- describe '.mongoize' do
27
- it 'converts anything to string' do
28
- MongoidPermalinkExtension::Permalink.mongoize(12).must_equal '12'
29
- end
30
- it 'stores transformed string' do
31
- MongoidPermalinkExtension::Permalink.mongoize("some some").must_be :present?
32
- end
33
- it 'stores nil if nil passed' do
34
- MongoidPermalinkExtension::Permalink.mongoize(nil).must_be_nil
35
- end
36
- it 'converts spaces to hyphens' do
37
- MongoidPermalinkExtension::Permalink.mongoize(" ").must_equal '-'
38
- MongoidPermalinkExtension::Permalink.mongoize(" ").must_equal '-'
39
- end
40
- it 'converts to camel case' do
41
- MongoidPermalinkExtension::Permalink.mongoize("hello hello").wont_include 'h'
42
- end
43
- it 'converts all dashes to hyphens' do
44
- MongoidPermalinkExtension::Permalink.mongoize("–").must_equal '-'
45
- MongoidPermalinkExtension::Permalink.mongoize("—").must_equal '-'
46
- end
47
- it 'remove non-alphanumeric characters' do
48
- %w(?!@#$%^&*()+=/.,;<>[]).shuffle.each do |i|
49
- MongoidPermalinkExtension::Permalink.mongoize(i).wont_include i
50
- end
51
- end
52
- it 'preserves accented characters' do
53
- MongoidPermalinkExtension::Permalink.mongoize('Bienále Brno Česká republika').must_equal 'Bienale-Brno-Ceska-Republika'
54
- end
55
- it 'produces nice slugs' do
56
- MongoidPermalinkExtension::Permalink.mongoize('Future Vocabularies?').must_equal 'Future-Vocabularies'
57
- MongoidPermalinkExtension::Permalink.mongoize('2011 space odyssey').must_equal '2011-Space-Odyssey'
58
- MongoidPermalinkExtension::Permalink.mongoize('A permalink with & in it').must_equal 'A-Permalink-With-In-It'
24
+ # ---------------------------------------------------------------------
25
+
26
+ describe '.mongoize' do
27
+ it 'converts anything to string' do
28
+ MongoidPermalinkExtension::Permalink.mongoize(12).must_equal '12'
29
+ end
30
+ it 'stores transformed string' do
31
+ MongoidPermalinkExtension::Permalink.mongoize("some some").must_be :present?
32
+ end
33
+ it 'stores nil if nil passed' do
34
+ MongoidPermalinkExtension::Permalink.mongoize(nil).must_be_nil
35
+ end
36
+ it 'converts spaces to hyphens' do
37
+ MongoidPermalinkExtension::Permalink.mongoize(" ").must_equal '-'
38
+ MongoidPermalinkExtension::Permalink.mongoize(" ").must_equal '-'
39
+ end
40
+ it 'converts slashes to hyphens' do
41
+ MongoidPermalinkExtension::Permalink.mongoize("/").must_equal '-'
42
+ end
43
+ it 'converts to camel case' do
44
+ MongoidPermalinkExtension::Permalink.mongoize("hello hello").wont_include 'h'
45
+ end
46
+ it 'converts all dashes to hyphens' do
47
+ MongoidPermalinkExtension::Permalink.mongoize("–").must_equal '-'
48
+ MongoidPermalinkExtension::Permalink.mongoize("—").must_equal '-'
49
+ end
50
+ it 'remove non-alphanumeric characters' do
51
+ %w(?!@#$%^&*()+=.,;<>[]).shuffle.each do |i|
52
+ MongoidPermalinkExtension::Permalink.mongoize(i).wont_include i
59
53
  end
60
54
  end
61
-
55
+ it 'preserves accented characters' do
56
+ MongoidPermalinkExtension::Permalink.mongoize('Bienále Brno Česká republika').must_equal 'Bienale-Brno-Ceska-Republika'
57
+ end
58
+ it 'produces nice slugs' do
59
+ MongoidPermalinkExtension::Permalink.mongoize('Future Vocabularies?').must_equal 'Future-Vocabularies'
60
+ MongoidPermalinkExtension::Permalink.mongoize('2011 space odyssey').must_equal '2011-Space-Odyssey'
61
+ MongoidPermalinkExtension::Permalink.mongoize('A permalink with & in it').must_equal 'A-Permalink-With-In-It'
62
+ end
62
63
  end
63
- end
64
+ end
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.2
4
+ version: 0.0.3
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-01-04 00:00:00.000000000 Z
11
+ date: 2015-06-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mongoid
@@ -165,7 +165,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
165
165
  version: '0'
166
166
  requirements: []
167
167
  rubyforge_project:
168
- rubygems_version: 2.2.2
168
+ rubygems_version: 2.4.8
169
169
  signing_key:
170
170
  specification_version: 4
171
171
  summary: Custom field type for Mongoid that automatically converts strings to URL