0.01
No commit activity in last 3 years
No release in over 3 years
To spin some text, mainly for SEO purpose. Spinning the string "Hi {there|you}! I'm {efficient|productive}." gives these four strings : * Hi there! I'm efficient. * Hi there! I'm productive. * Hi you! I'm efficient. * Hi you! I'm productive.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 3.4
 Project Readme

Content Spinning

Gem Version Build Status

ContentSpinning is a ruby library made to spin some text. It manages nested spinning.

Example

"Hi {there|you}! I'm {efficient|productive}.".spin
# or
ContentSpinning.spin("Hi {there|you}! I'm {efficient|productive}.")

returns this array :

[
  "Hi there! I'm efficient.",
  "Hi there! I'm productive.",
  "Hi you! I'm efficient.",
  "Hi you! I'm productive."
]

Install

gem install content_spinning

Usage

All spins

Calculating the number of possibilities:

> ContentSpinning.new("Hi {there|you}! I'm {efficient|productive}.").count

4

Generating:

> ContentSpinning.new("Hi {there|you}! I'm {efficient|productive}.").spin

[
  "Hi there! I'm efficient.",
  "Hi there! I'm productive.",
  "Hi you! I'm efficient.",
  "Hi you! I'm productive."
]

Beware, spins being combinatory, generating all the spins could be quite long.

Partial spins

There is no guaranty of unicity among the results returned (this is random). If you ask for a limit greater than the number of possibilities, this returns all the possibilities.

> ContentSpinning.new("Hi {there|you}! I'm {efficient|productive}.").spin(limit: 2)

[
  "Hi there! I'm efficient.",
  "Hi you! I'm productive."
]

> ContentSpinning.new("Hi {there|you}! I'm {efficient|productive}.").spin(limit: 500)

[
  "Hi there! I'm efficient.",
  "Hi there! I'm productive.",
  "Hi you! I'm efficient.",
  "Hi you! I'm productive."
]

Todo

A few things to do :

  • Executable