massive 0.1.0 → 0.1.1

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,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NDgzMGYwNDUzYmUyZTIzYTYwNmJiMzU1MzdkYTY1MGY5OWUzYmYwOQ==
4
+ NGVlNDc0ZmZjOWYzNDljMTdhMGViMTZmNWM4ZWRkMmZiOTIyOTBiNQ==
5
5
  data.tar.gz: !binary |-
6
- ODUxZDVlMjA3YWVmZjE0MjEzNTdhODU5ODRiNWU2ODg0YTBhZTE3YQ==
6
+ NzlmZGUwMDQ1MzM0NWNmNGU5NzUyYTU3ODAyNGNmOTZkMDAyMDRlMA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- OTE3ODEyZjc5NDVjYWI4MWVmMDk1YzkwYjFkYTJjZGM1YWU1ZmY0YjJiYzY4
10
- MTZhZjU0ZGU0MGUwYTUzZWNjOWE4YmMyMDE5MzEzNTE4MGM4YjM1MzFhODEy
11
- YzIyNTA1M2RmOWI4MDk1NTAyZjRkOTMyNjQ4ZjM0Mzk5NmFlNGU=
9
+ NzdjYzI4OTNiZTZiMDIxMmQ3OWRlN2JhNGIwZTlkNmI3YTE0YzNkYTBmMWMy
10
+ ODZkMjJlNjlmOGIxYjQ2ZjQ4ODYzMDg2YzYwY2ZkYjM4NDc5NDdkY2QxMjAx
11
+ N2UyMGJiYTg5Nzg5MDBjZGY5Y2Y1YzQ4NDM1OGYyYmU1YjU2OGM=
12
12
  data.tar.gz: !binary |-
13
- NTM0ZGQ5MDc0NGYwYjdmYTYwYjdlNWZiOWJhODFjZThlNjY3ZWJjZWEzMmI3
14
- YWYzN2RkMDlkODllNzczNzMzZDdjMjk0ZGUwOGE5NTJhMmI4MTRhY2E0ZTNk
15
- YWU0YWQ5YjQ3NjE2MDQxNDk3MTcyMTkwOWM0NjU0OTUwMThkNWI=
13
+ Yzk3NmI5ZWY2MTM3NjNkODIzOTNhYWMyYWU5MGMzM2QzNjY4MDc0ZTcxNzFk
14
+ Nzk0OGM0OWFhZWMxY2UzZTlhMGIxNmU4MjQyMzVmZDMyOGFmNGQ3MDVkMDBm
15
+ NWRmZGZlNGI3NDY1ZGZmOGIyYzYwZDNkZmRjMWJmNmVjNmMwZjI=
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- massive (0.1.0)
4
+ massive (0.1.1)
5
5
  active_model_serializers
6
6
  file_processor (= 0.2.0)
7
7
  mongoid (~> 3.1.x)
@@ -35,6 +35,10 @@ module Massive
35
35
  save
36
36
  end
37
37
 
38
+ def has_info?
39
+ [:encoding, :col_sep, :total_count].all? { |field| send(field).present? }
40
+ end
41
+
38
42
  def url
39
43
  read_attribute(:url).presence || authenticated_url
40
44
  end
@@ -32,6 +32,10 @@ module Massive
32
32
  steps.not_completed.none?
33
33
  end
34
34
 
35
+ def failed?
36
+ steps.any? { |step| step.failed_at? }
37
+ end
38
+
35
39
  def cancelled?
36
40
  cancelled_at? || redis.exists(cancelled_key)
37
41
  end
@@ -54,6 +54,7 @@ module Massive
54
54
 
55
55
  def enqueue
56
56
  Resque.enqueue(self.class, process.id.to_s, id.to_s)
57
+ notify(:enqueued)
57
58
  end
58
59
 
59
60
  def start!
@@ -1,3 +1,3 @@
1
1
  module Massive
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -206,4 +206,26 @@ describe Massive::File do
206
206
  end
207
207
  end
208
208
  end
209
+
210
+ describe "#has_info?" do
211
+ context "when file already has gathered info" do
212
+ before do
213
+ file.encoding = 'utf-8'
214
+ file.col_sep = '|'
215
+ file.total_count = 3000
216
+ end
217
+
218
+ its(:has_info?) { should be_true }
219
+ end
220
+
221
+ context "when file has not gathered info" do
222
+ before do
223
+ file.encoding = nil
224
+ file.col_sep = nil
225
+ file.total_count = nil
226
+ end
227
+
228
+ its(:has_info?) { should be_false }
229
+ end
230
+ end
209
231
  end
@@ -9,6 +9,12 @@ describe Massive::Process do
9
9
  let!(:second_step) { process.steps.build }
10
10
  let!(:third_step) { process.steps.build }
11
11
 
12
+ before do
13
+ first_step.stub(:reload).and_return(first_step)
14
+ second_step.stub(:reload).and_return(second_step)
15
+ third_step.stub(:reload).and_return(third_step)
16
+ end
17
+
12
18
  context "and none of them are completed" do
13
19
  it "enqueues the first step" do
14
20
  first_step.should_receive(:enqueue)
@@ -173,7 +179,7 @@ describe Massive::Process do
173
179
  its(:completed?) { should be_false }
174
180
  end
175
181
 
176
- context "when therere are no incompleted steps" do
182
+ context "when there are no incompleted steps" do
177
183
  before do
178
184
  step_1.update_attributes(finished_at: Time.now, failed_at: nil)
179
185
  step_2.update_attributes(finished_at: Time.now, failed_at: nil)
@@ -183,6 +189,23 @@ describe Massive::Process do
183
189
  end
184
190
  end
185
191
 
192
+ describe "#failed?" do
193
+ let!(:step_1) { process.steps.build }
194
+ let!(:step_2) { process.steps.build }
195
+
196
+ before { process.save }
197
+
198
+ context "when the steps not failed" do
199
+ its(:failed?) { should be_false }
200
+ end
201
+
202
+ context "when any step failed" do
203
+ before { step_2.update_attributes(failed_at: Time.now) }
204
+
205
+ its(:failed?) { should be_true }
206
+ end
207
+ end
208
+
186
209
  describe "#cancel" do
187
210
  let!(:now) do
188
211
  Time.now.tap do |now|
@@ -77,7 +77,10 @@ shared_examples_for Massive::Status do
77
77
 
78
78
  describe "#enqueued?" do
79
79
  context "when model is enqueued" do
80
- before { model.enqueue }
80
+ before do
81
+ model.stub(:reload).and_return(model)
82
+ model.enqueue
83
+ end
81
84
 
82
85
  its(:enqueued?) { should be_true }
83
86
  end
@@ -38,11 +38,18 @@ describe Massive::Step do
38
38
  end
39
39
 
40
40
  describe "#enqueue" do
41
+ before { step.stub(:reload).and_return(step) }
42
+
41
43
  it "enqueues itself, passing ids as strings" do
42
44
  Resque.should_receive(:enqueue).with(step.class, step.process.id.to_s, step.id.to_s)
43
45
  step.enqueue
44
46
  end
45
47
 
48
+ it "sends a :enqueued notification" do
49
+ step.should_receive(:notify).with(:enqueued)
50
+ step.enqueue
51
+ end
52
+
46
53
  context "when a subclass redefines calculate_total_count" do
47
54
  subject(:step) { CustomStep.new }
48
55
  before { process.steps << step }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: massive
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vicente Mundim
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-03 00:00:00.000000000 Z
11
+ date: 2014-05-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: resque