hashtrain-acts_as_random_id 1.0.0 → 1.0.1

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.
Files changed (5) hide show
  1. data/README.rdoc +49 -0
  2. data/Rakefile +3 -3
  3. data/lib/acts_as_random_id.rb +1 -1
  4. metadata +3 -3
  5. data/README +0 -22
data/README.rdoc ADDED
@@ -0,0 +1,49 @@
1
+ =ActsAsRandomId
2
+
3
+ Generating unique random id for ActiveRecord models
4
+
5
+ ==Example
6
+
7
+ class Comment < ActiveRecord::Base
8
+ acts_as_random_id
9
+ end
10
+
11
+ class Group < ActiveRecord::Base
12
+ acts_as_random_id do
13
+ rand(3_14159265) + 1
14
+ end
15
+ end
16
+
17
+ class Article < ActiveRecord::Base
18
+ acts_as_random_id do
19
+ Time.now.to_i
20
+ end
21
+ end
22
+
23
+ ==Install
24
+
25
+ gem install hashtrain-acts_as_random_id --source http://gems.github.com
26
+
27
+ ==Usage
28
+
29
+ As you know rails generates field ID easy auto_incriment. Thus, there is an opportunity to check how many objects in the DB. Sometimes it's secret information.
30
+
31
+ Using the plugin "acts_as_random_id" could generate a unique value id. Generation of ID will be until you will find a unique value ID. Of course you go to the full responsibility for the range.
32
+
33
+ By default, the plugin "acts_as_random_id" generates a unique id in the range of 1 to 2_147_483_647 (mysql and SQLite type integer)
34
+
35
+ class Comment < ActiveRecord::Base
36
+ acts_as_random_id
37
+ end
38
+
39
+ You can specify a range of transfer method "acts_as_random_id" block where the generator is implemented
40
+
41
+ class Group < ActiveRecord::Base
42
+ acts_as_random_id do
43
+ rand(3_14159265) + 1
44
+ end
45
+ end
46
+
47
+ ==License
48
+
49
+ Copyright (c) 2009 hashtrain.com and author idea Stanislav Pogrebnyak (stanislav.pogrebnyak@gmail.com), released under the MIT license.
data/Rakefile CHANGED
@@ -22,7 +22,7 @@ Rake::RDocTask.new(:rdoc) do |rdoc|
22
22
  rdoc.rdoc_dir = 'rdoc'
23
23
  rdoc.title = 'ActsAsRandomId'
24
24
  rdoc.options << '--line-numbers' << '--inline-source'
25
- rdoc.rdoc_files.include('README')
25
+ rdoc.rdoc_files.include('README.rdoc')
26
26
  rdoc.rdoc_files.include('lib/**/*.rb')
27
27
  end
28
28
 
@@ -38,7 +38,7 @@ PKG_FILES = FileList[
38
38
 
39
39
  spec = Gem::Specification.new do |s|
40
40
  s.name = "acts_as_random_id"
41
- s.version = "1.0.0"
41
+ s.version = "1.0.1"
42
42
  s.author = "hashtrain.com and author idea Stanislav Pogrebnyak (stanislav.pogrebnyak@gmail.com)"
43
43
  s.email = "mail@hashtrain.com"
44
44
  s.homepage = "http://github.com/hashtrain/acts_as_random_id/"
@@ -47,7 +47,7 @@ spec = Gem::Specification.new do |s|
47
47
  s.files = PKG_FILES.to_a
48
48
  s.require_path = "lib"
49
49
  s.has_rdoc = false
50
- s.extra_rdoc_files = ["README"]
50
+ s.extra_rdoc_files = ["README.rdoc"]
51
51
  end
52
52
 
53
53
  desc 'Turn this plugin into a gem.'
@@ -17,7 +17,7 @@ module ActsAsRandomId
17
17
  record.ensure_unique_id(&block)
18
18
  else
19
19
  record.ensure_unique_id do
20
- rand(2_147_483_647) + 1 #- mysql type "int 4 bytes"
20
+ rand(2_147_483_647) + 1 # mysql and SQLite type integer
21
21
  end
22
22
  end
23
23
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hashtrain-acts_as_random_id
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - hashtrain.com
@@ -21,11 +21,11 @@ executables: []
21
21
  extensions: []
22
22
 
23
23
  extra_rdoc_files:
24
- - README
24
+ - README.rdoc
25
25
  files:
26
26
  - MIT-LICENSE
27
27
  - Rakefile
28
- - README
28
+ - README.rdoc
29
29
  - lib/acts_as_random_id.rb
30
30
  - test/acts_as_random_id_test.rb
31
31
  - test/schema.rb
data/README DELETED
@@ -1,22 +0,0 @@
1
- ActsAsRandomId
2
- =============
3
-
4
- Generating unique random id for ActiveRecord models
5
-
6
-
7
- Example
8
- =======
9
-
10
- class Comment < ActiveRecord::Base
11
- acts_as_random_id
12
- end
13
-
14
- class Group < ActiveRecord::Base
15
- acts_as_random_id :generator => :auto_increment
16
- end
17
-
18
- class Article < ActiveRecord::Base
19
- acts_as_random_id :generator => Proc.new { Time.now.to_i }
20
- end
21
-
22
- Copyright (c) 2009 hashtrain.com and author idea Stanislav Pogrebnyak (stanislav.pogrebnyak@gmail.com), released under the MIT license