linecache 0.43 → 0.45
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +0 -317
- data/NEWS +6 -1
- data/README +14 -2
- data/Rakefile +64 -45
- data/ext/trace_nums.c +17 -3
- data/ext/trace_nums.h +1 -1
- data/lib/linecache.rb +237 -69
- data/lib/tracelines.rb +0 -0
- data/lib/version.rb +3 -0
- data/test/data/block1.rb +0 -0
- data/test/lnum-diag.rb +0 -0
- data/test/parse-show.rb +0 -0
- data/test/test-linecache.rb +2 -2
- data/test/test-lnum.rb +0 -0
- data/test/test-tracelines.rb +0 -0
- metadata +89 -64
- data/VERSION +0 -1
data/ChangeLog
CHANGED
@@ -1,317 +0,0 @@
|
|
1
|
-
2008-04-10 20:06 Rocky Bernstein
|
2
|
-
|
3
|
-
* NEWS: What's new for 0.41.
|
4
|
-
|
5
|
-
2008-04-10 20:02 Rocky Bernstein
|
6
|
-
|
7
|
-
* ChangeLog, Rakefile, VERSION: Forgot to add test/data to the gem.
|
8
|
-
|
9
|
-
2008-04-10 02:15 Rocky Bernstein
|
10
|
-
|
11
|
-
* NEWS:
|
12
|
-
|
13
|
-
2008-03-28 15:04 Rocky Bernstein
|
14
|
-
|
15
|
-
* test/data/if6.rb, test/data/if7.rb: More if tests
|
16
|
-
|
17
|
-
2008-03-09 23:24 Rocky Bernstein
|
18
|
-
|
19
|
-
* ChangeLog, Rakefile, VERSION, lib/linecache.rb: Deal with
|
20
|
-
Depricated win32.
|
21
|
-
|
22
|
-
2008-03-05 02:01 Rocky Bernstein
|
23
|
-
|
24
|
-
* Rakefile: Add rubyforge_upload task -- code from
|
25
|
-
ruby-memory-profiler.
|
26
|
-
|
27
|
-
2008-03-04 22:47 Rocky Bernstein
|
28
|
-
|
29
|
-
* README: Ooops - forgot to credit Ryan Davis and ParseTree.
|
30
|
-
|
31
|
-
2008-02-10 13:59 Rocky Bernstein
|
32
|
-
|
33
|
-
* ChangeLog, Rakefile, ext/trace_nums.c, ext/win32, svn2cl_usermap:
|
34
|
-
Go over Rakefile and doc for 0.3 release.
|
35
|
-
|
36
|
-
2008-01-29 21:51 Rocky Bernstein
|
37
|
-
|
38
|
-
* test/test-linecache.rb: Interface change. Don't know why this
|
39
|
-
didn't get updated before.
|
40
|
-
|
41
|
-
2008-01-28 15:35 Rocky Bernstein
|
42
|
-
|
43
|
-
* ChangeLog, lib/linecache.rb: Change line number return from a Set
|
44
|
-
to an Array.
|
45
|
-
|
46
|
-
2008-01-27 11:24 Rocky Bernstein
|
47
|
-
|
48
|
-
* ext/trace_nums.c, ext/trace_nums.h, test/data/if5.rb: Handle
|
49
|
-
defined? node. Add "if" weirdness test.
|
50
|
-
|
51
|
-
2008-01-27 04:26 Rocky Bernstein
|
52
|
-
|
53
|
-
* test/data/case5.rb: Verify that the 'else' doesn't appear in a
|
54
|
-
trace.
|
55
|
-
|
56
|
-
2008-01-27 04:21 Rocky Bernstein
|
57
|
-
|
58
|
-
* ext/trace_nums.c, test/data/block1.rb, test/data/block2.rb,
|
59
|
-
test/data/case1.rb, test/data/case2.rb, test/data/case3.rb,
|
60
|
-
test/data/case4.rb, test/data/case5.rb, test/data/def1.rb,
|
61
|
-
test/data/each1.rb, test/data/for1.rb, test/data/if3.rb,
|
62
|
-
test/data/if4.rb, test/data/match3.rb, test/data/match3a.rb,
|
63
|
-
test/data/not-lit.rb: Was not showing blocks after when's.
|
64
|
-
|
65
|
-
2008-01-27 04:03 Rocky Bernstein
|
66
|
-
|
67
|
-
* ext/trace_nums.c, test/data/block1.rb, test/data/block2.rb,
|
68
|
-
test/data/if4.rb, test/lnum-diag.rb: trace_nums.c, block1.c,
|
69
|
-
block2.c: bug in handling blocks
|
70
|
-
lnum-diag.rb: more graceful about not finding the source.
|
71
|
-
if4.rb: note weirdness in the way comparison works.
|
72
|
-
|
73
|
-
2008-01-27 02:11 Rocky Bernstein
|
74
|
-
|
75
|
-
* ext/trace_nums.c, ext/trace_nums.h, test/data/case4.rb,
|
76
|
-
test/data/def1.rb, test/data/if3.rb, test/lnum-diag.rb: Finish
|
77
|
-
adding all tree nodes. Work on case nodes some more.
|
78
|
-
lnum-diag.rb: add options to turn on and off various parts.
|
79
|
-
|
80
|
-
2008-01-26 11:12 Rocky Bernstein
|
81
|
-
|
82
|
-
* test/data/comments1.rb: Add comment test and situation where no
|
83
|
-
lines traced.
|
84
|
-
|
85
|
-
2008-01-26 11:08 Rocky Bernstein
|
86
|
-
|
87
|
-
* ext/trace_nums.c, test/data/class1.rb: Add class, scope and
|
88
|
-
module nodes.
|
89
|
-
|
90
|
-
2008-01-26 10:18 Rocky Bernstein
|
91
|
-
|
92
|
-
* ext/trace_nums.c, test/rcov-bug.rb, test/test-linecache.rb,
|
93
|
-
test/test-tracelines.rb: Add more tree nodes.
|
94
|
-
|
95
|
-
2008-01-26 02:09 Rocky Bernstein
|
96
|
-
|
97
|
-
* test/data/each1.rb, test/data/for1.rb, test/data/if1.rb,
|
98
|
-
test/data/if2.rb, test/test-lnum.rb: Add Debugger.init which
|
99
|
-
intializes things that rdebug does. This
|
100
|
-
allows a restart even though rdebug wasn't called initially.
|
101
|
-
|
102
|
-
2008-01-25 03:50 Rocky Bernstein
|
103
|
-
|
104
|
-
* ext/trace_nums.c: Some code cleanup.
|
105
|
-
|
106
|
-
2008-01-25 02:50 Rocky Bernstein
|
107
|
-
|
108
|
-
* ext/trace_nums.c, test/data/case1.rb, test/data/case2.rb,
|
109
|
-
test/data/case3.rb, test/data/match3.rb, test/data/match3a.rb:
|
110
|
-
Work over case, when and match3.
|
111
|
-
|
112
|
-
2008-01-25 00:17 Rocky Bernstein
|
113
|
-
|
114
|
-
* ext/trace_nums.c, test/data, test/lnum-data, test/lnum-diag.rb,
|
115
|
-
test/test-lnum.rb, test/test-tracelines.rb: Trace just line
|
116
|
-
numbers for now until we get a better handle on things.
|
117
|
-
|
118
|
-
2008-01-24 13:36 Rocky Bernstein
|
119
|
-
|
120
|
-
* test/lnum-diag.rb, test/rcov-bug.rb, test/test-linecache.rb,
|
121
|
-
test/test-tracelines.rb: Need recursion in more places because of
|
122
|
-
block continuation nodes.
|
123
|
-
Add nodes needed so we don't complain about rcov-bug.rb:
|
124
|
-
NODE_MATCH3, NODE_LASN, and NODE_STR (and those similar to that).
|
125
|
-
|
126
|
-
2008-01-24 04:09 Rocky Bernstein
|
127
|
-
|
128
|
-
* test/lnum-diag.rb: Fix bug if print_file == false
|
129
|
-
|
130
|
-
2008-01-24 04:04 Rocky Bernstein
|
131
|
-
|
132
|
-
* ext/trace_nums.c, test/lnum-data/begin3.rb,
|
133
|
-
test/lnum-data/end.rb, test/lnum-data/match.rb,
|
134
|
-
test/lnum-data/not-lit.rb, test/lnum-diag.rb: Add more
|
135
|
-
operatiors. Go over existing ones and add more tests of them.
|
136
|
-
|
137
|
-
2008-01-23 19:17 Rocky Bernstein
|
138
|
-
|
139
|
-
* NEWS: What's up.
|
140
|
-
|
141
|
-
2008-01-23 19:12 Rocky Bernstein
|
142
|
-
|
143
|
-
* test/lnum-diag.rb: Don't assume we have expected line numbers.
|
144
|
-
|
145
|
-
2008-01-23 19:05 Rocky Bernstein
|
146
|
-
|
147
|
-
* test/lnum-diag.rb: A conversion-error bug.
|
148
|
-
|
149
|
-
2008-01-23 19:04 Rocky Bernstein
|
150
|
-
|
151
|
-
* test/lnum-diag.rb: variable name typo.
|
152
|
-
|
153
|
-
2008-01-23 19:03 Rocky Bernstein
|
154
|
-
|
155
|
-
* ext, ext/trace_nums.c, test/lnum-diag.rb, test/parse-show.rb:
|
156
|
-
lnum-diag.rb and parse-show.rb - some diagnostic tools.
|
157
|
-
|
158
|
-
2008-01-23 16:06 Rocky Bernstein
|
159
|
-
|
160
|
-
* ChangeLog, ext/trace_nums.c: Show add_lines level, nicer
|
161
|
-
formatting including \n for end.
|
162
|
-
|
163
|
-
2008-01-23 15:32 Rocky Bernstein
|
164
|
-
|
165
|
-
* test/test-lnum.rb: Generalized routine to test everything in
|
166
|
-
lnum-data
|
167
|
-
|
168
|
-
2008-01-23 12:07 Rocky Bernstein
|
169
|
-
|
170
|
-
* Rakefile, ext, ext/extconf.rb, ext/trace_nums.c,
|
171
|
-
ext/trace_nums.h, lib/linecache.rb, lib/tracelines.rb,
|
172
|
-
test/lnum-data, test/lnum-data/begin1.rb,
|
173
|
-
test/lnum-data/begin2.rb, test/lnum-data/begin3.rb,
|
174
|
-
test/test-tracelines.rb: ParseTree is broken for our purposes.
|
175
|
-
Having custom code for getting
|
176
|
-
the trace line numbers is going remove a lot of headaches down
|
177
|
-
the line.
|
178
|
-
|
179
|
-
2008-01-20 21:37 Rocky Bernstein
|
180
|
-
|
181
|
-
* Rakefile, lib/linecache.rb, test/test-linecache.rb: Add
|
182
|
-
trace_line_numbers to save/get line numbers which we can set
|
183
|
-
breakpoints
|
184
|
-
on.
|
185
|
-
|
186
|
-
2008-01-20 16:31 Rocky Bernstein
|
187
|
-
|
188
|
-
* ChangeLog, Rakefile, lib/linecache.rb, lib/tracelines.rb,
|
189
|
-
test/rcov-bug.rb, test/test-tracelines.rb: Add module
|
190
|
-
TraceLineNumbers for extracting the stoppable lines in a
|
191
|
-
Ruby program.
|
192
|
-
|
193
|
-
2008-01-19 15:55 Rocky Bernstein
|
194
|
-
|
195
|
-
* lib/linecache.rb, test/test-linecache.rb: Allow nil to mean the
|
196
|
-
same file. More tests.
|
197
|
-
|
198
|
-
2008-01-19 15:45 Rocky Bernstein
|
199
|
-
|
200
|
-
* lib/linecache.rb, test/test-linecache.rb: Start remap_file_lines:
|
201
|
-
ability to remap file ranges.
|
202
|
-
|
203
|
-
2008-01-17 22:25 Rocky Bernstein
|
204
|
-
|
205
|
-
* lib/linecache.rb, test/test-linecache.rb: lines -> size. Add
|
206
|
-
empty? Add remap_file.
|
207
|
-
|
208
|
-
2008-01-17 20:05 Rocky Bernstein
|
209
|
-
|
210
|
-
* lib/linecache.rb, test/test-linecache.rb: Add method to get the
|
211
|
-
number of lines in a cached file.
|
212
|
-
|
213
|
-
2008-01-17 19:42 Rocky Bernstein
|
214
|
-
|
215
|
-
* lib/linecache.rb, test/short-file, test/test-linecache.rb: Add
|
216
|
-
convenience method for testing presence in SCRIPT_LINES__.
|
217
|
-
|
218
|
-
2008-01-17 07:30 Rocky Bernstein
|
219
|
-
|
220
|
-
* lib/linecache.rb, test/test-linecache.rb: Add path method and
|
221
|
-
test.
|
222
|
-
|
223
|
-
2008-01-17 06:54 Rocky Bernstein
|
224
|
-
|
225
|
-
* VERSION, lib/linecache.rb, test/test-linecache.rb: Add
|
226
|
-
@@full2file_cache_key. getlines wasn't returning the right value
|
227
|
-
sometimes.
|
228
|
-
Make return from checkcache meaningful. Change return value of
|
229
|
-
upate_cache().
|
230
|
-
test-linecache.rb: was testing for buggy behavior!
|
231
|
-
VERSION: now in 0.3 - hope we get it right this time.
|
232
|
-
|
233
|
-
2008-01-16 12:51 Rocky Bernstein
|
234
|
-
|
235
|
-
* lib/linecache.rb: Add cached_files.
|
236
|
-
|
237
|
-
2008-01-16 01:30 Rocky Bernstein
|
238
|
-
|
239
|
-
* NEWS: Update news for 0.2 release.
|
240
|
-
|
241
|
-
2008-01-15 22:43 Rocky Bernstein
|
242
|
-
|
243
|
-
* test/test-linecache.rb: Remove debug line.
|
244
|
-
|
245
|
-
2008-01-15 22:42 Rocky Bernstein
|
246
|
-
|
247
|
-
* lib/linecache.rb: Fix some syntax errors.
|
248
|
-
|
249
|
-
2008-01-15 22:40 Rocky Bernstein
|
250
|
-
|
251
|
-
* Rakefile, lib/linecache.rb, test/short-file,
|
252
|
-
test/test-linecache.rb: Add routine to save and get SHA1.
|
253
|
-
|
254
|
-
2008-01-15 22:16 Rocky Bernstein
|
255
|
-
|
256
|
-
* lib/linecache.rb, test/test-linecache.rb: Add cached? and stat
|
257
|
-
methods to determine in a file is cached and get
|
258
|
-
File.stat from it.
|
259
|
-
|
260
|
-
2008-01-15 08:49 Rocky Bernstein
|
261
|
-
|
262
|
-
* lib/linecache.rb: Don't ever modify SCRIPT_LINES__. And until
|
263
|
-
SCRIPT_LINES__ is fixed,
|
264
|
-
don't read from it. Corrections to comments.
|
265
|
-
|
266
|
-
2008-01-14 12:27 Rocky Bernstein
|
267
|
-
|
268
|
-
* ChangeLog, VERSION, lib/linecache.rb: Add parameter to getline
|
269
|
-
and getlines to reload file on change. Add
|
270
|
-
option on clear_file_cache to clear out SCRIPT_LINES__ as well.
|
271
|
-
TESTS ARE NEEDED.
|
272
|
-
Update to version 0.2.
|
273
|
-
|
274
|
-
2008-01-14 03:41 Rocky Bernstein
|
275
|
-
|
276
|
-
* lib/linecache.rb: Use SCRIPT_LINES__ if we can.
|
277
|
-
|
278
|
-
2007-12-10 16:24 Rocky Bernstein
|
279
|
-
|
280
|
-
* : release 0.1
|
281
|
-
|
282
|
-
2007-12-09 17:47 Rocky Bernstein
|
283
|
-
|
284
|
-
* : Make Ruby 1.9 compatible.
|
285
|
-
|
286
|
-
2007-12-09 17:17 Rocky Bernstein
|
287
|
-
|
288
|
-
* : Better tests mean more bugs found. "rake" defaults now to
|
289
|
-
"test".
|
290
|
-
|
291
|
-
2007-12-09 14:10 Rocky Bernstein
|
292
|
-
|
293
|
-
* : Add VERSION to gem.
|
294
|
-
|
295
|
-
2007-12-09 14:09 Rocky Bernstein
|
296
|
-
|
297
|
-
* : Change classname to something more appropriate.
|
298
|
-
|
299
|
-
2007-12-09 13:41 Rocky Bernstein
|
300
|
-
|
301
|
-
* : . : ignore doc and pkg
|
302
|
-
Rakefile: clean now does clobber_rdoc and clobber_package, i.e.
|
303
|
-
removes
|
304
|
-
the doc and pkg directories.
|
305
|
-
|
306
|
-
2007-12-09 13:15 Rocky Bernstein
|
307
|
-
|
308
|
-
* : NEWS, README, linecache.rb: Add $Id$ line
|
309
|
-
test-linecache.rb: make executable
|
310
|
-
Rakefile: Correct documentation
|
311
|
-
|
312
|
-
2007-12-09 12:58 Rocky Bernstein
|
313
|
-
|
314
|
-
* : Initial import of LineCache, a module for reading and caching
|
315
|
-
lines.
|
316
|
-
This time to trunk.
|
317
|
-
|
data/NEWS
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
0.45
|
2
|
+
06-12-11
|
3
|
+
- Support for syntax highlighting and caching eval strings. The former
|
4
|
+
is used in rb8-trepanning.
|
5
|
+
|
1
6
|
0.43
|
2
7
|
06-12-08
|
3
8
|
- tolerance for finding windows extension in lib rather than ext.
|
@@ -26,4 +31,4 @@
|
|
26
31
|
|
27
32
|
- Initial release of LineCache, a module for reading and caching lines.
|
28
33
|
|
29
|
-
$Id: NEWS
|
34
|
+
$Id: NEWS 265 2011-06-09 21:51:21Z rockyb $
|
data/README
CHANGED
@@ -1,4 +1,16 @@
|
|
1
|
-
= LineCache -
|
1
|
+
= LineCache - A module to read and cache file information of a Ruby program.
|
2
|
+
|
3
|
+
== SYNOPSIS
|
4
|
+
|
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
|
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.
|
2
14
|
|
3
15
|
== Summary
|
4
16
|
|
@@ -35,4 +47,4 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
35
47
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
36
48
|
GNU General Public License for more details.
|
37
49
|
|
38
|
-
$Id: README
|
50
|
+
$Id: README 169 2009-02-08 17:19:33Z rockyb $
|
data/Rakefile
CHANGED
@@ -5,12 +5,12 @@ require 'rake/gempackagetask'
|
|
5
5
|
require 'rake/rdoctask'
|
6
6
|
require 'rake/testtask'
|
7
7
|
|
8
|
-
SO_NAME =
|
8
|
+
SO_NAME = 'trace_nums.so'
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
10
|
+
ROOT_DIR = File.dirname(__FILE__)
|
11
|
+
load File.join %W(#{ROOT_DIR} lib version.rb)
|
12
|
+
|
13
|
+
PKG_VERSION = LineCache::VERSION
|
14
14
|
PKG_NAME = 'linecache'
|
15
15
|
PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
|
16
16
|
RUBY_FORGE_PROJECT = 'rocky-hacks'
|
@@ -23,7 +23,6 @@ FILES = FileList[
|
|
23
23
|
'NEWS',
|
24
24
|
'README',
|
25
25
|
'Rakefile',
|
26
|
-
'VERSION',
|
27
26
|
'ext/trace_nums.c',
|
28
27
|
'ext/trace_nums.h',
|
29
28
|
'ext/extconf.rb',
|
@@ -33,36 +32,38 @@ FILES = FileList[
|
|
33
32
|
'test/short-file'
|
34
33
|
]
|
35
34
|
|
36
|
-
desc
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
end
|
35
|
+
desc 'Test everything'
|
36
|
+
Rake::TestTask.new(:test) do |t|
|
37
|
+
t.libs << './lib'
|
38
|
+
t.pattern = 'test/test-*.rb'
|
39
|
+
t.options = '--verbose' if $VERBOSE
|
42
40
|
end
|
41
|
+
task :test => :lib
|
43
42
|
|
44
|
-
desc
|
43
|
+
desc 'Create the core ruby-debug shared library extension'
|
45
44
|
task :lib do
|
46
|
-
Dir.chdir(
|
45
|
+
Dir.chdir('ext') do
|
47
46
|
system("#{Gem.ruby} extconf.rb && make")
|
48
47
|
end
|
49
48
|
end
|
50
49
|
|
51
50
|
|
52
|
-
desc
|
51
|
+
desc 'Test everything - same as test.'
|
53
52
|
task :check => :test
|
54
53
|
|
55
|
-
desc
|
54
|
+
desc 'Create a GNU-style ChangeLog via svn2cl'
|
56
55
|
task :ChangeLog do
|
57
|
-
system(
|
56
|
+
system('svn2cl --authors=svn2cl_usermap')
|
58
57
|
end
|
59
58
|
|
59
|
+
gem_file = nil
|
60
|
+
|
60
61
|
# Base GEM Specification
|
61
62
|
default_spec = Gem::Specification.new do |spec|
|
62
|
-
spec.name =
|
63
|
+
spec.name = 'linecache'
|
63
64
|
|
64
|
-
spec.homepage =
|
65
|
-
spec.summary =
|
65
|
+
spec.homepage = 'http://rubyforge.org/projects/rocky-hacks/linecache'
|
66
|
+
spec.summary = 'Read file with caching'
|
66
67
|
spec.description = <<-EOF
|
67
68
|
LineCache is a module for reading and caching lines. This may be useful for
|
68
69
|
example in a debugger where the same lines are shown many times.
|
@@ -70,12 +71,12 @@ EOF
|
|
70
71
|
|
71
72
|
spec.version = PKG_VERSION
|
72
73
|
|
73
|
-
spec.author =
|
74
|
-
spec.email =
|
74
|
+
spec.author = 'R. Bernstein'
|
75
|
+
spec.email = 'rockyb@rubyforge.net'
|
75
76
|
spec.platform = Gem::Platform::RUBY
|
76
|
-
spec.require_path =
|
77
|
+
spec.require_path = 'lib'
|
77
78
|
spec.files = FILES.to_a
|
78
|
-
spec.extensions = [
|
79
|
+
spec.extensions = ['ext/extconf.rb']
|
79
80
|
|
80
81
|
spec.required_ruby_version = '>= 1.8.2'
|
81
82
|
spec.date = Time.now
|
@@ -86,10 +87,12 @@ EOF
|
|
86
87
|
spec.extra_rdoc_files = ['README', 'lib/linecache.rb', 'lib/tracelines.rb']
|
87
88
|
|
88
89
|
spec.test_files = FileList['test/*.rb']
|
90
|
+
gem_file = "#{spec.name}-#{spec.version}.gem"
|
91
|
+
|
89
92
|
end
|
90
93
|
|
91
94
|
# Rake task to build the default package
|
92
|
-
|
95
|
+
Rake::GemPackageTask.new(default_spec) do |pkg|
|
93
96
|
pkg.need_tar = true
|
94
97
|
end
|
95
98
|
|
@@ -102,12 +105,12 @@ win_spec.extensions = []
|
|
102
105
|
win_spec.platform = 'mswin32'
|
103
106
|
win_spec.files += ["lib/#{SO_NAME}"]
|
104
107
|
|
105
|
-
desc
|
108
|
+
desc 'Create Windows Gem'
|
106
109
|
task :win32_gem do
|
107
110
|
# Copy the win32 extension the top level directory.
|
108
111
|
current_dir = File.expand_path(File.dirname(__FILE__))
|
109
|
-
source = File.join(current_dir,
|
110
|
-
target = File.join(current_dir,
|
112
|
+
source = File.join(current_dir, 'ext', 'win32', SO_NAME)
|
113
|
+
target = File.join(current_dir, 'lib', SO_NAME)
|
111
114
|
cp(source, target)
|
112
115
|
|
113
116
|
# Create the gem, then move it to pkg.
|
@@ -119,37 +122,45 @@ task :win32_gem do
|
|
119
122
|
rm(target)
|
120
123
|
end
|
121
124
|
|
122
|
-
desc
|
125
|
+
desc 'Publish linecache to RubyForge.'
|
123
126
|
task :publish do
|
124
127
|
require 'rake/contrib/sshpublisher'
|
125
128
|
|
126
129
|
# Get ruby-debug path.
|
127
130
|
ruby_debug_path = File.expand_path(File.dirname(__FILE__))
|
128
131
|
|
129
|
-
publisher = Rake::SshDirPublisher.new(
|
130
|
-
|
132
|
+
publisher = Rake::SshDirPublisher.new('rockyb@rubyforge.org',
|
133
|
+
'/var/www/gforge-projects/rocky-hacks/linecache', ruby_debug_path)
|
134
|
+
end
|
135
|
+
|
136
|
+
desc 'Remove residue from running patch'
|
137
|
+
task :rm_patch_residue do
|
138
|
+
FileUtils.rm_rf Dir.glob('**/*.{rej,orig}'), :verbose => true
|
131
139
|
end
|
132
140
|
|
133
|
-
desc
|
134
|
-
task :
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
141
|
+
desc 'Remove ~ backup files'
|
142
|
+
task :rm_tilde_backups do
|
143
|
+
FileUtils.rm_rf Dir.glob('**/*~'), :verbose => true
|
144
|
+
end
|
145
|
+
|
146
|
+
desc 'Remove built files'
|
147
|
+
task :clean => [:clobber_package, :clobber_rdoc, :rm_patch_residue,
|
148
|
+
:rm_tilde_backups] do
|
149
|
+
cd 'ext' do
|
150
|
+
if File.exists?('Makefile')
|
151
|
+
sh 'make clean'
|
152
|
+
rm 'Makefile'
|
139
153
|
end
|
140
|
-
derived_files = Dir.glob(
|
154
|
+
derived_files = Dir.glob('.o') + Dir.glob('*.so')
|
141
155
|
rm derived_files unless derived_files.empty?
|
142
156
|
end
|
143
157
|
end
|
144
158
|
|
145
159
|
# --------- RDoc Documentation ------
|
146
|
-
desc
|
147
|
-
Rake::RDocTask.new(
|
160
|
+
desc 'Generate rdoc documentation'
|
161
|
+
Rake::RDocTask.new('rdoc') do |rdoc|
|
148
162
|
rdoc.rdoc_dir = 'doc'
|
149
|
-
rdoc.title = "linecache"
|
150
|
-
# Show source inline with line numbers
|
151
|
-
rdoc.options << "--inline-source" << "--line-numbers"
|
152
|
-
# Make the readme file the start page for the generated html
|
163
|
+
rdoc.title = "linecache #{LineCache::VERSION} Documentation"
|
153
164
|
rdoc.options << '--main' << 'README'
|
154
165
|
rdoc.rdoc_files.include('ext/**/*.c',
|
155
166
|
'lib/*.rb',
|
@@ -157,10 +168,18 @@ Rake::RDocTask.new("rdoc") do |rdoc|
|
|
157
168
|
'COPYING')
|
158
169
|
end
|
159
170
|
|
160
|
-
desc
|
171
|
+
desc 'Publish the release files to RubyForge.'
|
161
172
|
task :rubyforge_upload do
|
162
173
|
`rubyforge login`
|
163
174
|
release_command = "rubyforge add_release #{PKG_NAME} #{PKG_NAME} '#{PKG_NAME}-#{PKG_VERSION}' pkg/#{PKG_NAME}-#{PKG_VERSION}.gem"
|
164
175
|
puts release_command
|
165
176
|
system(release_command)
|
166
177
|
end
|
178
|
+
|
179
|
+
desc 'Install the gem locally'
|
180
|
+
task :install => :gem do
|
181
|
+
Dir.chdir(ROOT_DIR) do
|
182
|
+
sh %{gem install --local pkg/#{gem_file}}
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
data/ext/trace_nums.c
CHANGED
@@ -34,15 +34,29 @@
|
|
34
34
|
#include <ruby.h>
|
35
35
|
#include <version.h>
|
36
36
|
#include <node.h>
|
37
|
-
#include <env.h>
|
38
37
|
#include <rubysig.h>
|
39
38
|
#include "trace_nums.h"
|
40
39
|
|
41
40
|
VALUE mTraceLineNumbers;
|
42
|
-
|
41
|
+
RUBY_EXTERN NODE *ruby_eval_tree_begin;
|
42
|
+
RUBY_EXTERN int ruby_in_eval;
|
43
43
|
|
44
44
|
#define nd_3rd u3.node
|
45
45
|
|
46
|
+
extern struct FRAME {
|
47
|
+
VALUE self;
|
48
|
+
int argc;
|
49
|
+
ID last_func;
|
50
|
+
ID orig_func;
|
51
|
+
VALUE last_class;
|
52
|
+
struct FRAME *prev;
|
53
|
+
struct FRAME *tmp;
|
54
|
+
struct RNode *node;
|
55
|
+
int iter;
|
56
|
+
int flags;
|
57
|
+
unsigned long uniq;
|
58
|
+
} *ruby_frame;
|
59
|
+
|
46
60
|
struct METHOD {
|
47
61
|
VALUE klass, rklass;
|
48
62
|
VALUE recv;
|
@@ -87,7 +101,7 @@ struct BLOCK {
|
|
87
101
|
#endif
|
88
102
|
|
89
103
|
/* Used just in debugging. */
|
90
|
-
static indent_level = 0;
|
104
|
+
static int indent_level = 0;
|
91
105
|
|
92
106
|
static
|
93
107
|
void ln_eval(VALUE self, NODE * n, VALUE ary) {
|
data/ext/trace_nums.h
CHANGED
data/lib/linecache.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
# $Id: linecache.rb
|
2
|
+
# $Id: linecache.rb 266 2011-06-10 23:41:29Z rockyb $
|
3
3
|
#
|
4
|
-
# Copyright (C) 2007, 2008 Rocky Bernstein <rockyb@rubyforge.net>
|
4
|
+
# Copyright (C) 2007, 2008, 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
|
5
5
|
#
|
6
6
|
# This program is free software; you can redistribute it and/or modify
|
7
7
|
# it under the terms of the GNU General Public License as published by
|
@@ -22,16 +22,20 @@
|
|
22
22
|
# Author:: Rocky Bernstein (mailto:rockyb@rubyforge.net)
|
23
23
|
#
|
24
24
|
# = linecache
|
25
|
-
#
|
26
|
-
# == Version
|
27
|
-
# :include:VERSION
|
25
|
+
# A module to read and cache lines of a Ruby program.
|
28
26
|
|
29
27
|
# == SYNOPSIS
|
30
28
|
#
|
31
29
|
# The LineCache module allows one to get any line from any file,
|
32
|
-
# caching lines of the file on first access to the file.
|
33
|
-
#
|
34
|
-
#
|
30
|
+
# caching lines of the file on first access to the file. Although the
|
31
|
+
# file may be any file, the common use is when the file is a Ruby
|
32
|
+
# script since parsing of the file is done to figure out where the
|
33
|
+
# statement boundaries are.
|
34
|
+
#
|
35
|
+
# The routines here may be is useful when a small random sets of lines
|
36
|
+
# are read from a single file, in particular in a debugger to show
|
37
|
+
# source lines.
|
38
|
+
#
|
35
39
|
#
|
36
40
|
# require 'linecache'
|
37
41
|
# lines = LineCache::getlines('/tmp/myruby.rb')
|
@@ -43,7 +47,6 @@
|
|
43
47
|
# # Note lines[6] == line (if /tmp/myruby.rb has 6 lines)
|
44
48
|
#
|
45
49
|
# LineCache::clear_file_cache
|
46
|
-
# LineCache::clear_file_cache('/tmp/myruby.rb')
|
47
50
|
# LineCache::update_cache # Check for modifications of all cached files.
|
48
51
|
#
|
49
52
|
# Some parts of the interface is derived from the Python module of the
|
@@ -60,11 +63,13 @@ require 'digest/sha1'
|
|
60
63
|
require 'set'
|
61
64
|
|
62
65
|
begin require 'rubygems' rescue LoadError end
|
63
|
-
require '
|
66
|
+
require 'require_relative'
|
67
|
+
require_relative 'tracelines'
|
68
|
+
require_relative 'version'
|
64
69
|
# require 'ruby-debug' ; Debugger.start
|
65
70
|
|
66
71
|
# = module LineCache
|
67
|
-
#
|
72
|
+
# A module to read and cache lines of a Ruby program.
|
68
73
|
module LineCache
|
69
74
|
LineCacheInfo = Struct.new(:stat, :line_numbers, :lines, :path, :sha1) unless
|
70
75
|
defined?(LineCacheInfo)
|
@@ -72,6 +77,11 @@ module LineCache
|
|
72
77
|
# The file cache. The key is a name as would be given by Ruby for
|
73
78
|
# __FILE__. The value is a LineCacheInfo object.
|
74
79
|
@@file_cache = {}
|
80
|
+
@@script_cache = {}
|
81
|
+
|
82
|
+
|
83
|
+
# Used for CodeRay syntax highlighting
|
84
|
+
@@ruby_highlighter = nil
|
75
85
|
|
76
86
|
# Maps a string filename (a String) to a key in @@file_cache (a
|
77
87
|
# String).
|
@@ -87,28 +97,80 @@ module LineCache
|
|
87
97
|
# ranges. Will probably use this for that, but I'm not sure.
|
88
98
|
@@file2file_remap = {}
|
89
99
|
@@file2file_remap_lines = {}
|
100
|
+
@@script2file = {}
|
101
|
+
|
102
|
+
module_function
|
103
|
+
|
104
|
+
def remove_script_temps
|
105
|
+
@@script2file.values.each do |filename|
|
106
|
+
File.unlink(filename) if File.exist?(filename)
|
107
|
+
end
|
108
|
+
end
|
109
|
+
at_exit { remove_script_temps }
|
110
|
+
|
90
111
|
|
91
112
|
# Clear the file cache entirely.
|
92
|
-
def clear_file_cache()
|
93
|
-
|
94
|
-
|
95
|
-
|
113
|
+
def clear_file_cache(filename=nil)
|
114
|
+
if filename
|
115
|
+
if @@file_cache[filename]
|
116
|
+
@@file_cache.delete(filename)
|
117
|
+
end
|
118
|
+
else
|
119
|
+
@@file_cache = {}
|
120
|
+
@@file2file_remap = {}
|
121
|
+
@@file2file_remap_lines = {}
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
# Remove syntax-formatted lines in the cache. Use this
|
126
|
+
# when you change the CodeRay syntax or Token formatting
|
127
|
+
# and want to redo how files may have previously been
|
128
|
+
# syntax marked.
|
129
|
+
def clear_file_format_cache
|
130
|
+
@@file_cache.each_pair do |fname, cache_info|
|
131
|
+
cache_info.lines.each_pair do |format, lines|
|
132
|
+
next if :plain == format
|
133
|
+
@@file_cache[fname].lines[format] = nil
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
# Remove syntax-formatted lines in the cache. Use this
|
139
|
+
# when you change the CodeRay syntax or Token formatting
|
140
|
+
# and want to redo how files may have previously been
|
141
|
+
# syntax marked.
|
142
|
+
def clear_file_format_cache
|
143
|
+
@@file_cache.each_pair do |fname, cache_info|
|
144
|
+
cache_info.lines.each_pair do |format, lines|
|
145
|
+
next if :plain == format
|
146
|
+
@@file_cache[fname].lines[format] = nil
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
# Clear the script cache entirely.
|
152
|
+
def clear_script_cache()
|
153
|
+
@@script_cache = {}
|
96
154
|
end
|
97
|
-
module_function :clear_file_cache
|
98
155
|
|
99
156
|
# Return an array of cached file names
|
100
157
|
def cached_files()
|
101
158
|
@@file_cache.keys
|
102
159
|
end
|
103
|
-
module_function :cached_files
|
104
160
|
|
105
161
|
# Discard cache entries that are out of date. If +filename+ is +nil+
|
106
162
|
# all entries in the file cache +@@file_cache+ are checked.
|
107
|
-
# If we don't have stat information about a file which can happen
|
163
|
+
# If we don't have stat information about a file, which can happen
|
108
164
|
# if the file was read from __SCRIPT_LINES but no corresponding file
|
109
165
|
# is found, it will be kept. Return a list of invalidated filenames.
|
110
166
|
# nil is returned if a filename was given but not found cached.
|
111
|
-
def checkcache(filename=nil,
|
167
|
+
def checkcache(filename=nil, opts=false)
|
168
|
+
use_script_lines =
|
169
|
+
if opts.kind_of?(Hash)
|
170
|
+
opts[:use_script_lines]
|
171
|
+
else
|
172
|
+
opts
|
173
|
+
end
|
112
174
|
|
113
175
|
if !filename
|
114
176
|
filenames = @@file_cache.keys()
|
@@ -123,19 +185,60 @@ module LineCache
|
|
123
185
|
next unless @@file_cache.member?(filename)
|
124
186
|
path = @@file_cache[filename].path
|
125
187
|
if File.exist?(path)
|
126
|
-
cache_info = @@file_cache[filename]
|
188
|
+
cache_info = @@file_cache[filename].stat
|
127
189
|
stat = File.stat(path)
|
128
|
-
if
|
129
|
-
|
190
|
+
if cache_info
|
191
|
+
if stat &&
|
192
|
+
(cache_info.size != stat.size or cache_info.mtime != stat.mtime)
|
193
|
+
result << filename
|
194
|
+
update_cache(filename, opts)
|
195
|
+
end
|
196
|
+
else
|
130
197
|
result << filename
|
131
|
-
update_cache(filename,
|
198
|
+
update_cache(filename, opts)
|
132
199
|
end
|
133
200
|
end
|
134
201
|
end
|
135
202
|
return result
|
136
203
|
end
|
137
|
-
|
204
|
+
|
205
|
+
# Cache script if it's not already cached.
|
206
|
+
def cache_script(script, opts={})
|
207
|
+
if !@@script_cache.member?(script)
|
208
|
+
update_script_cache(script, opts)
|
209
|
+
end
|
210
|
+
script
|
211
|
+
end
|
212
|
+
|
213
|
+
# Cache file name or script object if it's not already cached.
|
214
|
+
# Return the expanded filename for it in the cache if a filename,
|
215
|
+
# or the script, or nil if we can't find the file.
|
216
|
+
def cache(file_or_script, reload_on_change=false)
|
217
|
+
if file_or_script.kind_of?(String)
|
218
|
+
cache_file(file_or_script, reload_on_change)
|
219
|
+
else
|
220
|
+
cache_script(file_or_script)
|
221
|
+
end
|
222
|
+
end
|
138
223
|
|
224
|
+
# Cache filename if it's not already cached.
|
225
|
+
# Return the expanded filename for it in the cache
|
226
|
+
# or nil if we can't find the file.
|
227
|
+
def cache_file(filename, reload_on_change=false, opts={})
|
228
|
+
if @@file_cache.member?(filename)
|
229
|
+
checkcache(filename) if reload_on_change
|
230
|
+
else
|
231
|
+
opts[:use_script_lines] = true
|
232
|
+
update_cache(filename, opts)
|
233
|
+
end
|
234
|
+
if @@file_cache.member?(filename)
|
235
|
+
@@file_cache[filename].path
|
236
|
+
else
|
237
|
+
nil
|
238
|
+
end
|
239
|
+
end
|
240
|
+
|
241
|
+
# Older routine - for compability.
|
139
242
|
# Cache filename if it's not already cached.
|
140
243
|
# Return the expanded filename for it in the cache
|
141
244
|
# or nil if we can't find the file.
|
@@ -151,80 +254,116 @@ module LineCache
|
|
151
254
|
nil
|
152
255
|
end
|
153
256
|
end
|
154
|
-
module_function :cache
|
155
257
|
|
156
|
-
# Return true if
|
157
|
-
def cached?(
|
158
|
-
|
258
|
+
# Return true if file_or_script is cached
|
259
|
+
def cached?(file_or_script)
|
260
|
+
if file_or_script.kind_of?(String)
|
261
|
+
@@file_cache.member?(unmap_file(file_or_script))
|
262
|
+
else
|
263
|
+
cached_script?(file_or_script)
|
264
|
+
end
|
159
265
|
end
|
160
|
-
module_function :cached?
|
161
266
|
|
162
267
|
def cached_script?(filename)
|
163
268
|
SCRIPT_LINES__.member?(unmap_file(filename))
|
164
269
|
end
|
165
|
-
module_function :cached_script?
|
166
270
|
|
167
271
|
def empty?(filename)
|
168
272
|
filename=unmap_file(filename)
|
169
|
-
|
273
|
+
!!@@file_cache[filename].lines[:plain]
|
170
274
|
end
|
171
|
-
module_function :empty?
|
172
275
|
|
173
276
|
# Get line +line_number+ from file named +filename+. Return nil if
|
174
277
|
# there was a problem. If a file named filename is not found, the
|
175
|
-
# function will look for it in the $:
|
278
|
+
# function will look for it in the $: array.
|
176
279
|
#
|
177
280
|
# Examples:
|
178
281
|
#
|
179
|
-
# lines = LineCache::getline('/tmp/myfile.rb)
|
282
|
+
# lines = LineCache::getline('/tmp/myfile.rb')
|
180
283
|
# # Same as above
|
181
284
|
# $: << '/tmp'
|
182
|
-
# lines =
|
183
|
-
# lines = LineCache::getlines ('myfile.rb')
|
184
|
-
# end
|
285
|
+
# lines = LineCache.getlines('myfile.rb')
|
185
286
|
#
|
186
|
-
def getline(
|
187
|
-
|
188
|
-
|
189
|
-
|
287
|
+
def getline(file_or_script, line_number, opts=true)
|
288
|
+
reload_on_change =
|
289
|
+
if opts.kind_of?(Hash)
|
290
|
+
opts[:reload_on_change]
|
291
|
+
else
|
292
|
+
opts
|
293
|
+
end
|
294
|
+
lines =
|
295
|
+
if file_or_script.kind_of?(String)
|
296
|
+
filename = unmap_file(file_or_script)
|
297
|
+
filename, line_number = unmap_file_line(filename, line_number)
|
298
|
+
getlines(filename, opts)
|
299
|
+
else
|
300
|
+
script_getlines(file_or_script)
|
301
|
+
end
|
190
302
|
if lines and (1..lines.size) === line_number
|
191
303
|
return lines[line_number-1]
|
192
304
|
else
|
193
305
|
return nil
|
194
306
|
end
|
195
307
|
end
|
196
|
-
module_function :getline
|
197
308
|
|
198
309
|
# Read lines of +filename+ and cache the results. However +filename+ was
|
199
310
|
# previously cached use the results from the cache. Return nil
|
200
311
|
# if we can't get lines
|
201
|
-
def getlines(filename,
|
202
|
-
|
312
|
+
def getlines(filename, opts=false)
|
313
|
+
if opts.kind_of?(Hash)
|
314
|
+
reload_on_change, use_script_lines =
|
315
|
+
[opts[:reload_on_change], opts[:use_script_lines]]
|
316
|
+
else
|
317
|
+
reload_on_change, use_script_lines = [opts, false]
|
318
|
+
opts = {:reload_on_change => reload_on_change}
|
319
|
+
end
|
203
320
|
checkcache(filename) if reload_on_change
|
321
|
+
format = opts[:output] || :plain
|
204
322
|
if @@file_cache.member?(filename)
|
205
|
-
|
323
|
+
lines = @@file_cache[filename].lines
|
324
|
+
if opts[:output] && !lines[format]
|
325
|
+
lines[format] =
|
326
|
+
highlight_string(lines[:plain].join(''), format).split(/\n/)
|
327
|
+
end
|
328
|
+
return lines[format]
|
206
329
|
else
|
207
|
-
|
208
|
-
|
330
|
+
opts[:use_script_lines] = true
|
331
|
+
update_cache(filename, opts)
|
332
|
+
if @@file_cache.member?(filename)
|
333
|
+
return @@file_cache[filename].lines[format]
|
334
|
+
else
|
335
|
+
return nil
|
336
|
+
end
|
209
337
|
end
|
210
338
|
end
|
211
|
-
|
339
|
+
|
340
|
+
def highlight_string(string, output_type)
|
341
|
+
require 'rubygems'
|
342
|
+
begin
|
343
|
+
require 'coderay'
|
344
|
+
require 'term/ansicolor'
|
345
|
+
rescue LoadError
|
346
|
+
return string
|
347
|
+
end
|
348
|
+
@@ruby_highlighter ||= CodeRay::Duo[:ruby, output_type]
|
349
|
+
@@ruby_highlighter.encode(string)
|
350
|
+
end
|
212
351
|
|
213
352
|
# Return full filename path for filename
|
214
353
|
def path(filename)
|
354
|
+
return unless filename.kind_of?(String)
|
215
355
|
filename = unmap_file(filename)
|
216
356
|
return nil unless @@file_cache.member?(filename)
|
217
357
|
@@file_cache[filename].path
|
218
358
|
end
|
219
|
-
module_function :path
|
220
359
|
|
221
360
|
def remap_file(from_file, to_file)
|
222
|
-
@@file2file_remap[
|
361
|
+
@@file2file_remap[from_file] = to_file
|
362
|
+
cache_file(to_file)
|
223
363
|
end
|
224
|
-
module_function :remap_file
|
225
364
|
|
226
365
|
def remap_file_lines(from_file, to_file, range, start)
|
227
|
-
range = (range..range) if range.
|
366
|
+
range = (range..range) if range.kind_of?(Fixnum)
|
228
367
|
to_file = from_file unless to_file
|
229
368
|
if @@file2file_remap_lines[to_file]
|
230
369
|
# FIXME: need to check for overwriting ranges: whether
|
@@ -243,21 +382,25 @@ module LineCache
|
|
243
382
|
return @@file_cache[filename].sha1.hexdigest if
|
244
383
|
@@file_cache[filename].sha1
|
245
384
|
sha1 = Digest::SHA1.new
|
246
|
-
@@file_cache[filename].lines.each do |line|
|
247
|
-
sha1 << line
|
385
|
+
@@file_cache[filename].lines[:plain].each do |line|
|
386
|
+
sha1 << line + "\n"
|
248
387
|
end
|
249
388
|
@@file_cache[filename].sha1 = sha1
|
250
389
|
sha1.hexdigest
|
251
390
|
end
|
252
|
-
module_function :sha1
|
253
391
|
|
254
392
|
# Return the number of lines in filename
|
255
|
-
def size(
|
256
|
-
|
257
|
-
|
258
|
-
|
393
|
+
def size(file_or_script)
|
394
|
+
cache(file_or_script)
|
395
|
+
if file_or_script.kind_of?(String)
|
396
|
+
file_or_script = unmap_file(file_or_script)
|
397
|
+
return nil unless @@file_cache.member?(file_or_script)
|
398
|
+
@@file_cache[file_or_script].lines[:plain].length
|
399
|
+
else
|
400
|
+
return nil unless @@script_cache.member?(file_or_script)
|
401
|
+
@@script_cache[file_or_script].lines[:plain].length
|
402
|
+
end
|
259
403
|
end
|
260
|
-
module_function :size
|
261
404
|
|
262
405
|
# Return File.stat in the cache for filename.
|
263
406
|
def stat(filename)
|
@@ -276,17 +419,16 @@ module LineCache
|
|
276
419
|
e = @@file_cache[filename]
|
277
420
|
unless e.line_numbers
|
278
421
|
e.line_numbers =
|
279
|
-
TraceLineNumbers.lnums_for_str_array(e.lines)
|
422
|
+
TraceLineNumbers.lnums_for_str_array(e.lines[:plain])
|
280
423
|
e.line_numbers = false unless e.line_numbers
|
281
424
|
end
|
282
425
|
e.line_numbers
|
283
426
|
end
|
284
|
-
module_function :trace_line_numbers
|
285
427
|
|
286
428
|
def unmap_file(file)
|
287
429
|
@@file2file_remap[file] ? @@file2file_remap[file] : file
|
288
430
|
end
|
289
|
-
|
431
|
+
alias :map_file :unmap_file
|
290
432
|
|
291
433
|
def unmap_file_line(file, line)
|
292
434
|
if @@file2file_remap_lines[file]
|
@@ -299,13 +441,32 @@ module LineCache
|
|
299
441
|
end
|
300
442
|
return [file, line]
|
301
443
|
end
|
302
|
-
|
444
|
+
|
445
|
+
# Update a cache entry. If something is wrong, return nil. Return
|
446
|
+
# true if the cache was updated and false if not.
|
447
|
+
def update_script_cache(script, opts)
|
448
|
+
# return false unless script_is_eval?(script)
|
449
|
+
# string = opts[:string] || script.eval_source
|
450
|
+
lines = {:plain => string.split(/\n/)}
|
451
|
+
lines[opts[:output]] = highlight_string(string, opts[:output]) if
|
452
|
+
opts[:output]
|
453
|
+
@@script_cache[script] =
|
454
|
+
LineCacheInfo.new(nil, nil, lines, nil, opts[:sha1],
|
455
|
+
opts[:compiled_method])
|
456
|
+
return true
|
457
|
+
end
|
303
458
|
|
304
459
|
# Update a cache entry. If something's
|
305
460
|
# wrong, return nil. Return true if the cache was updated and false
|
306
461
|
# if not. If use_script_lines is true, use that as the source for the
|
307
462
|
# lines of the file
|
308
|
-
def update_cache(filename,
|
463
|
+
def update_cache(filename, opts=false)
|
464
|
+
if opts.kind_of?(Hash)
|
465
|
+
use_script_lines = opts[:use_script_lines]
|
466
|
+
else
|
467
|
+
use_script_lines = opts
|
468
|
+
opts = {:use_script_lines => use_script_lines}
|
469
|
+
end
|
309
470
|
|
310
471
|
return nil unless filename
|
311
472
|
|
@@ -322,7 +483,11 @@ module LineCache
|
|
322
483
|
rescue
|
323
484
|
stat = nil
|
324
485
|
end
|
325
|
-
|
486
|
+
raw_lines = SCRIPT_LINES__[name]
|
487
|
+
lines = {:plain => raw_lines}
|
488
|
+
lines[opts[:output]] =
|
489
|
+
highlight_string(raw_lines.join, opts[:output]).split(/\n/) if
|
490
|
+
opts[:output]
|
326
491
|
@@file_cache[filename] = LineCacheInfo.new(stat, nil, lines, path, nil)
|
327
492
|
@@file2file_remap[path] = filename
|
328
493
|
return true
|
@@ -346,8 +511,13 @@ module LineCache
|
|
346
511
|
end
|
347
512
|
begin
|
348
513
|
fp = File.open(path, 'r')
|
349
|
-
|
514
|
+
raw_string = fp.read
|
515
|
+
fp.rewind
|
516
|
+
lines = {:plain => fp.readlines}
|
350
517
|
fp.close()
|
518
|
+
lines[opts[:output]] =
|
519
|
+
highlight_string(raw_string, opts[:output]).split(/\n/) if
|
520
|
+
opts[:output]
|
351
521
|
rescue
|
352
522
|
## print '*** cannot open', path, ':', msg
|
353
523
|
return nil
|
@@ -358,8 +528,6 @@ module LineCache
|
|
358
528
|
return true
|
359
529
|
end
|
360
530
|
|
361
|
-
module_function :update_cache
|
362
|
-
|
363
531
|
end
|
364
532
|
|
365
533
|
# example usage
|
data/lib/tracelines.rb
CHANGED
File without changes
|
data/lib/version.rb
ADDED
data/test/data/block1.rb
CHANGED
File without changes
|
data/test/lnum-diag.rb
CHANGED
File without changes
|
data/test/parse-show.rb
CHANGED
File without changes
|
data/test/test-linecache.rb
CHANGED
@@ -127,7 +127,7 @@ class TestLineCache < Test::Unit::TestCase
|
|
127
127
|
|
128
128
|
def test_path
|
129
129
|
assert_equal(nil, LineCache::path(__FILE__),
|
130
|
-
"path for #{__FILE__}
|
130
|
+
"path for #{__FILE__} should be nil - just cleared cache.")
|
131
131
|
path = LineCache::cache(__FILE__)
|
132
132
|
assert path
|
133
133
|
assert_equal(path, LineCache::path(__FILE__),
|
@@ -144,7 +144,7 @@ class TestLineCache < Test::Unit::TestCase
|
|
144
144
|
def test_sha1
|
145
145
|
test_file = File.join(@@TEST_DIR, 'short-file')
|
146
146
|
LineCache::cache(test_file)
|
147
|
-
assert_equal('
|
147
|
+
assert_equal('3e1d87f3399fc73ae5683e106bce1b5ba823fc50',
|
148
148
|
LineCache::sha1(test_file))
|
149
149
|
end
|
150
150
|
|
data/test/test-lnum.rb
CHANGED
File without changes
|
data/test/test-tracelines.rb
CHANGED
File without changes
|
metadata
CHANGED
@@ -1,33 +1,36 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.9.4
|
3
|
-
specification_version: 1
|
4
2
|
name: linecache
|
5
3
|
version: !ruby/object:Gem::Version
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
-
|
11
|
-
|
12
|
-
homepage: http://rubyforge.org/projects/rocky-hacks/linecache
|
13
|
-
rubyforge_project: rocky-hacks
|
14
|
-
description: 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.
|
15
|
-
autorequire:
|
16
|
-
default_executable:
|
17
|
-
bindir: bin
|
18
|
-
has_rdoc: true
|
19
|
-
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
|
-
requirements:
|
21
|
-
- - ">="
|
22
|
-
- !ruby/object:Gem::Version
|
23
|
-
version: 1.8.2
|
24
|
-
version:
|
4
|
+
hash: 81
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 45
|
9
|
+
version: "0.45"
|
25
10
|
platform: ruby
|
26
|
-
signing_key:
|
27
|
-
cert_chain:
|
28
|
-
post_install_message:
|
29
11
|
authors:
|
30
12
|
- R. Bernstein
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2011-06-11 00:00:00 -04:00
|
18
|
+
default_executable:
|
19
|
+
dependencies: []
|
20
|
+
|
21
|
+
description: |
|
22
|
+
LineCache is a module for reading and caching lines. This may be useful for
|
23
|
+
example in a debugger where the same lines are shown many times.
|
24
|
+
|
25
|
+
email: rockyb@rubyforge.net
|
26
|
+
executables: []
|
27
|
+
|
28
|
+
extensions:
|
29
|
+
- ext/extconf.rb
|
30
|
+
extra_rdoc_files:
|
31
|
+
- README
|
32
|
+
- lib/linecache.rb
|
33
|
+
- lib/tracelines.rb
|
31
34
|
files:
|
32
35
|
- AUTHORS
|
33
36
|
- COPYING
|
@@ -35,64 +38,86 @@ files:
|
|
35
38
|
- NEWS
|
36
39
|
- README
|
37
40
|
- Rakefile
|
38
|
-
- VERSION
|
39
41
|
- ext/trace_nums.c
|
40
42
|
- ext/trace_nums.h
|
41
43
|
- ext/extconf.rb
|
44
|
+
- lib/version.rb
|
42
45
|
- lib/tracelines.rb
|
43
46
|
- lib/linecache.rb
|
47
|
+
- test/parse-show.rb
|
48
|
+
- test/lnum-diag.rb
|
44
49
|
- test/rcov-bug.rb
|
45
|
-
- test/test-tracelines.rb
|
46
50
|
- test/test-lnum.rb
|
47
51
|
- test/test-linecache.rb
|
48
|
-
- test/
|
49
|
-
- test/
|
50
|
-
- test/data/for1.rb
|
51
|
-
- test/data/if6.rb
|
52
|
+
- test/test-tracelines.rb
|
53
|
+
- test/data/if1.rb
|
52
54
|
- test/data/comments1.rb
|
53
|
-
- test/data/if3.rb
|
54
|
-
- test/data/if5.rb
|
55
|
-
- test/data/begin3.rb
|
56
|
-
- test/data/end.rb
|
57
|
-
- test/data/case1.rb
|
58
|
-
- test/data/match.rb
|
59
|
-
- test/data/begin2.rb
|
60
|
-
- test/data/match3.rb
|
61
|
-
- test/data/case5.rb
|
62
55
|
- test/data/not-lit.rb
|
63
|
-
- test/data/
|
64
|
-
- test/data/if7.rb
|
65
|
-
- test/data/if4.rb
|
66
|
-
- test/data/case2.rb
|
56
|
+
- test/data/begin2.rb
|
67
57
|
- test/data/block2.rb
|
58
|
+
- test/data/if6.rb
|
59
|
+
- test/data/end.rb
|
60
|
+
- test/data/case4.rb
|
68
61
|
- test/data/begin1.rb
|
69
|
-
- test/data/
|
70
|
-
- test/data/
|
62
|
+
- test/data/for1.rb
|
63
|
+
- test/data/match.rb
|
64
|
+
- test/data/match3a.rb
|
71
65
|
- test/data/class1.rb
|
72
|
-
- test/data/
|
66
|
+
- test/data/if3.rb
|
67
|
+
- test/data/if5.rb
|
68
|
+
- test/data/case1.rb
|
69
|
+
- test/data/def1.rb
|
70
|
+
- test/data/if7.rb
|
73
71
|
- test/data/block1.rb
|
72
|
+
- test/data/begin3.rb
|
74
73
|
- test/data/case3.rb
|
74
|
+
- test/data/case2.rb
|
75
75
|
- test/data/each1.rb
|
76
|
-
- test/data/
|
76
|
+
- test/data/if2.rb
|
77
|
+
- test/data/match3.rb
|
78
|
+
- test/data/if4.rb
|
79
|
+
- test/data/case5.rb
|
77
80
|
- test/short-file
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
- test/test-lnum.rb
|
82
|
-
- test/test-linecache.rb
|
83
|
-
- test/parse-show.rb
|
84
|
-
- test/lnum-diag.rb
|
85
|
-
rdoc_options: []
|
81
|
+
has_rdoc: true
|
82
|
+
homepage: http://rubyforge.org/projects/rocky-hacks/linecache
|
83
|
+
licenses: []
|
86
84
|
|
87
|
-
|
88
|
-
|
89
|
-
- lib/linecache.rb
|
90
|
-
- lib/tracelines.rb
|
91
|
-
executables: []
|
85
|
+
post_install_message:
|
86
|
+
rdoc_options: []
|
92
87
|
|
93
|
-
|
94
|
-
-
|
88
|
+
require_paths:
|
89
|
+
- lib
|
90
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
91
|
+
none: false
|
92
|
+
requirements:
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
hash: 51
|
96
|
+
segments:
|
97
|
+
- 1
|
98
|
+
- 8
|
99
|
+
- 2
|
100
|
+
version: 1.8.2
|
101
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
102
|
+
none: false
|
103
|
+
requirements:
|
104
|
+
- - ">="
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
hash: 3
|
107
|
+
segments:
|
108
|
+
- 0
|
109
|
+
version: "0"
|
95
110
|
requirements: []
|
96
111
|
|
97
|
-
|
98
|
-
|
112
|
+
rubyforge_project: rocky-hacks
|
113
|
+
rubygems_version: 1.6.1
|
114
|
+
signing_key:
|
115
|
+
specification_version: 3
|
116
|
+
summary: Read file with caching
|
117
|
+
test_files:
|
118
|
+
- test/parse-show.rb
|
119
|
+
- test/lnum-diag.rb
|
120
|
+
- test/rcov-bug.rb
|
121
|
+
- test/test-lnum.rb
|
122
|
+
- test/test-linecache.rb
|
123
|
+
- test/test-tracelines.rb
|
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
0.43
|