rmtools 1.1.0 → 1.1.2

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
@@ -22,6 +22,7 @@ lib/rmtools/core/js.rb
22
22
  lib/rmtools/core/string_compliance.rb
23
23
  lib/rmtools/core/kernel.rb
24
24
  lib/rmtools/core/boolean.rb
25
+ lib/rmtools/core/aliases.rb
25
26
  lib/rmtools/core/module.rb
26
27
  lib/rmtools/core/object.rb
27
28
  lib/rmtools/core/regexp.rb
data/Rakefile CHANGED
@@ -2,9 +2,10 @@ require 'rake'
2
2
  require './lib/rmtools/setup'
3
3
  compile_manifest
4
4
 
5
+ RMTools_VERSION = '1.1.2'
5
6
  begin
6
7
  require 'hoe'
7
- config = Hoe.new('rmtools', '1.1.0') do |h|
8
+ config = Hoe.spec 'rmtools' do |h|
8
9
  h.developer("Shinku Templar", "tinbka@gmail.com")
9
10
 
10
11
  h.summary = 'Yet another Ruby applied framework'
@@ -37,6 +38,6 @@ Dir.chdir "ext" do
37
38
  if File.file? 'Makefile'
38
39
  system "#{make} clean" and FileUtils.rm_f "Makefile"
39
40
  end
40
- end unless ext_files_not_modified 'rmtools', '1.1.0'
41
+ end unless ext_files_not_modified 'rmtools', RMTools_VERSION
41
42
 
42
43
  puts "RMTools installed!"
data/lib/rmtools.rb CHANGED
@@ -1,6 +1,8 @@
1
1
  require 'active_support'
2
2
 
3
3
  module RMTools
4
+ VERSION = '1.1.2'
5
+
4
6
  require File.expand_path('require', __FILE__[0..-4])
5
7
  [ 'core', 'enumerable', 'text', 'b', 'time', 'functional',
6
8
  'conversions', 'ip', 'lang', 'rand',
@@ -1,4 +1,5 @@
1
- # encoding: utf-8
1
+ require_with_path 'enumerable/hash'
2
+
2
3
  module RMTools
3
4
 
4
5
  class Coloring
@@ -0,0 +1,10 @@
1
+ class Object
2
+ alias :resto :respond_to?
3
+ alias :requrie :require # most frequent typo, lol
4
+ end
5
+
6
+ class String
7
+ if !method_defined? :/
8
+ alias :/ :split
9
+ end
10
+ end
@@ -1,5 +1,3 @@
1
- require 'active_support/core_ext/hash'
2
-
3
1
  class Array
4
2
 
5
3
  # a, b, opts = [<hash1>].fetch_opts([<hash2>, <object1>]) may work unintuitive:
@@ -38,4 +38,6 @@ class Class
38
38
  (self.public_instance_methods - self.superclass.public_instance_methods).sort!.grep(filter)
39
39
  end
40
40
 
41
- end
41
+ end
42
+
43
+ [Array, Hash, Regexp, File, Dir].each {|klass| klass.__init__}
@@ -1,7 +1,5 @@
1
1
  # encoding: utf-8
2
2
  class Object
3
- alias :resto :respond_to?
4
- alias :requrie :require # most frequent typo, lol
5
3
 
6
4
  def is klass
7
5
  if Array === klass
@@ -39,18 +39,38 @@ class Binding
39
39
  def start_interaction(sandbox=true)
40
40
  $__env__ = inspect_env
41
41
  Kernel.puts RMTools.format_trace(caller(2)).join("\n")
42
- $env.present
42
+ $__env__.present
43
43
  $__binding__ = self
44
44
 
45
45
  $log << "entering irb"
46
- $__MAIN__.irb
47
- # Now input "irb_change_binding$__binding__" and have fun with debug
46
+ $__MAIN__.irb$__binding__
48
47
  $log << "exiting irb"
49
48
 
50
49
  if sandbox
51
- self.eval($env.keys.map {|k, v| "#{k} = $env[#{k.inspect}]"} * '; ')
50
+ self.eval($__env__.keys.map {|k, v| "#{k} = $__env__[#{k.inspect}]" if k != 'self'} * '; ')
52
51
  end
53
52
  $__env__ = nil
54
53
  end
55
54
 
56
- end
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
@@ -4,10 +4,10 @@ module RMTools
4
4
 
5
5
  def highlighted_line(file, line)
6
6
  if defined? SCRIPT_LINES__
7
- " >> #{Painter.green SCRIPT_LINES__[file][line.to_i - 1].chop}" if SCRIPT_LINES__[file]
7
+ " >> #{Painter.green SCRIPT_LINES__[file][line.to_i - 1].chop}" if SCRIPT_LINES__[file]
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.green read_lines(file, line.to_i).chop}" if File.file? file
11
11
  end
