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 CHANGED
@@ -2,7 +2,7 @@ require 'rake'
2
2
  require 'lib/rmtools/install'
3
3
  compile_manifest
4
4
 
5
- RMTOOLS_VERSION = '1.2.2d'
5
+ RMTOOLS_VERSION = '1.2.3'
6
6
  begin
7
7
  require 'hoe'
8
8
  config = Hoe.spec 'rmtools' do
@@ -54,4 +54,5 @@ module RMTools
54
54
  print %W{|\b /\b -\b \\\b +\b X\b}.rand
55
55
  end
56
56
 
57
+ module_function :tick!
57
58
  end
@@ -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
@@ -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.size}.max + opts[:padding]*2
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.center(cell_size)}*'|'+'|'
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
- nil
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
- calls << " -> `#{m.func}'"
35
+ calls << " -> `#{m.func}'"
36
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 = []
37
+ bt << "#{a[i]}#{calls.join}\n#{line}"
38
+ calls = []
39
39
  else bt << a[i]
40
40
  end
41
41
  i += 1
@@ -93,6 +93,10 @@ class Array
93
93
  !find {|e| yield(e)}
94
94
  end
95
95
 
96
+ def find_by(key, value)
97
+ find {|e| e.__send__(key) == value}
98
+ end
99
+
96
100
  # concatenation
97
101
  # analogue to String#>>
98
102
  def >>(ary)
@@ -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 == :sum ?
26
- __send__(iterator, args.shift) {|i| i.__send__ meth, *args, &block}:
27
- __send__(iterator) {|i| i.__send__ meth, *args, &block}
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
@@ -55,7 +55,7 @@ class File
55
55
  def mv(df)
56
56
  dir = File.dirname df
57
57
  FileUtils.mkpath dir unless File.directory? dir
58
- rename df
58
+ File.rename path, df
59
59
  end
60
60
 
61
61
  # Fixing windoze path problems
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
- RMTools::require 'lang/ansi'
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")]:
@@ -2,20 +2,23 @@
2
2
  RMTools::require 'lang/ansi'
3
3
 
4
4
  class String
5
- # Actually, for short strings and 1251<->65001 it's much faster to use predefined ANSI2UTF and UTF2ANSI procs
6
- def utf(from_encoding='WINDOWS-1251')
7
- Iconv.new('UTF-8', from_encoding).iconv(self)
8
- end
9
-
10
- def utf!(from_encoding='WINDOWS-1251')
11
- replace utf from_encoding
12
- end
13
-
14
- def ansi(from_encoding='UTF-8')
15
- Iconv.new('WINDOWS-1251', from_encoding).iconv(self)
16
- end
17
-
18
- def ansi!(from_encoding='UTF-8')
19
- replace ansi from_encoding
20
- end
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 {|patern, fun| pattern and matched[pattern]}
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
- arr = []
77
- each_byte {|b| arr << b.hex}
78
- arr
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: 33
5
- prerelease: 5
4
+ hash: 25
5
+ prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 2
9
- - 2
10
- - d
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: 2011-11-17 00:00:00 +03:00
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: 25
201
+ hash: 3
203
202
  segments:
204
- - 1
205
- - 3
206
- - 1
207
- version: 1.3.1
203
+ - 0
204
+ version: "0"
208
205
  requirements: []
209
206
 
210
207
  rubyforge_project: rmtools