randyname 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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 7b0d08e98d687c6880df3b321e3f3b7d1c8c6347513bb5d2156f6bf6f5692e14
4
+ data.tar.gz: 5b6c8512d4dd2cd621d6eebca3b17a005feafbbbd1241335c36cd41790cd2367
5
+ SHA512:
6
+ metadata.gz: c530a3f397327ac3e53d14ecdd6dedeade2114a58ea7ddd0c0e58a366ba1e40364dd3d70526e0d6e8028f22f674e8e04ae11d2bf8137eea90e171cf236af2f8b
7
+ data.tar.gz: 39dfd95150fed1b821fce63b8b35e467372a19fbbd6c01772094db11274898aef25caf4e0376a79beec039b2a2d8db7f46cae2ded978643185a63a9e235877a0
@@ -0,0 +1 @@
1
+ service_name: travis-ci
@@ -0,0 +1,22 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
@@ -0,0 +1,14 @@
1
+ AllCops:
2
+ DisplayCopNames: true
3
+
4
+ Style/StringLiterals:
5
+ EnforcedStyle: double_quotes
6
+
7
+ Documentation:
8
+ Enabled: false
9
+
10
+ Style/RegexpLiteral:
11
+ Enabled: false
12
+
13
+ Metrics/LineLength:
14
+ Max: 90
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in haikunator.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2020 Agustin Marmolejo
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,48 @@
1
+ # Randyname
2
+
3
+ Generate friendly and happy memorable random names to use in your apps or anywhere else.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'randyname'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install randyname
18
+
19
+ ## Usage
20
+
21
+ Randyname is pretty simple. There is nothing to configure and it only has a single method, `.randymize`:
22
+
23
+ ```ruby
24
+ Randyname.randymize # => "rough-snowflake-1142"
25
+
26
+ # Token range
27
+ Randyname.randymize(100) # => "nameless-star-13"
28
+
29
+ # Don't include the token
30
+ Randyname.randymize(0) # => "long-flower"
31
+
32
+ # Use a different delimiter
33
+ Randyname.randymize(9999, '.') # => "cool.leaf.6743"
34
+
35
+ # No token, no delimiter
36
+ Randyname.randymize(0, ' ') # => "green fire"
37
+ ```
38
+
39
+ ## Customize words
40
+
41
+ Create `config/initializers/randyname.rb`
42
+
43
+ Add your custome list as follow
44
+
45
+ ```
46
+ Randyname.adjectives = %w{good better}
47
+ Randyname.nouns = %w{boy girl}
48
+ ```
@@ -0,0 +1,8 @@
1
+ require "rake"
2
+ require "bundler/gem_tasks"
3
+
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task default: :spec
@@ -0,0 +1,60 @@
1
+ require "randyname/version"
2
+ require "securerandom"
3
+
4
+ module Randyname
5
+ class << self
6
+
7
+ attr_writer :adjectives
8
+ attr_writer :nouns
9
+
10
+ def randymize(token_range = 9999, delimiter = "-")
11
+ build(token_range, delimiter)
12
+ end
13
+
14
+ private
15
+
16
+ def build(token_range, delimiter)
17
+ sections = [
18
+ adjectives[random_seed % adjectives.length],
19
+ nouns[random_seed % nouns.length],
20
+ token(token_range)
21
+ ]
22
+
23
+ sections.compact.join(delimiter)
24
+ end
25
+
26
+ def random_seed
27
+ SecureRandom.random_number(4096)
28
+ end
29
+
30
+ def token(range)
31
+ SecureRandom.random_number(range) if range > 0
32
+ end
33
+
34
+ def adjectives
35
+ @adjectives ||= %w(
36
+ autumn hidden bitter misty silent empty dry dark summer
37
+ icy delicate quiet white cool spring winter patient
38
+ twilight dawn crimson wispy weathered blue billowing
39
+ broken cold damp falling frosty green long late lingering
40
+ bold little morning muddy old red rough still small
41
+ sparkling thrumming shy wandering withered wild black
42
+ young holy solitary fragrant aged snowy proud floral
43
+ restless divine polished ancient purple lively nameless
44
+ )
45
+ end
46
+
47
+ def nouns
48
+ @nouns ||= %w(
49
+ waterfall river breeze moon rain wind sea morning
50
+ snow lake sunset pine shadow leaf dawn glitter forest
51
+ hill cloud meadow sun glade bird brook butterfly
52
+ bush dew dust field fire flower firefly feather grass
53
+ haze mountain night pond darkness snowflake silence
54
+ sound sky shape surf thunder violet water wildflower
55
+ wave water resonance sun wood dream cherry tree fog
56
+ frost voice paper frog smoke star
57
+ )
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,3 @@
1
+ module Randyname
2
+ VERSION = "1.0.0"
3
+ end
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "randyname/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "randyname"
8
+ spec.version = Randyname::VERSION
9
+ spec.authors = ["Agustin Marmolejo"]
10
+ spec.email = ["eljamz@gmail.com"]
11
+ spec.summary = "Friendly and happy randon names"
12
+ spec.description = "Generate memorable random names to use in your apps"\
13
+ " or anywhere else."
14
+ spec.homepage = "https://github.com/eljamz/randyname"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0")
18
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
19
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_development_dependency "rake"
23
+ spec.add_development_dependency "rspec"
24
+ spec.add_development_dependency "coveralls"
25
+ end
@@ -0,0 +1,56 @@
1
+ require_relative "../spec_helper"
2
+
3
+ describe Randyname do
4
+ it "generates a name like still-silence-5012" do
5
+ name = Randyname.randymize
6
+
7
+ expect(name).to match(/\A\w+-\w+-\d{1,4}\z/)
8
+ end
9
+
10
+ it "won't return the same name for subsequent calls" do
11
+ name1 = Randyname.randymize
12
+ name2 = Randyname.randymize
13
+
14
+ expect(name1).not_to eql(name2)
15
+ end
16
+
17
+ it "permits optional configuration of the token range" do
18
+ name = Randyname.randymize(9)
19
+
20
+ expect(name).to match(/-\d{1}\z/)
21
+ end
22
+
23
+ it "drops the token if token range is 0" do
24
+ name = Randyname.randymize(0)
25
+
26
+ expect(name).to match(/\A\w+-\w+\z/)
27
+ end
28
+
29
+ it "permits optional configuration of the delimiter" do
30
+ name = Randyname.randymize(9999, ".")
31
+
32
+ expect(name).to match(/\A\w+\.\w+\.\d{1,4}\z/)
33
+ end
34
+
35
+ it "drops the token and delimiter if token range is 0 and delimiter empty space" do
36
+ name = Randyname.randymize(0, " ")
37
+
38
+ expect(name).to match(/\A\w+ \w+\z/)
39
+ end
40
+
41
+ it "config adjectives" do
42
+ adjectives = %w{good better}
43
+ Randyname.adjectives = adjectives
44
+ name = Randyname.randymize
45
+
46
+ expect(adjectives).to include(name.split('-')[0])
47
+ end
48
+
49
+ it "config nouns" do
50
+ nouns = %w{boy girl}
51
+ Randyname.nouns = nouns
52
+ name = Randyname.randymize
53
+
54
+ expect(nouns).to include(name.split('-')[1])
55
+ end
56
+ end
@@ -0,0 +1,23 @@
1
+ require "coveralls"
2
+ Coveralls.wear!
3
+
4
+ require "randyname"
5
+
6
+ RSpec.configure do |config|
7
+ config.expect_with :rspec do |expectations|
8
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
9
+ end
10
+
11
+ config.mock_with :rspec do |mocks|
12
+ mocks.verify_partial_doubles = true
13
+ end
14
+
15
+ # Use the specified formatter
16
+ config.formatter = :documentation
17
+
18
+ # Print top 2 slowest examples
19
+ config.profile_examples = 2
20
+
21
+ # Run specs in random order
22
+ config.order = :random
23
+ end
metadata ADDED
@@ -0,0 +1,100 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: randyname
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Agustin Marmolejo
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2020-06-09 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rake
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: coveralls
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: Generate memorable random names to use in your apps or anywhere else.
56
+ email:
57
+ - eljamz@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".coveralls.yml"
63
+ - ".gitignore"
64
+ - ".rspec"
65
+ - ".rubocop.yml"
66
+ - Gemfile
67
+ - LICENSE.txt
68
+ - README.md
69
+ - Rakefile
70
+ - lib/randyname.rb
71
+ - lib/randyname/version.rb
72
+ - randyname.gemspec
73
+ - spec/lib/randyname_spec.rb
74
+ - spec/spec_helper.rb
75
+ homepage: https://github.com/eljamz/randyname
76
+ licenses:
77
+ - MIT
78
+ metadata: {}
79
+ post_install_message:
80
+ rdoc_options: []
81
+ require_paths:
82
+ - lib
83
+ required_ruby_version: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ required_rubygems_version: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ version: '0'
93
+ requirements: []
94
+ rubygems_version: 3.0.1
95
+ signing_key:
96
+ specification_version: 4
97
+ summary: Friendly and happy randon names
98
+ test_files:
99
+ - spec/lib/randyname_spec.rb
100
+ - spec/spec_helper.rb