jobler 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/db/migrate/20170203161045_add_locale_to_jobs.rb +5 -0
- data/lib/jobler/base_jobler.rb +1 -1
- data/lib/jobler/job_runner.rb +20 -5
- data/lib/jobler/job_scheduler.rb +6 -1
- data/lib/jobler/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3623c18e11b1420eb4930ddd2f899e42d814c6c5
|
4
|
+
data.tar.gz: fa3ddd60982e1d53745983cce238b4960c49fcba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ed1449d9d221793711b4e65f8d2d875b2f554974aeccc8d464e5184852a65a0a6a2149e4f6665d5704c22ce97b026f02c8756846c0c031e8304fdf052336f848
|
7
|
+
data.tar.gz: 50e7709172176db511bf87badb9973e0c966560516a52183324eec3441df1cb84331999ebe8d31ea7dc3e3154686e0f87fc764fb02d4522b823716161abec162
|
data/lib/jobler/base_jobler.rb
CHANGED
data/lib/jobler/job_runner.rb
CHANGED
@@ -2,15 +2,30 @@ class Jobler::JobRunner < ActiveJob::Base
|
|
2
2
|
queue_as :jobler
|
3
3
|
|
4
4
|
def perform(job_id)
|
5
|
-
job = Jobler::Job.find(job_id)
|
6
|
-
job.update_attributes!(started_at: Time.zone.now, state: "started")
|
5
|
+
@job = Jobler::Job.find(job_id)
|
6
|
+
@job.update_attributes!(started_at: Time.zone.now, state: "started")
|
7
7
|
|
8
8
|
begin
|
9
|
-
|
10
|
-
|
9
|
+
with_locale do
|
10
|
+
@job.jobler.execute!
|
11
|
+
end
|
12
|
+
|
13
|
+
@job.update_attributes!(ended_at: Time.zone.now, progress: 1.0, state: "completed")
|
11
14
|
rescue Exception => e # rubocop:disable Lint/RescueException
|
12
|
-
job.update_attributes!(ended_at: Time.zone.now, state: "error")
|
15
|
+
@job.update_attributes!(ended_at: Time.zone.now, state: "error")
|
13
16
|
raise e
|
14
17
|
end
|
15
18
|
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def with_locale
|
23
|
+
if @job.locale?
|
24
|
+
I18n.with_locale(@job.locale) do
|
25
|
+
yield
|
26
|
+
end
|
27
|
+
else
|
28
|
+
yield
|
29
|
+
end
|
30
|
+
end
|
16
31
|
end
|
data/lib/jobler/job_scheduler.rb
CHANGED
@@ -11,10 +11,15 @@ class Jobler::JobScheduler
|
|
11
11
|
def initialize(args)
|
12
12
|
@jobler_type = args.fetch(:jobler_type)
|
13
13
|
@job_args = args[:job_args]
|
14
|
+
@locale = args[:locale]
|
14
15
|
end
|
15
16
|
|
16
17
|
def create_job
|
17
|
-
@job = Jobler::Job.create!(
|
18
|
+
@job = Jobler::Job.create!(
|
19
|
+
jobler_type: @jobler_type,
|
20
|
+
locale: @locale.presence || I18n.locale,
|
21
|
+
parameters: YAML.dump(@job_args)
|
22
|
+
)
|
18
23
|
end
|
19
24
|
|
20
25
|
def perform_job_later
|
data/lib/jobler/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jobler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kaspernj
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-02-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -49,6 +49,7 @@ files:
|
|
49
49
|
- config/routes.rb
|
50
50
|
- db/migrate/20170130220604_create_jobs.rb
|
51
51
|
- db/migrate/20170130220734_create_jobler_results.rb
|
52
|
+
- db/migrate/20170203161045_add_locale_to_jobs.rb
|
52
53
|
- lib/jobler.rb
|
53
54
|
- lib/jobler/base_jobler.rb
|
54
55
|
- lib/jobler/engine.rb
|