fortschritt 0.2.2 → 0.2.3

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: 8f425d2b3104d6a678b40d606fe087044c5a78d2
4
- data.tar.gz: 032e1ee974bae5f15d7845d2113c271601ac23df
3
+ metadata.gz: 9a92442302e3a29a76a4b7ad91023207829331f0
4
+ data.tar.gz: ef3b5987065f98e24da36364644dc8d023a929f4
5
5
  SHA512:
6
- metadata.gz: 3ef7622fbc5a9e891bfa74e5f889ceec6aa94b7e73574272cfaaabd5394b8bdaa4b5c70af6bff254ba0fdc7f3e9b62648d886394e47b7ace2f3451d2fea6bc37
7
- data.tar.gz: 3b6802dbdbffe8a07e7bd83afe7d95e7160d1dac728cad3fe2fa43d17a3d15ac002198178db26957fad9b0a8c0e9d44c8a3417099937a5a6d3a64ee670d90574
6
+ metadata.gz: 5d49b3d43256832e3484f636ad5395b6c3da842c054af1d5da03f64190cca85fe0edf5f2c09dd2c24bbaeee3f1fc11ad39d121a965e38ae5a88c6684438121dd
7
+ data.tar.gz: 2545182e4607938fd1e252faca16b23cc8d5222669f615231c362d6a62a67ffb19125a7f94d627d7d8e6cf84f53ab1e3d192cb99c7fdd8d846e84fa4c4eb8ec0
data/README.md CHANGED
@@ -32,6 +32,18 @@ end
32
32
  # will print something like this: 1616/145096 → 00:13:21 → ETA 2016-02-04 18:11:50
33
33
  ```
34
34
 
35
+ ### Silent
36
+
37
+ If no output is required or wanted invoke `with_fortschritt` with the `silent: true` option
38
+
39
+ ```ruby
40
+ User.all.with_fortschritt(silent: true).find_each do |user|
41
+ user.fortschritt.valid?
42
+ end
43
+
44
+ # won't output any progress
45
+ ```
46
+
35
47
  ## Contributing
36
48
 
37
49
  Bug reports and pull requests are welcome on GitHub at https://github.com/xijo/fortschritt.
data/lib/fortschritt.rb CHANGED
@@ -8,8 +8,8 @@ module Fortschritt
8
8
  @meter and @meter.increment
9
9
  end
10
10
 
11
- def self.init(total)
12
- @meter = Fortschritt::Meter.new(total)
11
+ def self.init(total, opts = {})
12
+ @meter = Fortschritt::Meter.new(total, opts)
13
13
  end
14
14
 
15
15
  def self.printer
@@ -1,6 +1,6 @@
1
1
  module Enumerable
2
- def with_fortschritt
3
- Fortschritt.init(size)
2
+ def with_fortschritt(opts = {})
3
+ Fortschritt.init(size, opts)
4
4
  self
5
5
  end
6
6
  end
@@ -17,8 +17,8 @@ if defined?(Rails)
17
17
 
18
18
  extend ActiveSupport::Concern
19
19
 
20
- def with_fortschritt
21
- Fortschritt.init(count)
20
+ def with_fortschritt(opts = {})
21
+ Fortschritt.init(count, opts)
22
22
  self
23
23
  end
24
24
  end
@@ -1,13 +1,14 @@
1
1
  module Fortschritt
2
2
  class Meter
3
- attr_accessor :total, :done, :updated_at, :average_seconds
3
+ attr_accessor :total, :done, :updated_at, :average_seconds, :silent
4
4
 
5
- def initialize(total)
5
+ def initialize(total, silent: false)
6
6
  @total = total
7
7
  @done = 0
8
8
  @updated_at = Time.now
9
9
  @average_seconds = 0
10
10
  @started_at = Time.now
11
+ @silent = silent
11
12
  end
12
13
 
13
14
  def increment
@@ -16,7 +17,7 @@ module Fortschritt
16
17
  @average_seconds = calculate_average_seconds(elapsed_seconds)
17
18
  @updated_at = @_now
18
19
  @done += 1
19
- print!
20
+ print! unless @silent
20
21
  end
21
22
 
22
23
  def completed?
@@ -1,3 +1,3 @@
1
1
  module Fortschritt
2
- VERSION = '0.2.2'
2
+ VERSION = '0.2.3'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fortschritt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Johannes Opper
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-02-10 00:00:00.000000000 Z
11
+ date: 2016-12-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -92,9 +92,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
92
92
  version: '0'
93
93
  requirements: []
94
94
  rubyforge_project:
95
- rubygems_version: 2.5.1
95
+ rubygems_version: 2.5.2
96
96
  signing_key:
97
97
  specification_version: 4
98
98
  summary: non-fancy progress
99
99
  test_files: []
100
- has_rdoc: