Permalink
Browse files

fixed dependency references to work with Rails. Removed String extension

  • Loading branch information...
1 parent 19a977f commit 78aff62085e252ba4e5dca72844551de9183959f Ismael Celis committed Nov 5, 2008
View
@@ -4,7 +4,6 @@ PostInstall.txt
README.markdown
Rakefile
lib/sluggable_finder.rb
-lib/sluggable_finder/core_ext.rb
lib/sluggable_finder/finder.rb
lib/sluggable_finder/orm.rb
script/console
View
@@ -7,8 +7,8 @@ module SluggableFinder
class << self
def enable_activerecord
- ActiveRecord::Base.extend Finder
- ActiveRecord::Base.class_eval{include Orm}
+ ActiveRecord::Base.extend SluggableFinder::Finder
+ ActiveRecord::Base.class_eval{include SluggableFinder::Orm}
# support for associations
a = ActiveRecord::Associations
returning([ a::AssociationCollection ]) { |classes|
@@ -17,14 +17,19 @@ def enable_activerecord
classes << a::HasManyThroughAssociation
end
}.each do |klass|
- klass.send :include, Finder
+ klass.send :include, SluggableFinder::Finder
klass.class_eval { alias_method_chain :find, :slug }
end
end
end
+ def self.encode(str)
+ ActiveSupport::Multibyte::Handlers::UTF8Handler.
+ normalize(str,:d).split(//u).reject { |e| e.length > 1 }.join.strip.gsub(/[^a-z0-9]+/i, '-').downcase
+ end
+
end
require 'rubygems'
@@ -1,8 +0,0 @@
-require 'iconv'
-class String
- # Iconv use borrowed from http://svn.robertrevans.com/plugins/Permalize/
- # Thanks!
- def to_slug
- (Iconv.new('US-ASCII//TRANSLIT', 'utf-8').iconv self).gsub(/[^\w\s\-\—]/,'').gsub(/[^\w]|[\_]/,' ').split.join('-').downcase
- end
-end
@@ -78,9 +78,9 @@ def create_sluggable_slug
suffix = ''
begin
proposed_slug = if self.send(destination_column.to_sym).blank?
- self.send(source_column.to_sym).to_slug
+ SluggableFinder.encode self.send(source_column.to_sym)
else
- self.send(destination_column.to_sym).to_slug
+ SluggableFinder.encode self.send(destination_column.to_sym)
end
rescue Exception => e
raise e
View
@@ -7,7 +7,7 @@ Gem::Specification.new do |s|
s.date = %q{2008-11-04}
s.email = ["ismaelct@gmail.com"]
s.extra_rdoc_files = ["History.txt", "Manifest.txt", "PostInstall.txt", "README.markdown"]
- s.files = ["History.txt", "Manifest.txt", "PostInstall.txt", "README.markdown", "Rakefile", "lib/sluggable_finder.rb", "lib/sluggable_finder/core_ext.rb", "lib/sluggable_finder/finder.rb", "lib/sluggable_finder/orm.rb", "script/console", "script/destroy", "script/generate", "spec/sluggable_finder_spec.rb", "spec/spec.opts", "spec/spec_helper.rb", "tasks/rspec.rake", "tasks/db.rake"]
+ s.files = ["History.txt", "Manifest.txt", "PostInstall.txt", "README.markdown", "Rakefile", "lib/sluggable_finder.rb", "lib/sluggable_finder/finder.rb", "lib/sluggable_finder/orm.rb", "script/console", "script/destroy", "script/generate", "spec/sluggable_finder_spec.rb", "spec/spec.opts", "spec/spec_helper.rb", "tasks/rspec.rake", "tasks/db.rake"]
s.has_rdoc = false
s.post_install_message = %q{PostInstall.txt}
s.rdoc_options = ["--main", "README.markdown"]
@@ -104,7 +104,7 @@ class ScopedItem < Item
end
it "should turn them to english characters" do
- @item.to_param.should == "un-nandu-super-nono-ive-seen"
+ @item.to_param.should == "un-nandu-super-nono-i-ve-seen"
end
end

0 comments on commit 78aff62

Please sign in to comment.