Sponsored Content
Full Discussion: Parsing the Ruby File
Top Forums Shell Programming and Scripting Parsing the Ruby File Post 302484171 by thillai_selvan on Thursday 30th of December 2010 03:43:25 AM
Old 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

Finding & Moving Oldest File by Parsing/Sorting Date Info in File Names

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

need help in Parsing a CSV file and generate a new output file

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

Perl parsing compared to Ksh parsing

#! /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

Script for parsing details in a log file to a seperate file

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

Parsing file, yaml file? Extracting specific sections

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

Parsing of file for Report Generation (String parsing and splitting)

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

Parsing a file

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

parsing data from a big file using keys from another smaller file

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

How to replicate Ruby´s binary file reading with Java?

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

Getting error: /usr/bin/env: ruby: No such file or directory

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
LASTLOGIN(8)						    BSD System Manager's Manual 					      LASTLOGIN(8)

NAME
lastlogin -- indicate last login time of users SYNOPSIS
lastlogin [-f file] [-rt] [user ...] DESCRIPTION
The lastlogin utility will list the last login session of each specified user, or for all users by default. Each line of output contains the user name, the tty from which the session was conducted, any hostname, and the start time for the session. If more than one user is given, the session information for each user is printed in the order given on the command line. Otherwise, informa- tion for all users is printed. By default, the entries are sorted by user name. The lastlogin utility differs from last(1) in that it only prints information regarding the very last login session. The last login database is never turned over or deleted in standard usage. The following options are available: -f file Open last login database file instead of the system-wide database. -r Print the entries in reverse sorted order. -t Sort the elements by last login time, instead of user name. FILES
/var/log/utx.lastlogin last login database SEE ALSO
last(1), getutxent(3), ac(8) AUTHORS
John M. Vinopal wrote this program in January 1996 and contributed it to the NetBSD project. BSD
June 6, 2011 BSD
All times are GMT -4. The time now is 08:22 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy