scripterator 1.3.2 → 1.4.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -1
- data/.travis.yml +6 -5
- data/CHANGELOG.md +5 -0
- data/Gemfile +2 -6
- data/Gemfile-rails-4.2.x +6 -0
- data/Gemfile-rails-5.0.x +6 -0
- data/Gemfile-rails-5.1.x +6 -0
- data/Gemfile-rails-5.2.x +6 -0
- data/lib/scripterator/version.rb +1 -1
- data/scripterator.gemspec +4 -4
- data/spec/runner_spec.rb +23 -23
- metadata +22 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f3a9bebcb93c93fd3590111a9de9c3b897b91fa72c8d92367324f20421c9a22a
|
4
|
+
data.tar.gz: e33762149d3e8755f922f3b42b2325bcdba9051468e8ecc02c7bb936ecd36e9b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 24c110bdc5b6641575155b7a97a73104bdab2b6a509518fbd4546377c5604f90044ecb52a6b5491274770801a7f4321655d5a1649c841c2a9fbe0245ba0f6a82
|
7
|
+
data.tar.gz: 569ad38184a922e01604b177fcc08b66c518864cbe0d78f3b5b29d043cb1b5eec0db4bd7c491367bafe16b3db4bfb1f2616b710b4296aaa33a69040ba8ac1dd9
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
language: ruby
|
2
2
|
rvm:
|
3
|
-
- 2.5.
|
3
|
+
- 2.5.8
|
4
4
|
script: bundle exec rspec
|
5
|
+
gemfile:
|
6
|
+
- Gemfile-rails-4.2.x
|
7
|
+
- Gemfile-rails-5.0.x
|
8
|
+
- Gemfile-rails-5.1.x
|
9
|
+
- Gemfile-rails-5.2.x
|
5
10
|
|
6
|
-
env:
|
7
|
-
- 'RAILS_VERSION=4.2'
|
8
|
-
- 'RAILS_VERSION=5.0'
|
9
|
-
- 'RAILS_VERSION=5.1'
|
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
data/Gemfile-rails-4.2.x
ADDED
data/Gemfile-rails-5.0.x
ADDED
data/Gemfile-rails-5.1.x
ADDED
data/Gemfile-rails-5.2.x
ADDED
data/lib/scripterator/version.rb
CHANGED
data/scripterator.gemspec
CHANGED
@@ -16,9 +16,9 @@ Gem::Specification.new do |gem|
|
|
16
16
|
gem.version = Scripterator::VERSION
|
17
17
|
|
18
18
|
gem.add_dependency 'activerecord', '< 6'
|
19
|
-
gem.add_dependency 'redis', '~>
|
19
|
+
gem.add_dependency 'redis', '~> 4.0'
|
20
20
|
|
21
|
-
gem.add_development_dependency 'fakeredis', '~> 0.
|
22
|
-
gem.add_development_dependency 'rspec', '~>
|
23
|
-
gem.add_development_dependency 'sqlite3'
|
21
|
+
gem.add_development_dependency 'fakeredis', '~> 0.8.0'
|
22
|
+
gem.add_development_dependency 'rspec', '~> 3.0'
|
23
|
+
gem.add_development_dependency 'sqlite3'
|
24
24
|
end
|
data/spec/runner_spec.rb
CHANGED
@@ -18,12 +18,12 @@ describe Scripterator::Runner do
|
|
18
18
|
|
19
19
|
shared_examples_for 'raises an error' do
|
20
20
|
specify do
|
21
|
-
expect { subject }.to raise_error
|
21
|
+
expect { subject }.to raise_error(StandardError)
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
25
|
it 'infers the model from the for_each block' do
|
26
|
-
runner.send(:model_finder).
|
26
|
+
expect(runner.send(:model_finder)).to eq Widget
|
27
27
|
end
|
28
28
|
|
29
29
|
context 'when a model block is defined' do
|
@@ -39,8 +39,8 @@ describe Scripterator::Runner do
|
|
39
39
|
let!(:widget2) { Widget.create(name: 'bla') }
|
40
40
|
|
41
41
|
it 'uses the given model finder code' do
|
42
|
-
Widget.
|
43
|
-
Widget.
|
42
|
+
expect(Widget).to receive(:transform_a_widget).once.with(widget2)
|
43
|
+
expect(Widget).not_to receive(:transform_a_widget).with(widget1)
|
44
44
|
subject
|
45
45
|
end
|
46
46
|
end
|
@@ -59,8 +59,8 @@ describe Scripterator::Runner do
|
|
59
59
|
|
60
60
|
it 'transforms each widget in the list' do
|
61
61
|
options[:id_list].each do |id|
|
62
|
-
runner.
|
63
|
-
arg1.id.
|
62
|
+
expect(runner).to receive(:transform_one_record) do |arg1|
|
63
|
+
expect(arg1.id).to eq id
|
64
64
|
end
|
65
65
|
end
|
66
66
|
subject
|
@@ -78,14 +78,14 @@ describe Scripterator::Runner do
|
|
78
78
|
it_behaves_like 'raises an error'
|
79
79
|
|
80
80
|
it 'does not run any other given blocks' do
|
81
|
-
Widget.
|
81
|
+
expect(Widget).to_not receive(:before_stuff)
|
82
82
|
subject rescue nil
|
83
83
|
end
|
84
84
|
end
|
85
85
|
|
86
86
|
context 'when there are no records for the specified model' do
|
87
87
|
it 'does not run the per-record block' do
|
88
|
-
Widget.
|
88
|
+
expect(Widget).to_not receive(:transform_a_widget)
|
89
89
|
subject
|
90
90
|
end
|
91
91
|
end
|
@@ -96,9 +96,9 @@ describe Scripterator::Runner do
|
|
96
96
|
before { num_widgets.times { Widget.create! } }
|
97
97
|
|
98
98
|
it 'runs the given script blocks' do
|
99
|
-
Widget.
|
100
|
-
Widget.
|
101
|
-
Widget.
|
99
|
+
expect(Widget).to receive(:before_stuff)
|
100
|
+
expect(Widget).to receive(:transform_a_widget).exactly(num_widgets).times
|
101
|
+
expect(Widget).to receive(:after_batch_stuff)
|
102
102
|
subject
|
103
103
|
end
|
104
104
|
|
@@ -107,10 +107,10 @@ describe Scripterator::Runner do
|
|
107
107
|
|
108
108
|
it 'marks only the checked IDs as checked' do
|
109
109
|
subject
|
110
|
-
Scripterator.already_run_for?(description, Widget.first.id).
|
111
|
-
Scripterator.checked_ids(description).
|
112
|
-
Scripterator.already_run_for?(description, Widget.last.id).
|
113
|
-
Scripterator.checked_ids(description).
|
110
|
+
expect(Scripterator.already_run_for?(description, Widget.first.id)).to be_falsey
|
111
|
+
expect(Scripterator.checked_ids(description)).to_not include Widget.first.id
|
112
|
+
expect(Scripterator.already_run_for?(description, Widget.last.id)).to be_truthy
|
113
|
+
expect(Scripterator.checked_ids(description)).to include Widget.last.id
|
114
114
|
end
|
115
115
|
end
|
116
116
|
|
@@ -118,20 +118,20 @@ describe Scripterator::Runner do
|
|
118
118
|
let(:checked_ids) { [Widget.first.id] }
|
119
119
|
|
120
120
|
before do
|
121
|
-
Scripterator.
|
122
|
-
Scripterator::ScriptRedis.
|
123
|
-
Scripterator::ScriptRedis.
|
121
|
+
allow(Scripterator).to receive(:checked_ids).and_return(checked_ids)
|
122
|
+
allow_any_instance_of(Scripterator::ScriptRedis).to receive(:already_run_for?).and_return(false)
|
123
|
+
allow_any_instance_of(Scripterator::ScriptRedis).to receive(:already_run_for?).with(Widget.first.id).and_return(true)
|
124
124
|
end
|
125
125
|
|
126
126
|
it 'only runs the per-record code for unchecked records' do
|
127
|
-
Widget.
|
127
|
+
expect(Widget).to receive(:transform_a_widget).exactly(num_widgets - 1).times
|
128
128
|
subject
|
129
129
|
end
|
130
130
|
end
|
131
131
|
|
132
132
|
context 'when the code for some records fails' do
|
133
133
|
before do
|
134
|
-
Widget.
|
134
|
+
allow(Widget).to receive(:transform_a_widget) do |widget|
|
135
135
|
raise 'Last widget expl0de' if widget.id == Widget.last.id
|
136
136
|
true
|
137
137
|
end
|
@@ -139,8 +139,8 @@ describe Scripterator::Runner do
|
|
139
139
|
|
140
140
|
it 'marks only the failed IDs as failed' do
|
141
141
|
subject
|
142
|
-
Scripterator.failed_ids(description).
|
143
|
-
Scripterator.failed_ids(description).
|
142
|
+
expect(Scripterator.failed_ids(description)).to_not include Widget.first.id
|
143
|
+
expect(Scripterator.failed_ids(description)).to include Widget.last.id
|
144
144
|
end
|
145
145
|
end
|
146
146
|
|
@@ -150,7 +150,7 @@ describe Scripterator::Runner do
|
|
150
150
|
|
151
151
|
it 'runs without Redis' do
|
152
152
|
expect { subject }.not_to raise_error
|
153
|
-
Scripterator.checked_ids(description).
|
153
|
+
expect(Scripterator.checked_ids(description)).to be_empty
|
154
154
|
end
|
155
155
|
end
|
156
156
|
end
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: scripterator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0.beta1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ted Dumitrescu
|
8
8
|
- Carl Furrow
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2021-04-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activerecord
|
@@ -31,56 +31,56 @@ dependencies:
|
|
31
31
|
requirements:
|
32
32
|
- - "~>"
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version: '
|
34
|
+
version: '4.0'
|
35
35
|
type: :runtime
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
39
|
- - "~>"
|
40
40
|
- !ruby/object:Gem::Version
|
41
|
-
version: '
|
41
|
+
version: '4.0'
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: fakeredis
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
46
|
- - "~>"
|
47
47
|
- !ruby/object:Gem::Version
|
48
|
-
version:
|
48
|
+
version: 0.8.0
|
49
49
|
type: :development
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
53
|
- - "~>"
|
54
54
|
- !ruby/object:Gem::Version
|
55
|
-
version:
|
55
|
+
version: 0.8.0
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
57
|
name: rspec
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
59
59
|
requirements:
|
60
60
|
- - "~>"
|
61
61
|
- !ruby/object:Gem::Version
|
62
|
-
version: '
|
62
|
+
version: '3.0'
|
63
63
|
type: :development
|
64
64
|
prerelease: false
|
65
65
|
version_requirements: !ruby/object:Gem::Requirement
|
66
66
|
requirements:
|
67
67
|
- - "~>"
|
68
68
|
- !ruby/object:Gem::Version
|
69
|
-
version: '
|
69
|
+
version: '3.0'
|
70
70
|
- !ruby/object:Gem::Dependency
|
71
71
|
name: sqlite3
|
72
72
|
requirement: !ruby/object:Gem::Requirement
|
73
73
|
requirements:
|
74
|
-
- - "
|
74
|
+
- - ">="
|
75
75
|
- !ruby/object:Gem::Version
|
76
|
-
version:
|
76
|
+
version: '0'
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
79
|
version_requirements: !ruby/object:Gem::Requirement
|
80
80
|
requirements:
|
81
|
-
- - "
|
81
|
+
- - ">="
|
82
82
|
- !ruby/object:Gem::Version
|
83
|
-
version:
|
83
|
+
version: '0'
|
84
84
|
description: Script iterator for ActiveRecord models
|
85
85
|
email:
|
86
86
|
- ted@lumoslabs.com
|
@@ -94,6 +94,10 @@ files:
|
|
94
94
|
- ".travis.yml"
|
95
95
|
- CHANGELOG.md
|
96
96
|
- Gemfile
|
97
|
+
- Gemfile-rails-4.2.x
|
98
|
+
- Gemfile-rails-5.0.x
|
99
|
+
- Gemfile-rails-5.1.x
|
100
|
+
- Gemfile-rails-5.2.x
|
97
101
|
- LICENSE
|
98
102
|
- README.md
|
99
103
|
- lib/scripterator.rb
|
@@ -108,7 +112,7 @@ files:
|
|
108
112
|
homepage: http://lumosity.com
|
109
113
|
licenses: []
|
110
114
|
metadata: {}
|
111
|
-
post_install_message:
|
115
|
+
post_install_message:
|
112
116
|
rdoc_options: []
|
113
117
|
require_paths:
|
114
118
|
- lib
|
@@ -119,13 +123,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
119
123
|
version: '0'
|
120
124
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
121
125
|
requirements:
|
122
|
-
- - "
|
126
|
+
- - ">"
|
123
127
|
- !ruby/object:Gem::Version
|
124
|
-
version:
|
128
|
+
version: 1.3.1
|
125
129
|
requirements: []
|
126
|
-
|
127
|
-
|
128
|
-
signing_key:
|
130
|
+
rubygems_version: 3.1.2
|
131
|
+
signing_key:
|
129
132
|
specification_version: 4
|
130
133
|
summary: DSL for running operations on each of a set of models
|
131
134
|
test_files:
|