views:

105

answers:

1

I know this seems silly, but I would like to call some of Rails' Text Helpers in a rake task I am setting up. (Thinks like the pluralize and cycle method: http://api.rubyonrails.org/classes/ActionView/Helpers/TextHelper.html)

How would you go about making these available in a rake task, or is it not easily possible?

+3  A: 

Adding ActiveSupport and ActionPack as dependencies could be heavy handed to simply have the convenience of a text helper -- unless your Rakefile is already loading Rails -- but here's an example Rakefile:

require 'rubygems'
require 'activesupport'
require 'actionpack'
require 'action_view/helpers'

extend ActionView::Helpers

task :plural do
  puts "I have #{pluralize(5, "dog")}"
  puts "You have #{pluralize(1, "dog")}"
end
Lytol
Thank you very much :)
Scott S.