tqdm 0.4.0 → 0.4.1

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: 72b63925baf593f87124eff5deaba635425475a900dd4432d07c772026488b45
4
- data.tar.gz: 036ac2f161ef3fca07351818d0de75ec0a4c932af831f73370d26c318213a5f1
3
+ metadata.gz: cfebca388873f5a48c60d396d7111a339f488e6b8dd5dd7f178616164bd5bcd0
4
+ data.tar.gz: 79f8f7213f5f63b69f8293bae71163922ed29801975d187cf6a097385ca1b0fe
5
5
  SHA512:
6
- metadata.gz: ca9b6cec37e773998ab099f6ab57e5c1d16f6fde371d82000d7a8750276ea5b3a018760ec0703a6b02830808d6292c4b387dd2beb733221b3b19f1d20bcd3504
7
- data.tar.gz: c8e3a86ac26c82998a792b1b361fd040953a6078397a69c7d4a09d95641b45b61a04ea5288768a0662169f8e557ec6adc47f1bdd7fdfb66bc02e0027f7d6fa03
6
+ metadata.gz: 1e9f372b270f9c914e8d3f5206105a702c25373d2f7a56aec7488468f2c593dfc3077ffa4b0d0cd19ce73f99c3d15b39728a82ce3157150277c8a50268624fc3
7
+ data.tar.gz: 80ebc6f10d9f2cad69ee96f210cd8bb8c48667fb537c2d2616e679e0c34cd9afc867df5787e30cf191ebbce7e2ce477d0202ebba912db6a56113dccecca67ad8
@@ -0,0 +1,38 @@
1
+ # This workflow uses actions that are not certified by GitHub.
2
+ # They are provided by a third-party and are governed by
3
+ # separate terms of service, privacy policy, and support
4
+ # documentation.
5
+ # This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
6
+ # For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
7
+
8
+ name: Ruby-CI
9
+
10
+ on:
11
+ push:
12
+ branches: [ "master" ]
13
+ pull_request:
14
+ branches: [ "master" ]
15
+
16
+ permissions:
17
+ contents: read
18
+
19
+ jobs:
20
+ test:
21
+
22
+ runs-on: ubuntu-latest
23
+ strategy:
24
+ matrix:
25
+ ruby-version: ['1.9', '2.0', '2.6', '2.7', '3.0', '3.1']
26
+
27
+ steps:
28
+ - uses: actions/checkout@v3
29
+ - name: Set up Ruby
30
+ # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
31
+ # change this to (see https://github.com/ruby/setup-ruby#versioning):
32
+ # uses: ruby/setup-ruby@v1
33
+ uses: ruby/setup-ruby@ee2113536afb7f793eed4ce60e8d3b26db912da4 # v1.127.0
34
+ with:
35
+ ruby-version: ${{ matrix.ruby-version }}
36
+ bundler-cache: true # runs 'bundle install' and caches installed gems automatically
37
+ - name: Run tests
38
+ run: bundle exec rake spec
data/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  # tqdm-ruby
2
- [![Build Status](https://travis-ci.org/powerpak/tqdm-ruby.svg?branch=master)](https://travis-ci.org/powerpak/tqdm-ruby) [![Gem Version](https://badge.fury.io/rb/tqdm.svg)](https://badge.fury.io/rb/tqdm)
2
+ [![Build Status](https://github.com/powerpak/tqdm-ruby/actions/workflows/ruby-ci.yml/badge.svg?branch=master&event=push)](https://github.com/powerpak/tqdm-ruby/actions/workflows/ruby-ci.yml?query=event%3Apush+branch%3Amaster) [![Gem Version](https://badge.fury.io/rb/tqdm.svg?version=0.4.0)](https://badge.fury.io/rb/tqdm)
3
3
 
4
4
  tqdm-ruby allows you to add a progress indicator to your loops with minimal effort.
5
5
 
@@ -1,6 +1,11 @@
1
1
  require 'tqdm/printer'
2
2
 
3
+ CLONE_UNFROZEN_SUPPORTED = RUBY_VERSION.split('.')[0..1].join('.').to_f >= 2.4
4
+
3
5
  module Tqdm
6
+
7
+ class DecoratorError < StandardError
8
+ end
4
9
 
5
10
  # Decorates the #each method of an `Enumerable` by wrapping it so that each
6
11
  # iteration produces a pretty progress bar printed to the console or a file handle.
@@ -112,16 +117,23 @@ module Tqdm
112
117
  end
113
118
 
114
119
  # Uses progressively more invasive techniques to return an unfrozen copy of @enumerable
115
- # Significantly, for some classes like Sequel::Dataset, both #clone and #dup re-freeze
116
- # the object, so we have to drop back to Object#clone
117
120
  def enumerable_unfrozen
118
- unfrozen = enumerable.clone(freeze: false)
119
- return unfrozen unless unfrozen.frozen?
120
- unfrozen = enumerable.dup
121
- return unfrozen unless unfrozen.frozen?
121
+ to_unfreeze = CLONE_UNFROZEN_SUPPORTED ? enumerable.clone(freeze: false) : enumerable.clone
122
+ return to_unfreeze unless to_unfreeze.frozen?
123
+ to_unfreeze = to_unfreeze.dup
124
+ return to_unfreeze unless to_unfreeze.frozen?
125
+
126
+ # Significantly, for some classes like Sequel::Dataset, both #clone and #dup re-freeze
127
+ # the object before returning it, so we have to drop back to Object#clone to avoid this
122
128
  @force_refreeze = true
123
- unfrozen = Object.instance_method(:clone).bind(enumerable).call(freeze: false)
124
- unfrozen
129
+ if CLONE_UNFROZEN_SUPPORTED
130
+ to_unfreeze = Object.instance_method(:clone).bind(enumerable).call(freeze: false)
131
+ end
132
+ if Object.instance_method(:frozen?).bind(to_unfreeze).call
133
+ raise DecoratorError.new("could not create an unfrozen clone")
134
+ end
135
+
136
+ to_unfreeze
125
137
  end
126
138
 
127
139
  def total!
data/lib/tqdm/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module Tqdm
2
2
  # The version of this module and gem by the same name.
3
- VERSION = "0.4.0"
3
+ VERSION = "0.4.1"
4
4
  end
data/spec/sequel_spec.rb CHANGED
@@ -40,12 +40,14 @@ describe 'When enumerating over a Sequel dataset' do
40
40
  end
41
41
 
42
42
  it 'returns a re-frozen object' do
43
- enhanced = timecop_loop(database[:items])
43
+ enhanced = nil
44
+ with_stderr { enhanced = timecop_loop(database[:items]) }
44
45
  expect(enhanced.frozen?).to be_truthy
45
46
  end
46
47
 
47
48
  it 'returns an object inheriting from Sequel::Dataset' do
48
- enhanced = timecop_loop(database[:items])
49
+ enhanced = nil
50
+ with_stderr { enhanced = timecop_loop(database[:items]) }
49
51
  expect(enhanced).to be_kind_of(Sequel::Dataset)
50
52
  end
51
53
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tqdm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Theodore Pak
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-12-31 00:00:00.000000000 Z
11
+ date: 2023-01-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -102,9 +102,9 @@ executables: []
102
102
  extensions: []
103
103
  extra_rdoc_files: []
104
104
  files:
105
+ - ".github/workflows/ruby-ci.yml"
105
106
  - ".gitignore"
106
107
  - ".rspec"
107
- - ".travis.yml"
108
108
  - ".yardopts"
109
109
  - Gemfile
110
110
  - LICENSE.txt
data/.travis.yml DELETED
@@ -1,12 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - "1.9.2"
4
- - "1.9.3"
5
- - "2.0.0"
6
- - "2.1.8"
7
- - "2.2.4"
8
- - "2.6.5"
9
- - "2.7.2"
10
- - "3.0.5"
11
- - "3.1.3"
12
- - rbx