rakefile

How can I run a ruby class from rake file?

ぃ、小莉子 提交于 2019-12-07 11:14:07
问题 I want to run a ruby class from a sample.rake file. Consider myruby.rb is a ruby file. I want to run this from sample.rake like ruby myruby.rb 回答1: Adding to what @tobias has to say here you go with an example script sample content of myruby.rb puts "hello world" Create file called Rakefile task :default => [:test] task :test do ruby "my_file.rb" end Now if you invoke rake it should file up hello world text in console. Update It would make more sense if you wrap your call in a function call

How can I run a ruby class from rake file?

僤鯓⒐⒋嵵緔 提交于 2019-12-05 14:50:37
I want to run a ruby class from a sample.rake file. Consider myruby.rb is a ruby file. I want to run this from sample.rake like ruby myruby.rb Adding to what @tobias has to say here you go with an example script sample content of myruby.rb puts "hello world" Create file called Rakefile task :default => [:test] task :test do ruby "my_file.rb" end Now if you invoke rake it should file up hello world text in console. Update It would make more sense if you wrap your call in a function call as suggested already by @tobias So your Rakefile would become something like require './myruby.rb' task

Can I pass an argument to rake db:seed?

杀马特。学长 韩版系。学妹 提交于 2019-12-03 04:46:31
问题 Part of my seeds.rb loads a lot of data into the database. I want to be able to selectively load this data. E.g. $ rake db:seed or $rake db:seed[0] would just load the necessary data to run the site, while $ rake db:seed[1] would load my big data file into the database as well. Is this possible? How can I make this happen? If not, can anyone think of a way to do what I'm trying to do? 回答1: Rake arguments are painful to pass around, unfortunately (and db:seed doesn't pass its arguments through

Can I pass an argument to rake db:seed?

青春壹個敷衍的年華 提交于 2019-12-02 17:59:59
Part of my seeds.rb loads a lot of data into the database. I want to be able to selectively load this data. E.g. $ rake db:seed or $rake db:seed[0] would just load the necessary data to run the site, while $ rake db:seed[1] would load my big data file into the database as well. Is this possible? How can I make this happen? If not, can anyone think of a way to do what I'm trying to do? Rake arguments are painful to pass around, unfortunately (and db:seed doesn't pass its arguments through, regardless). Your best bet is to use environment variables to pass your extra args through: rake db:seed

File.open, write and save?

こ雲淡風輕ζ 提交于 2019-11-30 06:06:05
I am trying to get a .rb file to make another .rb file within a specific directory with specified content, when that file is run. I dont know whether the best way to do this would be with a Ruby file or a Rake file. You input would be great. If you just need to perform a simple script like creating a file, you can simply use a Ruby script without creating a rake task. # file origin.rb target = "target.rb" content = <<-RUBY puts "I'm the target!" RUBY File.open(target, "w+") do |f| f.write(content) end And you can execute the file with $ ruby origin.rb directory = "../../directory" File.open

What is a Rakefile?

早过忘川 提交于 2019-11-29 21:15:02
I have started learning Ruby and just tried out my first hello world program in NetBeans IDE. I have one doubt, I can see that the new project wizard created set of package structure. It had one "Rakefile" in it. What does that mean and what is the use of it? It is an alternative to Makefile with Ruby syntax. As a follow-up, you may find these resources helpful: Using the Rake Build Language rake (there are good links here to additional tutorials or webcasts) Basic Rake (video of a talk by Jim Weirich) Power Rake (video of a talk by Jim Weirich) Jim was the creator and maintainer of Rake

File.open, write and save?

柔情痞子 提交于 2019-11-29 04:44:26
问题 I am trying to get a .rb file to make another .rb file within a specific directory with specified content, when that file is run. I dont know whether the best way to do this would be with a Ruby file or a Rake file. You input would be great. 回答1: If you just need to perform a simple script like creating a file, you can simply use a Ruby script without creating a rake task. # file origin.rb target = "target.rb" content = <<-RUBY puts "I'm the target!" RUBY File.open(target, "w+") do |f| f

What is a Rakefile?

元气小坏坏 提交于 2019-11-28 17:23:16
问题 I have started learning Ruby and just tried out my first hello world program in NetBeans IDE. I have one doubt, I can see that the new project wizard created set of package structure. It had one "Rakefile" in it. What does that mean and what is the use of it? 回答1: It is an alternative to Makefile with Ruby syntax. 回答2: As a follow-up, you may find these resources helpful: Using the Rake Build Language rake (there are good links here to additional tutorials or webcasts) Basic Rake (video of a