rbbt-util 5.26.141 → 5.26.142

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
  SHA256:
3
- metadata.gz: 58bced40c483ab601f0e5102ec48f4a0f437e50f119612ef37ce1e2e5ab4860e
4
- data.tar.gz: 5b66741f2e524751eb19ca0ae7d138b3654cf9ba01a417a5b84a91e4e0ab67ce
3
+ metadata.gz: fddb36a8c680b822b0282e4de2e9742b892376fb2b10d9af36be70aa5ec466f9
4
+ data.tar.gz: c22a9b145937dc65edf98f7e6e5c97bb7441a73fed8df39437a402193df0b080
5
5
  SHA512:
6
- metadata.gz: e9f57582295005dbee6cff4057431d2906d5502b2c92928abb2cb20afb541bcc6db8d5306bb46c7e4154056f03a0eed831802b37b96262460820c993449c8e9f
7
- data.tar.gz: 7b190f88dd9b9da0be937855f3c68a23069af19b3bb34f814f885941acbb6be25ea402813153f5559b56cb1e238b9af07961f5e153ea5a91e09b7458a6e1c64d
6
+ metadata.gz: 8ed646c095003525fb0b91b8e81ebcfadcd51b730f3f273452565234e57f428ee6b93b3c8e83406673b70d8ed62e28deffc4c8300e30c0f460c4409fc07801de
7
+ data.tar.gz: 312a01dc5c7351b0838eebf93d0741f101fcea01760832a05ec47456b3d1d4501310cccd86f92aefb8b5e74d5ed3d2523c637601d6f5421d710c1d6dee0ff853
@@ -69,6 +69,7 @@ module Rbbt::Config
69
69
  priorities = {}
70
70
  entries.each do |tokens, value|
71
71
  best_prio = nil
72
+ tokens = [tokens] unless Array === tokens
72
73
  tokens.each do |tok|
73
74
  tok, prio = token_priority tok
74
75
  best_prio = prio if best_prio.nil? or best_prio > prio
@@ -120,7 +121,10 @@ module Rbbt::Config
120
121
  end
121
122
 
122
123
  def self.with_config
123
- saved_config = CACHE.dup
124
+ saved_config = {}
125
+ CACHE.each do |k,v|
126
+ saved_config[k] = v.dup
127
+ end
124
128
  saved_got_keys = GOT_KEYS.dup
125
129
  begin
126
130
  yield
@@ -2,6 +2,16 @@ require 'rbbt/util/log'
2
2
  require 'rbbt/util/log/progress/util'
3
3
  require 'rbbt/util/log/progress/report'
4
4
  module Log
5
+
6
+ def self.no_bar=(value)
7
+ @@no_bar = value
8
+ end
9
+
10
+ def self.no_bar
11
+ @@no_bar = false unless defined?(@@no_bar)
12
+ @@no_bar || ENV["RBBT_NO_PROGRESS"] == "true"
13
+ end
14
+
5
15
  class ProgressBar
6
16
 
7
17
  attr_accessor :max, :ticks, :frequency, :depth, :desc, :file, :bytes
@@ -34,7 +44,7 @@ module Log
34
44
  end
35
45
 
36
46
  def tick(step = 1)
37
- return if ENV["RBBT_NO_PROGRESS"] == "true"
47
+ return if Log.no_bar
38
48
  @ticks += step
39
49
 
40
50
  time = Time.now
@@ -1,7 +1,7 @@
1
1
  module Log
2
2
  class ProgressBar
3
3
  def print(io, str)
4
- return if ENV["RBBT_NO_PROGRESS"] == "true"
4
+ return if Log.no_bar
5
5
  LOG_MUTEX.synchronize do
6
6
  STDERR.print str
7
7
  Log.logfile.puts str unless Log.logfile.nil?
@@ -14,5 +14,21 @@ class TestConfig < Test::Unit::TestCase
14
14
  def test_prio
15
15
  assert_equal 5, Rbbt::Config.get(:cpus, :slow, :test)
16
16
  end
17
+
18
+ def test_with_config
19
+ Rbbt::Config.add_entry 'key', 'valueA', 'token'
20
+ assert_equal "valueA", Rbbt::Config.get('key', 'token')
21
+ assert_equal "default", Rbbt::Config.get('key2', 'token', :default => 'default')
22
+
23
+ Rbbt::Config.with_config do
24
+ Rbbt::Config.add_entry 'key', 'valueB', 'token'
25
+ Rbbt::Config.add_entry 'key2', 'valueB2', 'token'
26
+ assert_equal "valueB", Rbbt::Config.get('key', 'token')
27
+ assert_equal "valueB2", Rbbt::Config.get('key2', 'token', :default => 'default')
28
+ end
29
+
30
+ assert_equal "valueA", Rbbt::Config.get('key', 'token')
31
+ assert_equal "default", Rbbt::Config.get('key2', 'token', :default => 'default')
32
+ end
17
33
  end
18
34
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rbbt-util
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.26.141
4
+ version: 5.26.142
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miguel Vazquez
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-02-13 00:00:00.000000000 Z
11
+ date: 2020-02-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake