Connie is a project mainly written in Ruby, based on the MIT license.
Light and customizable data generator.
= Connie ==== Little compact library to synthesise data that does not load big files in memory.
Heavily based on Forgery[http://github.com/sevenwire/forgery.git] it uses the same word sources. It's built to be a bit more customisable and allows you to define new strategies and styles both using ruby modules or big text lists.
== Install
On the console:
gem install connie
In your Gemfile gem 'connie'
== Usage
Connie offers four exciting functionalities:
===Dictionaries
A dictionary is a vast source of words for a subject, Connie has 4 dictionaries built in:
For example inspecting the names dictionary: Connie[:names].inspect # Shorthand to access a dictionary <Connie::Dictionary - Connie::Names - company last female suffix title male first gender> You receive a quick overview of what this dictionary can generate. To have the dictionary generate something simply: Connie[:names].first
===Shorthands
Connie provides a couple of shorthands methods to randomise your data: Connie([:one, :two, :three]) #=> returns randomly selected element of the array Connie.letter #=> returns a random lowercase letter Connie.letter :uppercase #=> returns a random uppercse letter Connie? #=> returns true or false. Randomly
===Interpolations
Interpolations happen in a dictionary but allow to reach others through scoping
Connie[:names].interpolate "Mr. :male :last: :geo.city, :geo.state_short"
=> "Mr. Mark Taylor: Pleasant Hill, NY"
A shorthand method i is provided for convenience and interpolation is also available through the global method: Connie(':names.male :names.last')
== Extending You can extend Dictionaries in two ways:
=== Word Lists This will ensure that calling the word type a line is randomly picked from word list file
You can provide word list files inside folder registered with connie:
=== Methods in the DictionaryName module Anywhere in your code by adding instance methods to the Connie::DictionaryName module
It's handy to aggregate different words from the lists and present the in different ways:
# e.g. Extending the names dictionary to return a full name
module Connie
module Names
# Returns a full name
def full
"#{first} #{last}"
end
end
end
To add a folder to Connie's sources just do something like this in your code: Connie.dictionaries_path << 'my/cool/dictionaries'
== What next It'd be nice to have an structured dictionary or a weighted one, where some options can occur more often than others (Eg not as many 'Count' as there are 'Dr.' or 'Mr.')
== Note on Patches/Pull Requests
== Copyright
Copyright (c) 2010 Leandro Pedroni. See LICENSE for details.