rmtools 1.1.11 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. data/Manifest.txt +16 -21
  2. data/README.txt +17 -5
  3. data/Rakefile +1 -1
  4. data/lib/rmtools/console/coloring.rb +58 -42
  5. data/lib/rmtools/console/highlight.rb +1 -1
  6. data/lib/rmtools/core/arguments.rb +7 -4
  7. data/lib/rmtools/core/js.rb +6 -5
  8. data/lib/rmtools/core/kernel.rb +37 -1
  9. data/lib/rmtools/core/module.rb +1 -1
  10. data/lib/rmtools/{debug → dev}/binding.rb +6 -6
  11. data/lib/rmtools/{experimental → dev}/blackhole.rb +0 -0
  12. data/lib/rmtools/dev/code_reader.rb +431 -0
  13. data/lib/rmtools/{debug → dev}/highlight.rb +2 -2
  14. data/lib/rmtools/{debug → dev}/logging.rb +44 -47
  15. data/lib/rmtools/{debug → dev}/observing.rb +8 -2
  16. data/lib/rmtools/dev/present.rb +63 -0
  17. data/lib/rmtools/{debug → dev}/timer.rb +3 -3
  18. data/lib/rmtools/{debug → dev}/trace_format.rb +3 -9
  19. data/lib/rmtools/{debug → dev}/traceback.rb +1 -1
  20. data/lib/rmtools/{debug.rb → dev.rb} +0 -0
  21. data/lib/rmtools/dev_min.rb +2 -0
  22. data/lib/rmtools/enumerable/array.rb +12 -1
  23. data/lib/rmtools/enumerable/array_iterators.rb +5 -3
  24. data/lib/rmtools/enumerable/common.rb +0 -2
  25. data/lib/rmtools/enumerable/hash.rb +10 -4
  26. data/lib/rmtools/enumerable/object_space.rb +11 -9
  27. data/lib/rmtools/enumerable/range.rb +21 -0
  28. data/lib/rmtools/fs/tools.rb +6 -2
  29. data/lib/rmtools/install.rb +4 -2
  30. data/lib/rmtools/lang/cyrillic.rb +2 -2
  31. data/lib/rmtools/lang/{shortcuts.rb → helpers.rb} +0 -0
  32. data/lib/rmtools/load.rb +1 -1
  33. data/lib/rmtools/text/regexp.rb +74 -0
  34. data/lib/rmtools/text/string_rtl.rb +28 -0
  35. data/lib/rmtools/text/string_scanner.rb +19 -9
  36. data/lib/rmtools/text/string_simple.rb +11 -3
  37. data/lib/rmtools/text/string_split.rb +1 -5
  38. data/lib/rmtools/xml/node.rb +1 -1
  39. data/lib/rmtools/xml/string.rb +2 -2
  40. data/lib/rmtools.rb +1 -8
  41. data/lib/rmtools_dev.rb +6 -0
  42. metadata +21 -26
  43. data/lib/rmtools/debug/present.rb +0 -39
  44. data/lib/rmtools/debug_notrace.rb +0 -2
  45. data/lib/rmtools/experimental/dumps.rb +0 -29
  46. data/lib/rmtools/experimental/numeric.rb +0 -54
  47. data/lib/rmtools/experimental/rails_backtrace.rb +0 -30
  48. data/lib/rmtools/experimental/string.rb +0 -56
  49. data/lib/rmtools/experimental/tree.rb +0 -72
  50. data/lib/rmtools/experimental.rb +0 -2
  51. data/lib/rmtools_nodebug.rb +0 -3
  52. data/lib/rmtools_notrace.rb +0 -7
  53. data/lib/rmtools_safe.rb +0 -2
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: 5
4
+ hash: 31
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
- - 1
9
- - 11
10
- version: 1.1.11
8
+ - 2
9
+ - 0
10
+ version: 1.2.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Shinku
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-04-03 00:00:00 +04:00
18
+ date: 2011-05-16 00:00:00 +04:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -89,6 +89,16 @@ files:
89
89
  - lib/rmtools/fs/tools.rb
90
90
  - lib/rmtools/ip/numeric.rb
91
91
  - lib/rmtools/ip/string.rb
92
+ - lib/rmtools/dev/present.rb
93
+ - lib/rmtools/dev/blackhole.rb
94
+ - lib/rmtools/dev/observing.rb
95
+ - lib/rmtools/dev/traceback.rb
96
+ - lib/rmtools/dev/binding.rb
97
+ - lib/rmtools/dev/logging.rb
98
+ - lib/rmtools/dev/trace_format.rb
99
+ - lib/rmtools/dev/highlight.rb
100
+ - lib/rmtools/dev/timer.rb
101
+ - lib/rmtools/dev/code_reader.rb
92
102
  - lib/rmtools/xml/xpath.rb
