Ripsum

Random Lorem Ipsum with every page load

Ripsum is a small Ruby gem that adds a helper method for outputting random amounts of Lorem Ipsum per page load. Each time you refresh the page, you get a new set of words.

The philosophy behind Ripsum is simple: designs should be stress tested. Don't fill your page with perfect, static text. You'll never find the problems that way. Instead, randomize your text to find edge cases you otherwise wouldn't notice. The next paragraph is an example of Ripsum in action.

Installation

Add the following to your Gemfile:

gem 'ripsum'

And then execute:

bundle install

Or Install it yourself via:

$ gem install ripsum

Usage

<%= ripsum(100) %>

Or

<%= ripsum(100, 0.5) %> # With Variance

The ripsum method takes two arguments. The first argument is the standard word count desired. In the example above, that would be 100 words.

The second argument is the variance. This argument is optional. The default value for variance is 0 and can be omitted from the method call. This would result in the exact number of words you specify with each page load, though the words themselves will continue to be random. If you would like variance in the word output, you must use a floating point decimal with a leading zero. Thus, in the example above, we desire a possible variance of 50%, so we use the decimal 0.5.

Ripsum takes the standard word count and calculates the minimum and maximum word count based on the variance. Then, it randomly chooses a number in that range and outputs that amount of Lorem ipsum text.

Configuration

Currently, the only configurable option is the library of words that Ripsum uses. You can pass your own string of words in a configuration block. If you're using Rails, create a file in the config/initializers directory, perhaps named ripsum_initializer.rb (though it can be named whatever you would like).

Make sure to restart your server. It is an initializer file after all.

Psst. There's More!

You might be wondering why a Heroku app has only a home page and no apparent app. That's because the app is a secret.

If you append two numbers to the end of the URL, you will hit the Ripsum API and return a small JSON object of random Lorem Ipsum text. In case you need a Ripsum and aren't using a Ruby framework, now you can AJAX some fresh words straight to your application.

To do so, do something like this:

http://ripsum.herokuapp.com/100/50

The only difference between this and the Ruby method is that variance should be supplied as an integer of the percent you would like and not a floating point number. Hence, 50 instead of 0.5. Got it? Good!