rmtools 1.2.8.1 → 1.2.10b

Sign up to get free protection for your applications and to get access to all the features.
data/README.txt CHANGED
@@ -8,6 +8,11 @@ Methods for basic classes addon collection.
8
8
 
9
9
  == CHANGES
10
10
 
11
+ == Version 1.2.10
12
+
13
+ * Update String#parse:caller to parse ruby 1.9 "block level". Now block level processes in RMLogger and RMTools.format_trace
14
+ * lib/dev/traceback.rb now applies to ruby > 1.9 as well
15
+
11
16
  == Version 1.2.8
12
17
 
13
18
  * StringScanner#each changed to compare `cbs' keys with @matched by number in ruby 1.8 and by first character in ruby 1.9, since ?x in 1.9 returns string instead of a charcode
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.8.1'
5
+ RMTOOLS_VERSION = '1.2.10b'
6
6
  begin
7
7
  require 'hoe'
8
8
  config = Hoe.spec 'rmtools' do
@@ -89,7 +89,7 @@ module RMTools
89
89
  String.class_eval %{
90
90
  def #{m.sub'sub','hl'} pattern, color=:red_bold
91
91
  Painter.#{m.sub'sub','hl'} self, pattern, color
92
- self
92
+ #{'self' if '!'.in m}
93
93
  end
94
94
  }
95
95
  }
@@ -47,4 +47,4 @@ class Class
47
47
  end
48
48
 
49
49
  require 'set'
50
- [Hash, Array, Set, Regexp, File, Dir, Range, Class, Module].each {|klass| klass.__init__}
50
+ [Hash, Set, Regexp, File, Dir, Range, Class, Module].each {|klass| klass.__init__}
@@ -107,7 +107,8 @@ module RMTools
107
107
  out = now.strftime cfg.out if cfg.path_format
108
108
  end
109
109
  if caler
110
- str.gsub! "%caller", caler.sub(String::CALLER_RE, cfg.cf)
110
+ caler.sub!(/block (?:\((\d+) levels\) )?in/) {"{#{$1||1}}"}
111
+ str.gsub! "%caller", caler.sub(String::SIMPLE_CALLER_RE, cfg.cf)
111
112
  end
112
113
  str.gsub! "%text", text
113
114
  str << "\n" if opts&INLINE==0
