random_name_generator 0.0.7 → 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 +4 -4
- data/.codeclimate.yml +18 -0
- data/.coveralls.yml +1 -0
- data/.rubocop.yml +1 -1
- data/Gemfile +3 -0
- data/Gemfile.lock +21 -1
- data/README.md +19 -0
- data/lib/random_name_generator/languages/demonic.txt +6 -3
- data/lib/random_name_generator/random_name_generator.rb +23 -9
- data/lib/random_name_generator/rng_syllable.rb +15 -1
- data/random_name_generator.gemspec +1 -1
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ef97eac73bd01cde0aacdd9342b7514ffa29788d
|
4
|
+
data.tar.gz: 97dd28a80b0d73b84f8f00e2dc6103930fab19c2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 40bb462a879adb4a844ed64b9443d5ded04f7c2f26a96355398501dbfb724b1e336d8e781391163ae3a33a9716fe6d2721af11c2993ee38958e3a2efa775f5b9
|
7
|
+
data.tar.gz: 46a06d12ab64b94ace324d895c4fd08a75acacbb02f35ee5ab1e7f14f603a87628a1e5d086c8c1aebd63b25e87a7810bd2d5c8e27606181688ab67812fc3fec2
|
data/.codeclimate.yml
ADDED
data/.coveralls.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
service_name: travis-ci
|
data/.rubocop.yml
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
random_name_generator (0.0
|
4
|
+
random_name_generator (1.0.0)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
@@ -15,11 +15,20 @@ GEM
|
|
15
15
|
builder (3.2.2)
|
16
16
|
codeclimate-engine-rb (0.3.1)
|
17
17
|
virtus (~> 1.0)
|
18
|
+
codeclimate-test-reporter (0.5.0)
|
19
|
+
simplecov (>= 0.7.1, < 1.0.0)
|
18
20
|
coderay (1.1.1)
|
19
21
|
coercible (1.0.0)
|
20
22
|
descendants_tracker (~> 0.0.1)
|
23
|
+
coveralls (0.8.13)
|
24
|
+
json (~> 1.8)
|
25
|
+
simplecov (~> 0.11.0)
|
26
|
+
term-ansicolor (~> 1.3)
|
27
|
+
thor (~> 0.19.1)
|
28
|
+
tins (~> 1.6.0)
|
21
29
|
descendants_tracker (0.0.4)
|
22
30
|
thread_safe (~> 0.3, >= 0.3.1)
|
31
|
+
docile (1.1.5)
|
23
32
|
equalizer (0.0.11)
|
24
33
|
ffi (1.9.10)
|
25
34
|
guard (1.4.0)
|
@@ -30,6 +39,7 @@ GEM
|
|
30
39
|
guard-compat (~> 1.2)
|
31
40
|
minitest (>= 3.0)
|
32
41
|
ice_nine (0.11.2)
|
42
|
+
json (1.8.3)
|
33
43
|
listen (3.0.6)
|
34
44
|
rb-fsevent (>= 0.9.3)
|
35
45
|
rb-inotify (>= 0.9.7)
|
@@ -66,9 +76,17 @@ GEM
|
|
66
76
|
ruby-progressbar (~> 1.7)
|
67
77
|
unicode-display_width (~> 1.0, >= 1.0.1)
|
68
78
|
ruby-progressbar (1.7.5)
|
79
|
+
simplecov (0.11.2)
|
80
|
+
docile (~> 1.1.0)
|
81
|
+
json (~> 1.8)
|
82
|
+
simplecov-html (~> 0.10.0)
|
83
|
+
simplecov-html (0.10.0)
|
69
84
|
slop (3.6.0)
|
85
|
+
term-ansicolor (1.3.2)
|
86
|
+
tins (~> 1.0)
|
70
87
|
thor (0.19.1)
|
71
88
|
thread_safe (0.3.5)
|
89
|
+
tins (1.6.0)
|
72
90
|
unicode-display_width (1.0.2)
|
73
91
|
virtus (1.0.5)
|
74
92
|
axiom-types (~> 0.1)
|
@@ -81,6 +99,8 @@ PLATFORMS
|
|
81
99
|
|
82
100
|
DEPENDENCIES
|
83
101
|
bundler (~> 1.11)
|
102
|
+
codeclimate-test-reporter
|
103
|
+
coveralls
|
84
104
|
guard
|
85
105
|
guard-minitest
|
86
106
|
minitest
|
data/README.md
CHANGED
@@ -1,6 +1,11 @@
|
|
1
1
|
# RandomNameGenerator
|
2
2
|
|
3
|
+
[](https://badge.fury.io/rb/random_name_generator)
|
3
4
|
[](https://travis-ci.org/folkengine/random_name_generator)
|
5
|
+
[](https://codeclimate.com/github/folkengine/random_name_generator)
|
6
|
+
[](https://gemnasium.com/folkengine/random_name_generator)
|
7
|
+
[](https://coveralls.io/github/folkengine/random_name_generator?branch=master)
|
8
|
+
[](http://inch-ci.org/github/folkengine/random_name_generator)
|
4
9
|
|
5
10
|
Ruby port of [java-random-name-generator](https://github.com/folkengine/java-random-name-generator).
|
6
11
|
|
@@ -70,6 +75,18 @@ bin/random_name_generator [-efgr?]
|
|
70
75
|
|
71
76
|
Add the gem's bin directory to you path in order to have instant access to RandomNameGenerator.
|
72
77
|
|
78
|
+
## Porting and Refactoring Notes
|
79
|
+
|
80
|
+
The big refactoring over the original Java version is the creation of the RNGSyllable class. It takes
|
81
|
+
over most of the complexity of parsing each syllable, greatly simplifying the Random Name Generator code.
|
82
|
+
|
83
|
+
Part of the reason for working on this gem was to work on the following goals to improve my Ruby craft:
|
84
|
+
|
85
|
+
* Code confidently in the spirit of Advi Grimm's [Confident Ruby](http://www.confidentruby.com/).
|
86
|
+
* Use [Travis-CI](https://travis-ci.org/folkengine/random_name_generator) for build validation.
|
87
|
+
* Use [Rubocop](https://github.com/bbatsov/rubocop) and [Reek](https://github.com/troessner/reek) for code quality.
|
88
|
+
* Deploy it to [RubyGems.org](https://rubygems.org/gems/random_name_generator).
|
89
|
+
|
73
90
|
## Development
|
74
91
|
|
75
92
|
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
@@ -84,6 +101,8 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
84
101
|
|
85
102
|
## Alternatives
|
86
103
|
|
104
|
+
There are several other great name generator gems. They really aren't designed for fantasy style names.
|
105
|
+
|
87
106
|
* [Faker](https://github.com/stympy/faker)
|
88
107
|
* [Namey](https://github.com/muffinista/namey)
|
89
108
|
* [How To Write A Name Generator (In Ruby)](http://www.skorks.com/2009/07/how-to-write-a-name-generator-in-ruby/)
|
@@ -16,6 +16,7 @@
|
|
16
16
|
-am
|
17
17
|
-an
|
18
18
|
-anc
|
19
|
+
-and +c
|
19
20
|
-ang
|
20
21
|
-anti
|
21
22
|
-ap
|
@@ -30,8 +31,10 @@ ama -c +c
|
|
30
31
|
ay -c
|
31
32
|
ast -c
|
32
33
|
bat
|
34
|
+
dra +c
|
33
35
|
dus
|
34
36
|
ez -c +v
|
37
|
+
ha -c +c
|
35
38
|
i -c +c
|
36
39
|
ia -c +c
|
37
40
|
it -c -v
|
@@ -43,6 +46,7 @@ or
|
|
43
46
|
ra +c
|
44
47
|
rat
|
45
48
|
rax +v
|
49
|
+
real
|
46
50
|
sh
|
47
51
|
thi +c
|
48
52
|
|
@@ -53,6 +57,7 @@ thi +c
|
|
53
57
|
+es -c
|
54
58
|
+ias -c
|
55
59
|
+iel
|
60
|
+
+ka
|
56
61
|
+lat
|
57
62
|
+lech
|
58
63
|
+ma
|
@@ -63,6 +68,7 @@ thi +c
|
|
63
68
|
+on -c
|
64
69
|
+rept -v
|
65
70
|
+res
|
71
|
+
+s -v
|
66
72
|
+van
|
67
73
|
+xas -v
|
68
74
|
+y -c
|
@@ -71,9 +77,6 @@ thi +c
|
|
71
77
|
|
72
78
|
# https://en.wikipedia.org/wiki/The_infernal_names
|
73
79
|
|
74
|
-
|
75
|
-
Andhaka (Hindu mythology)
|
76
|
-
Andras (Christian demonology)
|
77
80
|
Andrealphus (Christian demonology)
|
78
81
|
Andromalius (Christian demonology)
|
79
82
|
Antichrist (Christian demonology)
|
@@ -1,5 +1,17 @@
|
|
1
1
|
require_relative 'rng_syllable'
|
2
2
|
|
3
|
+
# RandomNameGenerator:
|
4
|
+
#
|
5
|
+
# Examples
|
6
|
+
#
|
7
|
+
# rng = RandomNameGenerator.new(RandomNameGenerator::GOBLIN)
|
8
|
+
# puts rng.compose(3)
|
9
|
+
#
|
10
|
+
# By default RandomNameGenerator uses the Fantasy syllable file and creates a name with between 2 and 5 syllables.
|
11
|
+
#
|
12
|
+
# rng = RandomNameGenerator.new
|
13
|
+
# puts rng.compose
|
14
|
+
#
|
3
15
|
class RandomNameGenerator
|
4
16
|
dirname = File.dirname(__FILE__)
|
5
17
|
|
@@ -19,6 +31,7 @@ class RandomNameGenerator
|
|
19
31
|
refresh
|
20
32
|
end
|
21
33
|
|
34
|
+
# Public: Static factory method that instantiates a RandomNameGenerator in a random language.
|
22
35
|
def self.flip_mode
|
23
36
|
langs = [RandomNameGenerator::FANTASY,
|
24
37
|
RandomNameGenerator::ELVEN,
|
@@ -36,6 +49,16 @@ class RandomNameGenerator
|
|
36
49
|
name.map(&:to_s).join.capitalize
|
37
50
|
end
|
38
51
|
|
52
|
+
def self.pick_number_of_syllables
|
53
|
+
[2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 5].sample
|
54
|
+
end
|
55
|
+
|
56
|
+
def to_s
|
57
|
+
"NameGenerator (#{@file.path})"
|
58
|
+
end
|
59
|
+
|
60
|
+
private
|
61
|
+
|
39
62
|
def determine_middle_syllables(count, pre)
|
40
63
|
determine_next_syllables(count, pre, @mid_syllables)
|
41
64
|
end
|
@@ -76,13 +99,4 @@ class RandomNameGenerator
|
|
76
99
|
end
|
77
100
|
end
|
78
101
|
end
|
79
|
-
|
80
|
-
def self.pick_number_of_syllables
|
81
|
-
distribution = [2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 5]
|
82
|
-
distribution.sample
|
83
|
-
end
|
84
|
-
|
85
|
-
def to_s
|
86
|
-
"NameGenerator (#{@file.path})"
|
87
|
-
end
|
88
102
|
end
|
@@ -1,3 +1,18 @@
|
|
1
|
+
# RNGSyllable: Class for managing properties of individual syllables with in language name file. Each line within a file
|
2
|
+
# translates into a syllable object. The reason behind this class is to take over most of the complexity of parsing each
|
3
|
+
# syllable, greatly simplifying the work done by RandomNameGenerator. This code is not meant to be called directly as a
|
4
|
+
# part of standard usage.
|
5
|
+
#
|
6
|
+
# Examples
|
7
|
+
#
|
8
|
+
# syllable = RNGSyllable.new('-foo +c')
|
9
|
+
#
|
10
|
+
# This creates a foo syllable object that needs to be the first syllable and followed by a constant.
|
11
|
+
#
|
12
|
+
# For testing purposes, passing in another RNGSyllable object will create a clone:
|
13
|
+
#
|
14
|
+
# syllable_clone = RNGSyllable.new(syllable)
|
15
|
+
#
|
1
16
|
# SYLLABLE CLASSIFICATION:
|
2
17
|
# Name is usually composed from 3 different class of syllables, which include prefix, middle part and suffix.
|
3
18
|
# To declare syllable as a prefix in the file, insert "-" as a first character of the line.
|
@@ -18,7 +33,6 @@
|
|
18
33
|
# 2) +c means that next syllable must definitely start with a consonant.
|
19
34
|
# 3) -v means that this syllable can only be added to another syllable, that ends with a vocal.
|
20
35
|
# 4) -c means that this syllable can only be added to another syllable, that ends with a consonant.
|
21
|
-
|
22
36
|
class RNGSyllable
|
23
37
|
attr_reader :raw, :syllable, :next_syllable_requirement, :previous_syllable_requirement
|
24
38
|
|
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = 'random_name_generator'
|
7
|
-
spec.version = '0.0
|
7
|
+
spec.version = '1.0.0'
|
8
8
|
spec.authors = ['folkengine']
|
9
9
|
spec.email = ['gaoler@electronicpanopticon.com']
|
10
10
|
spec.licenses = ['GPL-3.0']
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: random_name_generator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- folkengine
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-03-
|
11
|
+
date: 2016-03-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -46,6 +46,8 @@ executables: []
|
|
46
46
|
extensions: []
|
47
47
|
extra_rdoc_files: []
|
48
48
|
files:
|
49
|
+
- ".codeclimate.yml"
|
50
|
+
- ".coveralls.yml"
|
49
51
|
- ".gitignore"
|
50
52
|
- ".overcommit.yml"
|
51
53
|
- ".rubocop.yml"
|
@@ -88,7 +90,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
88
90
|
version: '0'
|
89
91
|
requirements: []
|
90
92
|
rubyforge_project:
|
91
|
-
rubygems_version: 2.
|
93
|
+
rubygems_version: 2.5.1
|
92
94
|
signing_key:
|
93
95
|
specification_version: 4
|
94
96
|
summary: Random Name Generator
|