rmtools 2.4.3 → 2.4.4

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: ba8d5846022ccf031d60062e4060c98a7990d4c0
4
- data.tar.gz: 72f136789d589bdc3f874f9f732805f98c1cf906
3
+ metadata.gz: 8fad210fdab682c8f871310b8a186b5f3185f0a2
4
+ data.tar.gz: 69dd15ad213beba220be5461f9675971f21eef01
5
5
  SHA512:
6
- metadata.gz: 0c5e969ef2e81d460003af525aea0e0db301141a4549dd05260d32586d480b811c17de0945a9e94c09d11128e34f4e675618b49ec240de1fb1fb77d01754a39e
7
- data.tar.gz: a3e5360e8e737bbf00671e91d68a6bf3b4efbf8bff0f4f1b791c45ecba5aa752ac4ef863651e36d56960f0205890f07658954dd36a906572ab870547dd7e981c
6
+ metadata.gz: 20b229499d85c0adc1e6c59b498b363aa9e9ab0d12829001dcaacbac888e36624a61dd1dc6eee77cf5b9687c6525490083f10e0eacd478b96143b7dc302e4e35
7
+ data.tar.gz: 7f177261217d69c58addc6daddac61a59cca8df0dc1f5360a01f7929b3bbe83bb34b739b4f6bb95e05ff7cea816217383795018b6922a5b73fa23ec33782aeb8
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
  module ActiveRecord
3
3
 
4
- def self.establish_connection_with config
4
+ def self.establish_connection_with config='config/database.yml'
5
5
  c = case config
6
6
  when String
7
7
  c = if config.inline
@@ -14,6 +14,12 @@ module ActiveRecord
14
14
  when IO then YAML.load config
15
15
  else config
16
16
  end
17
+ if defined? Rails
18
+ env = Rails.env.to_s
19
+ if c.include? env
20
+ c = c[env]
21
+ end
22
+ end
17
23
  Base.establish_connection(c) rescue(false)
18
24
  end
19
25
 
@@ -23,7 +23,7 @@ class Array
23
23
  end
24
24
  return opts if return_hash
25
25
  if defaults == :flags
26
- defauls = [:flags]
26
+ defaults = [:flags]
27
27
  end
28
28
  if defaults.last == :flags
29
29
  defaults.pop
@@ -10,7 +10,7 @@ module RMTools
10
10
  class RMLogger
11
11
  __init__
12
12
  attr_accessor :mute_info, :mute_error, :mute_warn, :mute_log, :mute_debug
13
- attr_reader :default_format
13
+ attr_reader :default_format, :log_level
14
14
 
15
15
  Modes = [:debug, :log, :info, :warn, :error]
16
16
  NOPRINT = 8
@@ -38,6 +38,8 @@ module RMTools
38
38
  self.log_level = 'WARN'
39
39
  elsif ENV['SILENT']
40
40
  self.log_level = 'ERROR'
41
+ else
42
+ self.log_level = 'INFO'
41
43
  end
42
44
  end
43
45
 
@@ -165,7 +167,7 @@ module RMTools
165
167
  opts[:mute] |= NOLOG if !cfg.out
166
168
  opts[:mute] |= NOPRINT if !cfg.print
167
169
  return if block_given? && (text = yield).nil?
168
- _print(:error, text, opts[:mute], cfg._caller && (@current_caller || caller)[opts[:caller].to_i], bind, cfg)
170
+ _print(:error, text, opts[:mute], cfg._caller && (@current_caller || caller)[(opts[:caller] || opts[:caller_offset]).to_i], bind, cfg)
169
171
  end
170
172
  end
171
173
 
@@ -176,7 +178,7 @@ module RMTools
176
178
  opts[:mute] |= NOLOG if !cfg.out
177
179
  opts[:mute] |= NOPRINT if !cfg.print
178
180
  return if block_given? && (text = yield).nil?
179
- _print(:warn, text, opts[:mute], cfg._caller && (@current_caller || caller)[opts[:caller].to_i], bind, cfg)
181
+ _print(:warn, text, opts[:mute], cfg._caller && (@current_caller || caller)[(opts[:caller] || opts[:caller_offset]).to_i], bind, cfg)
180
182
  end
181
183
  end
182
184
 
@@ -185,9 +187,9 @@ module RMTools
185
187
  if (cfg.out or cfg.print) && !@mute_log
186
188
  text, bind, opts = args.get_opts [!block_given? && args[0].kinda(Hash) ? args[0] : "\b\b ", nil], :mute => 0
187
189
  opts[:mute] |= NOLOG if !cfg.out
188
- opts[:mute] |= NOPRINT if !cfg.print
190
+ opts[:mute] |= NOPRINT if !(cfg.print && !@mute_debug)
189
191
  return if block_given? && (text = yield).nil?
190
- _print(:log, text, opts[:mute], cfg._caller && (@current_caller || caller)[opts[:caller].to_i], bind, cfg)
192
+ _print(:log, text, opts[:mute], cfg._caller && (@current_caller || caller)[(opts[:caller] || opts[:caller_offset]).to_i], bind, cfg)
191
193
  end
192
194
  end
193
195
 
@@ -198,7 +200,7 @@ module RMTools
198
200
  opts[:mute] |= NOLOG if !(cfg.out && cfg.out_all)
199
201
  opts[:mute] |= NOPRINT if !cfg.print
200
202
  return if block_given? && (text = yield).nil?
