catpants 2.5.0
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/.gitignore +45 -0
- data/CODE_OF_CONDUCT.md +13 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +61 -0
- data/Rakefile +1 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/catpants.gemspec +32 -0
- data/lib/catpants.rb +8 -0
- data/lib/catpants/version.rb +3 -0
- data/vendor/assets/javascripts/catpants.js +95 -0
- metadata +86 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 1d0560c49f1024c4eb64f2279148b4166da7cb81
|
|
4
|
+
data.tar.gz: 9ca7c0e80b77a0bab366141c869d404903cd5249
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 2f2769ec3f5700a8a2aeb9b8b57af20dc4dad3a2f0179a9166696e2e521bd729e3bf71bc7172fef68e1c811aff33c8f0accb36d04820b423c3c09f951c75d6ea
|
|
7
|
+
data.tar.gz: fa720fa7c9611cc823f055e41279c8c96729ab2bf70f3d12be5316828808d867d0eadbc3956ae15ca468e5e62dfd40f9d254c4a1c2ddeca327b752bb2b3d00c9
|
data/.gitignore
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
|
|
2
|
+
/.bundle/
|
|
3
|
+
/.yardoc
|
|
4
|
+
/Gemfile.lock
|
|
5
|
+
/_yardoc/
|
|
6
|
+
/coverage/
|
|
7
|
+
/doc/
|
|
8
|
+
/pkg/
|
|
9
|
+
/spec/reports/
|
|
10
|
+
/tmp/
|
|
11
|
+
*.rbc
|
|
12
|
+
capybara-*.html
|
|
13
|
+
.rspec
|
|
14
|
+
/log
|
|
15
|
+
/tmp
|
|
16
|
+
/db/*.sqlite3
|
|
17
|
+
/db/*.sqlite3-journal
|
|
18
|
+
/public/system
|
|
19
|
+
/coverage/
|
|
20
|
+
/spec/tmp
|
|
21
|
+
**.orig
|
|
22
|
+
rerun.txt
|
|
23
|
+
pickle-email-*.html
|
|
24
|
+
|
|
25
|
+
# TODO Comment out these rules if you are OK with secrets being uploaded to the repo
|
|
26
|
+
config/initializers/secret_token.rb
|
|
27
|
+
config/secrets.yml
|
|
28
|
+
|
|
29
|
+
## Environment normalisation:
|
|
30
|
+
/.bundle
|
|
31
|
+
/vendor/bundle
|
|
32
|
+
|
|
33
|
+
# these should all be checked in to normalise the environment:
|
|
34
|
+
# Gemfile.lock, .ruby-version, .ruby-gemset
|
|
35
|
+
|
|
36
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
|
37
|
+
.rvmrc
|
|
38
|
+
|
|
39
|
+
# if using bower-rails ignore default bower_components path bower.json files
|
|
40
|
+
/vendor/assets/bower_components
|
|
41
|
+
*.bowerrc
|
|
42
|
+
bower.json
|
|
43
|
+
|
|
44
|
+
# Ignore pow environment settings
|
|
45
|
+
.powenv
|
data/CODE_OF_CONDUCT.md
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Contributor Code of Conduct
|
|
2
|
+
|
|
3
|
+
As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
|
|
4
|
+
|
|
5
|
+
We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
|
|
6
|
+
|
|
7
|
+
Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
|
|
8
|
+
|
|
9
|
+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
|
|
10
|
+
|
|
11
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
|
|
12
|
+
|
|
13
|
+
This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2015 parkerdan
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all 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,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# Catpants
|
|
2
|
+
|
|
3
|
+
Password strength calculator on key up...with a cat emoji if your password is good enough.
|
|
4
|
+
Everyone needs a strength calculator, everyone loves emoji's. Win win here! Vanilla javascript meow 😻!
|
|
5
|
+
|
|
6
|
+
## Installation
|
|
7
|
+
|
|
8
|
+
Add this line to your application's Gemfile:
|
|
9
|
+
|
|
10
|
+
### **** Specify gem version ****
|
|
11
|
+
|
|
12
|
+
```ruby
|
|
13
|
+
gem 'catpants', '2.5.0'
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
And execute:
|
|
17
|
+
```ruby
|
|
18
|
+
$ bundle
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Usage
|
|
22
|
+
|
|
23
|
+
You need to require this in app.js
|
|
24
|
+
```ruby
|
|
25
|
+
//= require catpants
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
You must have a html label element for the password field with a class of `catpants`.
|
|
29
|
+
```html
|
|
30
|
+
<label class="catpants">
|
|
31
|
+
```
|
|
32
|
+
And a class of `catpants-password` on the password input
|
|
33
|
+
```html
|
|
34
|
+
<input class="catpants-password">
|
|
35
|
+
```
|
|
36
|
+
Here's a RAILS example with form helpers
|
|
37
|
+
```html
|
|
38
|
+
<div class="form-group">
|
|
39
|
+
<%= label_tag :password, "Password", class:"catpants" %>
|
|
40
|
+
<%= password_field_tag :password, "", class: "catpants-password" %>
|
|
41
|
+
</div>
|
|
42
|
+
```
|
|
43
|
+
RAILS with Simple Form example
|
|
44
|
+
```erb
|
|
45
|
+
<%= f.input :password, label_html: { class: 'catpants' }, input_html: {class:'catpants-password'} %>
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
Boom. Done.
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
## Contributing
|
|
55
|
+
|
|
56
|
+
Bug reports and pull requests are welcome on GitHub at http://github.com/parkerdan/catpants. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
## License
|
|
60
|
+
|
|
61
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/console
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require "bundler/setup"
|
|
4
|
+
require "catpants"
|
|
5
|
+
|
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
|
8
|
+
|
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
|
10
|
+
# require "pry"
|
|
11
|
+
# Pry.start
|
|
12
|
+
|
|
13
|
+
require "irb"
|
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
data/catpants.gemspec
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require 'catpants/version'
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = "catpants"
|
|
8
|
+
spec.version = Catpants::VERSION
|
|
9
|
+
spec.authors = ["parkerdan"]
|
|
10
|
+
spec.email = ["parker.daniel.o@gmail.com"]
|
|
11
|
+
|
|
12
|
+
spec.summary = "Checks passwords strength on key up, vanilla javascript"
|
|
13
|
+
spec.description = "Just add the class 'catpants' to the password label and class of 'password' to the input and BOOM...password strength checker with emoji's ;) "
|
|
14
|
+
spec.homepage = "http://github.com/parkerdan/catpants"
|
|
15
|
+
spec.license = "MIT"
|
|
16
|
+
|
|
17
|
+
# Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
|
|
18
|
+
# delete this section to allow pushing this gem to any host.
|
|
19
|
+
if spec.respond_to?(:metadata)
|
|
20
|
+
spec.metadata['allowed_push_host'] = "https://rubygems.org"
|
|
21
|
+
else
|
|
22
|
+
raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
|
26
|
+
spec.bindir = "exe"
|
|
27
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
28
|
+
spec.require_paths = ["lib"]
|
|
29
|
+
|
|
30
|
+
spec.add_development_dependency "bundler", "~> 1.10"
|
|
31
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
|
32
|
+
end
|
data/lib/catpants.rb
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
function strength(chars) {
|
|
2
|
+
var counter = 0
|
|
3
|
+
var blackList = ["password", "12345", "admin","master","11111","god", "supersecret"]
|
|
4
|
+
if (chars.length > 7) {
|
|
5
|
+
counter ++ }
|
|
6
|
+
if (/[a-z]/.test(chars) === true) {
|
|
7
|
+
counter ++ }
|
|
8
|
+
if (/[A-Z]/.test(chars) === true) {
|
|
9
|
+
counter ++ }
|
|
10
|
+
if (/[^a-zA-Z\d\s:]/.test(chars) === true) {
|
|
11
|
+
counter ++ }
|
|
12
|
+
if (chars.length > 13) {
|
|
13
|
+
counter ++ }
|
|
14
|
+
if (blackList.indexOf(chars.toLowerCase()) >= 0 ) {
|
|
15
|
+
counter = -1}
|
|
16
|
+
|
|
17
|
+
switch (counter) {
|
|
18
|
+
case counter = 0:
|
|
19
|
+
return {sentence:"Your password strength is not good... ",
|
|
20
|
+
emoji: String.fromCharCode(0xD83D, 0xDE1E),
|
|
21
|
+
color: 'red'}
|
|
22
|
+
break;
|
|
23
|
+
case counter = 1:
|
|
24
|
+
return {sentence:"It is slowly getting better ",
|
|
25
|
+
emoji: String.fromCharCode(0xD83D, 0xDE0F),
|
|
26
|
+
color:'red'}
|
|
27
|
+
break;
|
|
28
|
+
case counter = 2:
|
|
29
|
+
return {sentence:"Keep going ",
|
|
30
|
+
emoji: String.fromCharCode(0xD83D, 0xDE40),
|
|
31
|
+
color: 'orange'}
|
|
32
|
+
break;
|
|
33
|
+
case counter = 3:
|
|
34
|
+
return {sentence:"Almost a good password ",
|
|
35
|
+
emoji: String.fromCharCode(0xD83D, 0xDE01),
|
|
36
|
+
color: 'orange'}
|
|
37
|
+
break;
|
|
38
|
+
case counter = 4:
|
|
39
|
+
return {sentence:"Mine is usually this good ",
|
|
40
|
+
emoji: String.fromCharCode(0xD83D, 0xDE0A) + " " + String.fromCharCode(0xD83D, 0xDE18),
|
|
41
|
+
color: 'green'}
|
|
42
|
+
break;
|
|
43
|
+
case counter = 5:
|
|
44
|
+
return {sentence:"I doubt anyone will guess this ",
|
|
45
|
+
emoji: String.fromCharCode(0xD83D, 0xDE3B) + " " + String.fromCharCode(0xD83D, 0xDE3D),
|
|
46
|
+
color: 'green'}
|
|
47
|
+
break;
|
|
48
|
+
case counter = -1:
|
|
49
|
+
return {sentence:"Very funny....is this Tam? ",
|
|
50
|
+
emoji: String.fromCharCode(0xD83D, 0xDE1C) + " " + String.fromCharCode(0xD83D, 0xDE1D),
|
|
51
|
+
color: 'blue'}
|
|
52
|
+
break;
|
|
53
|
+
default: return "Something"
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
function bind_click(i){
|
|
58
|
+
document.getElementsByClassName("catpants-password")[i].onkeyup = function(event){
|
|
59
|
+
event = event || window.event;
|
|
60
|
+
var pw = document.getElementsByClassName("catpants-password")[i].value;
|
|
61
|
+
var responseObject = strength(pw);
|
|
62
|
+
|
|
63
|
+
document.getElementById("cat-message" + i).innerHTML= responseObject.sentence + "<span id='emoji' style='color:black;font-weight:normal;'>" + responseObject.emoji + "</span>";
|
|
64
|
+
document.getElementById("cat-message" + i).style.color=responseObject.color;
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
var listener = (window.Turbolinks) ? "page:change":"DOMContentLoaded";
|
|
69
|
+
|
|
70
|
+
document.addEventListener(listener, function(){
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
if (document.getElementsByClassName("catpants")) {
|
|
74
|
+
var ELEMENTS = document.getElementsByClassName("catpants");
|
|
75
|
+
for (var i = 0; i < ELEMENTS.length; i++) {
|
|
76
|
+
var para = document.createElement("p");
|
|
77
|
+
para.setAttribute("id","cat-message" + i);
|
|
78
|
+
var node = document.createTextNode("");
|
|
79
|
+
para.appendChild(node);
|
|
80
|
+
ELEMENTS[i].appendChild(para);
|
|
81
|
+
document.getElementById("cat-message" + i).style.color="red";
|
|
82
|
+
document.getElementById("cat-message" + i).style.transition="color 2s";
|
|
83
|
+
document.getElementById("cat-message" + i).innerHTML = "Your password strength is not good... <span id='emoji' style='color:black;font-weight:normal;'>" + String.fromCharCode(0xD83D, 0xDE1E) + "</span>" ;
|
|
84
|
+
};
|
|
85
|
+
if (document.getElementsByClassName("catpants-password")) {
|
|
86
|
+
var INPUTS = document.getElementsByClassName("catpants-password");
|
|
87
|
+
console.log(INPUTS);
|
|
88
|
+
for (var i = 0; i < INPUTS.length; i++) {
|
|
89
|
+
bind_click(i);
|
|
90
|
+
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
};
|
|
94
|
+
});
|
|
95
|
+
// bundle exec rake release
|
metadata
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: catpants
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 2.5.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- parkerdan
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: exe
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2016-09-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.10'
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '1.10'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: rake
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '10.0'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '10.0'
|
|
41
|
+
description: 'Just add the class ''catpants'' to the password label and class of ''password''
|
|
42
|
+
to the input and BOOM...password strength checker with emoji''s ;) '
|
|
43
|
+
email:
|
|
44
|
+
- parker.daniel.o@gmail.com
|
|
45
|
+
executables: []
|
|
46
|
+
extensions: []
|
|
47
|
+
extra_rdoc_files: []
|
|
48
|
+
files:
|
|
49
|
+
- ".gitignore"
|
|
50
|
+
- CODE_OF_CONDUCT.md
|
|
51
|
+
- Gemfile
|
|
52
|
+
- LICENSE.txt
|
|
53
|
+
- README.md
|
|
54
|
+
- Rakefile
|
|
55
|
+
- bin/console
|
|
56
|
+
- bin/setup
|
|
57
|
+
- catpants.gemspec
|
|
58
|
+
- lib/catpants.rb
|
|
59
|
+
- lib/catpants/version.rb
|
|
60
|
+
- vendor/assets/javascripts/catpants.js
|
|
61
|
+
homepage: http://github.com/parkerdan/catpants
|
|
62
|
+
licenses:
|
|
63
|
+
- MIT
|
|
64
|
+
metadata:
|
|
65
|
+
allowed_push_host: https://rubygems.org
|
|
66
|
+
post_install_message:
|
|
67
|
+
rdoc_options: []
|
|
68
|
+
require_paths:
|
|
69
|
+
- lib
|
|
70
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
71
|
+
requirements:
|
|
72
|
+
- - ">="
|
|
73
|
+
- !ruby/object:Gem::Version
|
|
74
|
+
version: '0'
|
|
75
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
76
|
+
requirements:
|
|
77
|
+
- - ">="
|
|
78
|
+
- !ruby/object:Gem::Version
|
|
79
|
+
version: '0'
|
|
80
|
+
requirements: []
|
|
81
|
+
rubyforge_project:
|
|
82
|
+
rubygems_version: 2.4.8
|
|
83
|
+
signing_key:
|
|
84
|
+
specification_version: 4
|
|
85
|
+
summary: Checks passwords strength on key up, vanilla javascript
|
|
86
|
+
test_files: []
|