do_username 0.0.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 +7 -0
- data/lib/do_username.rb +60 -0
- metadata +44 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: '09f079cdbd8c72bea94f5e5bfb240ed95d5341b9cba00157e199ccd8557e180c'
|
4
|
+
data.tar.gz: 37433ab171ce5aa5997be737825fd13daf3461328920f131b4293228b462b245
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 34b991167f4e87be84a0552ad404255ef4ff7fb9b19c4f1db6d9636c59307abc89f7ef693cd80930a472bcc98a5bb17a43657d5321be80a62e93018e0d4f121f
|
7
|
+
data.tar.gz: 82d574c0b51ad593c0f7989e131bf92c9e020f427dc4b9a2457b59b8ca87777c7fa876acf94e6e549bb8f9c9c2377ebd80c906e3c8a9978e814683dc3d95fa51
|
data/lib/do_username.rb
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
module DOUsername
|
2
|
+
SEA_CREATURES = %w(walrus seal fish shark clam coral whale crab lobster starfish eel dolphin squid jellyfish ray giantSquid shrimp mantaRay angler snorkler scubaDiver).freeze
|
3
|
+
SEA_OBJECTS = %w(boat ship submarine yacht dinghy raft kelp).freeze
|
4
|
+
|
5
|
+
DESCRIPTORS = %w(cute adorable lovable happy sandy).freeze
|
6
|
+
SIZE_DESCRIPTORS = %w(large big small).freeze
|
7
|
+
CREATURE_DESCRIPTORS= %w(swimming).freeze
|
8
|
+
|
9
|
+
COLORS = %w(blue blueGreen darkCyan electricBlue greenBlue lightCyan lightSeaGreen seaGreen turquoise aqua aquamarine teal cyan gray).freeze
|
10
|
+
|
11
|
+
extend self
|
12
|
+
|
13
|
+
def generate(max_size = 30)
|
14
|
+
# Choose a noun first
|
15
|
+
noun = random_noun
|
16
|
+
|
17
|
+
# Choose a descriptor
|
18
|
+
descriptor = random_descriptor(noun)
|
19
|
+
|
20
|
+
# Choose a color
|
21
|
+
color = random_color
|
22
|
+
|
23
|
+
# Convert to title case and remove whitespace
|
24
|
+
noun = format(noun)
|
25
|
+
descriptor = format(descriptor)
|
26
|
+
color = format(color)
|
27
|
+
|
28
|
+
# Combine to create username shorter than or equal to given length
|
29
|
+
if (descriptor + color + noun).length <= max_size
|
30
|
+
descriptor + color + noun
|
31
|
+
elsif (descriptor + noun).length <= max_size
|
32
|
+
descriptor + noun
|
33
|
+
elsif (color + noun).length <= max_size
|
34
|
+
descriptor + noun
|
35
|
+
else
|
36
|
+
noun[0...max_size]
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
|
42
|
+
def random_noun
|
43
|
+
(SEA_OBJECTS + SEA_CREATURES).sample
|
44
|
+
end
|
45
|
+
|
46
|
+
def random_descriptor(noun)
|
47
|
+
descriptors = DESCRIPTORS.dup
|
48
|
+
descriptors += SIZE_DESCRIPTORS unless noun.start_with?('giant')
|
49
|
+
descriptors += CREATURE_DESCRIPTORS if SEA_CREATURES.include?(noun)
|
50
|
+
descriptors.sample
|
51
|
+
end
|
52
|
+
|
53
|
+
def random_color
|
54
|
+
COLORS.sample
|
55
|
+
end
|
56
|
+
|
57
|
+
def format(string)
|
58
|
+
string[0].upcase + string[1..-1]
|
59
|
+
end
|
60
|
+
end
|
metadata
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: do_username
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- DigitalOcean
|
8
|
+
- Matt Cowley
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2020-10-22 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: A DigitalOcean-community-themed username generator.
|
15
|
+
email: me@mattcowley.co.uk
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- lib/do_username.rb
|
21
|
+
homepage: https://rubygems.org/gems/do_username
|
22
|
+
licenses:
|
23
|
+
- Apache-2.0
|
24
|
+
metadata: {}
|
25
|
+
post_install_message:
|
26
|
+
rdoc_options: []
|
27
|
+
require_paths:
|
28
|
+
- lib
|
29
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
35
|
+
requirements:
|
36
|
+
- - ">="
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '0'
|
39
|
+
requirements: []
|
40
|
+
rubygems_version: 3.1.4
|
41
|
+
signing_key:
|
42
|
+
specification_version: 4
|
43
|
+
summary: DigitalOcean Username Generator
|
44
|
+
test_files: []
|