wulffeld_slug 0.0.7 → 0.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.7
1
+ 0.0.8
@@ -6,7 +6,7 @@ module WulffeldSlug
6
6
  field :slug
7
7
  end
8
8
 
9
- validates_presence_of :slug
9
+ validates_format_of :slug, :with => /\A[[:alnum:]]+\Z/, :allow_blank => false
10
10
 
11
11
  before_validation :on => :create do
12
12
  cb_make_slug
@@ -34,6 +34,7 @@ module WulffeldSlug
34
34
 
35
35
  def to_unique_slug(s, n=nil)
36
36
  str_part = prepare_string(s)
37
+ str_part = self.id.to_s if str_part.blank?
37
38
 
38
39
  loop do
39
40
  slug = [str_part, n].compact.join('-')
@@ -80,9 +81,7 @@ module WulffeldSlug
80
81
  # Convert spaces to dashes.
81
82
  s.gsub!(/[^a-zA-Z0-9]+/i, '-')
82
83
  words = s.split('-').reject {|w| w.blank? }
83
- s = words.each { |word| word.sub!(/^[a-z]/) {|m| slug_config[:capitalize] ? m.tr('a-z', 'A-Z') : m} }.join('-')
84
-
85
- new_slug = s.blank? ? orig : s
84
+ new_slug = words.each { |word| word.sub!(/^[a-z]/) {|m| slug_config[:capitalize] ? m.tr('a-z', 'A-Z') : m} }.join('-')
86
85
  new_slug = new_slug[0..239]
87
86
  end
88
87
  end
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{wulffeld_slug}
8
- s.version = "0.0.7"
8
+ s.version = "0.0.8"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Martin Moen Wulffeld"]
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wulffeld_slug
3
3
  version: !ruby/object:Gem::Version
4
- hash: 17
4
+ hash: 15
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 7
10
- version: 0.0.7
9
+ - 8
10
+ version: 0.0.8
11
11
  platform: ruby
12
12
  authors:
13
13
  - Martin Moen Wulffeld