unique_names_generator 0.1.1

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: 9c3735cb47c574108e11dde60274f4d2013c0b281fd2bdf08cecc595e9acd2ac
4
+ data.tar.gz: 9ccbf1f0f972547de8baabe8675b1a1540ace3a4a24caf3dd88728d86650ba52
5
+ SHA512:
6
+ metadata.gz: c049f7832bc38164a17215c3ddaf830b534ec642b25494045f89c39ccb08d7c639a39af7fd061e988173bc7c5190eb8a634f2ebaed562b286d80411cbe77cdb9
7
+ data.tar.gz: f9a0be92fb3dbbe8a48bc588b202217d97edcd299f21699a26d7712d9b5129cb8dd0a535ffb7c4f0976bc0377f983f4e047fb9a597800131157262efc623de92
@@ -0,0 +1,31 @@
1
+ name: Ruby CI
2
+
3
+ on:
4
+ push:
5
+ branches: [ development ]
6
+ pull_request:
7
+ branches: [ development ]
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ubuntu-latest
12
+ strategy:
13
+ matrix:
14
+ ruby-version: ['2.6', '2.7.5', '3.0', '3.3']
15
+
16
+ steps:
17
+ - uses: actions/checkout@v3
18
+ - name: Set up Ruby ${{ matrix.ruby-version }}
19
+ uses: ruby/setup-ruby@v1
20
+ with:
21
+ ruby-version: ${{ matrix.ruby-version }}
22
+ - name: Install dependencies
23
+ run: |
24
+ if [[ "${{ matrix.ruby-version }}" < "3.0" ]]; then
25
+ gem install bundler -v '~> 2.4.22'
26
+ else
27
+ gem install bundler
28
+ fi
29
+ bundle install
30
+ - name: Run tests
31
+ run: bundle exec rspec
data/.pryrc ADDED
@@ -0,0 +1,8 @@
1
+ # .pryrc
2
+ def reload!
3
+ load './lib/unique_names_generator.rb'
4
+ puts 'Reloaded unique_names_generator.rb'
5
+ end
6
+
7
+ puts 'Custom commands loaded:'
8
+ puts 'reload! - Reloads the unique_names_generator.rb file'
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,31 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.6
3
+
4
+ Style/WordArray:
5
+ Enabled: false
6
+
7
+ Naming/MethodParameterName:
8
+ Enabled: false
9
+
10
+ Style/NumericLiterals:
11
+ Enabled: false
12
+
13
+ Metrics/ModuleLength:
14
+ Enabled: false
15
+
16
+ Metrics/MethodLength:
17
+ Enabled: false
18
+
19
+ Metrics/AbcSize:
20
+ Enabled: false
21
+
22
+ Metrics/BlockLength:
23
+ Exclude:
24
+ - 'spec/**/*'
25
+
26
+ Style/SymbolArray:
27
+ Exclude:
28
+ - 'spec/**/*'
29
+
30
+ Style/NumericPredicate:
31
+ Enabled: false
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ # Specify your gem's dependencies in <your-gem-name>.gemspec
6
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,32 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ unique_names_generator (0.1.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ diff-lcs (1.5.1)
10
+ rspec (3.13.0)
11
+ rspec-core (~> 3.13.0)
12
+ rspec-expectations (~> 3.13.0)
13
+ rspec-mocks (~> 3.13.0)
14
+ rspec-core (3.13.0)
15
+ rspec-support (~> 3.13.0)
16
+ rspec-expectations (3.13.1)
17
+ diff-lcs (>= 1.2.0, < 2.0)
18
+ rspec-support (~> 3.13.0)
19
+ rspec-mocks (3.13.1)
20
+ diff-lcs (>= 1.2.0, < 2.0)
21
+ rspec-support (~> 3.13.0)
22
+ rspec-support (3.13.1)
23
+
24
+ PLATFORMS
25
+ arm64-darwin-21
26
+
27
+ DEPENDENCIES
28
+ rspec (~> 3.0)
29
+ unique_names_generator!
30
+
31
+ BUNDLED WITH
32
+ 2.2.3
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Jon Girard
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 all
13
+ 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 THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,93 @@
1
+ ![Ruby CI](https://github.com/jongirard/unique_names_generator_ruby/actions/workflows/ruby.yml/badge.svg)
2
+
3
+ # UniqueNamesGenerator
4
+
5
+ Unique Names Generator is a Ruby package for generating random and unique names. Generation utilizes PRNG (pseudo random number generation) for either fully random or seeded name generation. It comes with a list of various dictionaries out of the box, but you can also provide custom ones. Inspired by the great "Unique Names Generator" available on [NPM](https://www.npmjs.com/package/unique-names-generator) by Andrea Sonny. Ported from the [Elixir version](https://github.com/jongirard/unique_names_generator) built by myself.
6
+
7
+ ## Installation
8
+
9
+ The package can be installed from [RubyGems](https://rubygems.org/gems/unique_names_generator)
10
+ by adding `unique_names_generator` to your list of gemfile dependencies:
11
+
12
+ Add this line to your application's Gemfile:
13
+
14
+ ```
15
+ gem 'unique_names_generator', "~> 0.1.0"
16
+ ```
17
+
18
+ And then execute:
19
+
20
+ ```
21
+ $ bundle
22
+ ```
23
+
24
+ Or install it yourself as:
25
+
26
+ ```
27
+ $ gem install unique_names_generator
28
+ ```
29
+
30
+ ## Usage
31
+
32
+ In a nutshell, you can begin generating randon names with UniqueNamesGenerator by simply specifying an array of one or more dictionaries via `UniqueNamesGenerator.generate`. Available dictionary types are `[:adjectives, :animals, :colors, :languages, :names, :numbers, :star_wars]`.
33
+
34
+ ```ruby
35
+ UniqueNamesGenerator.generate([:adjectives, :animals])
36
+ # => Generates ex: "dramatic_limpet"
37
+
38
+ UniqueNamesGenerator.generate([:adjectives, :colors, :animals])
39
+ # => Generates ex: "tremendous_brown_cat"
40
+
41
+ UniqueNamesGenerator.generate([:adjectives, :names, :numbers])
42
+ # => Generates ex: "doubtful_wanda_979"
43
+ ```
44
+
45
+ To use custom dictionaries, simply include your array of strings as part of the dictionaries array:
46
+
47
+ ```ruby
48
+ drinks = ['Sprite', 'Coca-Cola', 'Juice', 'Tea']
49
+ UniqueNamesGenerator.generate([:colors, drinks])
50
+ # => Generates ex: "cyan_sprite"
51
+ ```
52
+
53
+ ### Config options
54
+
55
+ UniqueNamesGenerator can be used with either the default provided config (`separator: '_', style: :lowercase, creativity: 0`) or by specifying any of your own configuration options for seeding, seperator, style and creativity.
56
+
57
+ #### More details on possible options
58
+
59
+ - **Separator options**: Any ASCII character string such as underscore, dash or blank space. `nil` for no space.
60
+ - ex: '_', '-', ' ' or `nil` for no space.
61
+ - **Style options**: Atom, one of `:lowercase`, `:uppercase`, `:capital`.
62
+ - **Creativity options**: An integer or float between 1 and 10.
63
+
64
+ ```ruby
65
+ UniqueNamesGenerator.generate([:colors, :animals], style: :capital, separator: ' ')
66
+ # => Generates ex: "Lavender Marlin"
67
+
68
+ UniqueNamesGenerator.generate([:colors, :adjectives, :animals], creativity: 8, style: :capital, separator: ' ')
69
+ # => Generates ex: "Yellow Local Hippopotamus"
70
+ ```
71
+
72
+ #### What is creativity?
73
+ Using the creativity option changes how `UniqueNamesGenerator` selects terms from the dictionaries in use, essentially acting as a multiplier. For dictionaries with a similar term length, while using a seed, the selection may at times appear to be alphabetical or closely related (ex: "Amber Anakin Skywalker"). Utilizing the `creative` option with a value between 1 and 10 will use a sequential multiplier for subsequent dictionaries providing a seemingly more "random" or "creative" result whilst still allowing for seeded generation.
74
+
75
+ ```ruby
76
+ UniqueNamesGenerator.generate([:colors, :adjectives, :animals], creativity: 8, seed: 'f6da7a28-5ae6-4d6b-b3b8-a197b99ed4eb')
77
+
78
+ # => Seed "f6da7a28-5ae6-4d6b-b3b8-a197b99ed4eb" with creativity of 8 always generates: "plum_flying_cobra"
79
+ ```
80
+
81
+ ### Seeded Generation
82
+
83
+ A seed can be used to deterministically generate a name. As long as the provided seed and creativity values are the same between runs, then the generated name will also always be the same. Simply provide a string or integer as the value of the seed key, ie; `seed: 'hello'`.
84
+
85
+ _(**Usecase example:** generate a username for an authenticated user based on UUID. Ex: `13a5d03e-61d0-4b5b-ae3b-57953c268c5f` will always generate the name "beige_boba_fett_145" when used together with the colors/star_wars/numbers dictionaries)._
86
+
87
+ ```ruby
88
+ UniqueNamesGenerator.generate([:colors, :star_wars, :numbers], seed: '13a5d03e-61d0-4b5b-ae3b-57953c268c5f')
89
+ # => Seed "13a5d03e-61d0-4b5b-ae3b-57953c268c5f" always generates: "beige_boba_fett_145"
90
+ ```
91
+
92
+ ## License
93
+ This project is licensed under the MIT License - see the [LICENSE file](https://github.com/jongirard/unique_names_generator_ruby/blob/development/LICENSE) for details.
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rspec/core/rake_task'
4
+
5
+ RSpec::Core::RakeTask.new(:spec)
6
+ task default: :spec