pwgen 0.1.0 → 1.0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 781a8343812268d938ed4c403ad1d00bef54f6cfa59ce8563fd66e264b917319
4
- data.tar.gz: 9e2afc567d6ce15332836f8e21ae9008f6c8ceeb4cd094fe1b47f1f94bdec728
3
+ metadata.gz: 4472ad381c4a88ef103a89f5c2de0ec9ab0e1cf986889da83fc969c729a510cc
4
+ data.tar.gz: b3bb08649f13c105300fe0a2c7e974b1609a40b20080edb97c2e80584f6d3986
5
5
  SHA512:
6
- metadata.gz: 14bbf8f04c8fe2df6240d6b00996066dc4f4f7eb408bc2471f006a18624318990c3ac60738b29b54d40dacd68b711e469d5baac6a2a0de70ebc0b9093aad1c13
7
- data.tar.gz: 6b8899bbfc35f3bc63c02612033cde3ff95ca095cc43df15c325358535dd101ca792c178b92e06089d8ac078a5a76eb77bedadae79170fd6f279abd6e6a86620
6
+ metadata.gz: f33c81b5c7bd7e0194fcf33354aa8ccbd517261acac318d04c3ff731054bbb2e55692e00020bc7ae28b1dbb6587e41db7b4f8417201002564d74b424a6ea8400
7
+ data.tar.gz: c7d28838150b5250048948d286b44b34c6234dfb894070ca4f0ded15e4284d94cbcb160ee502451b773d276ed2349c907f23bb716db111975e18032cfbf59720
@@ -2,19 +2,33 @@ sudo: required
2
2
  matrix:
3
3
  include:
4
4
  - language: ruby
5
- rvm: 2.2
5
+ env:
6
+ - NAME="Bundle test"
7
+ rvm: 2.3.8
6
8
  before_install:
7
- - gem install bundler -v 1.16.1
9
+ - gem install bundler -v 2.0.1
8
10
  - language: ruby
11
+ env:
12
+ - NAME="Bundle test"
9
13
  rvm: 2.4.4
10
14
  before_install:
11
- - gem install bundler -v 1.17.3
15
+ - gem install bundler -v 2.0.1
12
16
  - language: ruby
13
- rvm: 2.4.4
17
+ env:
18
+ - NAME="Bundle test"
19
+ rvm: 2.5.3
14
20
  before_install:
15
21
  - gem install bundler -v 2.0.1
16
22
  - language: ruby
17
- env: SKIP_INTERPRETER=true
23
+ env:
24
+ - NAME="Bundle test"
25
+ rvm: 2.6.0
26
+ before_install:
27
+ - gem install bundler -v 2.0.1
28
+ - language: ruby
29
+ env:
30
+ - NAME="Rubocop Checks"
31
+ - SKIP_INTERPRETER=true
18
32
  rvm: 2.4.4
19
33
  before_install:
20
34
  - git clone https://github.com/TravisToolbox/rubocop-travis.git
@@ -23,7 +37,9 @@ matrix:
23
37
  script:
24
38
  - ./rubocop-travis/scan.sh
25
39
  - language: ruby
26
- rvm: 2.2
40
+ env:
41
+ - NAME="Link Checker"
42
+ rvm: 2.4.4
27
43
  before_install:
28
44
  - mkdir travis
29
45
  - git clone https://github.com/TravisToolbox/awesomebot-travis.git travis/awesomebot
@@ -1,4 +1,4 @@
1
- ## 1.0.0 (January 28, 2019)
1
+ ## 1.0.0 (January 29, 2019)
2
2
 
3
3
  * Initial Release ([@TGWolf][])
4
4
 
data/README.md CHANGED
@@ -60,6 +60,26 @@ There are a number of options that can be password:
60
60
 
61
61
  You can also pass the options parameter to the 'generate_password' method to override the settings for a specific password creation.
62
62
 
63
+ ## Executable
64
+
65
+ There is also an executable linked to this gem which allows you to generate passwords within bash scripts etc.
66
+
67
+ ```
68
+ Usage: pwgen
69
+ -h, --help Display this screen
70
+ -c, --show-config Show the configuration
71
+ -d, --digits string Minimum number of digits to use. (default: random)
72
+ -l, --length string The length of the password (default 12)
73
+ -s, --symbols string Minimum number of symbols to use. (default: random)
74
+ -C, --skip-confusables Skip the use of letters which are easily confused e.g. 1 and l in passwords
75
+ -D, --skip-digits Skip the use of digits in passwords
76
+ -L, --skip-lower-case Skip the use of lower case letters in passwords
77
+ -P, --skip-phonetic Skip creation of the phonetic password
78
+ -S, --skip-symbols Skip the use of symbols in passwords
79
+ -U, --skip-upper-case Skip the use of upper case letters in passwords
80
+ -W, --skip-url-unsafe Skip the use of url (Web) unsafe characters in passwords
81
+ ```
82
+
63
83
  ## Development
64
84
 
