password_generator 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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 55f443c3bac316fa0f6c6694f5be0c1c2275c1f9488e39576dff050e33a0cf7f
4
+ data.tar.gz: a6b10a2f6b3be4e4bc4ff3559d32ac6a1cbfcecf916701a01275341f1468045c
5
+ SHA512:
6
+ metadata.gz: 103f307bd3878798e58e05d027269c613df57aad6075cda008f3c8a0e531b96678bf8b59bc93b85f2107732965b2bb4d80f375fbf99a4aed28dd91e0973efc25
7
+ data.tar.gz: 3f73789ec50f19466ef91ed0dd9c6f981af1bc10d623741178c23ce86f7f1ea09d3acc4c01e8fe451cba523bb95298c566610f320c621c748de86b83573378fd
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ # lib/password_generator/railtie.rb
4
+ module PasswordGenerator
5
+ # The `Railtie` class integrates the Password Generator gem with the Rails framework.
6
+ #
7
+ # It includes the `ViewHelper` module in the `ActionView::Base` class, making the
8
+ # `random_password_tag` helper method available for use in Rails views.
9
+ class Railtie < ::Rails::Railtie
10
+ # Initializes the `ViewHelper` inclusion in the `ActionView::Base`.
11
+ #
12
+ # This ensures that the `random_password_tag` helper method is available
13
+ # for use in Rails views.
14
+ #
15
+ # @note The inclusion is only triggered if the Rails framework is defined,
16
+ # preventing issues when the gem is used in non-Rails environments.
17
+ initializer 'password_generator.view_helpers' do
18
+ ActionView::Base.include ViewHelper
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ # lib/password_generator/view_helper.rb
4
+ module PasswordGenerator
5
+ # The `ViewHelper` module provides a helper method for generating random passwords
6
+ # in Rails views.
7
+ #
8
+ # It is automatically included in the `ActionView::Base` class through the `Railtie`,
9
+ # making the `random_password_tag` method available for use in views.
10
+ module ViewHelper
11
+ # Generates an HTML paragraph containing a randomly generated password.
12
+ #
13
+ # @param [Integer] length The length of the password to generate. Defaults to 12.
14
+ # @return [String] HTML paragraph tag containing the random password.
15
+ def random_password_tag(length = 12)
16
+ password = PasswordGenerator.generate_password(length)
17
+ content_tag(:p, "Password: #{password}")
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ # lib/password_generator.rb
4
+ module PasswordGenerator
5
+ def self.generate_password(length = 12)
6
+ characters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@\#$%^&*()_+"
7
+ Array.new(length) { characters[rand(characters.length)] }.join
8
+ end
9
+ end
10
+
11
+ require 'password_generator/view_helper' if defined?(Rails)
metadata ADDED
@@ -0,0 +1,60 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: password_generator
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Shabini Rajadas
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2024-01-17 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ description: A simple gem to generate random passwords for use in Rails applications.
28
+ email:
29
+ - shabiniraja90@gmail.com
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - lib/password_generator.rb
35
+ - lib/password_generator/railtie.rb
36
+ - lib/password_generator/view_helper.rb
37
+ homepage: https://github.com/ShabiniRajadas/password_generator
38
+ licenses:
39
+ - MIT
40
+ metadata: {}
41
+ post_install_message:
42
+ rdoc_options: []
43
+ require_paths:
44
+ - lib
45
+ required_ruby_version: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: 2.7.2
50
+ required_rubygems_version: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ requirements: []
56
+ rubygems_version: 3.4.22
57
+ signing_key:
58
+ specification_version: 4
59
+ summary: Generate random passwords for Rails applications
60
+ test_files: []