Dear Friends,
If there any pre-defined function or ruby options available
for removing the ruby comments from the source code. Please any on help
me if you already aware of this.
On Sep 1, 4:12 am, Arul hari <hariharan....@rediffmail.com> wrote:
Dear Friends,
If there any pre-defined function or ruby options available
for removing the ruby comments from the source code. Please any on help
me if you already aware of this.
Dear Friends,
If there any pre-defined function or ruby options available
for removing the ruby comments from the source code. Please any on help
me if you already aware of this.
--
Glenn Jackman
Write a wise saying and your name will live forever. -- Anonymous
Dear Friends,
If there any pre-defined function or ruby options available
for removing the ruby comments from the source code. Please any on help
me if you already aware of this.
The ruby_parser and ruby2ruby gems will do this:
require 'ruby_parser'
require 'ruby2ruby'
code = <<END
# a class
class Simple
# add the method "add"
def add(n1,n2)
n1 + n2 # return the sum
end
end
END
Dear Friends,
If there any pre-defined function or ruby options available
for removing the ruby comments from the source code. Please any on help
me if you already aware of this.
The ruby_parser and ruby2ruby gems will do this:
require 'ruby_parser'
require 'ruby2ruby'
code = <<END
# a class
class Simple
# add the method "add"
def add(n1,n2)
n1 + n2 # return the sum
end
end
END
The obvious thing to do is to special case the shebang line. Since a
shebang can only occur on the first line of a source file, just
examine the first line before munging the source and if it's a
shebang, add it back after the munging is done.
Note that you'll have the same issue with magic encoding lines as
well. A magic encoding line can also occur on the 1st line (or 2nd
line if the 1st line is a shebang) and should also be preserved if
present. (This is a ruby 1.9 only feature, tho. If ruby 1.9
compatibility is important to you, ruby2ruby isn't going to work for
you for all kinds of other reasons....)
···
On 3/2/10, Arul hari <hariharan.spc@rediffmail.com> wrote:
Dear Friends,
I am facing problem after removing comments.
#! => should not remove from the source code , but I am using
ruby2ruby module to remove the comments. Is there any way to not remove
the #! line.
Please anyone help me to go ahed on this. Kindly let me know it.