random-utils 0.2.2

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.
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ NzAxMzU2NjZlOTZkZjNjMDI1ZWU3NWQ2MDU5ZDFjOTMyNzM3YTc3NQ==
5
+ data.tar.gz: !binary |-
6
+ OTFhMjMxOTY4OTc0ZmZlOGRjNmI3ZjQ3ZjFiNTYyZTA2ZDZmMzFkMA==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ ZDhjYmYxZjJmNTA3YWVlY2I3MzU4OTU3NmY2MmRjNTlmNzZmZmM2YWNiZDkz
10
+ NWUzNTQ2M2MzNWJmZDM0YjE5ZWM2YWI4NmFjYjRkY2FmOTQ0YmY5NzQ5OTI0
11
+ MTBlYWM2MjU2MTkzNmY4YzMwMjg5NzgwOWUyYzdjM2RhZmJmZTc=
12
+ data.tar.gz: !binary |-
13
+ NzFiMDRlNmFkZjAxZTdlNzJlMjNjOWRjYmFlNjgzN2QxOWY5Y2Y4NzViMDQx
14
+ YjJjOTZhNjU3NzkyMGIwM2EwNGJiOWQxMTFlZWE0MjM3OGQ1ZjEyZDNhMmQz
15
+ MWJkOGFjMWUzZTNkYWI2NTFkOTA1MDdjNmZiZTA3MGI5ZDI0YjA=
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2013 Christian Tschoepe
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,4 @@
1
+ random-utils
2
+ ============
3
+
4
+ Some Utility methods for random numbers that makes generating huge ranges of random numbers faster and more efficient.
@@ -0,0 +1,27 @@
1
+ # Returns a number >= min, but <= max
2
+ def random min, max, options={}
3
+ rand(max - min) + min
4
+ end
5
+
6
+ # Returns a random upper or lowercase letter
7
+ def rand_let options={}
8
+ uppercase = random(0, 2) == 1
9
+ uppercaseLet = random(65, 91).chr
10
+ letter = (uppercase) ? (uppercaseLet) : (uppercaseLet.downcase)
11
+ letter
12
+ end
13
+
14
+ # Returns a random phone number w/ an area code of 210 (no international prefixes)
15
+ def rand_phone options={}
16
+ "210#{random(1111111, 9999999).to_s}"
17
+ end
18
+
19
+ # Gets a random <i>length</i> (default 36) character string consisting of uppercase and lowercase
20
+ # letters and numbers 0-9
21
+ def rand_token length=36
22
+ token = ''
23
+ length.times do
24
+ token += (random(0, 2)==1) ? (random(0,10).to_s) : (rand_let())
25
+ end
26
+ token
27
+ end
Binary file
@@ -0,0 +1,15 @@
1
+ Gem::Specification.new do |s|
2
+ files = Dir['lib/*.rb'] + Dir['bin/*'] + Dir['[A-Z]*'] + Dir['test/**/*']
3
+ files.reject { |fn| fn.include? "CVS" }
4
+
5
+ s.name = 'random-utils'
6
+ s.version = '0.2.2'
7
+ s.date = Time.now.strftime("%F")
8
+ s.summary = "Fast and Efficient helper methods!"
9
+ s.description = "Efficient random number and alpha-numeric string ('tokens') utilities"
10
+ s.author = 'thejava'
11
+ s.email = 'tschoepe.christian@gmail.com'
12
+ s.files = files
13
+ s.license = 'MIT'
14
+ #s.homepage = 'https://rubygems.org/gems/example'
15
+ end
metadata ADDED
@@ -0,0 +1,48 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: random-utils
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.2
5
+ platform: ruby
6
+ authors:
7
+ - thejava
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-08-12 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Efficient random number and alpha-numeric string ('tokens') utilities
14
+ email: tschoepe.christian@gmail.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/random-utils.rb
20
+ - LICENSE
21
+ - random-utils-0.2.1.gem
22
+ - random-utils.gemspec
23
+ - README.md
24
+ homepage:
25
+ licenses:
26
+ - MIT
27
+ metadata: {}
28
+ post_install_message:
29
+ rdoc_options: []
30
+ require_paths:
31
+ - lib
32
+ required_ruby_version: !ruby/object:Gem::Requirement
33
+ requirements:
34
+ - - ! '>='
35
+ - !ruby/object:Gem::Version
36
+ version: '0'
37
+ required_rubygems_version: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ! '>='
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ requirements: []
43
+ rubyforge_project:
44
+ rubygems_version: 2.0.6
45
+ signing_key:
46
+ specification_version: 4
47
+ summary: Fast and Efficient helper methods!
48
+ test_files: []