@@ -23,20 +23,26 @@ module RMTools
23
23
  IgnoreFiles = %r{#{Regexp.escape $:.grep(%r{/ruby/1\.(8|9\.\d)$})[0]}/irb(/|\.rb$)|/active_support/dependencies.rb$}
24
24
 
25
25
  def format_trace(a)
26
- bt, calls, i = [], [], 0
26
+ bt, steps, i = [], [], 0
27
27
  m = a[0].parse:caller
28
- m.line -= 1 if m.file =~ /\.haml$/
28
+ m.line -= 1 if m and m.file =~ /\.haml$/
29
29
  while i < a.size
30
30
  m2 = a[i+1] && a[i+1].parse(:caller)
31
31
  m2.line -= 1 if m2 and m2.file =~ /\.haml$/
32
32
  if !m or m.path =~ IgnoreFiles
33
- nil
34
- elsif m and m.func and m2 and [m.path, m.line] == [m2.path, m2.line]
35
- calls << " -> `#{m.func}'"
36
- elsif m and m.line != 0 and line = RMTools.highlighted_line(m.path, m.line)
37
- bt << "#{a[i]}#{calls.join}\n#{line}"
38
- calls = []
39
- else bt << a[i]
33
+ nil
34
+ else
35
+ step = a[i]
36
+ if m.block_level # > 1.9
37
+ step = step.sub(/block (\(\d+ levels\) )?in/, '{'+m.block_level+'}')
38
+ end
39
+ if m and m.func and m2 and [m.path, m.line] == [m2.path, m2.line]
40
+ steps << " -> `#{'{'+m.block_level+'} ' if m.block_level}#{m.func}'"
41
+ elsif m and m.line != 0 and line = RMTools.highlighted_line(m.path, m.line)
42
+ bt << "#{step}#{steps.join}\n#{line}"
43
+ steps = []
44
+ else bt << step
45
+ end
40
46
  end
41
47
  i += 1
42
48
  m = m2
@@ -3,7 +3,7 @@ RMTools::require 'dev/trace_format'
3
3
  require 'active_support/core_ext/class/attribute'
4
4
 
5
5
  # as for rmtools-1.1.0, 1.9 may hung up processing IO while generating traceback
6
- if RUBY_VERSION < '1.9'
6
+ #if RUBY_VERSION < '1.9'
7
7
  class Exception
8
8
  alias :set_bt :set_backtrace
9
9
  class_attribute :__trace_format
@@ -35,4 +35,4 @@ if RUBY_VERSION < '1.9'
35
35
  class SystemStackError
36
36
  trace_format false
37
37
  end
38
- end
38
+ #end
@@ -3,8 +3,6 @@ require 'iconv'
3
3
  # Although ruby >= 1.9.3 would complain about not using String#encode, iconv is 2-4 times faster and still handles the ruby string encoding
4
4
 
5
5
  module RMTools
6
- ANSI2UTF = Iconv.new("UTF-8", "WINDOWS-1251").method :iconv
7
- UTF2ANSI = Iconv.new("WINDOWS-1251", "UTF-8").method :iconv
8
6
 
9
7
  module Cyrillic
10
8
  RU_LETTERS = "абвгдеёжзийклмнопрстуфхцчшщьыъэюя", "АБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЬЫЪЭЮЯ"
@@ -17,17 +15,19 @@ module RMTools
17
15
  end
18
16
  end
19
17
 
18
+ ANSI2UTF = Cyrillic::ANSI2UTF = Iconv.new("UTF-8", "WINDOWS-1251").method(:iconv)
19
+ UTF2ANSI = Cyrillic::UTF2ANSI = Iconv.new("WINDOWS-1251", "UTF-8").method(:iconv)
20
+ ICONVS = {}
20
21
  end
21
22
 
22
23
  class String
23
24
 
24
- # Actually, for short strings and 1251<->65001 it's much faster to use predefined ANSI2UTF and UTF2ANSI procs
25
25
  def utf(from_encoding='WINDOWS-1251')
26
- Iconv.new('UTF-8', from_encoding).iconv(self)
26
+ (ICONVS['UTF-8<'+from_encoding] ||= Iconv.new('UTF-8', from_encoding)).iconv(self)
27
27
  end
28
28
 
29
29
  def ansi(from_encoding='UTF-8')
30
- Iconv.new('WINDOWS-1251', from_encoding).iconv(self)
30
+ (ICONVS['WINDOWS-1251<'+from_encoding] ||= Iconv.new('WINDOWS-1251', from_encoding)).iconv(self)
31
31
  end
32
32
 
33
33
  def utf!(from_encoding='WINDOWS-1251')
@@ -3,26 +3,26 @@ RMTools::require 'lang/ansi'
3
3
 
4
4
  class String
5
5
  include RMTools::Cyrillic
6
+
7
+ def swap
8
+ sub(/([a-zA-Z])|([А-пр-ёЁ])/) {|m| return $~[1]? en2ru: ru2en}
9
+ self
10
+ end
11
+
12
+ def caps?
13
+ self =~ /^[А-ЯЁ][А-ЯЁ\d ]+$/
14
+ end
15
+
16
+ def cyr?
17
+ self !~ /[^А-пр-ёЁ]/
18
+ end
19
+
20
+ if RUBY_VERSION > "1.9"
6
21
 
7
22
  def translit
8
- gsub(/[ёЁ]/, 'yo').gsub(/[йЙ]/, 'y').gsub(/[цЦ]/, 'c').gsub(/[уУ]/, 'u').gsub(/[кК]/, 'k').gsub(/[еЕ]/, 'e').gsub(/[нН]/, 'n').gsub(/[гГ]/, 'g').gsub(/[шШ]/, 'sh').gsub(/[щЩ]/, 'sch').gsub(/[зЗ]/, 'z').gsub(/[хХ]/, 'h').gsub(/[ьЬъЪ]/, "'").gsub(/[фФ]/, 'f').gsub(/[иИыЫ]/, 'i').gsub(/[вВ]/, 'v').gsub(/[аА]/, 'a').gsub(/[пП]/, 'p').gsub(/[рР]/, 'r').gsub(/[оО]/, 'o').gsub(/[лЛ]/, 'l').gsub(/[дД]/, 'd').gsub(/[жЖ]/, 'j').gsub(/[эЭ]/, 'e').gsub(/[яЯ]/, 'ya').gsub(/[чЧ]/, 'ch').gsub(/[сС]/, 's').gsub(/[мМ]/, 'm').gsub(/[тТ]/, 't').gsub(/[бБ]/, 'b').gsub(/[юЮ]/, 'yu')
9
- end
10
-
11
- def swap
12
- sub(/([a-zA-Z])|([А-пр-ёЁ])/) {|m| return $~[1]? en2ru: ru2en}
13
- self
23
+ gsub(/ё/i, 'yo').gsub(/й/i, 'y').gsub(/ц/i, 'c').gsub(/у/i, 'u').gsub(/к/i, 'k').gsub(/е/i, 'e').gsub(/н/i, 'n').gsub(/г/i, 'g').gsub(/ш/i, 'sh').gsub(/щ/i, 'sch').gsub(/з/i, 'z').gsub(/х/i, 'h').gsub(/[ьъ]/i, "'").gsub(/ф/i, 'f').gsub(/[иы]/i, 'i').gsub(/в/i, 'v').gsub(/а/i, 'a').gsub(/п/i, 'p').gsub(/р/i, 'r').gsub(/о/i, 'o').gsub(/л/i, 'l').gsub(/д/i, 'd').gsub(/ж/i, 'j').gsub(/э/i, 'e').gsub(/я/i, 'ya').gsub(/ч/i, 'ch').gsub(/с/i, 's').gsub(/м/i, 'm').gsub(/т/i, 't').gsub(/б/i, 'b').gsub(/ю/i, 'yu')
14
24
  end
15
25
 
16
- def caps?
17
- self =~ /^[А-ЯЁ][А-ЯЁ\d ]+$/
18
- end
19
-
20
- def cyr?
21
- self !~ /[^А-пр-ёЁ]/
22
- end
23
-
24
- if RUBY_VERSION > "1.9"
25
-
26
26
  def ru2en
27
27
  tr "ёйцукенгшщзхъфывапролдэячсмить/.ю?,б\"№;:жЁЙЦУКЕНГШЩЗХЪФЫВАПРОЛДЖЭЯЧСМИВТЬБЮ", "`qwertyuiop[]asdfghjkl'zxcvbnm|/.&?,@\#$^;~QWERTYUIOP{}ASDFGHJKL:\"ZXCVBDNM<>"
28
28
  end
@@ -61,7 +61,12 @@ class String
61
61
  alias csqueeze squeeze
62
62
 
63
63
  def ci; self end
64
+
64
65
  else
66
+
67
+ def translit
68
+ gsub(/[ёЁ]/, 'yo').gsub(/[йЙ]/, 'y').gsub(/[цЦ]/, 'c').gsub(/[уУ]/, 'u').gsub(/[кК]/, 'k').gsub(/[еЕ]/, 'e').gsub(/[нН]/, 'n').gsub(/[гГ]/, 'g').gsub(/[шШ]/, 'sh').gsub(/[щЩ]/, 'sch').gsub(/[зЗ]/, 'z').gsub(/[хХ]/, 'h').gsub(/[ьЬъЪ]/, "'").gsub(/[фФ]/, 'f').gsub(/[иИыЫ]/, 'i').gsub(/[вВ]/, 'v').gsub(/[аА]/, 'a').gsub(/[пП]/, 'p').gsub(/[рР]/, 'r').gsub(/[оО]/, 'o').gsub(/[лЛ]/, 'l').gsub(/[дД]/, 'd').gsub(/[жЖ]/, 'j').gsub(/[эЭ]/, 'e').gsub(/[яЯ]/, 'ya').gsub(/[чЧ]/, 'ch').gsub(/[сС]/, 's').gsub(/[мМ]/, 'm').gsub(/[тТ]/, 't').gsub(/[бБ]/, 'b').gsub(/[юЮ]/, 'yu')
69
+ end
65
70
 
66
71
  def csize
67
72
  UTF2ANSI[self].size
@@ -37,7 +37,7 @@ class Regexp
37
37
  next
38
38
  elsif ext and m == '#'
39
39
  s.scan_until(/\n\s*/)
40
- else case m.ord
40
+ else case m[0]
41
41
  when ?[; klass = ''
42
42
  when ?]; new << "[#{klass}]"; klass = nil
43
43
  when ?{; klass ? klass << m : count = ''
@@ -4,7 +4,11 @@ RMTools::require 'conversions/string'
4
4
  class String
5
5
  CALLER_RE = %r{^(.*?([^/\\]+?))#{ # ( path ( file ) )
6
6
  }:(\d+)(?::in #{ # :( line )[ :in
7
- }[`<](.+?)[>']#{ # `( closure )' ]
7
+ }`(block (?:\((\d+) levels\) )?in )?(.+?)'#{ # `[ block in ] ( closure )' ]
8
+ })?$}
9
+ SIMPLE_CALLER_RE = %r{^(.*?([^/\\]+?))#{ # ( path ( file ) )
10
+ }:(\d+)(?::in #{ # :( line )[ :in
11
+ }`(.+?)'#{ # `( closure )' ]
8
12
  })?$}
