
Security News
New Website “Is It Really FOSS?” Tracks Transparency in Open Source Distribution Models
A new site reviews software projects to reveal if they’re truly FOSS, making complex licensing and distribution models easy to understand.
A mixin to parse "spintax", a text format used for automated article generation. Can handle nested spintax, and can count the total number of unique variations. Now also supports consistent unspinning!
Read more about the motivation behind it at the announcement of its initial release.
Add this line to your application's Gemfile:
gem 'spintax_parser'
And then execute:
$ bundle
Or install it yourself as:
$ gem install spintax_parser
Perhaps the simplest way to use it is to mix SpintaxParser
directly into the global String
class, like this:
require 'spintax_parser'
class String
include SpintaxParser
end
Then you can safely call #unspin
on any string in your application:
spintext = "{Hello|Hi} {{world|worlds}|planet}{!|.|?}"
10.times do
puts spintext.unspin
end
Run the code above, and you will end up with several random variations of the same text, such as:
Hi worlds.
Hi planet?
Hello world?
Hi planet?
Hi world?
Hi world!
Hi world.
Hello world.
Hello world!
Hello worlds.
And don't worry: calling #unspin
on a string with no spintax will safely return an unaffected copy of the string.
Also, note that the #unspin
method doesn't really care if the class you mix it into is a descendant of String
or not, as long as its #to_s
method returns a string written in spintax.
Got a special project that requires unspinning the same spintax the same way in certain circumstances? No problem. If you're using a Ruby version >= 1.9.3, you can pass a pre-seeded random number generator to the #unspin
method just like you would to the Array#sample
method. Et voila! Consistent unspinning!
seed = Random.new_seed
spintext.unspin :random => Random.new(seed) # => "Hello world!"
spintext.unspin :random => Random.new(seed) # => "Hello world!"
You can also count the total number of unique variations of a spintax string. If you've mixed the SpintaxParser
into your String
class like above, just call the #count_spintax_variations
method on any string as shown below:
spintext = "{Hello|Hi} {{world|worlds}|planet}{!|.|?}"
spintext.count_spintax_variations # => 18
git checkout -b my-new-feature
)git commit -am 'Added some feature'
)git push origin my-new-feature
)FAQs
Unknown package
We found that spintax_parser demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A new site reviews software projects to reveal if they’re truly FOSS, making complex licensing and distribution models easy to understand.
Security News
Astral unveils pyx, a Python-native package registry in beta, designed to speed installs, enhance security, and integrate deeply with uv.
Security News
The Latio podcast explores how static and runtime reachability help teams prioritize exploitable vulnerabilities and streamline AppSec workflows.