65
85
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -72,7 +92,7 @@ For local testing make sure that you run `bundle exec rspec spec` and then `rake
72
92
 
73
93
  ## Contributing
74
94
 
75
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/pwgen. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
95
+ Bug reports and pull requests are welcome on GitHub at https://github.com/AntiPhotonltd/password_generator. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
76
96
 
77
97
  ## License
78
98
 
@@ -80,4 +100,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
80
100
 
81
101
  ## Code of Conduct
82
102
 
83
- Everyone interacting in the Pwgen project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/pwgen/blob/master/CODE_OF_CONDUCT.md).
103
+ Everyone interacting in the Pwgen project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/AntiPhotonltd/password_generator/blob/master/CODE_OF_CONDUCT.md).
data/exe/pwgen CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require 'optparse'
4
- require "pwgen"
4
+ require 'pwgen'
5
5
 
6
6
  # -------------------------------------------------------------------------------- #
7
7
  # Generate Password #
@@ -10,11 +10,19 @@ require "pwgen"
10
10
  # -------------------------------------------------------------------------------- #
11
11
 
12
12
  def generate_password(options)
13
- Pwgen::Password.generate_password(options[:length])
14
-
15
- pputs Pwgen::Password.password
16
-
17
- pputs Pwgen::Password.phonetic_password if options[:phonetic]
13
+ if options[:config]
14
+ Pwgen::Password.configure(options)
15
+ Pwgen::Password.show_configuration
16
+ else
17
+ begin
18
+ Pwgen::Password.generate_password(options[:length], options)
19
+ rescue RuntimeError => e
20
+ puts e.message
21
+ else
22
+ puts Pwgen::Password.password
23
+ puts Pwgen::Password.phonetic_password unless options[:skip_phonetic]
24
+ end
25
+ end
18
26
  end
19
27
 
20
28
  # -------------------------------------------------------------------------------- #
@@ -27,7 +35,7 @@ end
27
35
  # -------------------------------------------------------------------------------- #
28
36
 
29
37
  def process_arguments
30
- options = {}
38
+ options = { length: 12 }
31
39
  # Enforce the presence of
32
40
  mandatory = %I[length]
33
41
 
@@ -38,9 +46,50 @@ def process_arguments
38
46
  puts opts
39
47
  exit(1)
40
48
  end
41
- opts.on('-l', '--length string', 'The length of the password') do |length|
49
+
50
+ opts.on('-c', '--show-config', 'Show the configuration') do |_config|
51
+ options[:config] = true
52
+ end
53
+
54
+ opts.on('-d', '--digits string', 'Minimum number of digits to use. (default: random)') do |digits|
55
+ options[:digits] = digits
56
+ end
57
+
58
+ opts.on('-l', '--length string', 'The length of the password (default 12)') do |length|
42
59
  options[:length] = length
43
60
  end
61
+
62
+ opts.on('-s', '--symbols string', 'Minimum number of symbols to use. (default: random)') do |symbols|
63
+ options[:symbols] = symbols
64
+ end
65
+
66
+ opts.on('-C', '--skip-confusables', 'Skip the use of letters which are easily confused e.g. 1 and l in passwords') do |_skip_confusables|
67
+ options[:skip_confusables] = true
68
+ end
69
+
70
+ opts.on('-D', '--skip-digits', 'Skip the use of digits in passwords') do |_skip_digits|
71
+ options[:skip_digits] = true
72
+ end
73
+
74
+ opts.on('-L', '--skip-lower-case', 'Skip the use of lower case letters in passwords') do |_skip_lower_case|
75
+ options[:skip_lower_case] = true
76
+ end
77
+
78
+ opts.on('-P', '--skip-phonetic', 'Skip creation of the phonetic password') do |_skip_phonetic|
79
+ options[:skip_phonetic] = true
80
+ end
81
+
82
+ opts.on('-S', '--skip-symbols', 'Skip the use of symbols in passwords') do |_skip_symbols|
83
+ options[:skip_symbols] = true
84
+ end
85
+
86
+ opts.on('-U', '--skip-upper-case', 'Skip the use of upper case letters in passwords') do |_skip_upper_case|
87
+ options[:skip_upper_case] = true
88
+ end
89
+
90
+ opts.on('-W', '--skip-url-unsafe', 'Skip the use of url (Web) unsafe characters in passwords') do |_skip_url_unsafe|
91
+ options[:skip_url_unsafe] = true
92
+ end
44
93
  end
45
94
 
46
95
  begin
@@ -73,4 +122,3 @@ main
73
122
  # -------------------------------------------------------------------------------- #
74
123
  # This is the end - nothing more to see here. #
75
124
  # -------------------------------------------------------------------------------- #
76
-
@@ -12,7 +12,7 @@ module Pwgen
12
12
  # docs to go here
13
13
  #
14
14
  class Password
15
- UNFRIENDLY_CHARS = ['$', 'S', 's', '5', 'B', 'b', '8', '|', 'I', 'i', 'o', '0', '1', 'l', 'O', '!'].freeze
15
+ CONFUSABLE_CHARS = ['$', 'S', 's', '5', 'B', 'b', '8', '|', 'I', 'i', 'o', '0', '1', 'l', 'O', '!'].freeze
16
16
  URL_UNSAFE = ['$', '&', '+', ',', '/', ':', ';', '=', '?', '@', '<', '>', '#', '%', '{', '}', '|', '^', '~', '[', ']', '\\', '"', '`'].freeze
