rmtools 1.1.2 → 1.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Manifest.txt CHANGED
@@ -25,6 +25,7 @@ lib/rmtools/core/boolean.rb
25
25
  lib/rmtools/core/aliases.rb
26
26
  lib/rmtools/core/module.rb
27
27
  lib/rmtools/core/object.rb
28
+ lib/rmtools/core/deprecation.rb
28
29
  lib/rmtools/core/regexp.rb
29
30
  lib/rmtools/core/class.rb
30
31
  lib/rmtools/core/proc.rb
@@ -50,6 +51,7 @@ lib/rmtools/console/highlight.rb
50
51
  lib/rmtools/core.rb
51
52
  lib/rmtools/db.rb
52
53
  lib/rmtools/debug/present.rb
54
+ lib/rmtools/debug/observing.rb
53
55
  lib/rmtools/debug/traceback.rb
54
56
  lib/rmtools/debug/binding.rb
55
57
  lib/rmtools/debug/logging.rb
@@ -59,7 +61,9 @@ lib/rmtools/fs.rb
59
61
  lib/rmtools/ip.rb
60
62
  lib/rmtools/lang.rb
61
63
  lib/rmtools/functional.rb
64
+ lib/rmtools/load.rb
62
65
  lib/rmtools/experimental.rb
66
+ lib/rmtools/install.rb
63
67
  lib/rmtools/functional/string_to_proc.rb
64
68
  lib/rmtools/functional/fold.rb
65
69
  lib/rmtools/functional/unfold.rb
@@ -79,16 +83,16 @@ lib/rmtools/experimental/numeric.rb
79
83
  lib/rmtools/experimental/string.rb
80
84
  lib/rmtools/experimental/blackhole.rb
81
85
  lib/rmtools/experimental/tree.rb
82
- lib/rmtools/experimental/deprecation.rb
83
86
  lib/rmtools/experimental/dumps.rb
84
87
  lib/rmtools/experimental/rails_backtrace.rb
85
88
  lib/rmtools/xml.rb
86
89
  lib/rmtools/conversions.rb
87
- lib/rmtools/setup.rb
88
90
  lib/rmtools/conversions/string.rb
89
91
  lib/rmtools/conversions/enum.rb
90
92
  lib/rmtools/conversions/int.rb
91
93
  lib/rmtools/enumerable.rb
94
+ lib/rmtools_notrace.rb
95
+ lib/rmtools_nodebug.rb
92
96
  ./Rakefile
93
97
  ./Manifest.txt
94
98
  ./License.txt
data/Rakefile CHANGED
@@ -1,8 +1,8 @@
1
1
  require 'rake'
2
- require './lib/rmtools/setup'
2
+ require 'lib/rmtools/install'
3
3
  compile_manifest
4
4
 
5
- RMTools_VERSION = '1.1.2'
5
+ RMTOOLS_VERSION = '1.1.4'
6
6
  begin
7
7
  require 'hoe'
8
8
  config = Hoe.spec 'rmtools' do |h|
@@ -24,8 +24,6 @@ rescue Exception => e
24
24
  STDERR.puts "error message is: #{e.message}"
25
25
  end
26
26
 
27
- puts "Installing RMTools..."
28
-
29
27
  ruby = RbConfig::CONFIG['RUBY_INSTALL_NAME']
30
28
  windoze = PLATFORM =~ /mswin32/
31
29
  make = windoze ? 'nmake' : 'make'
@@ -38,6 +36,4 @@ Dir.chdir "ext" do
38
36
  if File.file? 'Makefile'
39
37
  system "#{make} clean" and FileUtils.rm_f "Makefile"
40
38
  end
41
- end unless ext_files_not_modified 'rmtools', RMTools_VERSION
42
-
43
- puts "RMTools installed!"
39
+ end unless ext_files_not_modified 'rmtools', RMTOOLS_VERSION
@@ -40,4 +40,4 @@ class Class
40
40
 
41
41
  end
42
42
 
43
- [Array, Hash, Regexp, File, Dir].each {|klass| klass.__init__}
43
+ [Hash, Regexp, File, Dir].each {|klass| klass.__init__}
@@ -1,9 +1,7 @@
1
- require_with_path 'console/coloring'
2
-
3
1
  class Object
4
2
  # class Klass
5
3
  # def old_method *argv
