ploymorphic_wuid 0.5.1 → 0.5.2

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.1
1
+ 0.5.2
@@ -1,9 +1,11 @@
1
1
  class Wuid < ActiveRecord::Base
2
2
 
3
+ RAND_TOKEN_SIZE = 11
4
+
3
5
  belongs_to :wuidable, :polymorphic => true
4
6
 
5
7
  before_validation do |record|
6
- record.rand_token = RandGen.generate
8
+ record.rand_token = RandGen.generate(RAND_TOKEN_SIZE)
7
9
  end
8
10
 
9
11
  validates_uniqueness_of :rand_token
@@ -26,9 +28,8 @@ class Wuid < ActiveRecord::Base
26
28
  when 0
27
29
  raise "Couldn't find #{name} without an ID"
28
30
  when 1
29
- if args[0].is_a?(Integer) || (args[0].is_a?(String) && args[0] =~ /^\d{1,}$/)
30
- raise "Don't support simple digest id any more"
31
- #super
31
+ if args[0].to_s.size != RAND_TOKEN_SIZE
32
+ raise "Wuid format error"
32
33
  else
33
34
  if args[0].is_a?(Array)
34
35
  if args[0].all?{|i| i.is_a?(Integer)} || args[0].all?{|i| i=~ /^\d{1,}$/}
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{ploymorphic_wuid}
8
- s.version = "0.5.1"
8
+ s.version = "0.5.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["tim.teng"]
12
- s.date = %q{2010-06-25}
12
+ s.date = %q{2010-07-30}
13
13
  s.description = %q{ This is a gem to generate an unique id in your application world.}
14
14
  s.email = %q{tim.rubist@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -26,7 +26,6 @@ Gem::Specification.new do |s|
26
26
  "lib/wuid/ploymorphic_module.rb",
27
27
  "lib/wuid/rand_gen.rb",
28
28
  "lib/wuid/wuid.rb",
29
- "pkg/ploymorphic_wuid-0.5.1.gem",
30
29
  "ploymorphic_wuid.gemspec",
31
30
  "test/helper.rb",
32
31
  "test/test_ploymorphic_wuid.rb"
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 5
8
- - 1
9
- version: 0.5.1
8
+ - 2
9
+ version: 0.5.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - tim.teng
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-06-25 00:00:00 +08:00
17
+ date: 2010-07-30 00:00:00 +08:00
18
18
  default_executable:
19
19
  dependencies: []
20
20
 
@@ -37,7 +37,6 @@ files:
37
37
  - lib/wuid/ploymorphic_module.rb
38
38
  - lib/wuid/rand_gen.rb
39
39
  - lib/wuid/wuid.rb
40
- - pkg/ploymorphic_wuid-0.5.1.gem
41
40
  - ploymorphic_wuid.gemspec
42
41
  - test/helper.rb
43
42
  - test/test_ploymorphic_wuid.rb