12
12
  end
13
13
 
@@ -1,6 +1,7 @@
1
1
  # encoding: utf-8
2
2
  require_with_path 'console/coloring'
3
3
  require_with_path 'text/string_parse'
4
+ require_with_path 'b'
4
5
 
5
6
  module RMTools
6
7
 
@@ -11,7 +12,7 @@ module RMTools
11
12
  attr_accessor :mute_info, :mute_warn, :mute_log, :mute_debug
12
13
  attr_reader :default_format
13
14
 
14
- Modes = %w{debug log info warn}.to_syms
15
+ Modes = [:debug, :log, :info, :warn]
15
16
  NOPRINT = 4
16
17
  NOLOG = 2
17
18
  INLINE = 1
@@ -118,7 +119,7 @@ module RMTools
118
119
  bind, opts = check_binding a
119
120
  opts |= NOLOG if !cfg.out
120
121
  opts |= NOPRINT if !cfg.print
121
- text ||= yield if block_given?
122
+ text = yield if block_given?
122
123
  _print(:warn, text, opts, cfg._caller && caller[0], bind, cfg)
123
124
  end
124
125
  end
@@ -129,7 +130,7 @@ module RMTools
129
130
  bind, opts = check_binding a
130
131
  opts |= NOLOG if !cfg.out
131
132
  opts |= NOPRINT if !(cfg.print && !$quiet && $verbose)
132
- text ||= yield if block_given?
133
+ text = yield if block_given?
133
134
  _print(:log, text, opts, cfg._caller && caller[0], bind, cfg)
134
135
  end
135
136
  end
@@ -140,7 +141,7 @@ module RMTools
140
141
  bind, opts = check_binding a
141
142
  opts |= NOLOG if !(cfg.out && cfg.out_all)
142
143
  opts |= NOPRINT if !(cfg.print && !$quiet)
143
- text ||= yield if block_given?
144
+ text = yield if block_given?
144
145
  _print(:info, text, opts, cfg._caller && caller[0], bind, cfg)
145
146
  end
146
147
  end
@@ -151,7 +152,7 @@ module RMTools
151
152
  bind, opts = check_binding a
152
153
  opts |= NOLOG if !(cfg.out && cfg.out_all)
153
154
  opts |= NOPRINT if !(cfg.print && $panic && !$quiet)
154
- text ||= yield if block_given?
155
+ text = yield if block_given?
155
156
  _print(:debug, text, opts, cfg._caller && caller[0], bind, cfg)
156
157
  end
157
158
  end
@@ -2,6 +2,7 @@
2
2
  class Object
3
3
 
4
4
  def present
5
+ [true, false, nil, Numeric, String, Regexp].each {|klass| return puts inspect if klass === self}
5
6
  Hash[readable_variables.map {|v| [":#{v}", __send__(v)]}].present
6
7
  end
7
8
 
@@ -1,4 +1,6 @@
1
1
  require_with_path 'debug/highlight'
2
+ require_with_path 'debug/logging'
3
+
2
4
  module Kernel
3
5
 
4
6
  # Python-like traceback for exceptions; uses ANSI coloring.
@@ -25,12 +27,12 @@ module Kernel
25
27
  m2 = a[i+1] && a[i+1].parse(:caller)
26
28
  # $log.info 'm', binding
27
29
  # $log.info 'm2', binding
28
- # $log.info 'm[3] m[1..2]==m2[1..2]', binding if m and m2
29
- # $log.info 'm[1] m[2]', binding if m
30
- # $log.info highlighted_line(*m[1..2]) if m
30
+ # $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
32
+ # $log.info RMTools.highlighted_line(m.path, m.line) if m
31
33
  if m and m.func and m2 and [m.path, m.line] == [m2.path, m2.line]
32
34
  calls << "`#{m.func}' -> "
33
- elsif m and m.line != 0 and line = highlighted_line(m.path, m.line)
35
+ elsif m and m.line != 0 and line = RMTools.highlighted_line(m.path, m.line)
34
36
  bt << "#{a[i]}#{calls.join}\n#{line}"
35
37
  calls = []
36
38
  else bt << a[i]
@@ -38,7 +40,7 @@ module Kernel
38
40
  i += 1
39
41
  m = m2
40
42
  end
41
- # $log << Painter.r("FORMAT DONE! #{bt.size} lines formatted")
43
+ # $log << RMTools::Painter.r("FORMAT DONE! #{bt.size} lines formatted")
42
44
  bt
43
45
  end
44
46
 
@@ -57,7 +59,7 @@ class Class
57
59
  def set_backtrace src
58
60
  set_bt src
59
61
  end
60
- })
62
+ }, __FILE__, __LINE__-10)
61
63
  else
62
64
  raise NoMethodError, "undefined method `trace_format' for class #{self}"
63
65
  end
@@ -1,3 +1,5 @@
1
+ require 'active_support/core_ext/hash'
2
+
1
3
  class Hash
2
4
  alias :>> :reverse_merge!
3
5
 
@@ -1,10 +1,10 @@
1
1
  require_with_path 'conversions/string'
2
2
 
3
3
  class String
4
- CALLER_RE = %r{^\(?(.*?([^/\\]+?))#{ # ( path ( file ) )
5
- }\)?:(\d+)(?::in #{ # :( line )[ :in
6
- }[`<]([^'>]+)[>']#{ # `( closure )' ]
7
- })?$}
4
+ CALLER_RE = %r{^(.*?([^/\\]+?))#{ # ( path ( file ) )
5
+ }:(\d+)(?::in #{ # :( line )[ :in
6
+ }[`<]([^'>]+)[>']#{ # `( closure )' ]
7
+ })?$}
8
8
  URL_RE = %r{^((?:([^:]+)://)#{ # ( protocol
9
9
  }([^/:]*(?::(\d+))?))?#{ # root[:port] )
10
10
  }((/[^?#]*?(?:\.(\w+))?)#{ # ( path[.( fileext )]
@@ -33,7 +33,7 @@ class String
33
33
  'anchor' => m[9] }
34
34
  when :caller
35
35
  m = match CALLER_RE
36
- m || m[0].empty? ? nil :
36
+ !m || m[0].empty? ? nil :
37
37
  { 'path' => m[1],
38
38
  'file' => m[2],
39
39
  'line' => m[3].to_i,
@@ -1,7 +1,4 @@
1
1
  class String
2
- if !method_defined? :/
3
- alias :/ :split
4
- end
5
2
 
6
3
  def inline
7
4
  count("\n") == 0
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: 19
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 1
9
- - 0
10
- version: 1.1.0
9
+ - 2
10
+ version: 1.1.2
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-03 00:00:00 +03:00
18
+ date: 2011-02-09 00:00:00 +03:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -106,6 +106,7 @@ files:
106
106
  - lib/rmtools/core/string_compliance.rb
107
107
  - lib/rmtools/core/kernel.rb
108
108
  - lib/rmtools/core/boolean.rb
109
+ - lib/rmtools/core/aliases.rb
109
110
  - lib/rmtools/core/module.rb
110
111
  - lib/rmtools/core/object.rb
111
112
  - lib/rmtools/core/regexp.rb
@@ -208,7 +209,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
208
209
  requirements: []
209
210
 
210
211
  rubyforge_project: rmtools
211
- rubygems_version: 1.4.2
212
+ rubygems_version: 1.5.0
212
213
  signing_key:
213
214
  specification_version: 3
214
215
  summary: Yet another Ruby applied framework