6
- # deprecation :new_method, *argv
4
+ # deprecate_method :new_method, *argv
7
5
  # end
8
6
  # end
9
7
  # Klass.new.old_method
@@ -13,15 +11,15 @@ class Object
13
11
  #
14
12
  # Same shit:
15
13
  # class Klass
16
- # deprecate :old_method, :new_method
14
+ # deprecate_method :old_method, :new_method
17
15
  # end
18
- def deprecation message="", *argv
16
+ def deprecate_method message="", *argv
19
17
  caler = caller[0].parse(:caller)
20
18
  sym = nil
21
19
  if message.is Symbol
22
20
  sym, message = message, "Use ##{message} instead."
23
21
  end
24
- STDERR.puts "#{RMTools::Painter.red 'DEPRECATION'} from #{RMTools::Painter.gray caler.path}: #{self.class}##{caler.func} is deprecated. #{message.capitalize}" if caler
22
+ STDERR.puts "DEPRECATION from #{caler.path}: #{self.class}##{caler.func} is deprecated. #{message.capitalize}" if caler
25
23
  __send__ sym, *argv if sym
26
24
  end
27
25
 
@@ -29,8 +27,8 @@ end
29
27
 
30
28
  class Class
31
29
 
32
- def deprecate old_method, new_method
33
- define_method(new_method) {|*argv| deprecation old_method, *argv}
30
+ def deprecate_method old_method, new_method
31
+ define_method(new_method) {|*argv| deprecate_method old_method, *argv}
34
32
  end
35
33
 
36
34
  end
@@ -1,6 +1,16 @@
1
- # encoding: utf-8
2
- class Module # :nodoc:
3
-
1
+ require 'active_support/core_ext/module/remove_method'
2
+
3
+ class Module
4
+
5
+ # rewrite of active suport method to not initialize significant part of NameErrors
6
+ def remove_possible_method(method)
7
+ if method_defined? method
8
+ begin remove_method method
9
+ rescue NameError
10
+ end
11
+ end
12
+ end
13
+
4
14
  def children
5
15
  constants.map! {|c| module_eval c}.find_all {|c| c.kinda Module rescue()}
6
16
  end
@@ -11,7 +21,7 @@ class Module # :nodoc:
11
21
  end
12
22
 
13
23
  def self_name
14
- @self_name ||= name.rsplit('::', 2)[1] || name
24
+ @self_name ||= name.match[/[^:]+$/]
15
25
  end
16
26
 
17
27
  def my_methods filter=//
data/lib/rmtools/db.rb CHANGED
@@ -2,6 +2,6 @@ begin
2
2
  require 'active_record'
3
3
  ActiveRecord::Base
4
4
  require_with_path __FILE__, 'active_record'
5
- rescue
5
+ rescue Exception
6
6
  nil
7
7
  end
@@ -1,3 +1,6 @@
1
+ require_with_path 'debug/logging'
2
+ require_with_path 'debug/present'
3
+
1
4
  class Binding
2
5
 
3
6
  def inspect_local_variables
@@ -41,6 +44,9 @@ class Binding
41
44
  Kernel.puts RMTools.format_trace(caller(2)).join("\n")
42
45
  $__env__.present
43
46
  $__binding__ = self
47
+ if defined? SCRIPT_LINES__
48
+ SCRIPT_LINES__['(irb#1)'] = []
49
+ end
44
50
 
45
51
  $log << "entering irb"
46
52
  $__MAIN__.irb$__binding__
@@ -52,25 +58,4 @@ class Binding
52
58
  $__env__ = nil
53
59
  end
54
60
 
