suri_password 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in password_strength.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Suraj Pratap
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # PasswordStrength
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'password_strength'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install password_strength
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
@@ -0,0 +1,80 @@
1
+ jQuery.fn.password_strength = function() {
2
+ var password_field = $(this[0])
3
+ var id = password_field.attr('id')
4
+ //password_field.css("float","left")
5
+ password_field.keyup(updatePasswordStrengthIndicator);
6
+ password_field.focus(updatePasswordStrengthIndicator)
7
+ password_field.blur(function(){
8
+ var container_div = password_field.parent()
9
+ var c = container_div.children()
10
+ $.each(c,function(key,value){
11
+ if (key != 0) {
12
+ $(c[key]).remove();
13
+ };
14
+ })
15
+ })
16
+ }
17
+
18
+ function updatePasswordStrengthIndicator(){
19
+ var password_field = $(this)
20
+ var password = this.value
21
+ var password_length = password.length
22
+ var container_div = password_field.parent()
23
+ if (password_length < 6) {
24
+ var c = container_div.children()
25
+ $.each(c,function(key,value){
26
+ if (key != 0) {
27
+ $(c[key]).remove();
28
+ };
29
+ })
30
+ container_div.append("<span class='password_strength_warning'>Password must be atleast SIX characters</span>");
31
+ return;
32
+ }
33
+ else{
34
+ var c = container_div.children()
35
+ $.each(c,function(key,value){
36
+ if (key != 0) {
37
+ $(c[key]).remove();
38
+ };
39
+ })
40
+ container_div.append("<span class='password_strength_strength'>Strength : </span>").append("<div class='password_strength_bar_holder'><div class='password_strength_meter'></div></div>").append("<span style='font-size:12px;color:blue;margin-left:4px'></span>");
41
+ }
42
+ var meter = $(container_div.children()[2]).children()
43
+ var strongnessHeader = $(container_div.children()[3])
44
+ if (strongStrengthed(password)) {
45
+ meter.css("width","80%").css("background-color","green")
46
+ strongnessHeader.empty().append("Strong").css("color","green")
47
+ }
48
+ else if (mediumStrengthed(password)) {
49
+ meter.css("width","50%").css("background-color","blue")
50
+ strongnessHeader.empty().append("Medium").css("color","blue")
51
+ }
52
+ else if (weakStrengthed(password)) {
53
+ meter.css("width","20%").css("background-color","red")
54
+ strongnessHeader.empty().append("Weak").css("color","red")
55
+ }
56
+ }
57
+
58
+ function mediumStrengthed(password){
59
+ if ( hasSpecialCharacter(password) & password.length >=6 & password.length < 10 || (!hasSpecialCharacter(password) & password.length >= 8) ) {
60
+ return true;
61
+ };
62
+ }
63
+
64
+ function strongStrengthed (password) {
65
+ if (hasSpecialCharacter(password) & password.length >= 10 || (password.length > 12)) {
66
+ return true;
67
+ };
68
+ }
69
+
70
+ function weakStrengthed(password){
71
+ if (!hasSpecialCharacter(password) & password.length >=6 & password.length < 10) {
72
+ return true;
73
+ };
74
+ }
75
+
76
+ function hasSpecialCharacter(string)
77
+ {
78
+ var patt = /[^a-z]/;
79
+ return patt.test(string)
80
+ }
@@ -0,0 +1,24 @@
1
+ .password_strength_warning{
2
+ color:red;
3
+ font-size:12px;
4
+ }
5
+
6
+ .password_strength_strength{
7
+ font-size:12px;
8
+ color:maroon;
9
+ }
10
+
11
+ .password_strength_bar_holder{
12
+ height:12px;
13
+ width:110px;
14
+ background-color:yellow;
15
+ margin-top:2px;
16
+ margin-left:4px;
17
+ display: inline-block;
18
+ }
19
+
20
+ .password_strength_meter{
21
+ height:100%;
22
+ width:20%;
23
+ background-color:red;
24
+ }
@@ -0,0 +1,5 @@
1
+ module PasswordStrength
2
+ class Engine < ::Rails::Engine
3
+
4
+ end
5
+ end
@@ -0,0 +1,3 @@
1
+ module PasswordStrength
2
+ VERSION = "1.1.0"
3
+ end
@@ -0,0 +1,3 @@
1
+ require 'password_strength/engine'
2
+ module PasswordStrength
3
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :password_strength do
3
+ # # Task goes here
4
+ # end
@@ -0,0 +1,23 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "password_strength/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "suri_password"
7
+ s.version = PasswordStrength::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Suraj Pratap"]
10
+ s.email = ["suraj.pratap24@gmail.com"]
11
+ s.homepage = "https://github.com/surajpratap/password_strength.git"
12
+ s.summary = %q{Password Streangth !}
13
+ s.description = %q{This gem generates a password strength meter}
14
+
15
+ s.add_development_dependency "sqlite"
16
+ s.add_dependency "jquery-rails"
17
+ s.add_dependency "rails >= 3.1"
18
+
19
+ s.files = `git ls-files`.split("\n")
20
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
21
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
22
+ s.require_paths = ["lib"]
23
+ end
metadata ADDED
@@ -0,0 +1,105 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: suri_password
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Suraj Pratap
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-10-16 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: sqlite
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: jquery-rails
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: rails >= 3.1
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ description: This gem generates a password strength meter
63
+ email:
64
+ - suraj.pratap24@gmail.com
65
+ executables: []
66
+ extensions: []
67
+ extra_rdoc_files: []
68
+ files:
69
+ - .gitignore
70
+ - Gemfile
71
+ - LICENSE
72
+ - README.md
73
+ - Rakefile
74
+ - lib/assets/javascripts/password_strength.js
75
+ - lib/assets/stylesheets/password_strength.css
76
+ - lib/password_strength.rb
77
+ - lib/password_strength/engine.rb
78
+ - lib/password_strength/version.rb
79
+ - lib/tasks/password_strength_tasks.rake
80
+ - password_strength.gemspec
81
+ homepage: https://github.com/surajpratap/password_strength.git
82
+ licenses: []
83
+ post_install_message:
84
+ rdoc_options: []
85
+ require_paths:
86
+ - lib
87
+ required_ruby_version: !ruby/object:Gem::Requirement
88
+ none: false
89
+ requirements:
90
+ - - ! '>='
91
+ - !ruby/object:Gem::Version
92
+ version: '0'
93
+ required_rubygems_version: !ruby/object:Gem::Requirement
94
+ none: false
95
+ requirements:
96
+ - - ! '>='
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
99
+ requirements: []
100
+ rubyforge_project:
101
+ rubygems_version: 1.8.24
102
+ signing_key:
103
+ specification_version: 3
104
+ summary: Password Streangth !
105
+ test_files: []