93
103
  - lib/rmtools/xml/string.rb
94
104
  - lib/rmtools/xml/libxml.rb
@@ -109,7 +119,7 @@ files:
109
119
  - lib/rmtools/core/regexp.rb
110
120
  - lib/rmtools/core/class.rb
111
121
  - lib/rmtools/core/proc.rb
112
- - lib/rmtools/lang/shortcuts.rb
122
+ - lib/rmtools/lang/helpers.rb
113
123
  - lib/rmtools/lang/ansi.rb
114
124
  - lib/rmtools/lang/regexp.rb
115
125
  - lib/rmtools/lang/cyrillic.rb
@@ -120,8 +130,10 @@ files:
120
130
  - lib/rmtools/text/string_simple.rb
121
131
  - lib/rmtools/text/string_scanner.rb
122
132
  - lib/rmtools/text/textilize.rb
133
+ - lib/rmtools/text/string_rtl.rb
123
134
  - lib/rmtools/text/string_split.rb
124
135
  - lib/rmtools/text/string_parse.rb
136
+ - lib/rmtools/text/regexp.rb
125
137
  - lib/rmtools/time/russian.rb
126
138
  - lib/rmtools/time/global.rb
127
139
  - lib/rmtools/rand.rb
@@ -130,20 +142,11 @@ files:
130
142
  - lib/rmtools/console/highlight.rb
131
143
  - lib/rmtools/core.rb
132
144
  - lib/rmtools/db.rb
133
- - lib/rmtools/debug/present.rb
134
- - lib/rmtools/debug/observing.rb
135
- - lib/rmtools/debug/traceback.rb
136
- - lib/rmtools/debug/binding.rb
137
- - lib/rmtools/debug/logging.rb
138
- - lib/rmtools/debug/trace_format.rb
139
- - lib/rmtools/debug/highlight.rb
140
- - lib/rmtools/debug/timer.rb
141
145
  - lib/rmtools/fs.rb
142
146
  - lib/rmtools/ip.rb
143
147
  - lib/rmtools/lang.rb
144
148
  - lib/rmtools/functional.rb
145
149
  - lib/rmtools/load.rb
146
- - lib/rmtools/experimental.rb
147
150
  - lib/rmtools/install.rb
148
151
  - lib/rmtools/functional/decorate.rb
149
152
  - lib/rmtools/functional/fold.rb
@@ -151,8 +154,7 @@ files:
151
154
  - lib/rmtools/text.rb
152
155
  - lib/rmtools/console.rb
153
156
  - lib/rmtools/time.rb
154
- - lib/rmtools/debug_notrace.rb
155
- - lib/rmtools/debug.rb
157
+ - lib/rmtools/dev.rb
156
158
  - lib/rmtools/enumerable/common.rb
157
159
  - lib/rmtools/enumerable/range.rb
158
160
  - lib/rmtools/enumerable/hash.rb
@@ -160,21 +162,14 @@ files:
160
162
  - lib/rmtools/enumerable/object_space.rb
161
163
  - lib/rmtools/enumerable/array_iterators.rb
162
164
  - lib/rmtools/require.rb
163
- - lib/rmtools/experimental/numeric.rb
164
- - lib/rmtools/experimental/string.rb
165
- - lib/rmtools/experimental/blackhole.rb
166
- - lib/rmtools/experimental/tree.rb
167
- - lib/rmtools/experimental/dumps.rb
168
- - lib/rmtools/experimental/rails_backtrace.rb
169
165
  - lib/rmtools/xml.rb
170
166
  - lib/rmtools/conversions.rb
171
167
  - lib/rmtools/conversions/string.rb
172
168
  - lib/rmtools/conversions/enum.rb
173
169
  - lib/rmtools/conversions/int.rb
174
170
  - lib/rmtools/enumerable.rb
175
- - lib/rmtools_notrace.rb
176
- - lib/rmtools_safe.rb
177
- - lib/rmtools_nodebug.rb
171
+ - lib/rmtools/dev_min.rb
172
+ - lib/rmtools_dev.rb
178
173
  - ./Rakefile
179
174
  - ./Manifest.txt
180
175
  - ./License.txt
