dronejob 1.0.5 → 1.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/dronejob/base.rb +1 -0
- data/lib/dronejob/command.rb +15 -2
- data/lib/dronejob/loader.rb +3 -1
- data/lib/dronejob/modules/workspace.rb +0 -38
- data/lib/dronejob/one_off.rb +77 -0
- data/lib/dronejob/version.rb +1 -1
- data/lib/dronejob/workspace_file.rb +0 -1
- data/lib/dronejob.rb +1 -0
- 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: 5f5df12fd8e611f67180596502d7779bfdf2256c
|
4
|
+
data.tar.gz: e6c626d975c8f4041628715085e6c7bef1ae72c4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c1772f75b8d08eb2b3689a344fe188f6385b9249661291453979aed9eb2ff22d3e2e65069e9c0a3efca6e0d51c80369548d00f05c750256e5041049944f2f730
|
7
|
+
data.tar.gz: f02a43b2ce9a4b512175ef085191d18e093be5540a0bbc92f2b09a721748be3a61fea62ad202372403f0ce18cb9144dadb39762fee3b5c109bae94d46e5f2553
|
data/Gemfile.lock
CHANGED
data/lib/dronejob/base.rb
CHANGED
data/lib/dronejob/command.rb
CHANGED
@@ -3,7 +3,7 @@ require "active_job"
|
|
3
3
|
module Dronejob
|
4
4
|
class Command < Thor
|
5
5
|
|
6
|
-
Dronejob::Loader.workers.each do |identifier, worker|
|
6
|
+
Dronejob::Loader.workers(:base).each do |identifier, worker|
|
7
7
|
desc identifier, "Queue #{identifier} worker"
|
8
8
|
|
9
9
|
# Pub/Sub options
|
@@ -56,6 +56,18 @@ module Dronejob
|
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
59
|
+
Dronejob::Loader.workers(:one_off).each do |identifier, worker|
|
60
|
+
desc identifier, "Run #{identifier} one-off worker"
|
61
|
+
method_option(:break, aliases: "-b", type: :boolean, default: false)
|
62
|
+
method_option(:skip, aliases: "-s", type: :array, default: [])
|
63
|
+
worker.params.each do |key, config|
|
64
|
+
method_option(key, required: config[:required], type: config[:type], default: config[:default])
|
65
|
+
end
|
66
|
+
define_method(identifier) do
|
67
|
+
worker.new.perform(options)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
59
71
|
desc :server, "Start Dronejob Server"
|
60
72
|
method_option(:queue_adapter, type: :string, default: "sidekiq", enum: ["sidekiq"])
|
61
73
|
method_option(:jobs_path, type: :string)
|
@@ -91,7 +103,8 @@ module Dronejob
|
|
91
103
|
end
|
92
104
|
|
93
105
|
desc :unarchive, "Unarchive Completed Job"
|
94
|
-
|
106
|
+
archives_dir = WorkspaceDir.new("archive")
|
107
|
+
archives = archives_dir.exists? ? archives_dir.children.map{|file| file.name.gsub(/\.zip$/, "")} : []
|
95
108
|
method_option(:archive, type: :string, required: true, enum: archives)
|
96
109
|
method_option(:force, aliases: "-f", type: :boolean, default: false)
|
97
110
|
def unarchive
|
data/lib/dronejob/loader.rb
CHANGED
@@ -33,44 +33,6 @@ module Dronejob
|
|
33
33
|
def asset_file(path)
|
34
34
|
WorkspaceDir.new("app/assets").file(path)
|
35
35
|
end
|
36
|
-
|
37
|
-
# def file_replace_contents(target_path, &block)
|
38
|
-
# binding.pry
|
39
|
-
# contents = File.open(target_path).read
|
40
|
-
# contents = block.call(contents)
|
41
|
-
# file_write(target_path, contents)
|
42
|
-
# end
|
43
|
-
#
|
44
|
-
# def file_delete_path(*args)
|
45
|
-
# binding.pry
|
46
|
-
# path = File.join(*args)
|
47
|
-
# FileUtils.rm_rf(path)
|
48
|
-
# path
|
49
|
-
# end
|
50
|
-
#
|
51
|
-
# def file_parse_haml(haml_path, output_path, options={})
|
52
|
-
# binding.pry
|
53
|
-
# engine = Haml::Engine.new(haml_path)
|
54
|
-
# open(output_path, 'wb') do |file|
|
55
|
-
# file << engine.render(Object.new, options)
|
56
|
-
# end
|
57
|
-
# end
|
58
|
-
#
|
59
|
-
# def file_root_dir
|
60
|
-
# binding.pry
|
61
|
-
# File.expand_path("../../../", __FILE__)
|
62
|
-
# end
|
63
|
-
#
|
64
|
-
# def file_data_path(target_path)
|
65
|
-
# binding.pry
|
66
|
-
# File.join(Gem.datadir("app-drone"), target_path)
|
67
|
-
# end
|
68
|
-
#
|
69
|
-
# def file_data_contents(target_path)
|
70
|
-
# binding.pry
|
71
|
-
# path = file_data_path(target_path)
|
72
|
-
# File.open(path).read
|
73
|
-
# end
|
74
36
|
end
|
75
37
|
end
|
76
38
|
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
require "active_job"
|
2
|
+
require 'dronejob/modules/core'
|
3
|
+
require 'dronejob/modules/log'
|
4
|
+
require 'dronejob/modules/options'
|
5
|
+
require 'dronejob/modules/params'
|
6
|
+
require 'dronejob/modules/phases'
|
7
|
+
|
8
|
+
module Dronejob
|
9
|
+
class OneOff
|
10
|
+
DRONEJOB_TYPE = "one_off"
|
11
|
+
include Modules::Core
|
12
|
+
include Modules::Log
|
13
|
+
include Modules::Options
|
14
|
+
include Modules::Params
|
15
|
+
include Modules::Phases
|
16
|
+
|
17
|
+
def perform(params)
|
18
|
+
@params = params
|
19
|
+
validate_parameters!
|
20
|
+
|
21
|
+
# Run through phases
|
22
|
+
each_phase do |phase, config|
|
23
|
+
begin
|
24
|
+
phase_result = public_send(phase)
|
25
|
+
rescue Exception => e
|
26
|
+
error(e.message)
|
27
|
+
error(e.backtrace.join("\n"))
|
28
|
+
return false
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def each_phase(&block)
|
34
|
+
self.class.phases.each do |phase, config|
|
35
|
+
fail "Phase not found: '#{phase}'" unless self.respond_to?(phase)
|
36
|
+
@phase = phase
|
37
|
+
before_phase(phase, config) if self.respond_to?(:before_phase)
|
38
|
+
|
39
|
+
logger.tagged(phase) do
|
40
|
+
if completed_phase?(phase) and !config[:always_run]
|
41
|
+
info("already completed")
|
42
|
+
elsif skip_phase?(phase)
|
43
|
+
info("skipping...")
|
44
|
+
else
|
45
|
+
# Require libraries
|
46
|
+
if !config[:require].nil?
|
47
|
+
config[:require].each do |library|
|
48
|
+
require library
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
# Include helpers
|
53
|
+
if !config[:helpers].nil?
|
54
|
+
config[:helpers].each do |helper|
|
55
|
+
helper_path = "helpers/#{helper}"
|
56
|
+
require "./app/#{helper_path}"
|
57
|
+
self.class.include helper_path.camelcase.constantize
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
block.call(phase, config)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
after_phase(phase, config) if self.respond_to?(:after_phase)
|
66
|
+
end
|
67
|
+
|
68
|
+
info("JOB COMPLETED")
|
69
|
+
end
|
70
|
+
|
71
|
+
def completed_phase?(phase)
|
72
|
+
false
|
73
|
+
end
|
74
|
+
|
75
|
+
ActiveSupport.run_load_hooks(:dronejob, self)
|
76
|
+
end
|
77
|
+
end
|
data/lib/dronejob/version.rb
CHANGED
data/lib/dronejob.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dronejob
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tobias Strebitzer
|
@@ -205,6 +205,7 @@ files:
|
|
205
205
|
- lib/dronejob/modules/phases.rb
|
206
206
|
- lib/dronejob/modules/queue.rb
|
207
207
|
- lib/dronejob/modules/workspace.rb
|
208
|
+
- lib/dronejob/one_off.rb
|
208
209
|
- lib/dronejob/railtie.rb
|
209
210
|
- lib/dronejob/railties/dronejob.rake
|
210
211
|
- lib/dronejob/server/sidekiq.rb
|
@@ -231,7 +232,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
231
232
|
version: '2.4'
|
232
233
|
requirements: []
|
233
234
|
rubyforge_project:
|
234
|
-
rubygems_version: 2.
|
235
|
+
rubygems_version: 2.6.3
|
235
236
|
signing_key:
|
236
237
|
specification_version: 4
|
237
238
|
summary: DroneJob Drone Factory
|