Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 51 lines (35 sloc) 1.628 kb
da76de5 Update doc.
Rocky Bernstein authored
1 = LineCache - A module to read and cache file information of a Ruby program.
dda6942 Update documentation.
Rocky Bernstein authored
2
3 == SYNOPSIS
4
da76de5 Update doc.
Rocky Bernstein authored
5 The LineCache module allows one to get any line from any file, caching
6 the lines and file information on first access to the file. Although
7 the file may be any file, the common use is when the file is a Ruby
dda6942 Update documentation.
Rocky Bernstein authored
8 script since parsing of the file is done to figure out where the
9 statement boundaries are.
10
11 The routines here may be is useful when a small random sets of lines
12 are read from a single file, in particular in a debugger to show
13 source lines.
ecb97d6 Initial import of LineCache, a module for reading and caching lines.
Rocky Bernstein authored
14
15 == Summary
16
17 require 'linecache'
18 lines = LineCache::getlines('/tmp/myruby.rb')
19 # The following lines have same effect as the above.
20 $: << '/tmp'
21 Dir.chdir('/tmp') {lines = LineCache::getlines('myruby.rb')
22
23 line = LineCache::getline('/tmp/myruby.rb', 6)
24 # Note lines[6] == line (if /tmp/myruby.rb has 6 lines)
25
26 LineCache::clear_file_cache
27 LineCache::clear_file_cache('/tmp/myruby.rb')
28 LineCache::update_cache # Check for modifications of all cached files.
29
30 == Credits
31
32 This is a port of the module of the same name from the Python distribution.
33
0441549 Ooops - forgot to credit Ryan Davis and ParseTree.
Rocky Bernstein authored
34 The idea for how TraceLineNumbers works, and some code was taken
35 from ParseTree by Ryan Davis.
36
ecb97d6 Initial import of LineCache, a module for reading and caching lines.
Rocky Bernstein authored
37 == Other stuff
38
39 Author:: Rocky Bernstein <rockyb@rubyforge.net>
0441549 Ooops - forgot to credit Ryan Davis and ParseTree.
Rocky Bernstein authored
40 License:: Copyright (c) 2007, 2008 Rocky Bernstein
ecb97d6 Initial import of LineCache, a module for reading and caching lines.
Rocky Bernstein authored
41 Released under the GNU GPL 2 license
42
43 == Warranty
44
45 This program is distributed in the hope that it will be useful,
46 but WITHOUT ANY WARRANTY; without even the implied warranty of
47 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
48 GNU General Public License for more details.
49
44717ce NEWS, README, linecache.rb: Add $Id$ line
Rocky Bernstein authored
50 $Id$
Something went wrong with that request. Please try again.