55
- end
56
- =begin
57
- $ignore_gems = %w{rmtools i18n active}
58
- $ignore_names = %w{irbrc.rb}
59
- $ignore_path = %r{(/usr/lib/ruby/(1.8/|gems/1.8/gems/#{"(#{$ignore_gems*'|'})" if !$ignore_all_gems})#{"|(#{$ignore_names*'|'})" if $ignore_names.b})}
60
- $binding_stack = []
61
- set_trace_func proc {|event, file, line, id, binding_here, classname|
62
- if file !~ $ignore_path
63
- if event == 'call'
64
- $binding_stack << binding_here
65
- elsif !$keep_binding_stack and event == 'return'
66
- $binding_stack.pop
67
- elsif event == 'raise'
68
- puts Painter.c_b "STOP!!!"
69
- $keep_binding_stack = true
70
- end
71
- puts "#{event} by #{caller[2]} -> #{classname}##{id} <#{file}>; stack size = #{$binding_stack.size}" if event.in %w{raise call return} if $panic
72
- end
73
- }
74
-
75
- begin; abc; rescue => e; $keep_binding_stack = false; $binding_stack.inspect_envs.present; $binding_stack.last.start_interaction; p e; $binding_stack = [] end
76
- =end
61
+ end
@@ -3,11 +3,11 @@ require_with_path 'console/coloring'
3
3
  module RMTools
4
4
 
5
5
  def highlighted_line(file, line)
6
- if defined? SCRIPT_LINES__
7
- " >> #{Painter.green SCRIPT_LINES__[file][line.to_i - 1].chop}" if SCRIPT_LINES__[file]
6
+ if defined? SCRIPT_LINES__ and SCRIPT_LINES__[file]
7
+ " >> #{Painter.green SCRIPT_LINES__[file][line.to_i - 1].chop}"
8
8
  else
9
9
  file = Readline::TEMPLOG if file == '(irb)' and defined? Readline::TEMPLOG
10
- " >> #{Painter.green read_lines(file, line.to_i).chop}" if File.file? file
10
+ " #{Painter.cyan '>>'} #{Painter.green read_lines(file, line.to_i).chop}" if File.file? file
11
11
  end
12
12
  end
13
13
 
@@ -173,5 +173,7 @@ module RMTools
173
173
  def inspect() get_format end
174
174
 
175
175
  end
176
-
176
+
177
+ # default logger now initialized here
178
+ $log = RMLogger.new
177
179
  end
@@ -0,0 +1,75 @@
1
+ require_with_path 'debug/binding'
2
+ require 'active_support/core_ext/class'
3
+
4
+ module RMTools
5
+ class Observer
6
+ cattr_reader :ignore_path, :ignore_gems, :ignore_names, :ignore_all_gems
7
+ cattr_accessor :keep_binding_stack
8
+
9
+ @@ignore_names = %w{irbrc.rb}
10
+ @@ignore_all_gems = true
11
+
12
+ @@binding_stack = []
13
+ DefaultRescue = lambda {|e|
14
+ @@binding_stack.inspect_envs.present
15
+ @@binding_stack.last.start_interaction
16
+ raise e
17
+ }
18
+
19
+ def self.ignore_names=ary
20
+ @@ignore_names =ary
21
+ update_ignore
22
+ end
23
+ def self.ignore_gems=ary
24
+ @@ignore_gems =ary
25
+ update_ignore
26
+ end
27
+ def self.ignore_all_gems=boolean
28
+ @@ignore_all_gems = boolean
29
+ update_ignore
30
+ end
31
+
32
+ def self.update_ignore
33
+ @@ignore_path = %r{(/usr/lib/ruby/(1.8/|gems/1.8/gems/#{
34
+ "(#{@@ignore_gems*'|'})" if !@@ignore_all_gems and @@ignore_gems
35
+ })#{
36
+ "|(#{@@ignore_names*'|'})" if @@ignore_names.b
37
+ })}
38
+ end
39
+
40
+ def self.start
41
+ @@binding_stack.clear
42
+ @@keep_binding_stack = false
43
+ set_trace_func proc {|event, file, line, id, binding_here, classname|
44
+ if file !~ @@ignore_path
45
+ if event == 'call'
46
+ @@binding_stack << binding_here
47
+ elsif !@@keep_binding_stack and event == 'return'
48
+ @@binding_stack.pop
49
+ elsif event == 'raise'
50
+ @@binding_stack << binding_here
51
+ @@keep_binding_stack = true
52
+ end
53
+ $log.debug {"#{event} by #{caller[2]} -> #{classname}##{id} <#{file}>; stack size = #{@@binding_stack.size}" if event.in %w{raise call return}}
54
+ end
55
+ }
56
+ end
57
+
58
+ def self.catch(rescue_proc=DefaultRescue)
59
+ begin yield
60
+ rescue => e
61
+ @@keep_binding_stack = false
62
+ begin
63
+ rescue_proc[e]
64
+ ensure
65
+ @@binding_stack.clear
66
+ end
67
+ end
68
+ end
69
+
70
+ def self.stop
71
+ set_trace_func nil
72
+ end
73
+
74
+ end
75
+ end
@@ -1,7 +1,7 @@
1
1
  require_with_path 'debug/highlight'
2
2
  require_with_path 'debug/logging'
3
3
 
4
- module Kernel
4
+ module RMTools
5
5
 
6
6
  # Python-like traceback for exceptions; uses ANSI coloring.
7
7
  # In case of any low-level ruby error it may hang up interpreter
@@ -18,20 +18,19 @@ module Kernel
18
18
  # >> 10/0 end
19
19
  # from (irb):3
20
20
  # >> divbyzero
21
- def format_trace a
21
+ def format_trace(a)
22
22
  bt, calls, i = [], [], 0
23
23
  # $log.info 'a.size', binding
24
24
  m = a[0].parse:caller
25
25
  while i < a.size
26
- # $log.info i
26
+ # $log.info 'i a[i]', binding
27
27
  m2 = a[i+1] && a[i+1].parse(:caller)
28
- # $log.info 'm', binding
29
- # $log.info 'm2', binding
28
+ # $log.info 'm m2', binding
30
29
  # $log.info 'm.func [m.path,m.line]==[m2.path,m2.line]', binding if m and m2
31
- # $log.info 'm.path m.line', binding if m
30
+ # $log.info 'm.path m.line a[i]', binding if m
32
31
  # $log.info RMTools.highlighted_line(m.path, m.line) if m
33
32
  if m and m.func and m2 and [m.path, m.line] == [m2.path, m2.line]
34
- calls << "`#{m.func}' -> "
33
+ calls << " -> `#{m.func}'"
35
34
  elsif m and m.line != 0 and line = RMTools.highlighted_line(m.path, m.line)
36
35
  bt << "#{a[i]}#{calls.join}\n#{line}"
37
36
  calls = []
@@ -44,22 +43,15 @@ module Kernel
44
43
  bt
45
44
  end
46
45
 
46
+ module_function :format_trace
47
47
  end
48
48
 
49
49
  class Class
50
-
50
+
51
+ private
51
52
  def trace_format method
52
53
  if Exception.in ancestors
53
- class_eval(method ? %{
54
- def set_backtrace src
55
- src = #{method} src
56
- set_bt src
57
- end
58
- } : %{
59
- def set_backtrace src
60
- set_bt src
61
- end
62
- }, __FILE__, __LINE__-10)
54
+ self.__trace_format = method
63
55
  else
64
56
  raise NoMethodError, "undefined method `trace_format' for class #{self}"
65
57
  end
@@ -71,6 +63,7 @@ end
71
63
  if RUBY_VERSION < '1.9'
72
64
  class Exception
73
65
  alias :set_bt :set_backtrace
66
+ class_attribute :__trace_format
74
67
 
75
68
  # to use trace formatting ensure that you have SCRIPT_LINES__ constant set
76
69
  # SCRIPT_LINES__ = {} unless defined? SCRIPT_LINES__
@@ -86,9 +79,19 @@ if RUBY_VERSION < '1.9'
86
79
  # end
87
80
  # it will be possible to get the lines entered in IRB
88
81
  # else it reads only ordinal require'd files
89
-
82
+ def set_backtrace src
83
+ if format = self.class.__trace_format
84
+ src = RMTools.__send__ format, src
85
+ end
86
+ set_bt src
87
+ end
88
+ end
89
+
90
+ class StandardError
90
91
  trace_format :format_trace
91
92
  end
92
93
 
93
- SystemStackError.trace_format false
94
+ class SystemStackError
95
+ trace_format false
96
+ end
94
97
  end
@@ -0,0 +1,19 @@
1
+ require 'active_support'
2
+
3
+ module RMTools
4
+ dir = File.dirname __FILE__
5
+ VERSION = IO.read(File.join dir, '..', '..', 'Rakefile').match(/RMTOOLS_VERSION = '(.+?)'/)[1]
6
+
7
+ require File.expand_path('require', dir)
8
+ [ 'core', 'enumerable', 'text', 'b', 'time', 'functional',
9
+ 'conversions', 'ip', 'lang', 'rand',
10
+ 'fs', 'db', 'xml',
11
+ '../rmtools.so'
12
+ ].each {|file| require_with_path file}
13
+ end
14
+
15
+ # Comment out in case of any method conflicts
16
+ # Library methods use module functions explicitly
17
+ class Object; include RMTools end
18
+
19
+ # default logger now initialized in debug/logging
data/lib/rmtools/xml.rb CHANGED
@@ -2,6 +2,6 @@ begin
2
2
  require 'xml'
3
3
  LibXML::XML
4
4
  require_with_path __FILE__, 'libxml'
5
- rescue
5
+ rescue Exception
6
6
  nil
7
7
  end
data/lib/rmtools.rb CHANGED
@@ -1,19 +1,4 @@
1
- require 'active_support'
2
-
3
- module RMTools
4
- VERSION = '1.1.2'
5
-
6
- require File.expand_path('require', __FILE__[0..-4])
7
- [ 'core', 'enumerable', 'text', 'b', 'time', 'functional',
8
- 'conversions', 'ip', 'lang', 'rand',
9
- 'console', 'fs', 'debug',
10
- 'db', 'xml',
11
- '../rmtools.so'
12
- ].each {|file| require_with_path file}
13
- end
14
-
15
- $log = RMTools::RMLogger.new
16
-
17
- # Comment out in case of any method conflicts
18
- # Library methods use module functions explicitly
19
- class Object; include RMTools end
1
+ SCRIPT_LINES__ = {} unless defined? SCRIPT_LINES__
2
+ require 'rmtools/load'
3
+ require_with_path 'debug'
4
+ require_with_path 'console'
@@ -0,0 +1 @@
1
+ require 'rmtools/load'
@@ -0,0 +1,4 @@
1
+ SCRIPT_LINES__ = {} unless defined? SCRIPT_LINES__
2
+ require 'rmtools/load'
3
+ require_with_path 'debug_notrace'
4
+ require_with_path 'console'
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rmtools
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 1
9
- - 2
10
- version: 1.1.2
9
+ - 4
10
+ version: 1.1.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Shinku Templar
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-02-09 00:00:00 +03:00
18
+ date: 2011-02-20 00:00:00 +03:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -109,6 +109,7 @@ files:
109
109
  - lib/rmtools/core/aliases.rb
110
110
  - lib/rmtools/core/module.rb
111
111
  - lib/rmtools/core/object.rb
112
+ - lib/rmtools/core/deprecation.rb
112
113
  - lib/rmtools/core/regexp.rb
113
114
  - lib/rmtools/core/class.rb
114
115
  - lib/rmtools/core/proc.rb
@@ -134,6 +135,7 @@ files:
134
135
  - lib/rmtools/core.rb
135
136
  - lib/rmtools/db.rb
136
137
  - lib/rmtools/debug/present.rb
138
+ - lib/rmtools/debug/observing.rb
137
139
  - lib/rmtools/debug/traceback.rb
138
140
  - lib/rmtools/debug/binding.rb
139
141
  - lib/rmtools/debug/logging.rb
@@ -143,7 +145,9 @@ files:
143
145
  - lib/rmtools/ip.rb
144
146
  - lib/rmtools/lang.rb
145
147
  - lib/rmtools/functional.rb
148
+ - lib/rmtools/load.rb
146
149
  - lib/rmtools/experimental.rb
150
+ - lib/rmtools/install.rb
147
151
  - lib/rmtools/functional/string_to_proc.rb
148
152
  - lib/rmtools/functional/fold.rb
149
153
  - lib/rmtools/functional/unfold.rb
@@ -163,16 +167,16 @@ files:
163
167
  - lib/rmtools/experimental/string.rb
164
168
  - lib/rmtools/experimental/blackhole.rb
165
169
  - lib/rmtools/experimental/tree.rb
166
- - lib/rmtools/experimental/deprecation.rb
167
170
  - lib/rmtools/experimental/dumps.rb
168
171
  - lib/rmtools/experimental/rails_backtrace.rb
169
172
  - lib/rmtools/xml.rb
170
173
  - lib/rmtools/conversions.rb
171
- - lib/rmtools/setup.rb
172
174
  - lib/rmtools/conversions/string.rb
173
175
  - lib/rmtools/conversions/enum.rb
174
176
  - lib/rmtools/conversions/int.rb
175
177
  - lib/rmtools/enumerable.rb
178
+ - lib/rmtools_notrace.rb
179
+ - lib/rmtools_nodebug.rb
176
180
  - ./Rakefile
177
181
  - ./Manifest.txt
178
182
  - ./License.txt
File without changes