17
17
 
18
18
  $lower_case = []
@@ -44,19 +44,19 @@ module Pwgen
44
44
  def self.configure(options)
45
45
  $lower_case = []
46
46
  $lower_case = ('a'..'z').to_a unless options[:skip_lower_case]
47
- $lower_case -= UNFRIENDLY_CHARS unless options[:dont_exclude_unfrieldly_chars]
47
+ $lower_case -= CONFUSABLE_CHARS if options[:skip_confusables]
48
48
 
49
49
  $upper_case = []
50
50
  $upper_case = ('A'..'Z').to_a unless options[:skip_upper_case]
51
- $upper_case -= UNFRIENDLY_CHARS unless options[:dont_exclude_unfrieldly_chars]
51
+ $upper_case -= CONFUSABLE_CHARS if options[:skip_confusables]
52
52
 
53
53
  $digits = []
54
54
  $digits = ('0'..'9').to_a unless options[:skip_digits]
55
- $digits -= UNFRIENDLY_CHARS unless options[:dont_exclude_unfrieldly_chars]
55
+ $digits -= CONFUSABLE_CHARS if options[:skip_confusables]
56
56
 
57
57
  $symbols = []
58
- $symbols = ['!', '@', '#', '£', '$', '%', '^', '&', '*', '(', ')', '-', '_', '+', '=', '{', '}', '[', ']', ':', ';', '"', '\'', '|', '\\', '~', '`', '<', '>', '?', ',', '.', '/', '\ '].freeze unless options[:skip_symbols]
59
- $symbols -= UNFRIENDLY_CHARS unless options[:dont_exclude_unfrieldly_chars]
58
+ $symbols = ['!', '@', '#', '£', '$', '%', '^', '&', '*', '(', ')', '-', '_', '+', '=', '{', '}', '[', ']', ':', ';', '"', '\'', '|', '\\', '~', '`', '<', '>', '?', ',', '.', '/', ' '].freeze unless options[:skip_symbols]
59
+ $symbols -= CONFUSABLE_CHARS if options[:skip_confusables]
60
60
  $symbols -= URL_UNSAFE if options[:skip_url_unsafe]
61
61
 
62
62
  $alpha = []
@@ -80,15 +80,22 @@ module Pwgen
80
80
  puts "Alpha: #{$alpha}"
81
81
  puts "AlphaNumeric: #{$alphanum}"
82
82
 
83
- puts "Unfriendly Chars: #{UNFRIENDLY_CHARS}"
83
+ puts "Confusable Chars: #{CONFUSABLE_CHARS}"
84
84
  puts "URL Unsafe: #{URL_UNSAFE}"
85
85
 
86
86
  puts "Full Character Set: #{$full_character_set}"
87
87
  end
88
88
 
89
89
  def self.generate_password(length = 12, options = {})
90
- raise 'length must be an integer!' unless length.is_a? Integer
91
- raise 'length must be a positive integer!' unless length > 0
90
+ raise 'length must be a number!' unless length !~ /\D/
91
+
92
+ length = length.to_i
93
+
94
+ raise 'length must be a positive number!' unless length > 0
95
+
96
+ if options[:digits] || options[:symbols]
97
+ raise 'length is to short to meet digits/symbols requirements!' if length < options[:digits].to_i + options[:symbols].to_i
98
+ end
92
99
 
93
100
  reset(options)
94
101
 
@@ -1,3 +1,3 @@
1
1
  module Pwgen
2
- VERSION = '0.1.0'.freeze
2
+ VERSION = '1.0.0'.freeze
3
3
  end
@@ -21,7 +21,9 @@ Gem::Specification.new do |spec|
21
21
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
22
  spec.require_paths = ["lib"]
23
23
 
24
- spec.add_development_dependency "bundler", "~> 1.16"
24
+ spec.required_ruby_version = '>= 2.3.0'
25
+
26
+ spec.add_development_dependency "bundler"
25
27
  spec.add_development_dependency "rake", "~> 10.0"
26
28
  spec.add_development_dependency "rspec", "~> 3.0"
27
29
 
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pwgen
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim Gurney aka Wolf
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-01-28 00:00:00.000000000 Z
11
+ date: 2019-01-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '1.16'
19
+ version: '0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '1.16'
26
+ version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -173,7 +173,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
173
173
  requirements:
174
174
  - - ">="
175
175
  - !ruby/object:Gem::Version
176
- version: '0'
176
+ version: 2.3.0
177
177
  required_rubygems_version: !ruby/object:Gem::Requirement
178
178
  requirements:
179
179
  - - ">="