rmtools 2.4.5 → 2.4.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: af0448d332967cee8b0d80fee93699332a70f074
4
- data.tar.gz: 3a3ff579353f252542fb0351aa77b27cd4870107
3
+ metadata.gz: 462fa51db69a84fe8f257bbaac98df036d08a1e4
4
+ data.tar.gz: 3f10da60daaebaa0a70ee9c878a9f9bf41c5813c
5
5
  SHA512:
6
- metadata.gz: be0323cc9ff20bda36ee83e85f2565748b31f27514479ca44b3127888bce9c87edf39bfed5cbcc1f085ab298c2367a80cd2bfc37cf94a4d44f375078eb1dc3d5
7
- data.tar.gz: 51dcd870acae5b9cb23390c6fdc044d6857e58219bb8843542d01e7e4da067c17ace344ea302f9c627411a488b7f0f9b3b73a3984dfe5bc7e6d2d3d2eec51756
6
+ metadata.gz: 4f23db7cd425392c4581341527d95870cda4e633029127b88cf1c5daf5ad15b15b6c4c8ca53c30ff7fe8602131e37f4167812dcf4fe361e723ea82c3ff16b835
7
+ data.tar.gz: 1914047c1a63963c127b0b1d710867d37108f780ea0110c9f843d1115bb25706db2b2282b540e9bc4b0a1e0e2ae3f4109888976427ac8107fc67f637382cae5b
@@ -1,26 +1,32 @@
1
1
  # encoding: utf-8
2
2
  module ActiveRecord
3
-
4
- def self.establish_connection_with config='config/database.yml'
5
- c = case config
6
- when String
7
- c = if config.inline
8
- if c = RMTools.read(config) then c
9
- else return; nil
3
+
4
+ class << self
5
+
6
+ def establish_connection_with config='config/database.yml'
7
+ c = case config
8
+ when String
9
+ c = if config.inline
10
+ if c = RMTools.read(config) then c
11
+ else return; nil
12
+ end
13
+ else config
10
14
  end
11
- else config
12
- end
13
- YAML.load c
14
- when IO then YAML.load config
15
- else config
16
- end
17
- if defined? Rails
18
- env = Rails.env.to_s
19
- if c.include? env
20
- c = c[env]
15
+ YAML.load c
16
+ when IO then YAML.load config
17
+ else config
18
+ end
19
+ if defined? Rails
20
+ env = Rails.env.to_s
21
+ if c.include? env
22
+ c = c[env]
23
+ end
21
24
  end
25
+ Base.establish_connection(c) rescue(false)
22
26
  end
23
- Base.establish_connection(c) rescue(false)
27
+
28
+ alias establish_connection establish_connection_with
29
+
24
30
  end
25
31
 
26
32
  class Base
@@ -3,12 +3,23 @@ RMTools::require 'console/coloring'
3
3
 
4
4
  class String
5
5
 
6
- def find_hl(pat, range=1000) idx = case pat
7
- when String; index pat
8
- when Regexp; self =~ pat
9
- else raise TypeError, "pattern must be string or regexp"
6
+ def find_hl(pat, range=1000)
7
+ idx = case pat
8
+ when String; index pat
9
+ when Regexp; self =~ pat
10
+ else raise TypeError, "pattern must be string or regexp"
10
11
  end
11
- puts Painter.ghl(self[[idx-range, 0].max, 2*range], pat)
12
+ puts self[[idx-range, 0].max, 2*range].ghl(pat)
13
+ idx
14
+ end
15
+
16
+ def find_all_hl(pat, range=1000)
17
+ target = Regexp(
18
+ ".{#{range}}#{pat.is(Regexp) ? pat.source : pat}.{#{range}}",
19
+ pat.is(Regexp) ? pat.options : 0)
20
+ matches = scan(target)
21
+ puts matches.ghls(pat)
22
+ matches.size
12
23
  end
13
24
 
14
25
  end
@@ -250,7 +250,7 @@ private
250
250
  iterator = iterator.to_sym
251
251
 
252
252
  case iterator
253
- when :sum, :sort_along_by
253
+ when :sum, :sort_along_by, :order_by
254
254
  # sum_posts_ids([], :all) =>
255
255
  # sum([]) {|e| e.posts_ids(:all)}
256
256
  Array.class_eval %{
@@ -76,20 +76,20 @@ class String
76
76
  replace ansi from_encoding
77
77
  end
78
78
 
79
- def is_utf!(utf='UTF-8')
80
- force_encoding utf
81
- end
82
-
83
79
  end
84
80
 
85
81
 
86
82
  def utf?
87
83
  begin
88
84
  encoding == Encoding::UTF_8 and self =~ /./u
89
- rescue Encoding::CompatibilityError
85
+ rescue Encoding::CompatibilityError, ArgumentError
90
86
  false
91
87
  end
92
88
  end
89
+
90
+ def is_utf!(utf='UTF-8')
91
+ force_encoding utf
92
+ end
93
93
 
94
94
  def find_compatible_encoding
95
95
  # UTF-8 by default
@@ -1,3 +1,3 @@
1
1
  module RMTools
2
- VERSION = '2.4.5'
2
+ VERSION = '2.4.6'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rmtools
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.5
4
+ version: 2.4.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sergey Baev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-26 00:00:00.000000000 Z
11
+ date: 2014-11-07 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: RMTools is a collection of helpers for debug, text/array/file processing
14
14
  and simply easing a coding process
@@ -138,9 +138,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
138
138
  version: '0'
139
139
  requirements: []
140
140
  rubyforge_project:
141
- rubygems_version: 2.2.2
141
+ rubygems_version: 2.4.1
142
142
  signing_key:
143
143
  specification_version: 4
144
144
  summary: Collection of helpers for debug, text/array/file processing and simply easing
145
145
  a coding process
146
146
  test_files: []
147
+ has_rdoc: