Code Monkey home page Code Monkey logo

frosty-meadow's Introduction

frosty-meadow

Build Status

What is this?

This gem will generate a random name for your server, much in the way Heroku does.

Installation

To install the gem, run the command: gem install frosty_meadow

Alternatively you can add the following to your Gemfile:

gem "frosty_meadow"

and then run bundle install

How do I use it?

It's simple really!

require 'frosty_meadow'

FrostyMeadow.generate #=> sparkling frost

You can specify a custom separator easily:

FrostyMeadow.generate(:separator => '-') #=> frosty-meadow

Custom adjectives/nouns may also be used:

FrostyMeadow.generate(:adjectives => ["beautiful", "amazing", "awesome"], :nouns => ["world", "earth", "globe"]) #=> amazing world

If you are using this to generate server names similar to how heroku does it, then the generate_hex_name method will provide you with one formatted similarly:

FrostyMeadow.generate_hex_name #=> billowing-snowflake-41aa3

You can generate a hex string like the example above (41aa3 in this case) by using (the first argument will be the length of the string required which defaults to 5):

FrostyMeadow::Hex.generate 	   #=> fa391
FrostyMeadow::Hex.generate(25) #=> 7c145ff861ad26a55e3ad83c1

Caching

There is a very basic caching method in place now that will stop FrostyMeadow reading from data/words.json every single time. If for whatever reason you need to skip the check for this cache and reload the file, you can pass :skip_cache as true into the params for .generate

Loading Words From External Files

Using the parameters to use a custom word list may be fine for small or dynamic purposes, but sometimes you may need to load from an external file. To do so, just pass :from_file as a parameter with the path of a valid JSON file in the following format:

{
   "adjectives":[
      "beautiful",
      "amazing",
      "awesome"
   ],
   "nouns":[
      "world",
      "earth",
      "globe"
   ]
}

For example, presuming the above JSON was in a file called something like data/my_custom_word_list.json the following would work:

FrostyMeadow.generate(:from_file => 'data/my_custom_word_list.json') #=> amazing world
FrostyMeadow.generate_hex_name(:from_file => 'data/my_custom_word_list.json') #=> awesome-globe-57c6d5

Contributors

* Andy Hamilton (@andyhmltn) (Repo Owner)
* Scott Simms (@scottmsims) (#12)

Pull requests

Pull requests are more than welcome. To test, just use rspec: bundle exec rspec. If you end up submitting a request, please increment the gem version by editing the 'VERSION' module in lib/frosty_meadow.rb

Credits

Credit to this great gist for the idea: https://gist.github.com/afriggeri/1266756

frosty-meadow's People

Contributors

andyhmltn avatar scottmsims avatar

Stargazers

Pascal Mathis avatar Matt Riley avatar Anton Cohen avatar Pellaeon Lin avatar Reilly Tucker Siemens avatar Luka Rajčević avatar Jason avatar Sergey Grankin avatar Nich avatar  avatar Christian Höppner avatar Sumeet Singh avatar

Watchers

 avatar

frosty-meadow's Issues

Make FrostyMeadow a class

You're treating the module FrostyMeadow like a class, giving it singleton methods that setup and then store/produce data, but it's a module.

Add an option called 'separator'

Currently, underscored is the only option that allows you to chain the word together and it only allows you to use... you guessed it: underscores.

I think replacing this with separator would be a better option.

License missing from gemspec

Some companies will only use gems with a certain license.
The canonical and easy way to check is via the gemspec
via e.g.

spec.license = 'MIT'
# or
spec.licenses = ['MIT', 'GPL-2']

Bundler now generates gems with a default 'MIT' license. There is even a License Finder
to help companies ensure all gems they use meet their licensing needs. This tool depends on license information being available in the gemspec.
Including a license in your gemspec is a good practice, in any case.

If you need help choosing a license, github has created a license picker tool

How did I find you?

I'm using a script to collect stats on gems, originally looking for download data, but decided to collect licenses too,
and make issues for gemspecs not specifying a license as a public service :)
So far it's going pretty well.
I've written a blog post about it

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.