How can I run a ruby class from rake file? -


i want run ruby class sample.rake file.

consider myruby.rb ruby file.

i want run sample.rake ruby myruby.rb

adding @tobias has here go example script

sample content of myruby.rb

puts "hello world" 

create file called rakefile

task :default => [:test]  task :test     ruby "my_file.rb" end 

now if invoke rake should file hello world text in console.

update

it make more sense if wrap call in function call suggested @tobias

so rakefile become like

require './myruby.rb' task :default => [:test]  task :test   ruby "my_file.rb" end  task :test2   do_something end 

and myruby.rb

def do_something   puts "do something" end 

now rake test2 should spit out do something


Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -