rmtools 2.3.3 → 2.3.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4c14d10479b262ef50e03d2ee4e3643677ac7174
4
- data.tar.gz: 17e0c478440bccc1e6a43e3bc4c6f107291de7b2
3
+ metadata.gz: 9334478c59f448c6ac5a6693e6a91975533614e2
4
+ data.tar.gz: c1377abc4ccb7bfb4ae55b636ecbae31906a4ab5
5
5
  SHA512:
6
- metadata.gz: e43360436dfa4fc935983ee0f87a1bc8376b27bbab765720b9ae498efa3ce4a6333a6534619298228731894fdf8156b08dcc921c9e30ddc14514bf1438026e7c
7
- data.tar.gz: a47880d138ccb5db7da325a1abf2db283ad6479bdf74593829c112c3fa87fa837a5fafd3c0e5052603d195075773f1d7f096d3dbd8ff1b802c8f6909b640f249
6
+ metadata.gz: 79964bcde63bb715714903d516507f60411510cb35de71fc83e441e7bb205f6b443ddfee9139f90a4f4447c95c5c9d7bb87eaf298ab2d2e1116755a57a16c437
7
+ data.tar.gz: aec618b40383d704a4ed558127bb77f52c950416769900ed56138c850ef916dd705fb8f45bc92939a6314d3ae642f10545a02d81c274752d09473865d1f4d507
data/.gitignore CHANGED
@@ -19,4 +19,5 @@ Manifest.txt
19
19
  Makefile
20
20
  *.out
21
21
  *.o
22
- *.so
22
+ *.so
23
+ .directory
data/README.md CHANGED
@@ -27,14 +27,26 @@ It's still randomly documented since it's just my working tool.
27
27
 
28
28
  ### CHANGES
29
29
 
30
- ##### Version 2.2.5
30
+ ##### Version 2.3.4
31
31
 
32
+ * Ruby 2+ behaviour:
33
+ * Disabled C-extension
34
+ * Used String#encode instead of Iconv#iconv
35
+
32
36
  * String
33
- * Added #fix_encoding! It differentiates only utf-8 and ansi-1251, though.
37
+ * Updated #digit_date to parse full english month names
38
+
39
+ ##### Version 2.2.6
40
+
41
+ * String
42
+ * Added #utf? and #find_compatible_encoding. Currently, latter one differentiates only utf-8 and ansi-1251.
34
43
 
35
44
  * Range
36
45
  * #include? never raises an exception
37
46
 
47
+ * Array/Set
48
+ * Added #is_subset_of?
49
+
38
50
  ##### Version 2.2.4
39
51
 
40
52
  * Hash
@@ -1,4 +1,6 @@
1
1
  # encoding: utf-8
2
+ require 'rmtools/core/object'
3
+
2
4
  class Class
3
5
 
4
6
  def method_proxy *vars
@@ -117,7 +117,7 @@ module RMTools
117
117
  cmd = "scp #{fullpath.inspect} #{[@host, fpath].join(':').inspect} 2>&1"
118
118
  print "`#{cmd}`: " if @debug
119
119
  if res = RMTools::tick_while {`#{cmd}`}.b
120
- puts "[ #{Painter.rb('Error')} ]: #{res}"
120
+ puts "[ #{Painter.r_b('Error')} ]: #{res}"
121
121
  else
122
122
  print "[ #{Painter.g('OK')} ]"
123
123
  end
@@ -222,9 +222,11 @@ class Array
222
222
  foldl(:+, &b) || identity
223
223
  end
224
224
 
225
- # fastering activesupport's method
226
- def group_by(&b)
227
- arrange(:group, &b)
225
+ if RUBY_VERSION < '2'
226
+ # fastering activesupport's method
227
+ def group_by(&b)
228
+ arrange(:group, &b)
229
+ end
228
230
  end
229
231
 
230
232
  end
@@ -73,5 +73,9 @@ end
73
73
  def truth_map
74
74
  map_values {|v| !!v}
75
75
  end
76
+
77
+ def key_value
78
+ to_a.first
79
+ end
76
80
 
77
81
  end
@@ -14,7 +14,8 @@ module RMTools
14
14
  alias :coallition :+
15
15
  alias :subtraction :-
16
16
  alias :intersection :&
17
- protected :union, :coallition, :subtraction, :intersection
17
+ # :& won't work this way if :intersection will be protected
18
+ protected :union, :coallition, :subtraction
18
19
 
19
20
  def |(ary)
20
21
  return ary.uniq if empty?
@@ -55,12 +56,17 @@ module RMTools
55
56
  [self - common, ary - common]
56
57
  end
57
58
 
58
- alias diff ^
59
+ alias :diff :^
59
60
 
