has_handle_fallback 0.0.10 → 0.0.11

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -10,8 +10,9 @@ begin
10
10
  gem.email = "seamus@abshere.net"
11
11
  gem.homepage = "http://github.com/seamusabshere/has_handle_fallback"
12
12
  gem.authors = ["Seamus Abshere"]
13
+ gem.add_dependency 'activesupport', '>=2.3.4'
13
14
  gem.add_dependency 'activerecord', '>=2.3.4'
14
- gem.add_dependency 'validates_decency_of', '>=1.5.0'
15
+ gem.add_dependency 'validates_decency_of', '>=1.5.1'
15
16
  # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
16
17
  end
17
18
  Jeweler::GemcutterTasks.new
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.10
1
+ 0.0.11
@@ -1,3 +1,6 @@
1
+ require 'active_support'
2
+ begin; require 'active_support/core_ext/string/inflections'; rescue MissingSourceFile; end
3
+ require 'active_record'
1
4
  require 'validates_decency_of'
2
5
 
3
6
  module HasHandleFallback
@@ -8,9 +11,11 @@ module HasHandleFallback
8
11
  RECORD_ID_REGEXP = /\A\d+\z/
9
12
 
10
13
  def self.str2handle(str)
11
- str = str.to_s.gsub ANTI_REGEXP, ''
14
+ str = str.to_s.dup
15
+ str.gsub! ANTI_REGEXP, ''
16
+ str = str.underscore
12
17
  str << ('_' * (LENGTH_RANGE.min - str.length)) if str.length < LENGTH_RANGE.min
13
- str
18
+ str[0, LENGTH_RANGE.max]
14
19
  end
15
20
 
16
21
  module ActiveRecordBaseMethods
@@ -38,7 +38,7 @@ class TestHasHandleFallback < Test::Unit::TestCase
38
38
 
39
39
  def test_can_use_alternate_columns
40
40
  pierre = Cat.new :name => 'Pierre Bourdieu'
41
- assert_equal 'PierreBourdieu', pierre.handle
41
+ assert_equal 'pierre_bourdieu', pierre.handle
42
42
  end
43
43
 
44
44
  def test_can_in_fact_require_handle
@@ -54,7 +54,11 @@ class TestHasHandleFallback < Test::Unit::TestCase
54
54
  def test_validates_uniqueness_ignoring_case
55
55
  Person.create!(:email => 'pierre.bourdieu@example.com', :handle => 'Pierre-Bourdieu_99')
56
56
  b = Person.create(:email => 'pierre.bourdieu@example.com', :handle => 'PIERRE-BOURDIEU_99')
57
- assert_equal "isn't unique", b.errors.on(:handle)
57
+ if ActiveRecord::VERSION::MAJOR == 2
58
+ assert_equal "isn't unique", b.errors.on(:handle)
59
+ else
60
+ assert_equal "isn't unique", b.errors[:handle].first
61
+ end
58
62
  end
59
63
 
60
64
  def test_can_have_nil_handle
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 10
9
- version: 0.0.10
8
+ - 11
9
+ version: 0.0.11
10
10
  platform: ruby
11
11
  authors:
12
12
  - Seamus Abshere
@@ -14,11 +14,11 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-04-02 00:00:00 -04:00
17
+ date: 2010-04-07 00:00:00 -04:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
- name: activerecord
21
+ name: activesupport
22
22
  prerelease: false
23
23
  requirement: &id001 !ruby/object:Gem::Requirement
24
24
  requirements:
@@ -32,19 +32,33 @@ dependencies:
32
32
  type: :runtime
33
33
  version_requirements: *id001
34
34
  - !ruby/object:Gem::Dependency
35
- name: validates_decency_of
35
+ name: activerecord
36
36
  prerelease: false
37
37
  requirement: &id002 !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ segments:
42
+ - 2
43
+ - 3
44
+ - 4
45
+ version: 2.3.4
46
+ type: :runtime
47
+ version_requirements: *id002
48
+ - !ruby/object:Gem::Dependency
49
+ name: validates_decency_of
50
+ prerelease: false
51
+ requirement: &id003 !ruby/object:Gem::Requirement
38
52
  requirements:
39
53
  - - ">="
40
54
  - !ruby/object:Gem::Version
41
55
  segments:
42
56
  - 1
43
57
  - 5
44
- - 0
45
- version: 1.5.0
58
+ - 1
59
+ version: 1.5.1
46
60
  type: :runtime
47
- version_requirements: *id002
61
+ version_requirements: *id003
48
62
  description: Make it easy to use handles (callsigns/monikers/usernames) in URLs, even if they might be blank. Provides sensible validations and a find_by_id_or_handle method.
49
63
  email: seamus@abshere.net
50
64
  executables: []