namna 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +18 -5
- data/lib/namna.rb +2 -2
- data/lib/namna/generator.rb +10 -4
- data/lib/namna/version.rb +1 -1
- data/namna.gemspec +2 -2
- data/test/generator_test.rb +17 -11
- data/test/string_test.rb +11 -6
- metadata +5 -7
- data/bin/namna +0 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a4aa7cd19f2b862feccc25d8cfdcc0893a41910d
|
4
|
+
data.tar.gz: 2fd8645ccf0420be4ef8443e56a6ce8f75afcf88
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 088a1b9035e07a8eb67f5e52236a4eeb510d31aa1f28af97271117a218c4335a00010890f0f8cce3c75fb2f5e2cefeddb2b8f505b56bb070cf3a9078a157eea7
|
7
|
+
data.tar.gz: 9df75ea79989b51286f2cdf3cb742e6f383e66438c5b20ed183f96e335943130843d523944a8f6da464807d51e8c50058087790a0850c1b88ed4f5b2062f2bd2
|
data/README.md
CHANGED
@@ -1,8 +1,9 @@
|
|
1
|
+
[![Gem Version](https://badge.fury.io/rb/namna.svg)](http://badge.fury.io/rb/namna)
|
1
2
|
[![Build Status](https://travis-ci.org/kodnin/namna.svg?branch=master)](https://travis-ci.org/kodnin/namna)
|
2
3
|
|
3
4
|
# Namna
|
4
5
|
|
5
|
-
|
6
|
+
A name generator written in Ruby.
|
6
7
|
|
7
8
|
## Installation
|
8
9
|
|
@@ -22,12 +23,24 @@ Or install it yourself as:
|
|
22
23
|
|
23
24
|
## Usage
|
24
25
|
|
25
|
-
|
26
|
+
Require the gem in your project or ```irb``` and generate a name:
|
26
27
|
|
27
|
-
|
28
|
-
|
28
|
+
```ruby
|
29
|
+
require 'namna'
|
30
|
+
# => true
|
31
|
+
Generator.random
|
32
|
+
# => 'nuceop'
|
33
|
+
Generator.random(5)
|
34
|
+
# => 'xtkna'
|
35
|
+
Generator.human
|
36
|
+
# => 'fizaze'
|
37
|
+
Generator.human(5)
|
38
|
+
# => 'oxemo'
|
39
|
+
Generator.format('a?*#z')
|
40
|
+
# => 'adebz'
|
41
|
+
```
|
29
42
|
|
30
|
-
|
43
|
+
Use the ```random``` method to generate a random name. Specify its length with an optional argument. Use the ```human``` method to generate a humanized random name. Again it is optional to specify a length. Use the ```format``` method to generate a formatted name. A ```?``` is substituted for a random character, a ```*``` is substituted for a vowel and a ```#``` is substituted for a consonant. Non-special characters remain unchanged.
|
31
44
|
|
32
45
|
## Contributing
|
33
46
|
|
data/lib/namna.rb
CHANGED
data/lib/namna/generator.rb
CHANGED
@@ -1,11 +1,17 @@
|
|
1
1
|
class Generator
|
2
|
-
|
2
|
+
def self.random(length=(3..7).to_a.sample)
|
3
|
+
generate('?' * length)
|
4
|
+
end
|
5
|
+
|
6
|
+
def self.human(length=(3..7).to_a.sample)
|
7
|
+
generate(('*#' * length).slice(rand(length), length))
|
8
|
+
end
|
3
9
|
|
4
|
-
def
|
5
|
-
|
10
|
+
def self.format(format)
|
11
|
+
generate(format)
|
6
12
|
end
|
7
13
|
|
8
|
-
def generate
|
14
|
+
def self.generate(format)
|
9
15
|
format.split('').map(&:namna_sub).join('')
|
10
16
|
end
|
11
17
|
end
|
data/lib/namna/version.rb
CHANGED
data/namna.gemspec
CHANGED
@@ -8,8 +8,8 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.version = Namna::VERSION
|
9
9
|
spec.authors = ['David Boot']
|
10
10
|
spec.email = ['kodnin@gmail.com']
|
11
|
-
spec.summary = %q{
|
12
|
-
spec.description = %q{
|
11
|
+
spec.summary = %q{Name generator.}
|
12
|
+
spec.description = %q{Name generator written in Ruby.}
|
13
13
|
spec.homepage = 'https://github.com/kodnin/namna'
|
14
14
|
spec.license = 'MIT'
|
15
15
|
|
data/test/generator_test.rb
CHANGED
@@ -1,20 +1,26 @@
|
|
1
1
|
require_relative './test_helper'
|
2
2
|
|
3
3
|
class TestGenerator < Minitest::Test
|
4
|
-
def
|
5
|
-
|
4
|
+
def test_random
|
5
|
+
assert (3..7).include?(Generator.random.length)
|
6
|
+
assert_equal 5, Generator.random(5).length
|
6
7
|
end
|
7
8
|
|
8
|
-
def
|
9
|
-
|
9
|
+
def test_human
|
10
|
+
assert (3..7).include?(Generator.human.length)
|
11
|
+
assert_equal 5, Generator.human(5).length
|
10
12
|
end
|
11
13
|
|
12
|
-
def
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
assert_equal 'z',
|
14
|
+
def test_format
|
15
|
+
name = Generator.format('a?*#z')
|
16
|
+
|
17
|
+
assert_equal 5, name.length
|
18
|
+
|
19
|
+
assert_equal 'a', name[0]
|
20
|
+
assert_equal 'z', name[4]
|
21
|
+
|
22
|
+
assert_includes String::ALPHABET, name[1]
|
23
|
+
assert_includes String::VOWELS, name[2]
|
24
|
+
assert_includes String::CONSONANTS, name[3]
|
19
25
|
end
|
20
26
|
end
|
data/test/string_test.rb
CHANGED
@@ -3,22 +3,27 @@ require_relative './test_helper'
|
|
3
3
|
class TestString < Minitest::Test
|
4
4
|
def test_constants
|
5
5
|
assert_equal 26, String::ALPHABET.length
|
6
|
-
assert_includes String::ALPHABET, 'a'
|
7
|
-
assert_includes String::ALPHABET, 'b'
|
6
|
+
assert_includes String::ALPHABET, 'a'
|
7
|
+
assert_includes String::ALPHABET, 'b'
|
8
|
+
|
8
9
|
assert_equal 5, String::VOWELS.length
|
9
|
-
assert_includes String::VOWELS, 'a'
|
10
|
-
refute_includes String::VOWELS, 'b'
|
10
|
+
assert_includes String::VOWELS, 'a'
|
11
|
+
refute_includes String::VOWELS, 'b'
|
12
|
+
|
11
13
|
assert_equal 21, String::CONSONANTS.length
|
12
|
-
assert_includes String::CONSONANTS, 'b'
|
13
|
-
refute_includes String::CONSONANTS, 'a'
|
14
|
+
assert_includes String::CONSONANTS, 'b'
|
15
|
+
refute_includes String::CONSONANTS, 'a'
|
14
16
|
end
|
15
17
|
|
16
18
|
def test_namna_sub
|
17
19
|
assert_equal 'a', 'a'.namna_sub
|
18
20
|
assert_equal 'b', 'b'.namna_sub
|
21
|
+
|
19
22
|
assert_includes String::ALPHABET, '?'.namna_sub
|
23
|
+
|
20
24
|
assert_includes String::VOWELS, '*'.namna_sub
|
21
25
|
refute_includes String::CONSONANTS, '*'.namna_sub
|
26
|
+
|
22
27
|
assert_includes String::CONSONANTS, '#'.namna_sub
|
23
28
|
refute_includes String::VOWELS, '#'.namna_sub
|
24
29
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: namna
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Boot
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-11-
|
11
|
+
date: 2014-11-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -52,11 +52,10 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: 5.4.2
|
55
|
-
description:
|
55
|
+
description: Name generator written in Ruby.
|
56
56
|
email:
|
57
57
|
- kodnin@gmail.com
|
58
|
-
executables:
|
59
|
-
- namna
|
58
|
+
executables: []
|
60
59
|
extensions: []
|
61
60
|
extra_rdoc_files: []
|
62
61
|
files:
|
@@ -66,7 +65,6 @@ files:
|
|
66
65
|
- LICENSE.txt
|
67
66
|
- README.md
|
68
67
|
- Rakefile
|
69
|
-
- bin/namna
|
70
68
|
- lib/namna.rb
|
71
69
|
- lib/namna/generator.rb
|
72
70
|
- lib/namna/string.rb
|
@@ -98,7 +96,7 @@ rubyforge_project:
|
|
98
96
|
rubygems_version: 2.4.2
|
99
97
|
signing_key:
|
100
98
|
specification_version: 4
|
101
|
-
summary:
|
99
|
+
summary: Name generator.
|
102
100
|
test_files:
|
103
101
|
- test/generator_test.rb
|
104
102
|
- test/string_test.rb
|
data/bin/namna
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require 'namna'
|
4
|
-
|
5
|
-
if ARGV.empty? || ARGV.first == '-h' || ARGV.first == '--help'
|
6
|
-
puts "namna '<format>'"
|
7
|
-
puts " where:"
|
8
|
-
puts " a-z remains a-z"
|
9
|
-
puts " ? becomes random"
|
10
|
-
puts " * becomes vowel"
|
11
|
-
puts " # becomes consonant"
|
12
|
-
elsif ARGV.first == '-v' || ARGV.first == '--version'
|
13
|
-
puts Namna::VERSION
|
14
|
-
else
|
15
|
-
puts Generator.new(ARGV.first).generate
|
16
|
-
end
|