rsl-stringex 1.0.1 → 1.0.2

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.
@@ -73,15 +73,13 @@ module LuckySneaks
73
73
  conditions << send(self.class.scope_for_url)
74
74
  end
75
75
  url_owners = self.class.find(:all, :conditions => conditions)
76
- if url_owners.size > 0
77
- return unless url_owners.map { |o| o.send(url_attribute) }.include?(base_url)
76
+ write_attribute url_attribute, base_url
77
+ if url_owners.any?{|owner| owner.send(url_attribute) == base_url}
78
78
  n = 1
79
- while url_owners.detect{|u| u.send(url_attribute) == "#{base_url}-#{n}"}
79
+ while url_owners.any?{|owner| owner.send(url_attribute) == "#{base_url}-#{n}"}
80
80
  n = n.succ
81
81
  end
82
82
  write_attribute url_attribute, "#{base_url}-#{n}"
83
- else
84
- write_attribute url_attribute, base_url
85
83
  end
86
84
  end
87
85
  end
data/stringex.gemspec CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{stringex}
5
- s.version = "1.0.1"
5
+ s.version = "1.0.2"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Russell Norris"]
9
- s.date = %q{2009-07-20}
9
+ s.date = %q{2009-08-19}
10
10
  s.description = %q{Some [hopefully] useful extensions to Ruby’s String class. Stringex is made up of three libraries: ActsAsUrl [permalink solution with better character translation], Unidecoder [Unicode to Ascii transliteration], and StringExtensions [miscellaneous helper methods for the String class].}
11
11
  s.email = %q{rsl@luckysneaks.com}
12
12
  s.extra_rdoc_files = [
@@ -204,12 +204,11 @@ Gem::Specification.new do |s|
204
204
  "lib/stringex.rb",
205
205
  "stringex.gemspec"
206
206
  ]
207
- s.has_rdoc = true
208
207
  s.homepage = %q{http://github.com/rsl/stringex}
209
208
  s.rdoc_options = ["--main", "README.rdoc", "--charset", "utf-8", "--line-numbers"]
210
209
  s.require_paths = ["lib"]
211
210
  s.rubyforge_project = %q{stringex}
212
- s.rubygems_version = %q{1.3.2}
211
+ s.rubygems_version = %q{1.3.5}
213
212
  s.summary = %q{Some [hopefully] useful extensions to Ruby’s String class}
214
213
  s.test_files = [
215
214
  "test/acts_as_url_test.rb",
@@ -109,6 +109,14 @@ class ActsAsUrlTest < Test::Unit::TestCase
109
109
  assert_equal "twonique-1", @other_doc2.url
110
110
  end
111
111
 
112
+ def test_should_create_unique_url_when_partial_url_already_exists
113
+ @doc = Document.create!(:title => "House Farms")
114
+ @other_doc = Document.create!(:title => "House Farm")
115
+
116
+ assert_equal "house-farms", @doc.url
117
+ assert_equal "house-farm", @other_doc.url
118
+ end
119
+
112
120
  def test_should_scope_uniqueness
113
121
  @moc = Mocument.create!(:title => "Mocumentary", :other => "I dunno why but I don't care if I'm unique")
114
122
  @other_moc = Mocument.create!(:title => "Mocumentary")
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rsl-stringex
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Russell Norris
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-07-20 00:00:00 -07:00
12
+ date: 2009-08-19 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -212,7 +212,7 @@ files:
212
212
  - lib/lucky_sneaks/unidecoder_data/xff.yml
213
213
  - lib/stringex.rb
214
214
  - stringex.gemspec
215
- has_rdoc: true
215
+ has_rdoc: false
216
216
  homepage: http://github.com/rsl/stringex
217
217
  licenses:
218
218
  post_install_message: