rmtools 2.4.5 → 2.4.6
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 +4 -4
- data/lib/rmtools/active_record/base.rb +24 -18
- data/lib/rmtools/console/highlight.rb +16 -5
- data/lib/rmtools/enumerable/array_iterators.rb +1 -1
- data/lib/rmtools/lang/ansi.rb +5 -5
- data/lib/rmtools/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 462fa51db69a84fe8f257bbaac98df036d08a1e4
|
4
|
+
data.tar.gz: 3f10da60daaebaa0a70ee9c878a9f9bf41c5813c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4f23db7cd425392c4581341527d95870cda4e633029127b88cf1c5daf5ad15b15b6c4c8ca53c30ff7fe8602131e37f4167812dcf4fe361e723ea82c3ff16b835
|
7
|
+
data.tar.gz: 1914047c1a63963c127b0b1d710867d37108f780ea0110c9f843d1115bb25706db2b2282b540e9bc4b0a1e0e2ae3f4109888976427ac8107fc67f637382cae5b
|
@@ -1,26 +1,32 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
module ActiveRecord
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
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
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
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
|
-
|
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)
|
7
|
-
|
8
|
-
|
9
|
-
|
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
|
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
|
data/lib/rmtools/lang/ansi.rb
CHANGED
@@ -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
|
data/lib/rmtools/version.rb
CHANGED
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.
|
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-
|
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.
|
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:
|