silent_progress_bar 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +3 -0
- data/.travis.yml +18 -0
- data/Gemfile +2 -0
- data/Gemfile.lock +151 -0
- data/Rakefile +7 -0
- data/Readme.md +43 -0
- data/lib/silent_progress_bar.rb +40 -0
- data/silent_progress_bar.gemspec +23 -0
- data/spec/lib/silent_progress_bar_spec.rb +41 -0
- data/spec/spec_helper.rb +11 -0
- metadata +145 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 1c00e16f481a13b63691ea0e12f3765e1f8c69a7
|
4
|
+
data.tar.gz: fa31505f7f86feb31e51e136471669ce4daae4f5
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e69c20eb746e9f2f5c8ff3f515ce77771e5d12e7fe926356c609e0dfa9d89e8a7e06ff08040d7dd06b75ac783661423035a4bc2e1514ed9fa132759cee8411ae
|
7
|
+
data.tar.gz: 26752c473df2121c6c4c2009b160397c85d619a7aace77be4305ee1afe87ed4f22d15db36d52e34706f108757c97072243727c11a61274dab536ae5dd22ef026
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
language: ruby
|
2
|
+
rvm:
|
3
|
+
- 2.5.1
|
4
|
+
branches:
|
5
|
+
except:
|
6
|
+
- "/^v[0-9]+\\.[0-9]+\\.[0-9]+(?:-.*)?/"
|
7
|
+
notifications:
|
8
|
+
email:
|
9
|
+
on_success: change
|
10
|
+
on_failure: always
|
11
|
+
before_script:
|
12
|
+
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
|
13
|
+
- chmod +x ./cc-test-reporter
|
14
|
+
- ./cc-test-reporter before-build
|
15
|
+
script:
|
16
|
+
- bundle exec rspec
|
17
|
+
after_script:
|
18
|
+
- ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,151 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
silent_progress_bar (0.0.1)
|
5
|
+
rails
|
6
|
+
ruby-progressbar
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
actioncable (5.2.1)
|
12
|
+
actionpack (= 5.2.1)
|
13
|
+
nio4r (~> 2.0)
|
14
|
+
websocket-driver (>= 0.6.1)
|
15
|
+
actionmailer (5.2.1)
|
16
|
+
actionpack (= 5.2.1)
|
17
|
+
actionview (= 5.2.1)
|
18
|
+
activejob (= 5.2.1)
|
19
|
+
mail (~> 2.5, >= 2.5.4)
|
20
|
+
rails-dom-testing (~> 2.0)
|
21
|
+
actionpack (5.2.1)
|
22
|
+
actionview (= 5.2.1)
|
23
|
+
activesupport (= 5.2.1)
|
24
|
+
rack (~> 2.0)
|
25
|
+
rack-test (>= 0.6.3)
|
26
|
+
rails-dom-testing (~> 2.0)
|
27
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
28
|
+
actionview (5.2.1)
|
29
|
+
activesupport (= 5.2.1)
|
30
|
+
builder (~> 3.1)
|
31
|
+
erubi (~> 1.4)
|
32
|
+
rails-dom-testing (~> 2.0)
|
33
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.3)
|
34
|
+
activejob (5.2.1)
|
35
|
+
activesupport (= 5.2.1)
|
36
|
+
globalid (>= 0.3.6)
|
37
|
+
activemodel (5.2.1)
|
38
|
+
activesupport (= 5.2.1)
|
39
|
+
activerecord (5.2.1)
|
40
|
+
activemodel (= 5.2.1)
|
41
|
+
activesupport (= 5.2.1)
|
42
|
+
arel (>= 9.0)
|
43
|
+
activestorage (5.2.1)
|
44
|
+
actionpack (= 5.2.1)
|
45
|
+
activerecord (= 5.2.1)
|
46
|
+
marcel (~> 0.3.1)
|
47
|
+
activesupport (5.2.1)
|
48
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
49
|
+
i18n (>= 0.7, < 2)
|
50
|
+
minitest (~> 5.1)
|
51
|
+
tzinfo (~> 1.1)
|
52
|
+
arel (9.0.0)
|
53
|
+
builder (3.2.3)
|
54
|
+
concurrent-ruby (1.0.5)
|
55
|
+
crass (1.0.4)
|
56
|
+
diff-lcs (1.3)
|
57
|
+
docile (1.3.1)
|
58
|
+
erubi (1.7.1)
|
59
|
+
globalid (0.4.1)
|
60
|
+
activesupport (>= 4.2.0)
|
61
|
+
i18n (1.1.1)
|
62
|
+
concurrent-ruby (~> 1.0)
|
63
|
+
json (2.1.0)
|
64
|
+
loofah (2.2.2)
|
65
|
+
crass (~> 1.0.2)
|
66
|
+
nokogiri (>= 1.5.9)
|
67
|
+
mail (2.7.1)
|
68
|
+
mini_mime (>= 0.1.1)
|
69
|
+
marcel (0.3.3)
|
70
|
+
mimemagic (~> 0.3.2)
|
71
|
+
method_source (0.9.0)
|
72
|
+
mimemagic (0.3.2)
|
73
|
+
mini_mime (1.0.1)
|
74
|
+
mini_portile2 (2.3.0)
|
75
|
+
minitest (5.11.3)
|
76
|
+
nio4r (2.3.1)
|
77
|
+
nokogiri (1.8.5)
|
78
|
+
mini_portile2 (~> 2.3.0)
|
79
|
+
rack (2.0.5)
|
80
|
+
rack-test (1.1.0)
|
81
|
+
rack (>= 1.0, < 3)
|
82
|
+
rails (5.2.1)
|
83
|
+
actioncable (= 5.2.1)
|
84
|
+
actionmailer (= 5.2.1)
|
85
|
+
actionpack (= 5.2.1)
|
86
|
+
actionview (= 5.2.1)
|
87
|
+
activejob (= 5.2.1)
|
88
|
+
activemodel (= 5.2.1)
|
89
|
+
activerecord (= 5.2.1)
|
90
|
+
activestorage (= 5.2.1)
|
91
|
+
activesupport (= 5.2.1)
|
92
|
+
bundler (>= 1.3.0)
|
93
|
+
railties (= 5.2.1)
|
94
|
+
sprockets-rails (>= 2.0.0)
|
95
|
+
rails-dom-testing (2.0.3)
|
96
|
+
activesupport (>= 4.2.0)
|
97
|
+
nokogiri (>= 1.6)
|
98
|
+
rails-html-sanitizer (1.0.4)
|
99
|
+
loofah (~> 2.2, >= 2.2.2)
|
100
|
+
railties (5.2.1)
|
101
|
+
actionpack (= 5.2.1)
|
102
|
+
activesupport (= 5.2.1)
|
103
|
+
method_source
|
104
|
+
rake (>= 0.8.7)
|
105
|
+
thor (>= 0.19.0, < 2.0)
|
106
|
+
rake (12.3.1)
|
107
|
+
rspec (3.8.0)
|
108
|
+
rspec-core (~> 3.8.0)
|
109
|
+
rspec-expectations (~> 3.8.0)
|
110
|
+
rspec-mocks (~> 3.8.0)
|
111
|
+
rspec-core (3.8.0)
|
112
|
+
rspec-support (~> 3.8.0)
|
113
|
+
rspec-expectations (3.8.2)
|
114
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
115
|
+
rspec-support (~> 3.8.0)
|
116
|
+
rspec-mocks (3.8.0)
|
117
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
118
|
+
rspec-support (~> 3.8.0)
|
119
|
+
rspec-support (3.8.0)
|
120
|
+
ruby-progressbar (1.10.0)
|
121
|
+
simplecov (0.16.1)
|
122
|
+
docile (~> 1.1)
|
123
|
+
json (>= 1.8, < 3)
|
124
|
+
simplecov-html (~> 0.10.0)
|
125
|
+
simplecov-html (0.10.2)
|
126
|
+
sprockets (3.7.2)
|
127
|
+
concurrent-ruby (~> 1.0)
|
128
|
+
rack (> 1, < 3)
|
129
|
+
sprockets-rails (3.2.1)
|
130
|
+
actionpack (>= 4.0)
|
131
|
+
activesupport (>= 4.0)
|
132
|
+
sprockets (>= 3.0.0)
|
133
|
+
thor (0.20.0)
|
134
|
+
thread_safe (0.3.6)
|
135
|
+
tzinfo (1.2.5)
|
136
|
+
thread_safe (~> 0.1)
|
137
|
+
websocket-driver (0.7.0)
|
138
|
+
websocket-extensions (>= 0.1.0)
|
139
|
+
websocket-extensions (0.1.3)
|
140
|
+
|
141
|
+
PLATFORMS
|
142
|
+
ruby
|
143
|
+
|
144
|
+
DEPENDENCIES
|
145
|
+
rake (~> 12.2, >= 12.2.1)
|
146
|
+
rspec (~> 3.7, >= 3.7.0)
|
147
|
+
silent_progress_bar!
|
148
|
+
simplecov (~> 0.15, >= 0.15.1)
|
149
|
+
|
150
|
+
BUNDLED WITH
|
151
|
+
1.16.4
|
data/Rakefile
ADDED
data/Readme.md
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
# Silent Progress Bar
|
2
|
+
|
3
|
+
[![Gem Version](https://img.shields.io/gem/v/silent_progress_bar.svg)](https://rubygems.org/gems/silent_progress_bar)
|
4
|
+
[![Build Status](https://travis-ci.org/jfiander/silent-progress-bar.svg)](https://travis-ci.org/jfiander/silent-progress-bar)
|
5
|
+
[![Maintainability](https://api.codeclimate.com/v1/badges/4c8be06f11872994f2c7/maintainability)](https://codeclimate.com/github/jfiander/silent-progress-bar/maintainability)
|
6
|
+
[![Test Coverage](https://api.codeclimate.com/v1/badges/4c8be06f11872994f2c7/test_coverage)](https://codeclimate.com/github/jfiander/silent-progress-bar/test_coverage)
|
7
|
+
|
8
|
+
A simple exponential backoff retry wrapper.
|
9
|
+
|
10
|
+
## Installation
|
11
|
+
|
12
|
+
Add this to your Gemfile:
|
13
|
+
|
14
|
+
```ruby
|
15
|
+
gem 'silent_progress_bar'
|
16
|
+
```
|
17
|
+
|
18
|
+
Or manually install the gem:
|
19
|
+
|
20
|
+
```sh
|
21
|
+
gem install silent_progress_bar
|
22
|
+
```
|
23
|
+
|
24
|
+
## Usage
|
25
|
+
|
26
|
+
Create a progress bar, then pass a block into it.
|
27
|
+
|
28
|
+
You must pass the block an argument to allow incrementing the progress bar.
|
29
|
+
|
30
|
+
```ruby
|
31
|
+
progress = SilentProgressBar.new(count: 10)
|
32
|
+
progress.run do |bar|
|
33
|
+
10.times { sleep 0.2; bar.increment }
|
34
|
+
end
|
35
|
+
```
|
36
|
+
|
37
|
+
You can also call `run` directly on the class.
|
38
|
+
|
39
|
+
```ruby
|
40
|
+
SilentProgressBar.run(count: 10) do |bar|
|
41
|
+
10.times { sleep 0.2; bar.increment }
|
42
|
+
end
|
43
|
+
```
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'active_record'
|
4
|
+
require 'ruby-progressbar'
|
5
|
+
|
6
|
+
# Suppresses output and displays a progress bar
|
7
|
+
class SilentProgressBar
|
8
|
+
attr_reader :progress_bar
|
9
|
+
|
10
|
+
def initialize(title: 'Progress', count: 1)
|
11
|
+
@title = title
|
12
|
+
@count = count
|
13
|
+
@progress_bar = create_progress_bar
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.run(title: 'Progress', count: 1)
|
17
|
+
bar = new(title: title, count: count)
|
18
|
+
|
19
|
+
bar.run { yield(bar.progress_bar) }
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.no_logging
|
23
|
+
old_logger = ActiveRecord::Base.logger
|
24
|
+
ActiveRecord::Base.logger = nil
|
25
|
+
result = yield
|
26
|
+
ActiveRecord::Base.logger = old_logger
|
27
|
+
result
|
28
|
+
end
|
29
|
+
|
30
|
+
def run
|
31
|
+
self.class.no_logging { yield(progress_bar) }
|
32
|
+
end
|
33
|
+
|
34
|
+
def create_progress_bar
|
35
|
+
ProgressBar.create(
|
36
|
+
title: @title, starting_at: 0, format: "%a %b\u{15E7}%i %p%% %t",
|
37
|
+
total: @count, progress_mark: ' ', remainder_mark: "\u{FF65}"
|
38
|
+
)
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = 'silent_progress_bar'
|
3
|
+
s.version = '0.0.1'
|
4
|
+
s.date = '2018-10-26'
|
5
|
+
s.summary = 'Silenced Progress Bar'
|
6
|
+
s.description = 'A progress bar that suppresses ActiveRecord logging.'
|
7
|
+
s.homepage = 'http://rubygems.org/gems/silent_progress_bar'
|
8
|
+
s.license = 'GPL-3.0'
|
9
|
+
s.authors = ['Julian Fiander']
|
10
|
+
s.email = 'julian@fiander.one'
|
11
|
+
s.require_paths = %w[lib spec doc]
|
12
|
+
s.files = `git ls-files`.split("\n")
|
13
|
+
s.test_files = `git ls-files -- spec/*`.split("\n")
|
14
|
+
|
15
|
+
s.required_ruby_version = '~> 2.2'
|
16
|
+
|
17
|
+
s.add_runtime_dependency 'rails'
|
18
|
+
s.add_runtime_dependency 'ruby-progressbar'
|
19
|
+
|
20
|
+
s.add_development_dependency 'rake', '~> 12.2', '>= 12.2.1'
|
21
|
+
s.add_development_dependency 'rspec', '~> 3.7', '>= 3.7.0'
|
22
|
+
s.add_development_dependency 'simplecov', '~> 0.15', '>= 0.15.1'
|
23
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
RSpec.describe SilentProgressBar do
|
6
|
+
it 'should output a progress bar from .run' do
|
7
|
+
expect do
|
8
|
+
SilentProgressBar.run(title: 'Testing 1', count: 5) do |bar|
|
9
|
+
5.times { bar.increment }
|
10
|
+
end
|
11
|
+
end.to output(/Testing 1/).to_stdout_from_any_process
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'should output a progress bar from #run' do
|
15
|
+
expect do
|
16
|
+
bar = SilentProgressBar.new(title: 'Testing 2', count: 5)
|
17
|
+
|
18
|
+
bar.run do |b|
|
19
|
+
5.times { b.increment }
|
20
|
+
end
|
21
|
+
end.to output(/Testing 2/).to_stdout_from_any_process
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'should return the final value' do
|
25
|
+
progress = SilentProgressBar.run(title: 'Testing 3', count: 5) do |b|
|
26
|
+
5.times { b.increment }
|
27
|
+
:result
|
28
|
+
end
|
29
|
+
|
30
|
+
expect(progress).to eql(:result)
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'should not output extra logging' do
|
34
|
+
expect do
|
35
|
+
SilentProgressBar.run(title: 'Testing 3', count: 5) do |b|
|
36
|
+
puts 'Bad log'
|
37
|
+
5.times { b.increment }
|
38
|
+
end
|
39
|
+
end.not_to output('Bad log').to_stdout_from_any_process
|
40
|
+
end
|
41
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,145 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: silent_progress_bar
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Julian Fiander
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-10-26 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: ruby-progressbar
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '12.2'
|
48
|
+
- - ">="
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: 12.2.1
|
51
|
+
type: :development
|
52
|
+
prerelease: false
|
53
|
+
version_requirements: !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - "~>"
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: '12.2'
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: 12.2.1
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: rspec
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - "~>"
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '3.7'
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: 3.7.0
|
71
|
+
type: :development
|
72
|
+
prerelease: false
|
73
|
+
version_requirements: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - "~>"
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '3.7'
|
78
|
+
- - ">="
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: 3.7.0
|
81
|
+
- !ruby/object:Gem::Dependency
|
82
|
+
name: simplecov
|
83
|
+
requirement: !ruby/object:Gem::Requirement
|
84
|
+
requirements:
|
85
|
+
- - "~>"
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0.15'
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: 0.15.1
|
91
|
+
type: :development
|
92
|
+
prerelease: false
|
93
|
+
version_requirements: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - "~>"
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '0.15'
|
98
|
+
- - ">="
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: 0.15.1
|
101
|
+
description: A progress bar that suppresses ActiveRecord logging.
|
102
|
+
email: julian@fiander.one
|
103
|
+
executables: []
|
104
|
+
extensions: []
|
105
|
+
extra_rdoc_files: []
|
106
|
+
files:
|
107
|
+
- ".gitignore"
|
108
|
+
- ".travis.yml"
|
109
|
+
- Gemfile
|
110
|
+
- Gemfile.lock
|
111
|
+
- Rakefile
|
112
|
+
- Readme.md
|
113
|
+
- lib/silent_progress_bar.rb
|
114
|
+
- silent_progress_bar.gemspec
|
115
|
+
- spec/lib/silent_progress_bar_spec.rb
|
116
|
+
- spec/spec_helper.rb
|
117
|
+
homepage: http://rubygems.org/gems/silent_progress_bar
|
118
|
+
licenses:
|
119
|
+
- GPL-3.0
|
120
|
+
metadata: {}
|
121
|
+
post_install_message:
|
122
|
+
rdoc_options: []
|
123
|
+
require_paths:
|
124
|
+
- lib
|
125
|
+
- spec
|
126
|
+
- doc
|
127
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '2.2'
|
132
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
133
|
+
requirements:
|
134
|
+
- - ">="
|
135
|
+
- !ruby/object:Gem::Version
|
136
|
+
version: '0'
|
137
|
+
requirements: []
|
138
|
+
rubyforge_project:
|
139
|
+
rubygems_version: 2.6.11
|
140
|
+
signing_key:
|
141
|
+
specification_version: 4
|
142
|
+
summary: Silenced Progress Bar
|
143
|
+
test_files:
|
144
|
+
- spec/lib/silent_progress_bar_spec.rb
|
145
|
+
- spec/spec_helper.rb
|