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 +4 -4
- data/lib/dekiru/data_migration_operator.rb +2 -1
- data/lib/dekiru/version.rb +1 -1
- data/spec/dekiru/data_migration_operator_spec.rb +31 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '0293842d02fc6417c18e53f353a842aec6bb0b41425a00afecae9fb6a11c7848'
|
4
|
+
data.tar.gz: 28f30a08869901b5f0621fba78a8d259bafe8e0c4630925baa5606b604a9840c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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)
|
data/lib/dekiru/version.rb
CHANGED
@@ -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.
|
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:
|
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
|