djanowski-permalink_fu 0.1.5 → 0.1.6

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.
@@ -8,7 +8,13 @@ end
8
8
  module PermalinkFu
9
9
 
10
10
  def self.escape(str)
11
- s = ActiveSupport::Multibyte::Handlers::UTF8Handler.normalize(str.to_s, :kd)
11
+ begin
12
+ s = ActiveSupport::Multibyte::Handlers::UTF8Handler.normalize(str.to_s, :kd)
13
+ rescue ActiveSupport::Multibyte::Handlers::EncodingError
14
+ require 'iconv'
15
+ s = Iconv.iconv('ascii//translit//IGNORE', 'utf-8', str).first.to_s
16
+ end
17
+
12
18
  s.gsub!(/[^\w -]+/n, '') # strip unwanted characters
13
19
  s.strip! # ohh la la
14
20
  s.downcase!
@@ -0,0 +1,4 @@
1
+ module PermalinkFu
2
+ module Spec
3
+ end
4
+ end
@@ -11,6 +11,11 @@ namespace :permalinks do
11
11
  models.each do |model|
12
12
  next unless model.respond_to?(:permalink_field)
13
13
 
14
+ if model.permalink_options.include?(:param)
15
+ puts "Skipping #{model} because it doesn't include the ID in #to_param."
16
+ next
17
+ end
18
+
14
19
  field = model.permalink_field
15
20
 
16
21
  objects = nil
@@ -19,9 +24,10 @@ namespace :permalinks do
19
24
  objects = model.find(:all, :conditions => {:permalink => nil}, :limit => 20)
20
25
 
21
26
  objects.each do |o|
27
+ puts "#{model} #{o.id}"
22
28
  o.send(:create_unique_permalink)
23
29
  value = o.send(model.permalink_field)
24
- puts "#{model} #{o.id} => #{value.inspect}"
30
+ puts "=> #{value.inspect}"
25
31
  model.update_all("#{field} = '#{value}'", "id = #{o.id}")
26
32
  end
27
33
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: djanowski-permalink_fu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Damian Janowski
@@ -24,6 +24,7 @@ extra_rdoc_files:
24
24
  files:
25
25
  - lib/permalink_fu/rake/tasks.rb
26
26
  - lib/permalink_fu/spec/matchers.rb
27
+ - lib/permalink_fu/spec.rb
27
28
  - lib/permalink_fu.rb
28
29
  - rails/tasks/permalink_fu.rake
29
30
  - init.rb