mongoid_permalink_extension 0.1.0 → 0.1.1

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: 20106137c1575960c55057f118d9b79d52f559d4
4
- data.tar.gz: 71e2921b9cc9627ba67ce545fb9c719f08fbc894
3
+ metadata.gz: afa92956e8ef6a3711242da5394ab3038cc67018
4
+ data.tar.gz: febc6cd2b8d1e6ac4c6af461dde98803d747bf17
5
5
  SHA512:
6
- metadata.gz: 60004b96fd19615febca960165d0f04fa93d9bcfa62791b30ea0aaae695a1a85d73838a9c2511738987633a28e07d75784852eace8c25fe8b4cff484a3d23969
7
- data.tar.gz: 71a0aba633340095bfd6d7c19386ac72aca7d96e684732ef34759153edec07938644a2b5a4415adc83a5d43fc67bd309f59686b920015dbc2edda93f7f7b53ef
6
+ metadata.gz: 835869deffcb225a7c79497637521612f9a6f04fdf183d56ad9bfc34555759f05f4c7aaee5bf18dfa401a3b5a99a41594e7d0f42d83a8f35c4356084ba90ea24
7
+ data.tar.gz: b628f68a4374240bd153783b52dba029974adcb53aa5e2ceab5a663a5e865d7c753c817d6bf064fd002daabea1c635ff6bb699c2d996ec4778f9481632992ab6
data/.gitignore CHANGED
@@ -15,3 +15,4 @@ spec/reports
15
15
  test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
+ .DS_Store
@@ -20,6 +20,7 @@ module MongoidPermalinkExtension
20
20
  gsub(/[^\p{Alnum} -]/, '').
21
21
  gsub(/\s+/, '-').
22
22
  gsub(/[-]+/, '-').
23
+ gsub(/\A\-/, '').
23
24
  gsub(/\b\w/){ $&.upcase }.
24
25
  to_ascii
25
26
  end
@@ -1,3 +1,3 @@
1
1
  module MongoidPermalinkExtension
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -34,11 +34,11 @@ describe MongoidPermalinkExtension::Permalink do
34
34
  MongoidPermalinkExtension::Permalink.mongoize(nil).must_be_nil
35
35
  end
36
36
  it 'converts spaces to hyphens' do
37
- MongoidPermalinkExtension::Permalink.mongoize(" ").must_equal '-'
38
- MongoidPermalinkExtension::Permalink.mongoize(" ").must_equal '-'
37
+ MongoidPermalinkExtension::Permalink.mongoize("A B").must_equal 'A-B'
38
+ MongoidPermalinkExtension::Permalink.mongoize("A B").must_equal 'A-B'
39
39
  end
40
40
  it 'converts slashes to hyphens' do
41
- MongoidPermalinkExtension::Permalink.mongoize("/").must_equal '-'
41
+ MongoidPermalinkExtension::Permalink.mongoize("A/B").must_equal 'A-B'
42
42
  end
43
43
  it 'converts to camel case' do
44
44
  MongoidPermalinkExtension::Permalink.mongoize("hello hello").wont_include 'h'
@@ -56,16 +56,20 @@ describe MongoidPermalinkExtension::Permalink do
56
56
  MongoidPermalinkExtension::Permalink.mongoize("Camel--Case").must_equal 'Camel-Case'
57
57
  end
58
58
  it 'converts all dashes to hyphens' do
59
- MongoidPermalinkExtension::Permalink.mongoize("–").must_equal '-'
60
- MongoidPermalinkExtension::Permalink.mongoize("----–").must_equal '-'
61
- MongoidPermalinkExtension::Permalink.mongoize("—").must_equal '-'
62
- MongoidPermalinkExtension::Permalink.mongoize("—––––––").must_equal '-'
59
+ MongoidPermalinkExtension::Permalink.mongoize("AZ").must_equal 'A-Z'
60
+ MongoidPermalinkExtension::Permalink.mongoize("A----–Z").must_equal 'A-Z'
61
+ MongoidPermalinkExtension::Permalink.mongoize("AZ").must_equal 'A-Z'
62
+ MongoidPermalinkExtension::Permalink.mongoize("A—––––––Z").must_equal 'A-Z'
63
63
  end
64
64
  it 'remove non-alphanumeric characters' do
65
- %w(?!@#$%^&*()+=.,;<>[]).shuffle.each do |i|
65
+ %w(?!@#$%^&*()+=.,;<>[]“”).shuffle.each do |i|
66
66
  MongoidPermalinkExtension::Permalink.mongoize(i).wont_include i
67
67
  end
68
68
  end
69
+ it 'does not start with a hyphen' do
70
+ MongoidPermalinkExtension::Permalink.mongoize("“Yes” to a Historic Moment").must_equal "Yes-To-A-Historic-Moment"
71
+ MongoidPermalinkExtension::Permalink.mongoize("¿Yes?").must_equal "Yes"
72
+ end
69
73
  it 'preserves accented characters' do
70
74
  MongoidPermalinkExtension::Permalink.mongoize('Bienále Brno Česká republika').must_equal 'Bienale-Brno-Ceska-Republika'
71
75
  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.1.0
4
+ version: 0.1.1
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-10-03 00:00:00.000000000 Z
11
+ date: 2015-10-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mongoid