safe_random 0.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.
- checksums.yaml +7 -0
- data/Gemfile +5 -0
- data/README.md +37 -0
- data/Rakefile +2 -0
- data/lib/safe_random/base.rb +18 -0
- data/lib/safe_random/constants.rb +5 -0
- data/lib/safe_random/version.rb +3 -0
- data/lib/safe_random.rb +4 -0
- metadata +79 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 11580dc6c0ef792353cad869f4fdd1a6d52e3da9396622966776d5fad2d10965
|
4
|
+
data.tar.gz: 5c0c2ebb3112f4d20ea8894e261244e5a0f1ea24ecaffbe66e8b3c1e00dd151d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 49a86bf5c595f9f4e59d8cb28982778beecc738ec4b4f08e18fdfeaf35b4c3a4fc9a3fe57da784a59fb2b5949980d51d929db723bac3cfdcd21bb8ced14f81c9
|
7
|
+
data.tar.gz: df27887c75914e9c7a6133b8ff972227fb2e86306cb1b2216c7dcc453db534c29ed04d9d862b180c66f57f1c6b78314a45afd07e1228aa6b9c8b2dd841f612b8
|
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
# SafeRandom
|
2
|
+
|
3
|
+
SafeRandom gem will help to generate random string, number and alphanumeric very easily.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'safe_random'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install safe_random
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
Try this snippet of code on ruby irb
|
22
|
+
|
23
|
+
require 'safe_random'
|
24
|
+
puts SafeRandom.number # => 44323547714622714350878229787161
|
25
|
+
puts SafeRandom.number(5) # => 54786
|
26
|
+
puts SafeRandom.string # => TrvzvDGrLUdrNRYHWyHcqcajqeWDvQSK
|
27
|
+
puts SafeRandom.string(5) # => qycdi
|
28
|
+
puts SafeRandom.alphanumeric # => PpHPUg1gPnsGD6RNDETsP3DAwm3sGqD3
|
29
|
+
puts SafeRandom.alphanumeric(5) # => rPtK2
|
30
|
+
|
31
|
+
## Contributing
|
32
|
+
|
33
|
+
1. Fork it ( https://github.com/[my-github-username]/safe_random/fork )
|
34
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
35
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
36
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
37
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
module SafeRandom
|
2
|
+
def self.number(_length = 32)
|
3
|
+
random(_length, Constants::SET_NUMBER)
|
4
|
+
end
|
5
|
+
|
6
|
+
def self.string(_length = 32, _case = nil)
|
7
|
+
random(_length, Constants::SET_STRING)
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.alphanumeric(_length = 32, _case = nil)
|
11
|
+
random(_length, Constants::SET_ALPHANUMBERIC)
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.random(len = 32, character_set)
|
15
|
+
chars = character_set.map { |x| x.is_a?(Range) ? x.to_a : x }.flatten
|
16
|
+
Array.new(len) { chars.sample }.join
|
17
|
+
end
|
18
|
+
end
|
data/lib/safe_random.rb
ADDED
metadata
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: safe_random
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Rahul Patil
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-10-29 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.6'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: ''
|
42
|
+
email:
|
43
|
+
- rahupatil_scs@yahoo.co.in
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- Gemfile
|
49
|
+
- README.md
|
50
|
+
- Rakefile
|
51
|
+
- lib/safe_random.rb
|
52
|
+
- lib/safe_random/base.rb
|
53
|
+
- lib/safe_random/constants.rb
|
54
|
+
- lib/safe_random/version.rb
|
55
|
+
homepage: ''
|
56
|
+
licenses:
|
57
|
+
- MIT
|
58
|
+
metadata: {}
|
59
|
+
post_install_message:
|
60
|
+
rdoc_options: []
|
61
|
+
require_paths:
|
62
|
+
- lib
|
63
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
68
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '0'
|
73
|
+
requirements: []
|
74
|
+
rubyforge_project:
|
75
|
+
rubygems_version: 2.7.7
|
76
|
+
signing_key:
|
77
|
+
specification_version: 4
|
78
|
+
summary: Safe Random
|
79
|
+
test_files: []
|