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

Issues changing the value of an element in an array in matlab -

php - MySQLi binding parameters in a prepared statement doesn't work unless inserted after "WHERE" -

vb.net - Alternative to the T-SQL AS keyword -