Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Updated Rakefile

  • Loading branch information...
commit ff1eb0c8ee8204ca69d005568a8ead949ca78f2f 1 parent b66a4c9
rrevans authored
Showing with 8 additions and 5 deletions.
  1. +1 −1  Rakefile
  2. +3 −1 TODO
  3. +4 −3 lib/permalizer.rb
View
2  Rakefile
@@ -3,7 +3,7 @@ require 'rake/gempackagetask'
PLUGIN = "permalizer"
NAME = "permalizer"
-VERSION = "0.0.5"
+VERSION = "0.0.6"
AUTHOR = "Robert R Evans"
EMAIL = "revans@robertrevans.com"
HOMEPAGE = "http://robertrevans.com"
View
4 TODO
@@ -1 +1,3 @@
-Add in Support for more languages that iconv doesn't support.
+Add in Support for more languages that iconv doesn't support.
+
+Add Ruby 1.9 string encoding support for fun.
View
7 lib/permalizer.rb
@@ -4,9 +4,9 @@
module Permalizer
# permalize! is a destructive method that will make the given string for use as a clean URL
- # <tt>example:</tt>
- # blog.title = "My Cool Merb Plugin!"
- # blog.title.permalize! # => "my-cool-merb-plugin"
+ # example:
+ # blog.title = "My Cool Gem!"
+ # blog.title.permalize! # => "my-cool-gem"
#
def permalize!
permalink!(self)
@@ -25,6 +25,7 @@ def permalize
# permalink!
# Fix unicode characters, regex unwanted characters, split string, thus removing all whitespace, join it, and downcase it
#
+ # TODO: Ruby 1.9 string encoding
def permalink!(word)
(Iconv.new('US-ASCII//TRANSLIT', 'utf-8').iconv word).gsub(/[^\w\s\-\—]/,'').gsub(/[^\w]|[\_]/,' ').split.join('-').downcase
end
Please sign in to comment.
Something went wrong with that request. Please try again.