201
- _print(:info, text, opts[:mute], cfg._caller && (@current_caller || caller)[opts[:caller].to_i], bind, cfg)
203
+ _print(:info, text, opts[:mute], cfg._caller && (@current_caller || caller)[(opts[:caller] || opts[:caller_offset]).to_i], bind, cfg)
202
204
  end
203
205
  end
204
206
 
@@ -209,7 +211,7 @@ module RMTools
209
211
  opts[:mute] |= NOLOG if !(cfg.out && cfg.out_all)
210
212
  opts[:mute] |= NOPRINT if !cfg.print
211
213
  return if block_given? && (text = yield).nil?
212
- _print(:debug, text, opts[:mute], cfg._caller && (@current_caller || caller)[opts[:caller].to_i], bind, cfg)
214
+ _print(:debug, text, opts[:mute], cfg._caller && (@current_caller || caller)[(opts[:caller] || opts[:caller_offset]).to_i], bind, cfg)
213
215
  end
214
216
  end
215
217
 
@@ -227,6 +229,7 @@ module RMTools
227
229
  unless level.is_a? Integer
228
230
  level = ::Logger.const_get(level.to_s.upcase)
229
231
  end
232
+ @log_level = level
230
233
  self.debug = level < 1
231
234
  self.info = level < 2
232
235
  self.log = level < 2
@@ -57,10 +57,14 @@ class String
57
57
  end
58
58
 
59
59
  private
60
+ # Если последний (в итераторе в #split_to_blocks
61
+ # результат #split_by_syntax окажется слишком велик,
62
+ # он всё равно не будет включен в результат #split_to_blocks.
60
63
  def split_by_syntax(str, maxlen, buflen=0)
61
64
  len, add = maxlen - buflen, nil
62
- [/[^.?!…]+\z/, /[^;]+\z/, /[^,:]+\z/, /[^\n]+/, /\S+\z/, /[^。、]+z/].each {|t|
63
- if !(add = str[t]) or add.size <= len
65
+ [/[^.?!…]+\z/, /[^;]+\z/, /[^,:]+\z/, /[^\n]+/, /\S+\z/, /[^。、]+\z/].each {|t|
66
+ add = str[t]
67
+ if !add or add.size <= len
64
68
  return add
65
69
  end
66
70
  }
@@ -84,14 +88,14 @@ class String
84
88
  blocks = []
85
89
  term_re = /[^#{terminator}]+\z/ if terminator and terminator != :syntax
86
90
  words, buf = split(opts[:strips] ? ' ' : / /), nil
87
- while !words.empty? or !buf.empty?
91
+ while !words.empty? or (buf and !buf.empty?)
88
92
  if terminator and !blocks.empty?
89
93
  buf_add = if terminator == :syntax
90
94
  split_by_syntax blocks[-1], maxlen, buf.size
91
95
  else
92
96
  blocks[-1][term_re]
93
97
  end
94
- if !buf_add.empty?
98
+ if buf_add and !buf_add.empty?
95
99
  if buf_add == blocks[-1]
96
100
  blocks.pop
97
101
  else
@@ -159,16 +163,16 @@ class String
159
163
  if RUBY_VERSION < '1.9'
160
164
  def split_to_lines(maxlen, *opts)
161
165
  raise Exception, "Can't break text with maxlen = #{maxlen}" if maxlen < 1
162
- opts = opts.fetch_opts([:flags], :strips => true).merge(:strict_overhead => false)
166
+ opts = opts.fetch_opts(:flags, :strips => true)[0].merge(:strict_overhead => false)
163
167
  opts[:charsize] ||= a[0].cyr? ? 2 : 1
164
168
  split("\n").map {|string| string.strip.split_to_blocks(maxlen*opts[:charsize], opts)}.flatten*"\n"
165
169
  end
166
170
  else
167
171
  def split_to_lines(maxlen, *opts)
168
172
  raise Exception, "Can't break text with maxlen = #{maxlen}" if maxlen < 1
169
- opts = opts.fetch_opts([:flags], :strips => true).merge(:strict_overhead => false)
173
+ opts = opts.fetch_opts(:flags, :strips => true)[0].merge(:strict_overhead => false)
170
174
  split("\n").map {|string| string.strip.split_to_blocks(maxlen, opts)}.flatten*"\n"
171
175
  end
172
176
  end
173
177
 
174
- end
178
+ end
@@ -1,3 +1,3 @@
1
1
  module RMTools
2
- VERSION = '2.4.3'
2
+ VERSION = '2.4.4'
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.3
4
+ version: 2.4.4
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-13 00:00:00.000000000 Z
11
+ date: 2014-10-22 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
@@ -19,7 +19,7 @@ extensions:
19
19
  - ext/extconf.rb
20
20
  extra_rdoc_files: []
21
21
  files:
22
- - ".gitignore"
22
+ - .gitignore
23
23
  - Gemfile
24
24
  - LICENSE
25
25
  - README.md
@@ -128,19 +128,20 @@ require_paths:
128
128
  - lib
129
129
  required_ruby_version: !ruby/object:Gem::Requirement
130
130
  requirements:
131
- - - ">="
131
+ - - '>='
132
132
  - !ruby/object:Gem::Version
133
133
  version: '0'
134
134
  required_rubygems_version: !ruby/object:Gem::Requirement
135
135
  requirements:
136
- - - ">="
136
+ - - '>='
137
137
  - !ruby/object:Gem::Version
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: