password_generator_cli 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 51e68d5d5fc4ac5e73a425b59a5a40546cfdc48511399d3665b1f59b0337db28
4
+ data.tar.gz: 89502a8fadad82d032bae818627695dc2fe4fdae79e57290534fa4e64f833f4b
5
+ SHA512:
6
+ metadata.gz: 28b4325600447e1d46e9e7e8fba795d71f5995dfef1e3a7477a8411e5f7945884bc06ae3bfa643a08c15d22b144ddd445b834b9d696c6c2bfdd0d278403f077a
7
+ data.tar.gz: '09ae7d023dc028a15708421e5ccd710d0523f0b501bdd051b9aa04e46eb74c9dd646beba13f0545a020b069fc766bec689f09dae5ae5fd95cddd70959e553bb8'
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2022-01-24
4
+
5
+ - Initial release
@@ -0,0 +1,84 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
+
9
+ ## Our Standards
10
+
11
+ Examples of behavior that contributes to a positive environment for our community include:
12
+
13
+ * Demonstrating empathy and kindness toward other people
14
+ * Being respectful of differing opinions, viewpoints, and experiences
15
+ * Giving and gracefully accepting constructive feedback
16
+ * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
+ * Focusing on what is best not just for us as individuals, but for the overall community
18
+
19
+ Examples of unacceptable behavior include:
20
+
21
+ * The use of sexualized language or imagery, and sexual attention or
22
+ advances of any kind
23
+ * Trolling, insulting or derogatory comments, and personal or political attacks
24
+ * Public or private harassment
25
+ * Publishing others' private information, such as a physical or email
26
+ address, without their explicit permission
27
+ * Other conduct which could reasonably be considered inappropriate in a
28
+ professional setting
29
+
30
+ ## Enforcement Responsibilities
31
+
32
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
+
34
+ Community leaders 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, and will communicate reasons for moderation decisions when appropriate.
35
+
36
+ ## Scope
37
+
38
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
+
40
+ ## Enforcement
41
+
42
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at vinicius.kammradt1@gmail.com. All complaints will be reviewed and investigated promptly and fairly.
43
+
44
+ All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
+
46
+ ## Enforcement Guidelines
47
+
48
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
+
50
+ ### 1. Correction
51
+
52
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
+
54
+ **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
+
56
+ ### 2. Warning
57
+
58
+ **Community Impact**: A violation through a single incident or series of actions.
59
+
60
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
+
62
+ ### 3. Temporary Ban
63
+
64
+ **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
+
66
+ **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
+
68
+ ### 4. Permanent Ban
69
+
70
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
+
72
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
73
+
74
+ ## Attribution
75
+
76
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
+ available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
+
79
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
+
81
+ [homepage]: https://www.contributor-covenant.org
82
+
83
+ For answers to common questions about this code of conduct, see the FAQ at
84
+ https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ # Specify your gem's dependencies in password_generator.gemspec
6
+ gemspec
7
+
8
+ gem 'rake', '~> 13.0'
data/Gemfile.lock ADDED
@@ -0,0 +1,19 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ password_generator_cli (0.1.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ rake (13.0.6)
10
+
11
+ PLATFORMS
12
+ x86_64-linux
13
+
14
+ DEPENDENCIES
15
+ password_generator_cli!
16
+ rake (~> 13.0)
17
+
18
+ BUNDLED WITH
19
+ 2.2.33
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2022 Vinicius Kammradt
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,48 @@
1
+ <h1 align="center">Welcome to pgen 👋</h1>
2
+ <p>
3
+ <a href="https://twitter.com/kammzinho" target="_blank">
4
+ <img alt="Twitter: kammzinho" src="https://img.shields.io/twitter/follow/kammzinho.svg?style=social" />
5
+ </a>
6
+ </p>
7
+
8
+ > A password generator build on learning purpouses
9
+
10
+ ## Usage
11
+ :construction:
12
+ I still need to figure out how to make it easy to distribute as some kind of binary
13
+
14
+ ```sh
15
+ # Generic usage
16
+ pgen [OPTIONS]
17
+
18
+ # Minimal example (using all defaults)
19
+ # 12 chars, being a to z, A to Z, 0 to 9 and ! to /
20
+ pgen
21
+ > 5ugvs5.JOv!1
22
+
23
+ # Changing the default length
24
+ pgen -l 32
25
+ > mtu2WUh+M8ry2qw&YO#mI.Y!aSd43noi
26
+
27
+ # Generating a pin (only numbers)
28
+ pgen -p -l 8
29
+ > 27843429
30
+
31
+ # Generating without special characters (default is true)
32
+ pgen -s false -l 8
33
+ > HvLaAWB1
34
+ ```
35
+
36
+ ## Author
37
+
38
+ 👤 **Vinicius Kammradt**
39
+
40
+ * Website: [kammradt.super.site](https://kammradt.super.site)
41
+ * Twitter: [@kammzinho](https://twitter.com/kammzinho)
42
+ * Github: [@kammzinho](https://github.com/kammzinho)
43
+ * LinkedIn: [@vinicius-kammradt](https://linkedin.com/in/vinicius-kammradt)
44
+
45
+ ## Show your support
46
+
47
+ Give a ⭐️ if this project helped you!
48
+
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task default: :spec
data/bin/pgen ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'bundler/setup'
5
+ require 'password_generator'
6
+
7
+ puts PasswordGenerator.handle
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/lib/generator.rb ADDED
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Generator
4
+ attr_accessor :available_chars
5
+
6
+ def initialize
7
+ self.available_chars = {
8
+ lower_upper: ('a'..'z').to_a + ('A'..'Z').to_a,
9
+ numbers: ('0'..'9').to_a,
10
+ special_chars: ('!'..'/').to_a
11
+ }
12
+ end
13
+
14
+ def generate(options)
15
+ random_password options
16
+ end
17
+
18
+ private
19
+
20
+ def random_password(options)
21
+ password_length = options[:length]
22
+
23
+ # Generates a possible range of chars N times the password length
24
+ available_chars = get_available_chars(options) * password_length
25
+
26
+ available_chars.shuffle.join[0...password_length]
27
+ end
28
+
29
+ def get_available_chars(options)
30
+ return available_chars[:numbers] if options[:numbers_only]
31
+
32
+ regular_and_numbers = available_chars[:lower_upper] + available_chars[:numbers]
33
+ return regular_and_numbers + available_chars[:special_chars] if options[:include_special_chars]
34
+
35
+ regular_and_numbers
36
+ end
37
+ end
data/lib/parser.rb ADDED
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'optparse'
4
+
5
+ class Parser
6
+ attr_accessor :options
7
+
8
+ def initialize
9
+ self.options = {
10
+ length: 12,
11
+ numbers_only: false,
12
+ include_special_chars: true
13
+ }
14
+ end
15
+
16
+ def parse
17
+ OptionParser.new do |parser|
18
+ parser.on('-l LENGTH', '--length LENGTH', 'Password length as integer. Default: 12. Ex pgen -l 32', Integer)
19
+
20
+ parser.on('-p [PIN]', '--pin [PIN]',
21
+ 'Should use a pin password (numbers only). Default: false. Ex: pgen -p | pgen -p true | pgen -p false') do |pin|
22
+ options[:numbers_only] = parse_optional_bool_flag pin
23
+ end
24
+
25
+ parser.on('-s [SPECIAL]', '--special [SPECIAL]',
26
+ 'Should use special characters (!?;). Default: true. Ex: pgen -p | pgen -p true | pgen -p false') do |special|
27
+ options[:include_special_chars] = parse_optional_bool_flag special
28
+ end
29
+ end.parse!(into: options)
30
+
31
+ options
32
+ end
33
+
34
+ private
35
+
36
+ def parse_optional_bool_flag(flag)
37
+ # `flag.nil?` verifies if the input is just `-X` (considered true).
38
+ # If -X has an argument, convert it to bool
39
+
40
+ flag.nil? || flag.to_s == 'true'
41
+ end
42
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module PasswordGenerator
4
+ VERSION = '0.1.0'
5
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'password_generator/version'
4
+ require 'generator'
5
+ require 'parser'
6
+
7
+ module PasswordGenerator
8
+ class Error < StandardError; end
9
+
10
+ def self.handle
11
+ Generator.new.generate(Parser.new.parse)
12
+ end
13
+ end
@@ -0,0 +1,4 @@
1
+ module PasswordGenerator
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ end
metadata ADDED
@@ -0,0 +1,62 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: password_generator_cli
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Vinicius Kammradt
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2022-01-25 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description:
14
+ email:
15
+ - vinicius.kammradt1@gmail.com
16
+ executables:
17
+ - pgen
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - ".rspec"
22
+ - CHANGELOG.md
23
+ - CODE_OF_CONDUCT.md
24
+ - Gemfile
25
+ - Gemfile.lock
26
+ - LICENSE.txt
27
+ - README.md
28
+ - Rakefile
29
+ - bin/pgen
30
+ - bin/setup
31
+ - lib/generator.rb
32
+ - lib/parser.rb
33
+ - lib/password_generator.rb
34
+ - lib/password_generator/version.rb
35
+ - sig/password_generator.rbs
36
+ homepage: https://github.com/kammradt/pgen-cli
37
+ licenses:
38
+ - MIT
39
+ metadata:
40
+ homepage_uri: https://github.com/kammradt/pgen-cli
41
+ source_code_uri: https://github.com/kammradt/pgen-cli
42
+ changelog_uri: https://github.com/kammradt/pgen-cli/blob/master/CHANGELOG.md
43
+ post_install_message:
44
+ rdoc_options: []
45
+ require_paths:
46
+ - lib
47
+ required_ruby_version: !ruby/object:Gem::Requirement
48
+ requirements:
49
+ - - ">="
50
+ - !ruby/object:Gem::Version
51
+ version: 2.6.0
52
+ required_rubygems_version: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: '0'
57
+ requirements: []
58
+ rubygems_version: 3.1.6
59
+ signing_key:
60
+ specification_version: 4
61
+ summary: A password generator build on learning purpouses.
62
+ test_files: []