60
61
  def intersects?(ary)
61
62
  (self & ary).any?
62
63
  end
63
64
  alias :x? :intersects?
65
+
66
+ def =~(ary)
67
+ (self - ary).empty?
68
+ end
69
+ alias :is_subset_of? :=~
64
70
  }
65
71
  super
66
72
  end
@@ -19,7 +19,7 @@ module RMTools
19
19
  ANSI_ENCODING = ANSI_LETTERS_UC[0].encoding
20
20
  end
21
21
 
22
- ENCODINGS_PATTERNS["WINDOWS-1251"] = /[#{ANSI_LETTERS_UC.concat(ANSI_YOYE).join}]/
22
+ ENCODINGS_PATTERNS["WINDOWS-1251"] = /[#{ANSI_LETTERS_UC.join}]/
23
23
  end
24
24
 
25
25
  if RUBY_VERSION < '2'
@@ -40,60 +40,60 @@ class String
40
40
 
41
41
  if RUBY_VERSION < '2'
42
42
 
43
- def utf(from_encoding='WINDOWS-1251//IGNORE')
44
- (ICONVS['UTF-8<'+from_encoding] ||= Iconv.new('UTF-8//IGNORE', from_encoding)).iconv(self)
43
+ def utf(from_encoding=encoding.name.upcase)
44
+ from_encoding += "//IGNORE"
45
+ (ICONVS["UTF-8<#{from_encoding}"] ||= Iconv.new('UTF-8//IGNORE', from_encoding)).iconv(self)
45
46
  end
46
47
 
47
- def ansi(from_encoding='UTF-8//IGNORE')
48
- (ICONVS['WINDOWS-1251<'+from_encoding] ||= Iconv.new('WINDOWS-1251//IGNORE', from_encoding)).iconv(self)
48
+ def ansi(from_encoding=encoding.name.upcase)
49
+ from_encoding += "//IGNORE"
50
+ (ICONVS["WINDOWS-1251<#{from_encoding}"] ||= Iconv.new('WINDOWS-1251//IGNORE', from_encoding)).iconv(self)
49
51
  end
50
52
 
51
- def utf!(from_encoding='WINDOWS-1251//IGNORE')
53
+ def utf!(from_encoding=encoding.name.upcase)
52
54
  replace utf from_encoding
53
55
  end
54
56
 
55
- def ansi!(from_encoding='UTF-8//IGNORE')
57
+ def ansi!(from_encoding=encoding.name.upcase)
56
58
  replace ansi from_encoding
57
59
  end
58
60
 
59
61
  else
60
62
 
61
- def utf(from_encoding='WINDOWS-1251')
63
+ def utf(from_encoding="UTF-16")
62
64
  encode(from_encoding, :invalid => :replace, :undef => :replace, :replace => "").encode("UTF-8", :invalid => :replace, :undef => :replace, :replace => "")
63
65
  end
64
66
 
65
- def ansi(from_encoding='UTF-8')
67
+ def ansi(from_encoding="UTF-16")
66
68
  encode(from_encoding, :invalid => :replace, :undef => :replace, :replace => "").encode("WINDOWS-1251", :invalid => :replace, :undef => :replace, :replace => "")
67
69
  end
68
70
 
69
- def utf!(from_encoding='WINDOWS-1251')
71
+ def utf!(from_encoding="UTF-16")
70
72
  replace utf from_encoding
71
73
  end
72
74
 
73
- def ansi!(from_encoding='UTF-8')
75
+ def ansi!(from_encoding="UTF-16")
74
76
  replace ansi from_encoding
75
77
  end
76
78
 
77
79
  end
78
80
 
79
81
 
80
- def valid_encoding?
82
+ def utf?
81
83
  begin
82
- self =~ /./
83
- rescue ArgumentError
84
+ encoding == Encoding::UTF_8 and self =~ /./u
85
+ rescue Encoding::CompatibilityError
84
86
  false
85
- else
86
- true
87
87
  end
88
88
  end
89
89
 
90
- def fix_encoding!
90
+ def find_compatible_encoding
91
91
  # UTF-8 by default
92
- return nil if valid_encoding?
92
+ return nil if utf?
93
93
  for enc, pattern in ENCODINGS_PATTERNS
94
94
  force_encoding(enc)
95
- if valid_encoding? and self =~ pattern
96
- return encoding.name.upcase
95
+ if self =~ pattern
96
+ return enc
97
97
  end
98
98
  end
99
99
  false
@@ -1,3 +1,3 @@
1
1
  module RMTools
2
- VERSION = '2.3.3'
2
+ VERSION = '2.3.4'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rmtools
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.3
4
+ version: 2.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sergey Baev