haikunator-1.1.0/0000755000000000000000000000000012772502533012362 5ustar rootroothaikunator-1.1.0/.travis.yml0000644000000000000000000000057212772502533014477 0ustar rootrootlanguage: ruby cache: bundler rvm: - 2.2.0 - 2.1.2 - 2.1.0 - 2.0.0 - 1.9.3 script: 'bundle exec rake' notifications: email: on_failure: change on_success: never slack: secure: j0pMnM5JiBxiNsFf1n4DtsNSSkmaSW6w8KRy9D5V0ArxPEr7GdlAVfmsgqFIsOCEnm7CvREvUDGEQqx2Y9oIUxjxtnKYhQgru+DG+dONZQIEtOyRGL4UQKYDms/843DnXKuHuFUVeAu7alL9sKFTXFqaVT/r+YRk79cGt4vdfYg= haikunator-1.1.0/.rubocop.yml0000644000000000000000000000027612772502533014641 0ustar rootrootAllCops: DisplayCopNames: true Style/StringLiterals: EnforcedStyle: double_quotes Documentation: Enabled: false Style/RegexpLiteral: Enabled: false Metrics/LineLength: Max: 90 haikunator-1.1.0/Rakefile0000644000000000000000000000020212772502533014021 0ustar rootrootrequire "rake" require "bundler/gem_tasks" require "rspec/core/rake_task" RSpec::Core::RakeTask.new(:spec) task default: :spec haikunator-1.1.0/Gemfile0000644000000000000000000000013712772502533013656 0ustar rootrootsource "https://rubygems.org" # Specify your gem's dependencies in haikunator.gemspec gemspec haikunator-1.1.0/haikunator.gemspec0000644000000000000000000000172712772502533016103 0ustar rootroot# coding: utf-8 lib = File.expand_path("../lib", __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require "haikunator/version" Gem::Specification.new do |spec| spec.name = "haikunator" spec.version = Haikunator::VERSION spec.authors = ["Usman Bashir"] spec.email = ["me@usmanbashir.com"] spec.summary = "Heroku-like random name generator." spec.description = "Generate memorable random names to use in your apps"\ " or anywhere else." spec.homepage = "https://github.com/usmanbashir/haikunator" spec.license = "MIT" spec.files = `git ls-files -z`.split("\x0") spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) spec.require_paths = ["lib"] spec.add_development_dependency "rake" spec.add_development_dependency "rspec" spec.add_development_dependency "coveralls" end haikunator-1.1.0/README.md0000644000000000000000000000300612772502533013640 0ustar rootroot# Haikunator [![Gem Version](https://badge.fury.io/rb/haikunator.svg)](http://badge.fury.io/rb/haikunator) [![Build Status](https://travis-ci.org/usmanbashir/haikunator.svg?branch=master)](https://travis-ci.org/usmanbashir/haikunator) [![Coverage Status](https://coveralls.io/repos/usmanbashir/haikunator/badge.svg)](https://coveralls.io/r/usmanbashir/haikunator) Generate Heroku-like memorable random names to use in your apps or anywhere else. ## Installation Add this line to your application's Gemfile: gem 'haikunator' And then execute: $ bundle Or install it yourself as: $ gem install haikunator ## Usage Haikunator is pretty simple. There is nothing to configure and it only has a single method, `.haikunate`: ```ruby Haikunator.haikunate # => "rough-snowflake-1142" # Token range Haikunator.haikunate(100) # => "nameless-star-13" # Don't include the token Haikunator.haikunate(0) # => "long-flower" # Use a different delimiter Haikunator.haikunate(9999, '.') # => "cool.leaf.6743" # No token, no delimiter Haikunator.haikunate(0, ' ') # => "green fire" ``` ## History View the [changelog](https://github.com/usmanbashir/haikunator/blob/master/CHANGELOG.md) ## Contributing Everyone is encouraged to help improve this project. Here are a few ways you can help: - [Report bugs](https://github.com/usmanbashir/haikunator/issues) - Fix bugs and [submit pull requests](https://github.com/usmanbashir/haikunator/pulls) - Write, clarify, or fix documentation - Suggest or add new features ## License MIT haikunator-1.1.0/CHANGELOG.md0000644000000000000000000000003212772502533014166 0ustar rootroot## 1.0.0 - First release haikunator-1.1.0/LICENSE.txt0000644000000000000000000000205512772502533014207 0ustar rootrootCopyright (c) 2015 Usman Bashir MIT License Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. haikunator-1.1.0/.coveralls.yml0000644000000000000000000000003012772502533015146 0ustar rootrootservice_name: travis-ci haikunator-1.1.0/.gitignore0000644000000000000000000000027112772502533014352 0ustar rootroot*.gem *.rbc .bundle .config .yardoc Gemfile.lock InstalledFiles _yardoc coverage doc/ lib/bundler/man pkg rdoc spec/reports test/tmp test/version_tmp tmp *.bundle *.so *.o *.a mkmf.log haikunator-1.1.0/.rspec0000644000000000000000000000003612772502533013476 0ustar rootroot--color --require spec_helper haikunator-1.1.0/lib/0000755000000000000000000000000012772502533013130 5ustar rootroothaikunator-1.1.0/lib/haikunator.rb0000644000000000000000000000322012772502533015617 0ustar rootrootrequire "haikunator/version" require "securerandom" module Haikunator class << self def haikunate(token_range = 9999, delimiter = "-") seed = random_seed build(seed, token_range, delimiter) end private def build(seed, token_range, delimiter) sections = [ adjectives[seed % adjectives.length], nouns[seed % nouns.length], token(token_range) ] sections.compact.join(delimiter) end def random_seed (SecureRandom.random_number * (2**12)).floor end def token(range) SecureRandom.random_number(range) if range > 0 end def adjectives %w( autumn hidden bitter misty silent empty dry dark summer icy delicate quiet white cool spring winter patient twilight dawn crimson wispy weathered blue billowing broken cold damp falling frosty green long late lingering bold little morning muddy old red rough still small sparkling throbbing shy wandering withered wild black young holy solitary fragrant aged snowy proud floral restless divine polished ancient purple lively nameless ) end def nouns %w( waterfall river breeze moon rain wind sea morning snow lake sunset pine shadow leaf dawn glitter forest hill cloud meadow sun glade bird brook butterfly bush dew dust field fire flower firefly feather grass haze mountain night pond darkness snowflake silence sound sky shape surf thunder violet water wildflower wave water resonance sun wood dream cherry tree fog frost voice paper frog smoke star ) end end end haikunator-1.1.0/lib/haikunator/0000755000000000000000000000000012772502533015275 5ustar rootroothaikunator-1.1.0/lib/haikunator/version.rb0000644000000000000000000000005212772502533017304 0ustar rootrootmodule Haikunator VERSION = "1.1.0" end haikunator-1.1.0/spec/0000755000000000000000000000000012772502533013314 5ustar rootroothaikunator-1.1.0/spec/spec_helper.rb0000644000000000000000000000075512772502533016141 0ustar rootrootrequire "coveralls" Coveralls.wear! require "haikunator" RSpec.configure do |config| config.expect_with :rspec do |expectations| expectations.include_chain_clauses_in_custom_matcher_descriptions = true end config.mock_with :rspec do |mocks| mocks.verify_partial_doubles = true end # Use the specified formatter config.formatter = :documentation # Print top 2 slowest examples config.profile_examples = 2 # Run specs in random order config.order = :random end haikunator-1.1.0/spec/lib/0000755000000000000000000000000012772502533014062 5ustar rootroothaikunator-1.1.0/spec/lib/haikunator_spec.rb0000644000000000000000000000171712772502533017574 0ustar rootrootrequire_relative "../spec_helper" describe Haikunator do it "generates a name like still-silence-5012" do name = Haikunator.haikunate expect(name).to match(/\A\w+-\w+-\d{1,4}\z/) end it "won't return the same name for subsequent calls" do name1 = Haikunator.haikunate name2 = Haikunator.haikunate expect(name1).not_to eql(name2) end it "permits optional configuration of the token range" do name = Haikunator.haikunate(9) expect(name).to match(/-\d{1}\z/) end it "drops the token if token range is 0" do name = Haikunator.haikunate(0) expect(name).to match(/\A\w+-\w+\z/) end it "permits optional configuration of the delimiter" do name = Haikunator.haikunate(9999, ".") expect(name).to match(/\A\w+\.\w+\.\d{1,4}\z/) end it "drops the token and delimiter if token range is 0 and delimiter empty space" do name = Haikunator.haikunate(0, " ") expect(name).to match(/\A\w+ \w+\z/) end end