rand62 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +20 -5
- data/lib/rand62/version.rb +1 -1
- data/rand62.gemspec +1 -1
- metadata +2 -2
data/README.md
CHANGED
@@ -7,7 +7,7 @@ Rand62.safe(10)
|
|
7
7
|
=> "yTX35RzROS"
|
8
8
|
```
|
9
9
|
|
10
|
-
|
10
|
+
Rand62 has better space efficiency than `SecureRandom.uuid` or `SecureRandom.hex`. It's sexier than `SecureRandom.base64` or `SecureRandom.urlsafe_base64` as it doesn't contain any symbols.
|
11
11
|
|
12
12
|
If you care more about database efficiency than Ruby, and user-friendliness of the look of IDs, use Rand62.
|
13
13
|
|
@@ -15,21 +15,27 @@ If you care more about database efficiency than Ruby, and user-friendliness of t
|
|
15
15
|
|
16
16
|
Add this line to your application's Gemfile:
|
17
17
|
|
18
|
-
|
18
|
+
```ruby
|
19
|
+
gem 'rand62'
|
20
|
+
```
|
19
21
|
|
20
22
|
And then execute:
|
21
23
|
|
22
|
-
|
24
|
+
```sh
|
25
|
+
$ bundle
|
26
|
+
```
|
23
27
|
|
24
28
|
Or install it yourself as:
|
25
29
|
|
26
|
-
|
30
|
+
```sh
|
31
|
+
$ gem install rand62
|
32
|
+
```
|
27
33
|
|
28
34
|
## Usage
|
29
35
|
|
30
36
|
There are two methods: `fast` and `safe`.
|
31
37
|
|
32
|
-
* **safe** - It has less chance of collision, as internally it uses `SecureRandom`. Use this method until the performance
|
38
|
+
* **safe** - It has less chance of collision, as internally it uses `SecureRandom`. Use this method until the performance becomes a real problem.
|
33
39
|
* **fast** - About 10x faster than `safe` on Mac, but be careful as internally it uses rand().
|
34
40
|
|
35
41
|
```ruby
|
@@ -40,6 +46,15 @@ Rand62.safe(10)
|
|
40
46
|
=> "yTX35RzROS"
|
41
47
|
```
|
42
48
|
|
49
|
+
## Performance
|
50
|
+
|
51
|
+
The following test results came from ruby 1.9.3p125 on iMac 2011 Core i5 2.7GHz.
|
52
|
+
|
53
|
+
```ruby
|
54
|
+
Rand62.fast(1000): 0.000654
|
55
|
+
Rand62.safe(1000): 0.007871
|
56
|
+
```
|
57
|
+
|
43
58
|
## Contributing
|
44
59
|
|
45
60
|
1. Fork it
|
data/lib/rand62/version.rb
CHANGED
data/rand62.gemspec
CHANGED
@@ -6,7 +6,7 @@ Gem::Specification.new do |gem|
|
|
6
6
|
gem.email = ["kenn.ejima@gmail.com"]
|
7
7
|
gem.description = %q{Generates random alphanumeric characters}
|
8
8
|
gem.summary = %q{Generates random alphanumeric characters}
|
9
|
-
gem.homepage = ""
|
9
|
+
gem.homepage = "https://github.com/kenn/rand62"
|
10
10
|
|
11
11
|
gem.files = `git ls-files`.split($\)
|
12
12
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rand62
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -28,7 +28,7 @@ files:
|
|
28
28
|
- lib/rand62/version.rb
|
29
29
|
- rand62.gemspec
|
30
30
|
- test/test_rand62.rb
|
31
|
-
homepage:
|
31
|
+
homepage: https://github.com/kenn/rand62
|
32
32
|
licenses: []
|
33
33
|
post_install_message:
|
34
34
|
rdoc_options: []
|