1
0
mirror of https://github.com/danbee/slugtastic synced 2025-03-04 08:49:05 +00:00

Fixed minor bug when the source field is empty.

This commit is contained in:
Dan Barber 2011-10-08 12:32:20 +01:00
parent fc2071e13e
commit c6207af494
3 changed files with 5 additions and 5 deletions

View File

@ -2,7 +2,7 @@ require 'rubygems'
require 'rake' require 'rake'
require 'echoe' require 'echoe'
Echoe.new('slugtastic', '0.1.1') do |p| Echoe.new('slugtastic', '0.1.2') do |p|
p.description = "A simple slug string generator for ActiveRecord. Will populate a slug attribute from another attribute." p.description = "A simple slug string generator for ActiveRecord. Will populate a slug attribute from another attribute."
p.url = "http://github.com/danbee/slugtastic" p.url = "http://github.com/danbee/slugtastic"
p.author = "Dan Barber" p.author = "Dan Barber"

View File

@ -4,7 +4,7 @@ module Slugtastic
end end
def generate_slug(string) def generate_slug(string)
string.downcase.gsub(/ /, '_').gsub(/[^a-z0-9\-_]/, '') string.downcase.gsub(/ /, '_').gsub(/[^a-z0-9\-_]/, '') unless string.nil?
end end
module ClassMethods module ClassMethods

View File

@ -2,15 +2,15 @@
Gem::Specification.new do |s| Gem::Specification.new do |s|
s.name = %q{slugtastic} s.name = %q{slugtastic}
s.version = "0.1.1" s.version = "0.1.2"
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version= s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
s.authors = [%q{Dan Barber}] s.authors = [%q{Dan Barber}]
s.date = %q{2011-10-04} s.date = %q{2011-10-08}
s.description = %q{A simple slug string generator for ActiveRecord. Will populate a slug attribute from another attribute.} s.description = %q{A simple slug string generator for ActiveRecord. Will populate a slug attribute from another attribute.}
s.email = %q{danbee@gmail.com} s.email = %q{danbee@gmail.com}
s.extra_rdoc_files = [%q{README.md}, %q{lib/slugtastic.rb}] s.extra_rdoc_files = [%q{README.md}, %q{lib/slugtastic.rb}]
s.files = [%q{README.md}, %q{Rakefile}, %q{lib/slugtastic.rb}, %q{Manifest}, %q{slugtastic.gemspec}] s.files = [%q{Manifest}, %q{README.md}, %q{Rakefile}, %q{lib/slugtastic.rb}, %q{slugtastic.gemspec}]
s.homepage = %q{http://github.com/danbee/slugtastic} s.homepage = %q{http://github.com/danbee/slugtastic}
s.rdoc_options = [%q{--line-numbers}, %q{--inline-source}, %q{--title}, %q{Slugtastic}, %q{--main}, %q{README.md}] s.rdoc_options = [%q{--line-numbers}, %q{--inline-source}, %q{--title}, %q{Slugtastic}, %q{--main}, %q{README.md}]
s.require_paths = [%q{lib}] s.require_paths = [%q{lib}]