dekiru 0.2.1 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fcd978fde22a3be50e588396b36e5956217c4614b955a1ab45c017425861662c
4
- data.tar.gz: 2e302850fe5fb912bc02e7d1114dae4e7b904094d21fca641ec26e1d1dc84ee5
3
+ metadata.gz: '0293842d02fc6417c18e53f353a842aec6bb0b41425a00afecae9fb6a11c7848'
4
+ data.tar.gz: 28f30a08869901b5f0621fba78a8d259bafe8e0c4630925baa5606b604a9840c
5
5
  SHA512:
6
- metadata.gz: 4a7749d34c73ca1ce3463f78de7d7b50c86b0ce4c508061e2c522ccba9e6501ec46ee318909619b171f386e630b5701dd43d291b5fd07e6e62824423231d348e
7
- data.tar.gz: 2206deba2fa7e617f5c1ddb3d386574270edab4551679e2eb978dfa67e76547e3a42aea0dccce1ddfe626645b4207b966c323c73af79fe116f96ef8ccfcddcbd
6
+ metadata.gz: fdb142b9f203cb3e47a4b2305a2b67f1b0c649f36710bef29c9cbdf34be4d55cf2c8475f59bc370281e8d7e90a1603d2b2a47bb8ea3adb80c190328f115945ed
7
+ data.tar.gz: f92cf2b65aacb0da17014580b537cbf9eac9fa190b3f3c5032590cccfc46b01f8bdea6fac453f3015a4899beef9c4bd25a27c72a907006c297bf258353435fcb
@@ -48,10 +48,11 @@ module Dekiru
48
48
  end
49
49
 
50
50
  def find_each_with_progress(target_scope, options = {})
51
+ total = options.delete(:total)
51
52
  opt = {
52
53
  format: '%a |%b>>%i| %p%% %t',
53
54
  }.merge(options).merge(
54
- total: target_scope.count,
55
+ total: total || target_scope.count,
55
56
  output: stream
56
57
  )
57
58
  pb = ::ProgressBar.create(opt)
@@ -1,3 +1,3 @@
1
1
  module Dekiru
2
- VERSION = '0.2.1'
2
+ VERSION = '0.2.2'
3
3
  end
@@ -127,5 +127,36 @@ describe Dekiru::DataMigrationOperator do
127
127
  expect(operator.stream.out).to include('Finished successfully:')
128
128
  expect(operator.stream.out).to include('Total time:')
129
129
  end
130
+
131
+ it 'total をオプションで渡すことができる' do
132
+ class Dekiru::DummyRecord
133
+ def self.count
134
+ raise "won't call"
135
+ end
136
+
137
+ def self.find_each
138
+ yield 99
139
+ end
140
+ end
141
+
142
+ allow(STDIN).to receive(:gets) do
143
+ "yes\n"
144
+ end
145
+
146
+ sum = 0
147
+ operator.execute do
148
+ find_each_with_progress(Dekiru::DummyRecord, title: 'pass total as option', total: 1) do |num|
149
+ sum += num
150
+ end
151
+ end
152
+
153
+ expect(sum).to eq(99)
154
+ expect(operator.result).to eq(true)
155
+ expect(operator.error).to eq(nil)
156
+ expect(operator.stream.out).to include('Are you sure to commit?')
157
+ expect(operator.stream.out).to include('pass total as option:')
158
+ expect(operator.stream.out).to include('Finished successfully:')
159
+ expect(operator.stream.out).to include('Total time:')
160
+ end
130
161
  end
131
162
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dekiru
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Akihiro Matsumura
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-11-02 00:00:00.000000000 Z
11
+ date: 2022-01-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: http_accept_language