haikunator 1.0.1 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.coveralls.yml +1 -0
- data/.rspec +2 -0
- data/.rubocop.yml +14 -0
- data/.travis.yml +18 -0
- data/CHANGELOG.md +3 -0
- data/Gemfile +1 -1
- data/README.md +17 -5
- data/Rakefile +6 -0
- data/haikunator.gemspec +9 -4
- data/lib/haikunator.rb +37 -28
- data/lib/haikunator/version.rb +1 -1
- data/spec/lib/haikunator_spec.rb +40 -0
- data/spec/spec_helper.rb +23 -0
- metadata +55 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2fef78768bf20722486d7686a36d34044747e04a
|
4
|
+
data.tar.gz: ee83c6dd21f8f180a6d307d1e35153cad6b707aa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0565bb6f7147e555b6287aafef4e70393cb2c28e97a74819e1c4a63496d0eeb9775470d31ca6fd9f9176e75f8edad5c384d1928e21a15afb9691be7aa1648ded
|
7
|
+
data.tar.gz: 81f887bfcf2670e2f30940e986453afa1be7a00aa2cdc91687050ecab811da53d3417d8f9a04ecd4176622acc311e428f00c263e793f2348a0f667d792c2d49e
|
data/.coveralls.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
service_name: travis-ci
|
data/.rspec
ADDED
data/.rubocop.yml
ADDED
data/.travis.yml
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
language: ruby
|
2
|
+
cache: bundler
|
3
|
+
|
4
|
+
rvm:
|
5
|
+
- 2.2.0
|
6
|
+
- 2.1.2
|
7
|
+
- 2.1.0
|
8
|
+
- 2.0.0
|
9
|
+
- 1.9.3
|
10
|
+
|
11
|
+
script: 'bundle exec rake'
|
12
|
+
|
13
|
+
notifications:
|
14
|
+
email:
|
15
|
+
on_failure: change
|
16
|
+
on_success: never
|
17
|
+
slack:
|
18
|
+
secure: j0pMnM5JiBxiNsFf1n4DtsNSSkmaSW6w8KRy9D5V0ArxPEr7GdlAVfmsgqFIsOCEnm7CvREvUDGEQqx2Y9oIUxjxtnKYhQgru+DG+dONZQIEtOyRGL4UQKYDms/843DnXKuHuFUVeAu7alL9sKFTXFqaVT/r+YRk79cGt4vdfYg=
|
data/CHANGELOG.md
ADDED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
# Haikunator
|
2
2
|
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/haikunator.svg)](http://badge.fury.io/rb/haikunator)
|
4
|
+
[![Build Status](https://travis-ci.org/usmanbashir/haikunator.svg?branch=master)](https://travis-ci.org/usmanbashir/haikunator)
|
5
|
+
[![Coverage Status](https://coveralls.io/repos/usmanbashir/haikunator/badge.svg)](https://coveralls.io/r/usmanbashir/haikunator)
|
4
6
|
|
5
7
|
Generate Heroku-like memorable random names to use in your apps or anywhere else.
|
6
8
|
|
@@ -38,10 +40,20 @@ Haikunator.haikunate(9999, '.') # => "cool.leaf.6743"
|
|
38
40
|
Haikunator.haikunate(0, ' ') # => "green fire"
|
39
41
|
```
|
40
42
|
|
43
|
+
## History
|
44
|
+
|
45
|
+
View the [changelog](https://github.com/usmanbashir/haikunator/blob/master/CHANGELOG.md)
|
46
|
+
|
41
47
|
## Contributing
|
42
48
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
49
|
+
Everyone is encouraged to help improve this project. Here are a few ways you can help:
|
50
|
+
|
51
|
+
- [Report bugs](https://github.com/usmanbashir/haikunator/issues)
|
52
|
+
- Fix bugs and [submit pull requests](https://github.com/usmanbashir/haikunator/pulls)
|
53
|
+
- Write, clarify, or fix documentation
|
54
|
+
- Suggest or add new features
|
55
|
+
|
56
|
+
|
57
|
+
## License
|
58
|
+
|
59
|
+
MIT
|
data/Rakefile
CHANGED
data/haikunator.gemspec
CHANGED
@@ -1,15 +1,16 @@
|
|
1
1
|
# coding: utf-8
|
2
|
-
lib = File.expand_path(
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
3
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require
|
4
|
+
require "haikunator/version"
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = "haikunator"
|
8
8
|
spec.version = Haikunator::VERSION
|
9
9
|
spec.authors = ["Usman Bashir"]
|
10
10
|
spec.email = ["me@usmanbashir.com"]
|
11
|
-
spec.summary =
|
12
|
-
spec.description =
|
11
|
+
spec.summary = "Heroku-like random name generator."
|
12
|
+
spec.description = "Generate memorable random names to use in your apps"\
|
13
|
+
" or anywhere else."
|
13
14
|
spec.homepage = "https://github.com/usmanbashir/haikunator"
|
14
15
|
spec.license = "MIT"
|
15
16
|
|
@@ -17,4 +18,8 @@ Gem::Specification.new do |spec|
|
|
17
18
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
19
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
20
|
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
spec.add_development_dependency "rspec"
|
24
|
+
spec.add_development_dependency "coveralls"
|
20
25
|
end
|
data/lib/haikunator.rb
CHANGED
@@ -1,49 +1,58 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "haikunator/version"
|
2
|
+
require "securerandom"
|
3
3
|
|
4
4
|
module Haikunator
|
5
5
|
class << self
|
6
|
+
def haikunate(token_range = 9999, delimiter = "-")
|
7
|
+
seed = random_seed
|
6
8
|
|
7
|
-
|
8
|
-
|
9
|
+
build(seed, token_range, delimiter)
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
9
13
|
|
10
|
-
|
11
|
-
sections
|
12
|
-
|
13
|
-
|
14
|
+
def build(seed, token_range, delimiter)
|
15
|
+
sections = [
|
16
|
+
adjectives[seed % adjectives.length],
|
17
|
+
nouns[seed % nouns.length],
|
18
|
+
token(token_range)
|
19
|
+
]
|
14
20
|
|
15
21
|
sections.compact.join(delimiter)
|
16
22
|
end
|
17
23
|
|
18
|
-
|
24
|
+
def random_seed
|
25
|
+
(SecureRandom.random_number * (2**12)).floor
|
26
|
+
end
|
19
27
|
|
20
28
|
def token(range)
|
21
29
|
SecureRandom.random_number(range) if range > 0
|
22
30
|
end
|
23
31
|
|
24
32
|
def adjectives
|
25
|
-
%w
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
red rough still small
|
31
|
-
wandering withered wild black
|
32
|
-
fragrant aged snowy proud floral
|
33
|
-
polished ancient purple lively nameless
|
33
|
+
%w(
|
34
|
+
autumn hidden bitter misty silent empty dry dark summer
|
35
|
+
icy delicate quiet white cool spring winter patient
|
36
|
+
twilight dawn crimson wispy weathered blue billowing
|
37
|
+
broken cold damp falling frosty green long late lingering
|
38
|
+
bold little morning muddy old red rough still small
|
39
|
+
sparkling throbbing shy wandering withered wild black
|
40
|
+
young holy solitary fragrant aged snowy proud floral
|
41
|
+
restless divine polished ancient purple lively nameless
|
42
|
+
)
|
34
43
|
end
|
35
44
|
|
36
45
|
def nouns
|
37
|
-
%w
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
wood dream cherry tree fog
|
45
|
-
frog smoke star
|
46
|
+
%w(
|
47
|
+
waterfall river breeze moon rain wind sea morning
|
48
|
+
snow lake sunset pine shadow leaf dawn glitter forest
|
49
|
+
hill cloud meadow sun glade bird brook butterfly
|
50
|
+
bush dew dust field fire flower firefly feather grass
|
51
|
+
haze mountain night pond darkness snowflake silence
|
52
|
+
sound sky shape surf thunder violet water wildflower
|
53
|
+
wave water resonance sun wood dream cherry tree fog
|
54
|
+
frost voice paper frog smoke star
|
55
|
+
)
|
46
56
|
end
|
47
|
-
|
48
57
|
end
|
49
58
|
end
|
data/lib/haikunator/version.rb
CHANGED
@@ -0,0 +1,40 @@
|
|
1
|
+
require_relative "../spec_helper"
|
2
|
+
|
3
|
+
describe Haikunator do
|
4
|
+
it "generates a name like still-silence-5012" do
|
5
|
+
name = Haikunator.haikunate
|
6
|
+
|
7
|
+
expect(name).to match(/\A\w+-\w+-\d{1,4}\z/)
|
8
|
+
end
|
9
|
+
|
10
|
+
it "won't return the same name for subsequent calls" do
|
11
|
+
name1 = Haikunator.haikunate
|
12
|
+
name2 = Haikunator.haikunate
|
13
|
+
|
14
|
+
expect(name1).not_to eql(name2)
|
15
|
+
end
|
16
|
+
|
17
|
+
it "permits optional configuration of the token range" do
|
18
|
+
name = Haikunator.haikunate(9)
|
19
|
+
|
20
|
+
expect(name).to match(/-\d{1}\z/)
|
21
|
+
end
|
22
|
+
|
23
|
+
it "drops the token if token range is 0" do
|
24
|
+
name = Haikunator.haikunate(0)
|
25
|
+
|
26
|
+
expect(name).to match(/\A\w+-\w+\z/)
|
27
|
+
end
|
28
|
+
|
29
|
+
it "permits optional configuration of the delimiter" do
|
30
|
+
name = Haikunator.haikunate(9999, ".")
|
31
|
+
|
32
|
+
expect(name).to match(/\A\w+\.\w+\.\d{1,4}\z/)
|
33
|
+
end
|
34
|
+
|
35
|
+
it "drops the token and delimiter if token range is 0 and delimiter empty space" do
|
36
|
+
name = Haikunator.haikunate(0, " ")
|
37
|
+
|
38
|
+
expect(name).to match(/\A\w+ \w+\z/)
|
39
|
+
end
|
40
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require "coveralls"
|
2
|
+
Coveralls.wear!
|
3
|
+
|
4
|
+
require "haikunator"
|
5
|
+
|
6
|
+
RSpec.configure do |config|
|
7
|
+
config.expect_with :rspec do |expectations|
|
8
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
9
|
+
end
|
10
|
+
|
11
|
+
config.mock_with :rspec do |mocks|
|
12
|
+
mocks.verify_partial_doubles = true
|
13
|
+
end
|
14
|
+
|
15
|
+
# Use the specified formatter
|
16
|
+
config.formatter = :documentation
|
17
|
+
|
18
|
+
# Print top 2 slowest examples
|
19
|
+
config.profile_examples = 2
|
20
|
+
|
21
|
+
# Run specs in random order
|
22
|
+
config.order = :random
|
23
|
+
end
|
metadata
CHANGED
@@ -1,15 +1,57 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: haikunator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Usman Bashir
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
12
|
-
dependencies:
|
11
|
+
date: 2015-02-22 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rake
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rspec
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: coveralls
|
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'
|
13
55
|
description: Generate memorable random names to use in your apps or anywhere else.
|
14
56
|
email:
|
15
57
|
- me@usmanbashir.com
|
@@ -17,7 +59,12 @@ executables: []
|
|
17
59
|
extensions: []
|
18
60
|
extra_rdoc_files: []
|
19
61
|
files:
|
62
|
+
- ".coveralls.yml"
|
20
63
|
- ".gitignore"
|
64
|
+
- ".rspec"
|
65
|
+
- ".rubocop.yml"
|
66
|
+
- ".travis.yml"
|
67
|
+
- CHANGELOG.md
|
21
68
|
- Gemfile
|
22
69
|
- LICENSE.txt
|
23
70
|
- README.md
|
@@ -25,6 +72,8 @@ files:
|
|
25
72
|
- haikunator.gemspec
|
26
73
|
- lib/haikunator.rb
|
27
74
|
- lib/haikunator/version.rb
|
75
|
+
- spec/lib/haikunator_spec.rb
|
76
|
+
- spec/spec_helper.rb
|
28
77
|
homepage: https://github.com/usmanbashir/haikunator
|
29
78
|
licenses:
|
30
79
|
- MIT
|
@@ -49,4 +98,6 @@ rubygems_version: 2.2.2
|
|
49
98
|
signing_key:
|
50
99
|
specification_version: 4
|
51
100
|
summary: Heroku-like random name generator.
|
52
|
-
test_files:
|
101
|
+
test_files:
|
102
|
+
- spec/lib/haikunator_spec.rb
|
103
|
+
- spec/spec_helper.rb
|