random_password_generator 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.
Potentially problematic release.
This version of random_password_generator might be problematic. Click here for more details.
- data/.gitignore +5 -0
- data/Gemfile +4 -0
- data/Rakefile +2 -0
- data/lib/random_password_generator.rb +22 -0
- data/lib/random_password_generator/version.rb +3 -0
- data/random_password_generator.gemspec +21 -0
- data/test/random_password_generator_test.rb +15 -0
- metadata +74 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
module RandomPasswordGenerator
|
2
|
+
# Generates a random password
|
3
|
+
# Arguments:
|
4
|
+
# +length+: The length of the password to be generated. Default value: 8
|
5
|
+
# +options+: Various options to generate password
|
6
|
+
# +:skip_lower_case+: Skips lower case alphabets if set to true
|
7
|
+
# +:skip_upper_case+: Skips upper case alphabets if set to true
|
8
|
+
# +:skip_numbers+: Skips numbers if set to true
|
9
|
+
# +:skip_symbols+: Skips symbols if set to true
|
10
|
+
# +:dont_exclude_unfrieldly_chars+: Does not skip commonly mistaken characters if set to true
|
11
|
+
def self.generate(length = 8, options = {})
|
12
|
+
chars = []
|
13
|
+
chars += ("a".."z").to_a unless options[:skip_lower_case]
|
14
|
+
chars += ("A".."Z").to_a unless options[:skip_upper_case]
|
15
|
+
chars += ("0".."9").to_a unless options[:skip_numbers]
|
16
|
+
chars += ["!", "@", "#", "$", "%", "^", "&", "(", ")", "{", "}", "[", "]", "-", "_", "<", ">", "?"] unless options[:skip_symbols]
|
17
|
+
# Skip easily mistaken characters
|
18
|
+
chars -= %w(i o 0 1 l !) unless options[:dont_exclude_unfrieldly_chars]
|
19
|
+
|
20
|
+
(1..length).collect{chars[rand(chars.size)]}.join
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "random_password_generator/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "random_password_generator"
|
7
|
+
s.version = RandomPasswordGenerator::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Satyaram B V"]
|
10
|
+
s.email = ["bvsatyaram AT gmail DOT com"]
|
11
|
+
s.homepage = ""
|
12
|
+
s.summary = %q{Random password generator}
|
13
|
+
s.description = %q{Generates a random password with variuos useful options}
|
14
|
+
|
15
|
+
s.rubyforge_project = "random_password_generator"
|
16
|
+
|
17
|
+
s.files = `git ls-files`.split("\n")
|
18
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
19
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
|
+
s.require_paths = ["lib"]
|
21
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
$:.unshift File.join(File.dirname(__FILE__),'..','lib')
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require 'random_password_generator'
|
5
|
+
|
6
|
+
class RandomPasswordGeneratorTest < Test::Unit::TestCase
|
7
|
+
def test_generate
|
8
|
+
password = RandomPasswordGenerator.generate
|
9
|
+
assert password.is_a?(String)
|
10
|
+
assert_equal 8, password.length
|
11
|
+
|
12
|
+
password = RandomPasswordGenerator.generate(10)
|
13
|
+
assert_equal 10, password.length
|
14
|
+
end
|
15
|
+
end
|
metadata
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: random_password_generator
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 29
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 1
|
10
|
+
version: 0.0.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Satyaram B V
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2011-03-12 00:00:00 +05:30
|
19
|
+
default_executable:
|
20
|
+
dependencies: []
|
21
|
+
|
22
|
+
description: Generates a random password with variuos useful options
|
23
|
+
email:
|
24
|
+
- bvsatyaram AT gmail DOT com
|
25
|
+
executables: []
|
26
|
+
|
27
|
+
extensions: []
|
28
|
+
|
29
|
+
extra_rdoc_files: []
|
30
|
+
|
31
|
+
files:
|
32
|
+
- .gitignore
|
33
|
+
- Gemfile
|
34
|
+
- Rakefile
|
35
|
+
- lib/random_password_generator.rb
|
36
|
+
- lib/random_password_generator/version.rb
|
37
|
+
- random_password_generator.gemspec
|
38
|
+
- test/random_password_generator_test.rb
|
39
|
+
has_rdoc: true
|
40
|
+
homepage: ""
|
41
|
+
licenses: []
|
42
|
+
|
43
|
+
post_install_message:
|
44
|
+
rdoc_options: []
|
45
|
+
|
46
|
+
require_paths:
|
47
|
+
- lib
|
48
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
hash: 3
|
54
|
+
segments:
|
55
|
+
- 0
|
56
|
+
version: "0"
|
57
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
58
|
+
none: false
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
hash: 3
|
63
|
+
segments:
|
64
|
+
- 0
|
65
|
+
version: "0"
|
66
|
+
requirements: []
|
67
|
+
|
68
|
+
rubyforge_project: random_password_generator
|
69
|
+
rubygems_version: 1.3.7
|
70
|
+
signing_key:
|
71
|
+
specification_version: 3
|
72
|
+
summary: Random password generator
|
73
|
+
test_files: []
|
74
|
+
|