Project

rujitsu

0.01
No commit activity in last 3 years
No release in over 3 years
Various helper methods to smooth over Ruby development
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.12
~> 10.0
~> 3.0
 Project Readme

rujitsu¶ ↑

A ruby gem with various helper methods to smooth out your Ruby development.

Install¶ ↑

Add the following to your Gemfile

gem "rujitsu"

Including¶ ↑

require "rujitsu"
require "rujitsu/grammar"

For using in irb, there’s a nice shortcut for you to use:

$ irb -rubygems -rujitsu

(This works because -r is the argument to require a file, and both ‘ubygems.rb’ and ‘ujitsu.rb’ exist.)

Documentation¶ ↑

Run rake docs and open doc/index.html.

Usage¶ ↑

Generating random strings¶ ↑

The Fixnum class has a couple of extensions allowing you to generate random strings.

5.random_letters
5.random_numbers
5.random_characters

You can also generate a variable length string.

(3..5).random_letters

This generates a string of random letters whose length is 3, 4 or 5 characters.

(All the above methods exist in the singular too. eg, 1.random_letter)

URL-friendly strings¶ ↑

The String class has an extension that strips out URL-unfriendly characters.

""$%hello!@ 123 there'".to_url # => "hello-123-there"

Truncating strings¶ ↑

The String class has an extension that truncates it to a customisable length with a customisable suffix.

"this is a string".truncate(:length => 15) # => "this is a st..."

Testing for inclusion within a container¶ ↑

As Rubyists we are all familiar with using include? to test if our variable is one of a number of values.

if ['hello', 'world'].include?(@my_value) ...

However, it doesn’t read correctly. Rujitsu allows you to write the following as it reads much more like English.

if @my_value.in? ['hello', 'world'] ...

Grammar¶ ↑

So far the grammar library just adds the method should_recieve for rspec assertions. Use it to find out what it does!

Released under the MIT Licence¶ ↑

Copyright © 2008 Brightbox Systems Ltd

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.

See www.brightbox.co.uk/ for contact details.