12-30-2010
Parsing the Ruby File
Hai any one pls guide me...
We can extract the line number of the sub routine/function/method in a Ruby file using the ctags command.
But I want to know the line number in which the sub routine is ending.
Example:
Quote:
#
# Function name : get_days_in_hash
# Argument :
# no arguments
# Return value :
# days information in hash format.
# Description :
# get the days. Assigned value for each day.
# 1 => 'Mon' ,
# 2 => 'Tues' ,
# 3 => 'Wed' ,
# 4 => 'Thu' ,
# 5 => 'Fri' ,
# 6 => 'Sat' ,
# 7 => 'Sun' ,
# 8 => 'Leave' ,
# 9 => 'Holiday'
# Logical flow :
# generate the hash
#
def get_days_in_hash
{ 1 => 'Mon' , 2 => 'Tues' , 3 => 'Wed' , 4 => 'Thu' , 5 => 'Fri' , 6 => 'Sat' , 7 => 'Sun' , 8 => 'Leave' , 9 => 'Holiday' }
end
Quote:
#
# Function name : user_filter
# Argument :
# get the controller and action.
# Return value :
# if the user not login then display the login page.
# Description :
# check the user is login or not.
# Logical flow :
# check the controller and action is not the login page or not.
# check the user is log-in or not.
# if not login then redirect the page to login page.
#
def user_filter()
# set the header information for the Browser
no_cache()
# check it is a login page or not.
# If it is not a not the login page then check the session whether he is login or not
# if is not login then display the login page.
if( not ( params[:controller] == 'main' && ( params[:action] == 'login' || params[:action] == 'index' ) ) )
if( not session[:user_id] )
#redirect_to :controller => 'main' , :action => 'login'
if( params[:action] == 'logout' )
flash[:notice] = 'Logged out Successfully'
else
flash[:notice] = "Session Expired"
end
render :text => "<script>
window.location='#{url_for(:controller => 'main' , :action => 'login' )}';
</script>"
end
end
end
Say the function get_days_in_hash starts in the line number 20.
It will be returned by the ctags command.
I want to know in which line number that appropriate function is ending.
For each functions in the file I want this informations like starting line of the file and the ending line of the file.
Please help me about how to achieve this.
Thanks in Advance,
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I'm trying to write a script that will look in an /exports folder for the oldest export file and move it to a /staging folder. "Oldest" in this case is actually determined by date information embedded in the file names themselves.
Also, the script should only move a file from /exports to... (6 Replies)
Discussion started by: nikosey
6 Replies
2. Shell Programming and Scripting
Hi Scripting Gurus,
I am trying to parse a csv file and generate a new output file.
The input file will be a variable length in turns of rows and columns.
output file will have 8 columns. we have three columns from the header for each set.
just to give little bit more clarification each row... (15 Replies)
Discussion started by: vkr
15 Replies
3. Shell Programming and Scripting
#! /usr/local/bin/perl -w
$ip = "$ARGV";
$rw = "$ARGV";
$snmpg = "/usr/local/bin/snmpbulkget -v2c -Cn1 -Cn2 -Os -c $rw";
$snmpw = "/usr/local/bin/snmpwalk -Os -c $rw";
$syst=`$snmpg $ip system sysName sysObjectID`;
sysDescr.0 = STRING: Cisco Internetwork Operating System Software... (1 Reply)
Discussion started by: popeye
1 Replies
4. UNIX for Dummies Questions & Answers
Hi Experts,
Im a new bee for scripting,
I would ned to do the following via linux shell scripting, I have an application which throws a log file, on each action of a particular work with the application, as sson as the action is done, the log file would vanish or stops updating there, the... (2 Replies)
Discussion started by: pingnagan
2 Replies
5. Shell Programming and Scripting
Here is a data file, which I believe is in YAML. I am trying to retrieve just the 'addon_domains" section, which doesnt seem to be as easy as I had originally thought. Any help on this would be greatly appreciated!! I have been trying to do this in awk and mostly bash scripting instead of perl... (3 Replies)
Discussion started by: Rhije
3 Replies
6. Shell Programming and Scripting
Hey guys,
I have this file generated by me... i want to create some HTML output from it.
The problem is that i am really confused about how do I go about reading the file.
The file is in the following format:
TID1 Name1 ATime=xx AResult=yyy AExpected=yyy BTime=xx BResult=yyy... (8 Replies)
Discussion started by: umar.shaikh
8 Replies
7. Shell Programming and Scripting
I am writing some fairly heavy software. As of current solely in bash. It will change the world when I am done. Why do I ask for help? I am thinking a ( as a variable has me stumped. The ones commented I have played with 0 results, $PWD is the current folder we are playing with as per bash.
... (0 Replies)
Discussion started by: TheeMahn
0 Replies
8. Shell Programming and Scripting
Hi,
I have 2 files
format of file 1 is:
a1
b2
a2
c2
d1
f3
format of file 2 is (tab delimited):
a1 1.2 0.5 0.06 0.7 0.9 1 0.023
a3 0.91 0.007 0.12 0.34 0.45 1 0.7
a2 1.05 2.3 0.25 1 0.9 0.3 0.091
b1 1 5.4 0.3 9.2 0.3 0.2 0.1
b2 3 5 7 0.9 1 9 0 1
b3 0.001 1 2.3 4.6 8.9 10 0 1 0... (10 Replies)
Discussion started by: Lucky Ali
10 Replies
9. Programming
Hello to all guys,
Maybe some expert could help me.
I have a working ruby script shown below that reads a big binary file (more than 2GB). The chunks of data I want to analyze
is separated by the sequence FF47 withing the binary. So, in the ruby script is defined as "line separator" =... (10 Replies)
Discussion started by: Ophiuchus
10 Replies
10. Shell Programming and Scripting
Hi,
I installed ruby using rvm with root user on Linux.
Now i m trying the below command as a non root user with sudo privileges.
sudo /usr/local/rvm/rubies/ruby-2.2.5/bin/gem install passenger
I get the below error:
I had even reset the path for both gem as well as ruby as you... (8 Replies)
Discussion started by: mohtashims
8 Replies
LEARN ABOUT OPENDARWIN
chsh
CHSH(1) User Commands CHSH(1)
NAME
chsh - change login shell
SYNOPSIS
chsh [options] [LOGIN]
DESCRIPTION
The chsh command changes the user login shell. This determines the name of the user's initial login command. A normal user may only change
the login shell for her own account; the superuser may change the login shell for any account.
OPTIONS
The options which apply to the chsh command are:
-h, --help
Display help message and exit.
-R, --root CHROOT_DIR
Apply changes in the CHROOT_DIR directory and use the configuration files from the CHROOT_DIR directory.
-s, --shell SHELL
The name of the user's new login shell. Setting this field to blank causes the system to select the default login shell.
If the -s option is not selected, chsh operates in an interactive fashion, prompting the user with the current login shell. Enter the new
value to change the shell, or leave the line blank to use the current one. The current shell is displayed between a pair of [ ] marks.
NOTE
The only restriction placed on the login shell is that the command name must be listed in /etc/shells, unless the invoker is the superuser,
and then any value may be added. An account with a restricted login shell may not change her login shell. For this reason, placing /bin/rsh
in /etc/shells is discouraged since accidentally changing to a restricted shell would prevent the user from ever changing her login shell
back to its original value.
FILES
/etc/passwd
User account information.
/etc/shells
List of valid login shells.
/etc/login.defs
Shadow password suite configuration.
SEE ALSO
chfn(1), login.defs(5), passwd(5).
shadow-utils 4.5 01/25/2018 CHSH(1)