rmtools 1.2.2b → 1.2.2c

Sign up to get free protection for your applications and to get access to all the features.
data/Manifest.txt CHANGED
@@ -17,8 +17,8 @@ lib/rmtools/dev/binding.rb
17
17
  lib/rmtools/dev/logging.rb
18
18
  lib/rmtools/dev/trace_format.rb
19
19
  lib/rmtools/dev/highlight.rb
20
- lib/rmtools/dev/code_reading.rb
21
20
  lib/rmtools/dev/timer.rb
21
+ lib/rmtools/dev/code_reader.rb
22
22
  lib/rmtools/xml/xpath.rb
23
23
  lib/rmtools/xml/string.rb
24
24
  lib/rmtools/xml/libxml.rb
data/Rakefile CHANGED
@@ -2,7 +2,7 @@ require 'rake'
2
2
  require 'lib/rmtools/install'
3
3
  compile_manifest
4
4
 
5
- RMTOOLS_VERSION = '1.2.2b'
5
+ RMTOOLS_VERSION = '1.2.2c'
6
6
  begin
7
7
  require 'hoe'
8
8
  config = Hoe.spec 'rmtools' do
@@ -72,6 +72,7 @@ module RMTools
72
72
  ['sub', 'gsub', 'sub!', 'gsub!'].each {|m|
73
73
  class_eval %{
74
74
  def #{m.sub'sub','hl'} str, pattern, color=:red_bold
75
+ pattern = pattern.to_s unless pattern.is Regexp
75
76
  str.#{m} pattern do |word|
76
77
  if str[/^\\e\\[(\\d+(;\\d+)?)/]
77
78
  "\\e[m\#{send(color, word)}\\e[\#$1m"
@@ -80,6 +81,12 @@ module RMTools
80
81
  end
81
82
  end
82
83
  end
84
+ }
85
+ String.class_eval %{
86
+ def #{m.sub'sub','hl'} pattern, color=:red_bold
87
+ Painter.#{m.sub'sub','hl'} self, pattern, color
88
+ self
89
+ end
83
90
  }
84
91
  }
85
92
 
@@ -1,6 +1,4 @@
1
1
  # encoding: utf-8
2
- require 'active_record'
3
-
4
2
  module ActiveRecord
5
3
 
6
4
  def self.establish_connection_with config
@@ -6,7 +6,7 @@ module RMTools
6
6
  attr_reader :MethodCache, :stack
7
7
 
8
8
  module Defaults
9
- Leftop = leftop = '\[{(<=>~+\-*,;:^&\|'
9
+ Leftop = leftop = '\[{(<=>~+\-*,;^&\|'
10
10
  rightop = '\])}?!'
11
11
  sname = '\w<=>~+\-*/\]\[\^%!?@&\|'
12
12
  compname = "([\\.:#{sname}]+)"
@@ -17,8 +17,8 @@ module RMTools
17
17
  space_ = '[ \t]*'
18
18
  kw = 'if|elsif|else|unless|while|until|case|begin|rescue|when|then|or|and|not'
19
19
  heredoc_handle = %q{<<(-)?(\w+|`[^`]+`|'[^']+'|"[^"]+")}
20
- heredoc = %{([\\s#{leftop}?]|[#{leftop}\\w!?][ \t])\\s*#{heredoc_handle}}
21
- re_sugar = %{(^|[#{leftop}\\n?;]|\W!|\\b(#{kw})[ \t]|[\\w#{rightop}]/)\\s*/}
20
+ heredoc = %{([\\s#{leftop}?]|[#{leftop}:\\w!?][ \t])\\s*#{heredoc_handle}}
21
+ re_sugar = %{(^|[#{leftop}\\n?;]|\W!|(^|[\{(,;\\s])(#{kw})[ \t]|[\\w#{rightop}]/)\\s*/}
22
22
  percent = '%([xwqrQW])?([\\/<({\[!\|])'
23
23
  simple = [re_sugar, percent, '[#\'"`]']*'|'
24
24
  mod_def = "module +#{mname}"
@@ -29,14 +29,18 @@ module RMTools
29
29
 
30
30
  StringParseRE = /#{heredoc}|#{simple}|[{}]|[^\w#{rightop}'"`\/\\]\?\\?\S/m
31
31
  HeredocParseRE = /\n|#{heredoc}|#{simple}/m
32
- ArgumentsParseRE = /#{simple}|[{}()\[\]\n;,\|]| end\b|[:@$.\w!?]+(\b|[( ] *)| +[:?]\s+| *=>\s*/m
32
+ ArgumentsParseRE = /#{simple
33
+ }|(\d[\d.]+|:[@$_a-z]\w*|[@$]\w+) *#{
34
+ }|([@$_a-z][:.\w!?]+)([(`"' ] *|:['"]?)?#{
35
+ }| *( [:?]\s|=[>~]|[<!>]=|[+\-\|*%,])\s*#{
36
+ }|[{}()\[\]\n;,\|]| end\b/m
33
37
 
34
38
  StringRE = /(^['"`]$)|^#{percent}$/
35
39
  RERE = %r{(?:^|[#{leftop}\w!\s/])\s*(/)}
36
40
  HeredocRE = heredoc_handle.to_re
37
41
  Symbol = /^:#{name}$/
38
42
  Attrs = /\s(c)?(?:attr_(reader|writer|accessor))[( ] *((?::\w+ *,\s*)*:\w+)#{Ender}/
39
- Include = /\s(include|extend) +#{mname}/
43
+ Include = /\s(include|extend)[( ] *#{mname}/
40
44
  AliasMethod = /\salias_method :#{name} *,\s*:#{name}/
41
45
  Beginners = /(([#{leftop}\n]?\s*)(if|unless|while|until))#{
42
46
  }|(.)?(?:(do|for)|begin|case)/
@@ -48,14 +52,14 @@ module RMTools
48
52
  }|#{call_}|[{}]#{
49
53
  }|(^|\n)=begin\b#{
50
54
  }|^\s*[;\(]? *(#{mod_def}|#{method_def})#{
51
- }|:#{name}#{
55
+ }|:#{name
52
56
  }|[^\w#{rightop}'"`\/\\]\?\\?\S#{
53
57
  }|#{heredoc
54
58
  }|(^|[#{leftop}\n])\s*((if|unless)\b|#{
55
59
  }[;\(]? *#{class_def})#{
56
60
  }|(^|[\n;])\s*(while|until)\b#{
57
61
  }|(^|[#{leftop}\s?])(do|case|begin|for)\b#{
58
- }\s(c)?(?:attr_(reader|writer|accessor))[( ] *((?::\w+ *,\s*)*:\w+)#{Ender
62
+ }|\s(c)?(?:attr_(reader|writer|accessor))[( ] *((?::\w+ *,\s*)*:\w+)#{Ender
59
63
  }|\salias_method +:#{name} *,\s*:#{name
60
64
  }|\s(include|extend)[( ] *#{mname
61
65
  }|(^|[;\s])(#{alias_def}|end|__END__)\b/m
@@ -65,8 +69,14 @@ module RMTools
65
69
  MethodDef = method_def.to_re
66
70
  AliasDef = alias_def.to_re
67
71
 
68
- def self::Class(s, m)
69
- debug
72
+ def debug(s)
73
+ $log.debug(:caller=>1) {"#{s.string[0, s.pos].count("\n")+1}:#{s.head.size + s.matched_size - ((s.head+s.matched).reverse.index("\n") || 0)}"}
74
+ $log.debug(@stack, :caller=>1)
75
+ $log.debug(:caller=>1) {Painter.g(s.head+s.matched)}
76
+ end
77
+
78
+ def Class(s, m)
79
+ debug(s)
70
80
  _stack = clean_stack
71
81
  if _stack[-1] == [:block]
72
82
  stack << [:beginner]
@@ -88,40 +98,41 @@ module RMTools
88
98
  name = fix_module_name new, m[3] if m[3]
89
99
  new << '::' if new.b
90
100
  new << m[2]
91
- MethodCache[new] ||= {}
101
+ @MethodCache[new] ||= {}
92
102
  inherit! new, name if m[3]
93
103
  end
94
104
  end
95
105
 
96
- def self::Module(s, m)
97
- debug
106
+ def Module(s, m)
107
+ debug(s)
98
108
  stack << [:mod, m[1]]
99
- MethodCache[clean_stack.lasts*'::'] = {}
109
+ @MethodCache[clean_stack.lasts*'::'] = {}
100
110
  end
101
111
 
102
- def self::Method(s, m)
103
- debug
112
+ def Method(s, m)
113
+ debug(s)
104
114
  _stack = clean_stack(true)
105
115
  if _stack[-1] == [:block]
106
- stack << [:beginner]
107
- end
108
- start = s.pos - s.matched[/[^\n]+$/].size
109
- name = m[1].sub(/::([^:.]+)$/, '.\1')
110
- name.sub!(/#{_stack.last[1]}\./, 'self.') if _stack.any?
111
- if name[/^self\.(.+)/]
116
+ stack << [:beginner]
117
+ else
118
+ start = s.pos - s.matched[/[^\n]+$/].size
119
+ name = m[1].sub(/::([^:.]+)$/, '.\1')
120
+ name.sub!(/#{_stack.last[1]}\./, 'self.') if _stack.any?
121
+ if name[/^self\.(.+)/]
112
122
  stack << [:def, "#{_stack.lasts*'::'}.#$1", start]
113
- elsif name['.'] and name =~ /^[A-Z]/
123
+ elsif name['.'] and name =~ /^[A-Z]/
114
124
  mod, name = name/'.'
115
125
  fix_module_name(_stack.lasts*'::', mod) >> '.' >> name
116
126
  stack << [:def, name, start]
117
- else
127
+ else
118
128
  prefix = (_stack.any? && _stack[-1][0] == :singleton) ? _stack[-1][1]+'.' : _stack.lasts*'::'+'#'
119
129
  stack << [:def, prefix+name, start]
130
+ end
120
131
  end
121
132
  end
122
133
 
123
- def self::Alias(s, m)
124
- debug
134
+ def Alias(s, m)
135
+ debug(s)
125
136
  _stack = clean_stack
126
137
  case _stack.any? && _stack[-1][0]
127
138
  when false, :def, :block
@@ -133,7 +144,7 @@ module RMTools
133
144
  prefix = _stack.lasts*'::'
134
145
  new, old = '#'+m[1], '#'+m[2]
135
146
  end
136
- MethodCache[prefix][new] = MethodCache[prefix][old] || "def #{new}(*args)\n #{old}(*args)\nend"
147
+ @MethodCache[prefix][new] = @MethodCache[prefix][old] || "def #{new}(*args)\n #{old}(*args)\nend"
137
148
  end
138
149
 
139
150
  end if !defined? Defaults
@@ -143,43 +154,43 @@ module RMTools
143
154
  def init_instructions
144
155
  [
145
156
  [/^\#/, lambda {|s, m| s.scan_until(/\n/)}],
146
- [@Processor::StringRE, method(:string)],
157
+ [StringRE, method(:string)],
147
158
 
148
159
  [/^\{$/, lambda {|s, m|
149
- debug
160
+ debug(s)
150
161
  $log.debug @curls_count
151
162
  @curls_count += 1
152
163
  }],
153
164
 
154
165
  [/^\}$/, method(:curl_close)],
155
- [@Processor::Ord],
166
+ [Ord],
156
167
 
157
- [@Processor::BlockOpen, lambda {|s, m|
158
- debug
168
+ [BlockOpen, lambda {|s, m|
169
+ debug(s)
159
170
  $log.debug @curls_count
160
171
  @stack << [:block]
161
172
  }],
162
173
 
163
- [@Processor::ModDef, @Processor.method(:Module)],
164
- [@Processor::ClassDef, @Processor.method(:Class)],
165
- [@Processor::MethodDef, @Processor.method(:Method)],
166
- [@Processor::AliasDef, @Processor.method(:Alias)],
167
- [@Processor::Symbol],
168
- [@Processor::RERE, method(:string)],
169
- [@Processor::HeredocRE, method(:heredoc)],
174
+ [ModDef, method(:Module)],
175
+ [ClassDef, method(:Class)],
176
+ [MethodDef, method(:Method)],
177
+ [AliasDef, method(:Alias)],
178
+ [Symbol],
179
+ [RERE, method(:string)],
180
+ [HeredocRE, method(:heredoc)],
170
181
 
171
182
  [/(^|\n)=begin/, lambda {|s, m| s.scan_until(/\n=end\s*\n/m)}],
172
183
 
173
- [@Processor::Attrs, lambda {|s, m|
184
+ [Attrs, lambda {|s, m|
174
185
  attr_accessors s, m
175
186
  if s.matched =~ / end$/
176
187
  end!(s)
177
- elsif s.matched =~ /[^\?]}$/
188
+ elsif s.matched =~ /[^\?]\}$/
178
189
  curl_close
179
190
  end
180
191
  }],
181
192
 
182
- [@Processor::Include, lambda {|s, m|
193
+ [Include, lambda {|s, m|
183
194
  _stack = clean_stack
184
195
  if _stack.empty?
185
196
  if m[1] == 'include'
@@ -196,7 +207,7 @@ module RMTools
196
207
  end
197
208
  }],
198
209
 
199
- [@Processor::AliasMethod, lambda {|s, m|
210
+ [AliasMethod, lambda {|s, m|
200
211
  _stack = clean_stack
201
212
  if _stack[-1][0] == :class
202
213
  new, old = m[1..2]
@@ -205,12 +216,12 @@ module RMTools
205
216
  end
206
217
  }],
207
218
 
208
- [@Processor::Beginners, lambda {|s, m|
209
- debug
219
+ [Beginners, lambda {|s, m|
220
+ debug(s)
210
221
  $log.debug [m, s.last, s.string[s.last-1,1].to_s]
211
222
  if (m[2] and s.last != 0 and m[2].tr(' \t', '').empty? and !(s.string[s.last-1,1].to_s)[/[\n;({\[]/])
212
223
  else
213
- if m[3] == 'if' and @stack.empty? and s.check_until(@Processor::EOF) and s.matched != "\n"
224
+ if m[3] == 'if' and @stack.empty? and s.check_until(EOF) and s.matched != "\n"
214
225
  throw :EOF
215
226
  end
216
227
  @stack << [m[5] ? :block : :beginner]
@@ -221,20 +232,15 @@ module RMTools
221
232
  [/(^|[\s;])__END__/, lambda {|s, m| throw :EOF}]
222
233
  ].dup
223
234
  end
224
-
225
- def debug(s,m)
226
- $log.debug(:caller=>2) {"#{s.string[0, s.pos].count("\n")+1}:#{s.head.size + s.matched_size - ((s.head+s.matched).reverse.index("\n") || 0)}"}
227
- $log.debug(@stack, :caller=>2)
228
- $log.debug(:caller=>2) {Painter.g(s.head+s.matched)}
229
- end
230
235
 
231
236
  def initialize(instructions_module=Defaults)
232
237
  @MethodCache = {'Object' => {}}
233
238
  @ReadPaths = {}
234
- @Processor = instructions_module
239
+ #extend instructions_module
240
+ self.class.__send__(:include, instructions_module)
235
241
  @Instructions = init_instructions
236
- @MainParseRE = @Processor::MainParseRE
237
- add_method_seeker('get_opts') {|s, args| $log << args}
242
+ @MainParseRE = MainParseRE
243
+ add_method_seeker('.get_opts') {|s, args| $log << args}
238
244
  end
239
245
 
240
246
  def add_instruction(re, &callback)
@@ -243,8 +249,14 @@ module RMTools
243
249
  end
244
250
 
245
251
  def add_method_seeker(name, *args, &callback)
246
- pattern = /(?:^|[\s#{@Processor::Leftop}])(#{name})[( ] */
252
+ if name.ord == ?.
253
+ pattern = /\w\.(#{name[1..-1]})([(`"' ] *|:['"]?)/
254
+ else
255
+ pattern = /(?:^|[\s#{Leftop}])(#{name})([(`"' ] *|:['"]?)/
256
+ end
257
+ $log<<pattern
247
258
  add_instruction(pattern) {|s, m|
259
+ $log << m
248
260
  yield s, arguments(s, m)
249
261
  }
250
262
  end
@@ -252,44 +264,64 @@ module RMTools
252
264
  # Parser methods
253
265
 
254
266
  def arguments(s, m)
267
+ $panic=true
268
+ debug(s)
269
+ $panic=false
270
+ $log<<m
271
+ if m[2] =~ /['"`:]/
272
+ s.pos -= 1
273
+ s.matched_size -= 1
274
+ if m[2] =~ /:['"]/
275
+ s.pos -= 1
276
+ s.matched_size -= 1
277
+ end
278
+ end
255
279
  arg_list = [m[1]]
280
+ parens = m[2]=='('
256
281
  counts = {'}' => 0, ']' => 0, ')' => 0}
257
- catch(:EOL) {s.each(@Processor::ArgumentsParseRE, [
258
- [/^[{\[(]$/, lambda {|s, m| counts[Closers[m[0]]] += 1}],
282
+ eol = catch(:EOL) {s.each(ArgumentsParseRE, [
283
+ [/^[{\[(]$/, lambda {|s, m| $log<<m;arg_list << m[0];counts[Closers[m[0]]] += 1}],
259
284
  [/^[}\])]$/, lambda {|s, m|
285
+ $log<<m;
260
286
  if counts[m[0]] > 0
261
287
  counts[m[0]] -= 1
262
288
  else
263
- curl_close
264
- throw :EOL
289
+ curl_close if m[0]=='}'
290
+ throw :EOL, :arguments
265
291
  end
266
292
  }],
267
- [/^[,\|]$/, lambda {|s, m| s.scan_until(/\s*/m)}],
268
- [/[#\n;]| end\b/, lambda {|s, m|
293
+ [/[#\n;]| end\b/, lambda {|s, m| $log<<m;
269
294
  s.scan_until(/\n/) if m[0] == '#'
270
- heredoc_list.each {|opener| string(s, [nil]*4+opener)}
271
295
  throw :EOL
272
296
  }],
273
- [@Processor::StringRE, lambda {|s, m|
297
+ [StringRE, lambda {|s, m| $log<<m;
274
298
  str = [s.pos-1, string(s, m)]
275
299
  str[1] ? arg_list << s.string[str[0]...str[1]] : arg_list << s.string[str[0]-1..str[0]]
276
300
  }],
277
- [@Processor::RERE, lambda {|s, m|
301
+ [RERE, lambda {|s, m| $log<<m;
278
302
  str = [s.pos-1, string(s, m)]
279
303
  arg_list << s.string[str[0]...str[1]]
280
304
  }],
281
- [/^ +[:?]\s+$/],
282
- [/^ *=>\s*$/, lambda {|s, m| arg_list << '=>'}],
283
- [/^[:@$.\w!?]+([( ] *)?$/, lambda {|s, m|
284
- str = [s.pos-s.matched_size, arguments(s, m) && s.pos]
285
- arg_list << s.string[str[0]...str[1]] if str[1]
305
+ [/^ *(?:( [:?]\s|=[>~]|[<!>]=|[+\-\|*%])|,)\s*$/, lambda {|s, m| $log<<m;arg_list << m[1] if m[1]}],
306
+ [/^(\d[\d.]+|:[@$_a-z]\w*|[@$]\w+) *$/, lambda {|s, m| $log<<m;arg_list << m[1]}],
307
+ [/^([@$_a-z][:.\w!?]+)([(`"' ] *|:['"]?)?$/, lambda {|s, m| $log<<m;
308
+ str_beg = s.pos-s.matched_size
309
+ a, eol = arguments(s, m)
310
+ if a
311
+ $log << [a, s.string[str_beg...s.pos]]
312
+ arg_list << s.string[str_beg...s.pos]
313
+ end
314
+ if eol == :arguments
315
+ throw :EOL
316
+ end
286
317
  }]
287
318
  ])}
288
- arg_list
319
+ $log << [arg_list, eol]
320
+ [arg_list, eol]
289
321
  end
290
322
 
291
323
  def string(s, m)
292
- debug
324
+ debug(s)
293
325
  return if m[1] and s.- == '$'
294
326
  opener = m[1] || m[3] || m[5]
295
327
  $log.log {"entering #{opener}-quotes, matched as '#{Painter.g s.matched}' at #{s.string[0..s.pos].count("\n")+1}"}
@@ -305,7 +337,7 @@ module RMTools
305
337
  backslash = false
306
338
  quote_re |= /#\{/ if (m[5] and m[5].ord != ?') or closer =~ /[\/"`]/ or (m[2] =~ /[xrQW]/ or m[3])
307
339
  instructions = [
308
- [@Processor::Ord],
340
+ [Ord],
309
341
  [/\s*#{Regexp.escape closer}$/, lambda {|s, m|
310
342
  if backslash
311
343
  backslash = false
@@ -341,7 +373,7 @@ module RMTools
341
373
  end
342
374
  $log.log "entering curls"
343
375
  inner_curls_count += 1
344
- catch(:inner_out) {s.each(@Processor::StringParseRE, [
376
+ catch(:inner_out) {s.each(StringParseRE, [
345
377
  [/^\#$/, lambda {|s, m|
346
378
  $log.log 'reading comment'
347
379
  s.scan_until(/\n/)}],
@@ -355,9 +387,9 @@ module RMTools
355
387
  else
356
388
  $log.log "decreasing curls count"
357
389
  end}],
358
- [@Processor::HeredocRE, method(:heredoc)],
359
- [@Processor::StringRE, method(:string)],
360
- [@Processor::RERE, method(:string)]
390
+ [HeredocRE, method(:heredoc)],
391
+ [StringRE, method(:string)],
392
+ [RERE, method(:string)]
361
393
  ])}
362
394
  }]
363
395
  ]
@@ -378,17 +410,17 @@ module RMTools
378
410
  s.pos
379
411
  end
380
412
 
381
- def heredoc(s=nil, m)
413
+ def heredoc(s, m)
382
414
  heredoc_list = [m[1..2]]
383
- catch(:EOL) {s.each(@Processor::HeredocParseRE, [
415
+ catch(:EOL) {s.each(HeredocParseRE, [
384
416
  [/[#\n]/, lambda {|s, m|
385
417
  s.scan_until(/\n/) if m[0] == '#'
386
418
  heredoc_list.each {|opener| string(s, [nil]*4+opener)}
387
419
  throw :EOL
388
420
  }],
389
- [@Processor::HeredocRE, lambda {|s, m| heredoc_list << m[1..2]}],
390
- [@Processor::StringRE, method(:string)],
391
- [@Processor::RERE, method(:string)]
421
+ [HeredocRE, lambda {|s, m| heredoc_list << m[1..2]}],
422
+ [StringRE, method(:string)],
423
+ [RERE, method(:string)]
392
424
  ])}
393
425
  end
394
426
 
@@ -401,7 +433,7 @@ module RMTools
401
433
  end
402
434
 
403
435
  def end!(s, *)
404
- debug
436
+ debug(s)
405
437
  if s.+ !~ /[?!(]/
406
438
  exit = @stack.pop
407
439
  case exit[0]
@@ -411,7 +443,7 @@ module RMTools
411
443
  prefix, name = 'Object', prefix
412
444
  end
413
445
  if @MethodCache[prefix]
414
- (@MethodCache[prefix][name] ||= []) << (path.inline ? [path, exit[2]...s.pos] : s.string[exit[2]...s.pos])
446
+ (@MethodCache[prefix][name] ||= []) << (@path.inline ? [@path, exit[2]...s.pos] : s.string[exit[2]...s.pos])
415
447
  end
416
448
  end
417
449
  end
@@ -433,6 +465,7 @@ module RMTools
433
465
 
434
466
  def parse_file(path)
435
467
  @stack = []
468
+ @path = path
436
469
 
437
470
  if path.inline
438
471
  return if @ReadPaths[path]
@@ -449,7 +482,7 @@ module RMTools
449
482
 
450
483
  @curls_count = 0
451
484
  catch(:EOF) { ss.each @MainParseRE, @Instructions }
452
- raise "Can't parse: #{@stack.inspect}, #{ss.string[ss.last..ss.pos].inspect}" if @stack.any?
485
+ raise "Can't parse: #{@stack.inspect}, #{ss.string[ss.last..ss.pos].inspect}\nfile:#{path}" if @stack.any?
453
486
  ss
454
487
  end
455
488
 
@@ -507,36 +540,42 @@ module RMTools
507
540
  end
508
541
  if path.is String
509
542
  prefix, name = path.sharp_split(/[.#]/, 2)
510
- elsif Class === path
543
+ raise "If first parameter is a string then it must be of Module{#|.}method form" if !name
544
+ elsif Module === path
511
545
  prefix = path.name
512
546
  name = ".#{name}"
513
547
  else
514
548
  prefix = path.class.name
515
549
  name = "##{name}"
516
550
  end
517
- if !(@MethodCache[prefix]||{})[name]
518
- puts "looking up script lines, please wait..."
519
- SCRIPT_LINES__.each_key {|k| parse_file k
520
- break if (@MethodCache[prefix]||{})[name]
521
- }
522
- end
523
- if !(@MethodCache[prefix]||{})[name]
524
- print "nothing was found for #{prefix}#{name}"
525
- name = name.tr('#.', '.#')
526
- if (@MethodCache[prefix]||{})[name]
527
- puts ", but found for #{name}:"
551
+ if SCRIPT_LINES__.size == @ReadPaths.size and (SCRIPT_LINES__.keys - @ReadPaths.keys).empty?
552
+ puts "nothing was found for #{prefix}#{name}"
553
+ else
554
+ if !(@MethodCache[prefix]||{})[name]
555
+ puts "looking up script lines, please wait..."
556
+ SCRIPT_LINES__.each_key {|k| parse_file k
557
+ break if (@MethodCache[prefix]||{})[name]
558
+ }
559
+ end
560
+ if !(@MethodCache[prefix]||{})[name]
561
+ print "nothing was found for #{prefix}#{name}"
562
+ name = name.tr('#.', '.#')
563
+ if (@MethodCache[prefix]||{})[name]
564
+ puts ", but found for #{name}:"
565
+ print_lines prefix, name, all
566
+ else puts
567
+ end
568
+ else
569
+ puts "code for #{prefix}#{name}:"
528
570
  print_lines prefix, name, all
529
- else puts ''
530
571
  end
531
- else
532
- puts "code for #{prefix}#{name}:"
533
- print_lines prefix, name, all
534
572
  end
535
573
  end
536
574
 
537
575
  end
538
-
576
+ if !defined? Reader
539
577
  Reader = CodeReader.new
578
+ end
540
579
  end
541
580
 
542
581
  module Kernel
@@ -44,11 +44,12 @@ module RMTools
44
44
  end
45
45
 
46
46
  def defaults
47
- puts %{ :q => false, # not print
48
- :out => false, # output to file, may have strftime's %H%M%Y for filename
49
- :time => ["%H:%M:%S", "%03d"], # strftime, [msecs]
50
- :caller => "#{@c.gray('%f:%l')} #{@c.red_bold(':%m')}", # file:line :method
51
- :format => "%time %mode [%caller]: %text" # no comments}
47
+ puts %{ :q => false, # not print
48
+ :out => false, # output to file, may contain strftime's %H%M%Y etc for filename
49
+ :color_out => false # do not clean control characters that make output to file colorful (set to true makes more readable out of tail -n/-f but hardly readable file as text by gui)
50
+ :time => ["%H:%M:%S", "%03d"], # strftime, [msecs]
51
+ :caller => "#{@c.gray('%f:%l')} #{@c.red_bold(':%m')}", # file:line :method
52
+ :format => "%time %mode [%caller]: %text" # format of entire log string, %mode is {#{%w(debug log info warn).map {|i| @highlight[i.to_sym]}*', '}}}
52
53
  end
53
54
 
54
55
  # set any needed params, the rest will be set by default
@@ -96,7 +97,7 @@ module RMTools
96
97
  if caler
97
98
  str.sub! "%caller", caler.sub(String::CALLER_RE, cfg.cf)
98
99
  end
99
- log_str = @c.clean str if !cfg.color_out
100
+ log_str = cfg.color_out ? str : @c.clean(str)
100
101
  RMTools.write out, log_str if log_
101
102
  Kernel.print str if print_
102
103
  end
@@ -1,6 +1,5 @@
1
1
  # encoding: utf-8
2
2
  RMTools::require 'console/coloring'
3
-
4
3
  module RMTools
5
4
 
6
5
  def timer(ts=1, output=true)
@@ -20,7 +20,7 @@ if RUBY_VERSION < '1.9'
20
20
  # it will be possible to get the lines entered in IRB
21
21
  # else it reads only ordinal require'd files
22
22
  def set_backtrace src
23
- message.hl! self.class
23
+ #message.hl! self.class
24
24
  if format = self.class.__trace_format
25
25
  src = RMTools.__send__ format, src
26
26
  end
data/lib/rmtools_dev.rb CHANGED
@@ -3,4 +3,4 @@ $__MAIN__ = self
3
3
  require 'rmtools/init'
4
4
  RMTools::require 'dev'
5
5
 
6
- unless defined? Rails; class Object; include RMTools end end
6
+ unless defined? Rails; class Object; include RMTools end end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rmtools
3
3
  version: !ruby/object:Gem::Version
4
- hash: 35
4
+ hash: 32
5
5
  prerelease: 5
6
6
  segments:
7
7
  - 1
8
8
  - 2
9
9
  - 2
10
- - b
11
- version: 1.2.2b
10
+ - c
11
+ version: 1.2.2c
12
12
  platform: ruby
13
13
  authors:
14
14
  - Shinku
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2011-11-16 00:00:00 +03:00
19
+ date: 2011-11-17 00:00:00 +03:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
@@ -57,14 +57,13 @@ dependencies:
57
57
  requirement: &id003 !ruby/object:Gem::Requirement
58
58
  none: false
59
59
  requirements:
60
- - - ">="
60
+ - - ~>
61
61
  - !ruby/object:Gem::Version
62
- hash: 43
62
+ hash: 27
63
63
  segments:
64
64
  - 2
65
- - 9
66
- - 0
67
- version: 2.9.0
65
+ - 12
66
+ version: "2.12"
68
67
  type: :development
69
68
  version_requirements: *id003
70
69
  description: Applied framework primarily for debug and text/arrays/files operation.
@@ -98,8 +97,8 @@ files:
98
97
  - lib/rmtools/dev/logging.rb
99
98
  - lib/rmtools/dev/trace_format.rb
100
99
  - lib/rmtools/dev/highlight.rb
101
- - lib/rmtools/dev/code_reading.rb
102
100
  - lib/rmtools/dev/timer.rb
101
+ - lib/rmtools/dev/code_reader.rb
103
102
  - lib/rmtools/xml/xpath.rb
104
103
  - lib/rmtools/xml/string.rb
105
104
  - lib/rmtools/xml/libxml.rb