namna 0.0.3 → 0.0.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 88875ba589b38bf48c968caaff07fcd1a9a9a065
4
- data.tar.gz: e6ae08ae68ff77a6c27c16a60499e2b32d9202ec
3
+ metadata.gz: a4aa7cd19f2b862feccc25d8cfdcc0893a41910d
4
+ data.tar.gz: 2fd8645ccf0420be4ef8443e56a6ce8f75afcf88
5
5
  SHA512:
6
- metadata.gz: fcfb246b23484a02fecae130fb8b026aefa85d78c67ebc95ca84e9f5983cc5555ce23b1e38baabba73d4f80411eda2b1b60f8460b629c3d6572a5c1a10075cf3
7
- data.tar.gz: c7f38bc4f1430d1b2a7b3dd0ef3e1ab9c125316666618772a1b98ad75c8b62f4085f85a31d3045a7772f4be3a57c48404b18aa6a32601f66d508c62f22e1bb61
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
- Namna is a simple formatted name generator for the command line written in Ruby.
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
- Generate a name by invoking the ```namna``` command with a format argument. For example:
26
+ Require the gem in your project or ```irb``` and generate a name:
26
27
 
27
- $ namna 'a?*#z'
28
- => adebz
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
- results in a name of five characters starting with an 'a', followed by a random character (?), a vowel (*), a consonant (#) and ending with a 'z'.
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
 
@@ -1,6 +1,6 @@
1
- require 'namna/version'
2
- require 'namna/string'
3
1
  require 'namna/generator'
2
+ require 'namna/string'
3
+ require 'namna/version'
4
4
 
5
5
  module Namna
6
6
  end
@@ -1,11 +1,17 @@
1
1
  class Generator
2
- attr_reader :format
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 initialize(format)
5
- @format = format.downcase
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
@@ -1,3 +1,3 @@
1
1
  module Namna
2
- VERSION = '0.0.3'
2
+ VERSION = '0.0.4'
3
3
  end
@@ -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{Simple formatted name generator.}
12
- spec.description = %q{A simple formatted name generator for the command line.}
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
 
@@ -1,20 +1,26 @@
1
1
  require_relative './test_helper'
2
2
 
3
3
  class TestGenerator < Minitest::Test
4
- def setup
5
- @generator = Generator.new('a?*#z')
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 test_initialize
9
- assert_equal 5, @generator.format.length
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 test_generate
13
- assert_equal 5, @generator.generate.length
14
- assert_equal 'a', @generator.generate[0]
15
- assert_includes String::ALPHABET, @generator.generate[1]
16
- assert_includes String::VOWELS, @generator.generate[2]
17
- assert_includes String::CONSONANTS, @generator.generate[3]
18
- assert_equal 'z', @generator.generate[4]
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
@@ -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'.namna_sub
7
- assert_includes String::ALPHABET, 'b'.namna_sub
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'.namna_sub
10
- refute_includes String::VOWELS, 'b'.namna_sub
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'.namna_sub
13
- refute_includes String::CONSONANTS, 'a'.namna_sub
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.3
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-07 00:00:00.000000000 Z
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: A simple formatted name generator for the command line.
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: Simple formatted name generator.
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