https://github.com/rocky/rb-linecache2
LineCache is a module for reading and caching lines. This may be useful for example in a debugger where the same lines are shown many times.
https://github.com/rocky/rb-linecache2
Last synced: 5 months ago
JSON representation
LineCache is a module for reading and caching lines. This may be useful for example in a debugger where the same lines are shown many times.
- Host: GitHub
- URL: https://github.com/rocky/rb-linecache2
- Owner: rocky
- License: gpl-2.0
- Created: 2016-07-17T23:32:08.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2021-12-21T23:30:42.000Z (over 3 years ago)
- Last Synced: 2024-04-25T05:02:47.474Z (about 1 year ago)
- Language: Ruby
- Size: 204 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: ChangeLog
- License: COPYING
Awesome Lists containing this project
README
The LineCache module allows one to get any line from any file, caching
the lines and file information on first access to the file. Although
the file may be any file, the common use is when the file is a Ruby
script since parsing of the file is done to figure out where the
statement boundaries are, and we also cache syntax formatting.The routines here may be is useful when a small random sets of lines
are read from a single file, in particular in a debugger to show
source lines.*Example*:
```ruby
require 'linecache'
lines = LineCache::getlines('/tmp/myruby.rb')
# The following lines have same effect as the above.
$: << '/tmp'
Dir.chdir('/tmp') {lines = LineCache::getlines('myruby.rb')line = LineCache::getline('/tmp/myruby.rb', 6)
# Note lines[6] == line (if /tmp/myruby.rb has 6 lines)LineCache::clear_file_cache
LineCache::clear_file_cache('/tmp/myruby.rb')
LineCache::update_cache # Check for modifications of all cached files.
```This code is for Ruby version 2 and greater.