I wrote the following rake task to execute the ''ls'' UNIX
command using
the ''command'' method in the ''FileOperation''
module
require ''rake''
require ''rake/testtask''
require ''rake/rdoctask''
require ''FileOperations''
include FileOperations
namespace :test do
task :post_heartrate do
FileOperations.command ''ls''
end
end
When I run it, I get the following error:
no such file to load -- FileOperations
Then, I get the following error if I take out the ''require''
line:
uninitialized constant FileOperations
I know this is a very basic problem. Any suggestions?
Thanks
Chirag
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
HI Chirag,
I''m guessing you copied the rake from the middle of a Rails app maybe?
There is a lot of extra requires that are not "required".
Here is a rake file that accomplishes what you describe. There were no
other requires or anything else. This is the defined "Rake File
Format".
Also, Dir.glob is in the Ruby core, so no requires are necessary. :
=== start RakeFile.rb ==desc "List Files in current dir."
task :list_files do
Dir.glob("*").each do |d|
puts d
end
end
=== end RakeFile.rb ==
And the output :
$ ls -l
total 1
-rw-r--r-- 1 mlpf mkgroup-l-d 101 Aug 21 09:26 RakeFile.rb
$ rake -T
(in /home/mlpf/ruby)
rake list_files # List Files in current dir.
$ rake list_files
(in /home/mlpf/ruby)
RakeFile.rb
Here are the references I reviewed:
http://rake.rubyforge.org/
"Rake Tutorial": http://docs.rubyrake.org/read/book/1
"Rake Users Guide": http://docs.rubyrake.org/read/book/2
Hope that helps!
Peter Fitzgibbons
http://fitzgibbons.info
On 8/20/07, chirag <patelc75-/E1597aS9LQAvxtiuMwx3w@public.gmane.org>
wrote:>
>
> I wrote the following rake task to execute the ''ls'' UNIX
command using
> the ''command'' method in the
''FileOperation'' module
>
> require ''rake''
> require ''rake/testtask''
> require ''rake/rdoctask''
>
> require ''FileOperations''
> include FileOperations
>
> namespace :test do
> task :post_heartrate do
> FileOperations.command ''ls''
> end
> end
>
> When I run it, I get the following error:
> no such file to load -- FileOperations
>
> Then, I get the following error if I take out the
''require'' line:
> uninitialized constant FileOperations
>
> I know this is a very basic problem. Any suggestions?
>
> Thanks
> Chirag
>
>
> >
>
--
Peter Fitzgibbons
------------------------------
iPhone -- "IT"-ness.
hrefhttp://www.macdailynews.com/index.php/weblog/comments/apples_iphone_could_become_iconic_it_object
------------------------------
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
On 8/20/07, chirag <patelc75-/E1597aS9LQAvxtiuMwx3w@public.gmane.org> wrote:> > I wrote the following rake task to execute the ''ls'' UNIX command using > the ''command'' method in the ''FileOperation'' module > > require ''rake'' > require ''rake/testtask'' > require ''rake/rdoctask'' > > require ''FileOperations'' > include FileOperations > > namespace :test do > task :post_heartrate do > FileOperations.command ''ls'' > end > end > > When I run it, I get the following error: > no such file to load -- FileOperationsFileOperations is part of the guts of Rails. To run an external command, use the "sh" method which Rake provides: sh ''somecommand'' Rake includes the Ruby standard FileUtils and adds a few handy extensions, so that''s where you should be starting. http://www.ruby-doc.org/stdlib/libdoc/fileutils/rdoc/index.html http://rake.rubyforge.org/classes/FileUtils.html --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---