@@ -1,39 +0,0 @@
1
- # encoding: utf-8
2
- class Object
3
-
4
- def present
5
- [true, false, nil, Numeric, String, Regexp].each {|klass| return puts inspect if klass === self}
6
- Hash[readable_variables.map {|v| [":#{v}", __send__(v)]}].present
7
- end
8
-
9
- end
10
-
11
- class Array
12
-
13
- def present(inspect_string=nil)
14
- res = "[ "
15
- indent = (size-1).to_s.size
16
- res << map_with_index {|k,i|
17
- "#{i.to_s.rjust(indent)}: #{(k.is String and !inspect_string) ? k : k.inspect}"
18
- }*"\n "
19
- res << "]"
20
- puts res
21
- end
22
-
23
- end
24
-
25
- class Hash
26
-
27
- def present(inspect_string=nil)
28
- str = "{ "
29
- sorted = sort rescue to_a.sort_by_to_s
30
- str << sorted.map {|k,v|
31
- "#{(k.is String and !inspect_string) ? k : k.inspect} => #{(v.is String and !inspect_string) ? v : v.inspect},"
32
- }*"\n "
33
- str << "}"
34
- puts str
35
- end
36
-
37
- end
38
-
39
-
@@ -1,2 +0,0 @@
1
- # encoding: utf-8
2
- RMTools::require 'debug/{observing,timer,trace_format}'
@@ -1,29 +0,0 @@
1
- # encoding: utf-8
2
- class Array
3
-
4
- def dump(depth=5)
5
- res = "[ "
6
- res << map_with_index {|j, i|
7
- j = 'nil' if j.nil?
8
- "%0*d: %s、"%[i, (size-1).to_s.size, dump_recurse(j,0,depth)]
9
- }*"\n "
10
- res << "]\n"
11
- end
12
-
13
- end
14
-
15
- class Hash
16
-
17
- def dump(depth=5)
18
- res = "{ "
19
- res << map {|i, j|
20
- i = 'nil' if i.nil?
21
- j = 'nil' if j.nil?
22
- "%0*s => %s、\n"%[i, keys.to_ss.max, dump_recurse(j,0,depth)]
23
- }*"\n "
24
- res << "}\n"
25
- end
26
-
27
- end
28
-
29
-
@@ -1,54 +0,0 @@
1
- # encoding: utf-8
2
- class Float
3
-
4
- def partial(range=100)
5
- return to_i.to_s if to_i == self
6
- a = abs
7
- (2..range-1).each {|i| (1..range).each {|j|
8
- n = j.to_f/i
9
- break if n > a
10
- return "#{'-' if self != a}#{j}/#{i}" if n == a
11
- } }
12
- self
13
- end
14
-
15
- end
16
-
17
- class Integer
18
-
19
- def digits
20
- nums = []
21
- while (int ||= self) > 0
22
- nums << int%10
23
- int /= 10
24
- end
25
- nums
26
- end
27
-
28
- def each_bit # descending order
29
- to_s(2).each_byte {|b| yield(b == 49)}
30
- end
31
-
32
- def to_array(base=10)
33
- int = self
34
- ary = []
35
- begin
36
- a = int.divmod base
37
- ary << a[1]
38
- int = a[0]
39
- end while int != 0
40
- ary.reverse!
41
- end
42
-
43
- end
44
-
45
- class Array
46
-
47
- def compile_int(base=10)
48
- int = 0
49
- pos = size
50
- each {|i| int += base**(pos -= 1) * i}
51
- int
52
- end
53
-
54
- end
@@ -1,30 +0,0 @@
1
- # encoding: utf-8
2
- module RMTools
3
- def highlighted_line_html file, line
4
- if File.file?(file)
5
- " >> <a style=\"color:#0A0; text-decoration: none;\"#{
6
- " href=\"http://#{
7
- defined?(DEBUG_SERVER) ? DEBUG_SERVER : 'localhost:8888'
8
- }/code/#{CGI.escape CGI.escape(file).gsub('.', '%2E')}/#{line}\""
9
- }>#{read_lines(file, line.to_i).chop}</a>"
10
- end
11
- end
12
-
13
- def format_trace_html a
14
- bt, calls, i = [], [], 0
15
- m = a[0].match(/^(.+):(\d+)(?::in `([^']+)')?$/)
16
- while i < a.size
17
- m2 = a[i+1] && a[i+1].match(/^(.+):(\d+)(?::in `([^']+)')?$/)
18
- if m and m[3] and m2 and m[1..2] == m2[1..2]
19
- calls.unshift " <- `#{m[3]}'"
20
- elsif m and m[1] !~ /\.gemspec$/ and line = highlighted_line_html(*m[1..2])
21
- bt << "#{a[i]}#{calls.join}\n#{line}"
22
- calls = []
23
- else bt << a[i]
24
- end
25
- i += 1
26
- m = m2
27
- end
28
- bt
29
- end
30
- end
@@ -1,56 +0,0 @@
1
- # encoding: utf-8
2
- class String
3
-
4
- def bytes
5
- arr = []
6
- each_byte {|b| arr << b.hex}
7
- arr
8
- end
9
-
10
- def to_limited len=100
11
- LimitedString.new self, len
12
- end
13
-
14
- end
15
-
16
- class Indent < String
17
- attr_reader :indent
18
-
19
- def initialize(indent=' ')
20
- @indent = indent
21
- super ''
22
- end
23
-
24
- def +@
25
- self << @indent
26
- end
27
-
28
- def -@
29
- self.chomp! @indent
30
- end
31
-
32
- def i(&block)
33
- +self
34
- res = yield
35
- -self
36
- res
37
- end
38
-
39
- end
40
-
41
- # Compact string inspect
42
- class LimitedString < String
43
- attr_reader :len
44
- __init__
45
-
46
- def initialize str="", len=100
47
- @len = len
48
- super str
49
- end
50
-
51
- def inspect
52
- @len ||= 100
53
- size > @len ? String.new(self[0...@len]+"…").inspect : super
54
- end
55
-
56
- end
@@ -1,72 +0,0 @@
1
- # encoding: utf-8
2
- class Array
3
-
4
- def to_tree(set_keys=false)
5
- ary = Tree.new dup
6
- ary.set_keys! if set_keys
7
- ary
8
- end
9
-
10
- protected
11
- def set_keys!(i=-1)
12
- each {|e| Array === e && e.unshift(i+=1).set_keys!}
13
- end
14
-
15
- end
16
-
17
- module RMTools
18
-
19
- class Tree < Array
20
-
21
- def self.from(*obj) new(*obj) end
22
-
23
- def initialize(obj, to_ary_method=nil)
24
- super(to_ary_method ? recurse_build(obj, to_ary_method) : obj.to_a)
25
- end
26
-
27
- def recurse_build(obj, to_ary_method)
28
- to_ary_method = [to_ary_method] unless Array === to_ary_method
29
- if to_ary_method = to_ary_method.find {|m| obj.respond_to?(m) && Array === (ary = obj.send m) && ary.size > 0}
30
- obj.send(to_ary_method).map {|branch|
31
- [branch, recurse_build(branch, to_ary_method)]
32
- }
33
- else
34
- [self]
35
- end
36
- end
37
-
38
- def trace_leaf(a, c, cont=[])
39
- return unless Array === a
40
- return (a[0] == c && cont) if a.size == 1
41
- y = nil
42
- a[1..-1].each_with_index.find {|_, i|
43
- y = trace_leaf(_, c, cont+[[a[0], i]])
44
- }; y
45
- end
46
-
47
- def trace_branch(a, c, cont=[])
48
- return unless Array === a
49
- return cont if a[0] == c
50
- y = nil
51
- a[1..-1].each_with_index.find {|_, i|
52
- y = trace_branch(_, c, cont+[[a[0], i]])
53
- }; y
54
- end
55
-
56
- def leaves
57
- y=[]
58
- each {|_| Array === node && (node.size>1 ? y.concat(node.leaves) : y.concat(node))}
59
- y
60
- end
61
-
62
- def get_branch_by_key(a, key, value)
63
- return unless Array === a
64
- return a if a[0][key] == value
65
- y = nil
66
- a[1..-1].find {|record| y = get_branch_by_key(record, key, value)}
67
- y
68
- end
69
-
70
- end
71
-
72
- end
@@ -1,2 +0,0 @@
1
- # encoding: utf-8
2
- RMTools::require __FILE__, '*'
@@ -1,3 +0,0 @@
1
- # encoding: utf-8
2
- require 'rmtools/load'
3
- RMTools::require 'b'
@@ -1,7 +0,0 @@
1
- # encoding: utf-8
2
- SCRIPT_LINES__ = {} unless defined? SCRIPT_LINES__
3
- $__MAIN__ = self
4
- require 'rmtools/load'
5
- RMTools::require 'b'
6
- RMTools::require 'debug_notrace'
7
- RMTools::require 'console'
data/lib/rmtools_safe.rb DELETED
@@ -1,2 +0,0 @@
1
- # encoding: utf-8
2
- require 'rmtools/load'