name-generator 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2b95220803965203899331e54552c4592c8015a6
4
- data.tar.gz: 4fe72923e04b3ede1ee6fd9cde4856657595cfd8
3
+ metadata.gz: ec178ae128ee1ff1f1c0d50866c81bfb71ba59fc
4
+ data.tar.gz: 1f923c479dcd9a63b7a02ed8145975bb7de3517a
5
5
  SHA512:
6
- metadata.gz: c666890d804306707ae2887faa75915007732e7432193cc9f906e27106c4bf12ed45076a10260afc99f38e440e3b07fe01e103a09ff5b4abb2fa2a04b6070887
7
- data.tar.gz: 463fd39b860964ac529fb494cc725627cf62dc35319ba2caf1f0902bdd0a8bbe4191f18b59c1bcdf5e4c66945b60f2a7b6138580e733d2328cbdaba78456fbf7
6
+ metadata.gz: 16a7d908ae57eb2e1cfaa1bdd902c01464f92512dae1eadf703d9b92da6486f6b6a5f3e4783bdfc24f0b29945b705eaf6a8e05e17e2a31908d0454f3c0a2c2d3
7
+ data.tar.gz: a51895083b7e1a178c49adc11d56844ec3d0b38d5ade009000c3c7a983b7f7a2953e5f5c578487425a377de87afc267e5598eb68e925f231935d51d23d921ed5
data/README.md CHANGED
@@ -17,6 +17,18 @@ Use in your code:
17
17
  generator = NameGenerator::Main.new
18
18
  puts generator.next_name
19
19
  # => "Foonqtar"
20
+
21
+ 10.times { puts generator.next_name }
22
+ Ties
23
+ Hamiedla
24
+ Artoni
25
+ Folo
26
+ Acendro
27
+ Jula
28
+ Tuveqtpha
29
+ Gubouna
30
+ Axlesone
31
+ Oisova
20
32
  ```
21
33
 
22
34
  For more examples see [the specs](spec/name-generator/main_spec.rb).
data/Rakefile CHANGED
@@ -5,3 +5,23 @@ require 'bundler/gem_tasks'
5
5
  require 'rspec/core/rake_task'
6
6
  RSpec::Core::RakeTask.new(:spec)
7
7
  task default: :spec
8
+
9
+ desc 'Do what a CI server would do'
10
+ task ci: [:spec, 'test:rubocop']
11
+
12
+ namespace :test do
13
+ require 'rubocop/rake_task'
14
+ RuboCop::RakeTask.new(:rubocop) do |task|
15
+ # run with .rubocop.yml config:
16
+ task.options = [
17
+ '--config', '.rubocop.yml',
18
+ '--fail-level', 'W'
19
+ ]
20
+ # only show the files with failures
21
+ task.formatters = %w(clang offenses)
22
+ # silence "Running RuboCop..." output:
23
+ task.verbose = ENV['CI']
24
+ # abort rake on failure
25
+ task.fail_on_error = true
26
+ end
27
+ end
@@ -7,24 +7,22 @@
7
7
  # the Mote project (http://mote.sourceforge.net/)
8
8
 
9
9
  module NameGenerator
10
+ # Your one stop location for generating random names
10
11
  class Main
11
-
12
- def next_name syllables = random_syllable_count
12
+ def next_name(syllables = random_syllable_count)
13
13
  name = generate_name(syllables)
14
- until sensible_name?(name)
15
- name = generate_name(syllables)
16
- end
14
+ name = generate_name(syllables) until sensible_name?(name)
17
15
  titlecase(name)
18
16
  end
19
17
 
20
18
  private
21
19
 
22
- def titlecase name
20
+ def titlecase(name)
23
21
  name[0] = name[0].upcase
24
22
  name
25
23
  end
26
24
 
27
- def generate_name syllables
25
+ def generate_name(syllables)
28
26
  name = (1...syllables).collect do
29
27
  digraphs.sample
30
28
  end
@@ -33,8 +31,8 @@ module NameGenerator
33
31
  name.join
34
32
  end
35
33
 
36
- def sensible_name? name
37
- name !=~ /.*[aeiou]{3}.*/i # reject if at least three vowels in a row
34
+ def sensible_name?(name)
35
+ name != ~ /.*[aeiou]{3}.*/i # reject if at least three vowels in a row
38
36
  end
39
37
 
40
38
  def random_syllable_count
@@ -42,23 +40,15 @@ module NameGenerator
42
40
  end
43
41
 
44
42
  def digraphs
45
- [
46
- "a", "ac", "ad", "ar", "as", "at", "ax", "ba", "bi", "bo", "ce", "ci",
47
- "co", "de", "di", "e", "ed", "en", "es", "ex", "fa", "fo", "ga", "ge",
48
- "gi", "gu", "ha", "he", "in", "is", "it", "ju", "ka", "ky", "la", "le",
49
- "le", "lo", "mi", "mo", "na", "ne", "ne", "ni", "no", "o", "ob", "oi",
50
- "ol", "on", "or", "or", "os", "ou", "pe", "pi", "po", "qt", "re", "ro",
51
- "sa", "se", "so", "ta", "te", "ti", "to", "tu", "ud", "um", "un", "us",
52
- "ut", "va", "ve", "ve", "za", "zi"
53
- ]
43
+ %w(a ac ad ar as at ax ba bi bo ce ci co de di e ed en es ex fa fo
44
+ ga ge gi gu ha he in is it ju ka ky la le le lo mi mo na ne ne ni
45
+ no o ob oi ol on or or os ou pe pi po qt re ro sa se so ta te ti
46
+ to tu ud um un us ut va ve ve za zi)
54
47
  end
55
48
 
56
49
  def trigraphs
57
- [
58
- "cla", "clu", "cra", "cre", "dre", "dro", "pha", "phi", "pho", "sha",
59
- "she", "sta", "stu", "tha", "the", "thi", "thy", "tri"
60
- ]
50
+ %w(cla clu cra cre dre dro pha phi pho sha she sta stu tha the thi
51
+ thy tri)
61
52
  end
62
-
63
53
  end
64
54
  end
@@ -1,3 +1,4 @@
1
+ # Simple and automatic name generation
1
2
  module NameGenerator
2
- VERSION = '0.1.2'
3
- end
3
+ VERSION = '0.1.3'
4
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: name-generator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Laust Rud Jacobsen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-08 00:00:00.000000000 Z
11
+ date: 2015-09-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rubocop
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'
41
55
  description:
42
56
  email: laust@object.io
43
57
  executables: []
@@ -71,7 +85,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
71
85
  version: '0'
72
86
  requirements: []
73
87
  rubyforge_project:
74
- rubygems_version: 2.4.5
88
+ rubygems_version: 2.4.8
75
89
  signing_key:
76
90
  specification_version: 4
77
91
  summary: Easily generate game-compatible names