9
13
  URL_RE = %r{^((?:([^:]+)://)#{ # ( protocol
10
14
  }([^/:]*(?::(\d+))?))?#{ # root[:port] )
@@ -38,10 +42,11 @@ class String
38
42
  { 'path' => m[1],
39
43
  'file' => m[2],
40
44
  'line' => m[3].to_i,
41
- 'func' => m[4],
42
- 'fullpath' =>
43
- m[1]['('] ? m[1] :
44
- File.expand_path(m[1]) }
45
+ 'block_level' => m[4] && (m[5] || 1).to_i, # > 1.9
46
+ 'func' => m[6],
47
+ 'fullpath' => m[1] =~ /[\(\[]/ ?
48
+ m[1] :
49
+ File.expand_path(m[1]) }
45
50
  when :ip; self[IP_RE]
46
51
  when :ip_range; (m = match IP_RANGE_RE) && m[1]..m[2]
47
52
  else raise ArgumentError, "Incorrect flag. Correct flags: :uri, :caller, :ip, :ip_range"
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: 109
5
- prerelease:
4
+ hash: 3
5
+ prerelease: 6
6
6
  segments:
7
7
  - 1
8
8
  - 2
9
- - 8
10
- - 1
11
- version: 1.2.8.1
9
+ - 10
10
+ - b
11
+ version: 1.2.10b
12
12
  platform: ruby
13
13
  authors:
14
14
  - Sergey Baev
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2012-07-27 00:00:00 Z
19
+ date: 2012-08-01 00:00:00 Z
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
22
  name: rake
@@ -195,12 +195,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
195
195
  required_rubygems_version: !ruby/object:Gem::Requirement
196
196
  none: false
197
197
  requirements:
198
- - - ">="
198
+ - - ">"
199
199
  - !ruby/object:Gem::Version
200
- hash: 3
200
+ hash: 25
201
201
  segments:
202
- - 0
203
- version: "0"
202
+ - 1
203
+ - 3
204
+ - 1
205
+ version: 1.3.1
204
206
  requirements: []
205
207
 
206
208
  rubyforge_project: rmtools