rmtools 1.2.2d → 1.2.3
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/Rakefile +1 -1
- data/lib/rmtools/console/printing.rb +1 -0
- data/lib/rmtools/dev/code_reader.rb +2 -2
- data/lib/rmtools/dev/present.rb +2 -2
- data/lib/rmtools/dev/trace_format.rb +5 -5
- data/lib/rmtools/enumerable/array.rb +4 -0
- data/lib/rmtools/enumerable/array_iterators.rb +6 -4
- data/lib/rmtools/fs/file.rb +1 -1
- data/lib/rmtools/lang/cyrillic.rb +22 -2
- data/lib/rmtools/lang/helpers.rb +19 -16
- data/lib/rmtools/text/string_scanner.rb +1 -1
- data/lib/rmtools/text/string_simple.rb +7 -5
- metadata +9 -12
data/Rakefile
CHANGED
@@ -475,9 +475,9 @@ module RMTools
|
|
475
475
|
lines = path.sharp_split(/\n/)
|
476
476
|
end
|
477
477
|
if RUBY_VERSION > '1.9'
|
478
|
-
ss = StringScanner lines.join.force_encoding('UTF-8')
|
478
|
+
ss = StringScanner.new lines.join.force_encoding('UTF-8')
|
479
479
|
else
|
480
|
-
ss = StringScanner lines.join
|
480
|
+
ss = StringScanner.new lines.join
|
481
481
|
end
|
482
482
|
|
483
483
|
@curls_count = 0
|
data/lib/rmtools/dev/present.rb
CHANGED
@@ -26,7 +26,7 @@ class Array
|
|
26
26
|
opts = {:max_cols => Inf, :padding => 0}.merge opts
|
27
27
|
return inspect unless cols = ENV['COLUMNS']
|
28
28
|
cols = cols.to_i
|
29
|
-
cell_size = map {|e| e.inspect.
|
29
|
+
cell_size = map {|e| e.inspect.csize}.max + opts[:padding]*2
|
30
30
|
if n = [(1..cols/2).max {|i| i*(cell_size+1) < cols}, opts[:max_cols]].min
|
31
31
|
table = div(n)
|
32
32
|
border = '+'+('-'*cell_size+'+')*n
|
@@ -36,7 +36,7 @@ class Array
|
|
36
36
|
border :
|
37
37
|
'+'+('-'*cell_size+'+')*table.last.size + '-'*((cell_size+1)*(n-table.last.size)-1) + '+'
|
38
38
|
table.map {|rows|
|
39
|
-
str = '|'+rows.map {|cell| cell.inspect.
|
39
|
+
str = '|'+rows.map {|cell| cell.inspect.ccenter(cell_size)}*'|'+'|'
|
40
40
|
str << ' '*((cell_size+1)*(n-rows.size)-1)+'|' if rows.size < n
|
41
41
|
border + str + ("\n" if need_lb)
|
42
42
|
}.join + last_border
|
@@ -29,13 +29,13 @@ module RMTools
|
|
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
|
-
if m.path =~ IgnoreFiles
|
33
|
-
|
32
|
+
if !m or m.path =~ IgnoreFiles
|
33
|
+
nil
|
34
34
|
elsif m and m.func and m2 and [m.path, m.line] == [m2.path, m2.line]
|
35
|
-
|
35
|
+
calls << " -> `#{m.func}'"
|
36
36
|
elsif m and m.line != 0 and line = RMTools.highlighted_line(m.path, m.line)
|
37
|
-
|
38
|
-
|
37
|
+
bt << "#{a[i]}#{calls.join}\n#{line}"
|
38
|
+
calls = []
|
39
39
|
else bt << a[i]
|
40
40
|
end
|
41
41
|
i += 1
|
@@ -18,13 +18,15 @@ unless defined? RMTools::Iterators
|
|
18
18
|
|
19
19
|
def method_missing(method, *args, &block)
|
20
20
|
if match = (meth = method.to_s).match(RMTools::Iterators)
|
21
|
-
iterator, meth = match[1], match[2].to_sym
|
21
|
+
iterator, meth = match[1].to_sym, match[2].to_sym
|
22
22
|
begin
|
23
23
|
iterator = :every? if iterator == :every
|
24
24
|
iterator = :no? if iterator == :no
|
25
|
-
return iterator
|
26
|
-
|
27
|
-
|
25
|
+
return case iterator
|
26
|
+
when :sum; sum(args.shift) {|i| i.__send__ meth, *args, &block}
|
27
|
+
when :find_by; find_by(meth, *args)
|
28
|
+
else __send__(iterator) {|i| i.__send__ meth, *args, &block}
|
29
|
+
end
|
28
30
|
rescue NoMethodError => e
|
29
31
|
e.message << " (`#{method}' interpreted as decorator-function `#{meth}')"
|
30
32
|
raise e
|
data/lib/rmtools/fs/file.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
-
RMTools::require 'lang/
|
2
|
+
RMTools::require 'lang/helpers'
|
3
3
|
|
4
4
|
class String
|
5
5
|
include RMTools::Cyrillic
|
@@ -65,9 +65,29 @@ class String
|
|
65
65
|
ANSI2UTF[UTF2ANSI[self].tr(*ANSI_YOYE)]:
|
66
66
|
tr(*ANSI_YOYE)
|
67
67
|
end
|
68
|
-
|
68
|
+
|
69
|
+
alias csize size
|
70
|
+
alias cljust ljust
|
71
|
+
alias cjust just
|
72
|
+
alias ccenter center
|
69
73
|
else
|
70
74
|
|
75
|
+
def csize
|
76
|
+
UTF2ANSI[self].size
|
77
|
+
end
|
78
|
+
|
79
|
+
def cljust(*args)
|
80
|
+
ANSI2UTF[UTF2ANSI[self].ljust(*args)]
|
81
|
+
end
|
82
|
+
|
83
|
+
def cjust(*args)
|
84
|
+
ANSI2UTF[UTF2ANSI[self].just(*args)]
|
85
|
+
end
|
86
|
+
|
87
|
+
def ccenter(*args)
|
88
|
+
ANSI2UTF[UTF2ANSI[self].center(*args)]
|
89
|
+
end
|
90
|
+
|
71
91
|
def cupcase(encode=1)
|
72
92
|
encode ?
|
73
93
|
ANSI2UTF[UTF2ANSI[self].tr("\270\340-\377", "\250\300-\337")]:
|
data/lib/rmtools/lang/helpers.rb
CHANGED
@@ -2,20 +2,23 @@
|
|
2
2
|
RMTools::require 'lang/ansi'
|
3
3
|
|
4
4
|
class String
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
5
|
+
ANSI2UTF = Iconv.new("UTF-8", "WINDOWS-1251").method :iconv
|
6
|
+
UTF2ANSI = Iconv.new("WINDOWS-1251", "UTF-8").method :iconv
|
7
|
+
|
8
|
+
# Actually, for short strings and 1251<->65001 it's much faster to use predefined ANSI2UTF and UTF2ANSI procs
|
9
|
+
def utf(from_encoding='WINDOWS-1251')
|
10
|
+
Iconv.new('UTF-8', from_encoding).iconv(self)
|
11
|
+
end
|
12
|
+
|
13
|
+
def utf!(from_encoding='WINDOWS-1251')
|
14
|
+
replace utf from_encoding
|
15
|
+
end
|
16
|
+
|
17
|
+
def ansi(from_encoding='UTF-8')
|
18
|
+
Iconv.new('WINDOWS-1251', from_encoding).iconv(self)
|
19
|
+
end
|
20
|
+
|
21
|
+
def ansi!(from_encoding='UTF-8')
|
22
|
+
replace ansi from_encoding
|
23
|
+
end
|
21
24
|
end
|
@@ -39,7 +39,7 @@ class StringScanner
|
|
39
39
|
end
|
40
40
|
else
|
41
41
|
while res
|
42
|
-
if cb = cbs.find {|
|
42
|
+
if cb = cbs.find {|pattern, fun| pattern and matched[pattern]}
|
43
43
|
# patterns should be as explicit as possible
|
44
44
|
cb[1][self, $~] if cb[1]
|
45
45
|
@last = pos
|
@@ -72,10 +72,12 @@ class String
|
|
72
72
|
|
73
73
|
# "b ц ~ \255 秀".bytes
|
74
74
|
### => ["62", "20", "d1", "86", "20", "7e", "20", "ad", "20", "e7", "a7", "80"]
|
75
|
-
def bytes
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
end
|
75
|
+
#def bytes
|
76
|
+
# arr = []
|
77
|
+
# each_byte {|b| arr << b.hex}
|
78
|
+
# arr
|
79
|
+
#end
|
80
|
+
#
|
81
|
+
# this method defined in Enumerable and returns Enumerable::Enumerator that should be converted to array of integers, not hex-strings
|
80
82
|
|
81
83
|
end
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rmtools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 25
|
5
|
+
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
|
11
|
-
version: 1.2.2d
|
9
|
+
- 3
|
10
|
+
version: 1.2.3
|
12
11
|
platform: ruby
|
13
12
|
authors:
|
14
13
|
- Shinku
|
@@ -16,7 +15,7 @@ autorequire:
|
|
16
15
|
bindir: bin
|
17
16
|
cert_chain: []
|
18
17
|
|
19
|
-
date:
|
18
|
+
date: 2012-02-02 00:00:00 +03:00
|
20
19
|
default_executable:
|
21
20
|
dependencies:
|
22
21
|
- !ruby/object:Gem::Dependency
|
@@ -197,14 +196,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
197
196
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
198
197
|
none: false
|
199
198
|
requirements:
|
200
|
-
- - "
|
199
|
+
- - ">="
|
201
200
|
- !ruby/object:Gem::Version
|
202
|
-
hash:
|
201
|
+
hash: 3
|
203
202
|
segments:
|
204
|
-
-
|
205
|
-
|
206
|
-
- 1
|
207
|
-
version: 1.3.1
|
203
|
+
- 0
|
204
|
+
version: "0"
|
208
205
|
requirements: []
|
209
206
|
|
210
207
|
rubyforge_project: rmtools
|