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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fd8f532e514f39895a0f4354c94cb82d4eeae876
4
- data.tar.gz: f9a648b600d5b0d2cdfcf6507dc099596b4f7c20
3
+ metadata.gz: 2fef78768bf20722486d7686a36d34044747e04a
4
+ data.tar.gz: ee83c6dd21f8f180a6d307d1e35153cad6b707aa
5
5
  SHA512:
6
- metadata.gz: fe51c0bc411d67a4f2149777676e62686cae191a8b7d7c8675f43a909df34abc988f27182346819e46dacd0a7636585799bd013dc2e97add4ea1d103b857cfce
7
- data.tar.gz: 6c6047dc844e60b9192cb975c74fc212215c25228a1f57eefe8629debcec19d574241ddec52d01bae34be7cca91c9a6c00bb674687efb5b9a7b014c54d9c0a6d
6
+ metadata.gz: 0565bb6f7147e555b6287aafef4e70393cb2c28e97a74819e1c4a63496d0eeb9775470d31ca6fd9f9176e75f8edad5c384d1928e21a15afb9691be7aa1648ded
7
+ data.tar.gz: 81f887bfcf2670e2f30940e986453afa1be7a00aa2cdc91687050ecab811da53d3417d8f9a04ecd4176622acc311e428f00c263e793f2348a0f667d792c2d49e
@@ -0,0 +1 @@
1
+ service_name: travis-ci
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
@@ -0,0 +1,14 @@
1
+ AllCops:
2
+ DisplayCopNames: true
3
+
4
+ Style/StringLiterals:
5
+ EnforcedStyle: double_quotes
6
+
7
+ Documentation:
8
+ Enabled: false
9
+
10
+ Style/RegexpLiteral:
11
+ Enabled: false
12
+
13
+ Metrics/LineLength:
14
+ Max: 90
@@ -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=
@@ -0,0 +1,3 @@
1
+ ## 1.0.0
2
+
3
+ - First release
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source 'https://rubygems.org'
1
+ source "https://rubygems.org"
2
2
 
3
3
  # Specify your gem's dependencies in haikunator.gemspec
4
4
  gemspec
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
- 1. Fork it ( https://github.com/[my-github-username]/haikunator/fork )
44
- 2. Create your feature branch (`git checkout -b my-new-feature`)
45
- 3. Commit your changes (`git commit -am 'Add some feature'`)
46
- 4. Push to the branch (`git push origin my-new-feature`)
47
- 5. Create a new Pull Request
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
@@ -1,2 +1,8 @@
1
+ require "rake"
1
2
  require "bundler/gem_tasks"
2
3
 
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task default: :spec
@@ -1,15 +1,16 @@
1
1
  # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
2
+ lib = File.expand_path("../lib", __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'haikunator/version'
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 = %q{Heroku-like random name generator.}
12
- spec.description = %q{Generate memorable random names to use in your apps or anywhere else.}
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
@@ -1,49 +1,58 @@
1
- require 'haikunator/version'
2
- require 'securerandom'
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
- def haikunate(token_range = 9999, delimiter = '-')
8
- rnd = (rand * (2 ** 12)).floor
9
+ build(seed, token_range, delimiter)
10
+ end
11
+
12
+ private
9
13
 
10
- sections = []
11
- sections << adjectives[rnd % adjectives.length]
12
- sections << nouns[rnd % nouns.length]
13
- sections << token(token_range)
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
- private
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[autumn hidden bitter misty silent empty dry dark
26
- summer icy delicate quiet white cool spring winter
27
- patient twilight dawn crimson wispy weathered blue
28
- billowing broken cold damp falling frosty green
29
- long late lingering bold little morning muddy old
30
- red rough still small sparkling throbbing shy
31
- wandering withered wild black young holy solitary
32
- fragrant aged snowy proud floral restless divine
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[waterfall river breeze moon rain wind sea morning
38
- snow lake sunset pine shadow leaf dawn glitter
39
- forest hill cloud meadow sun glade bird brook
40
- butterfly bush dew dust field fire flower firefly
41
- feather grass haze mountain night pond darkness
42
- snowflake silence sound sky shape surf thunder
43
- violet water wildflower wave water resonance sun
44
- wood dream cherry tree fog frost voice paper
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
@@ -1,3 +1,3 @@
1
1
  module Haikunator
2
- VERSION = "1.0.1"
2
+ VERSION = "1.1.0"
3
3
  end
@@ -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
@@ -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.1
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-01-18 00:00:00.000000000 Z
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