Use TextExpander to generate fake content


As a developer, I always need to generate some fake contents for testing purpose. Ruby has a nice gem called “ffaker” to do this kind of job. I integrated the gem with TextExpander so that I can fill pseudo data just by a few keystrokes.

First, you need to install gem “ffaker”. Run following command in the terminal:

sudo gem install ffaker

Then, create a new snippet in TextExpander with following content to generate a paragraph:

#!/usr/bin/env ruby

require 'rubygems'
require 'ffaker'	
print Faker::Lorem.paragraph

Don’t forget to set the content type as “Shell Script”.

textexpander

Script to generate a fake name:

#!/usr/bin/env ruby
require 'rubygems'
require 'ffaker'
faker = Faker::Name
print "#{faker.first_name} #{faker.last_name}"

Script to generate a fake sentence:

#!/usr/bin/env ruby
require 'rubygems'
require 'ffaker'
print Faker::Lorem.sentence

ffaker can generate much more fake contents. Now you get the idea and can check the document of ffaker to make up your own scripts.