dronejob 1.0.4 → 1.0.5
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/.gitignore +1 -0
- data/Gemfile.lock +1 -1
- data/lib/dronejob/command.rb +38 -0
- data/lib/dronejob/modules/attr_store.rb +2 -2
- data/lib/dronejob/modules/phases.rb +4 -0
- data/lib/dronejob/version.rb +1 -1
- data/lib/dronejob/workspace_dir.rb +30 -0
- data/lib/dronejob/workspace_file.rb +3 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 06339a1fef10bf3f164d9eff6565c05a4208c315
|
4
|
+
data.tar.gz: 67b287c477a60ca2962c264d38050cbf71dc51b9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4fd156af7248545a3a2cc140bc14a44ae628cd5c063c4aaa110d09ef99b6f9130e2dffe7f0d36c88f5ca458970893f621762717dbe285229545ebb2dda6f6242
|
7
|
+
data.tar.gz: 4a44ffac4db1a1cef18221ad6d8b44d5bf1d9c452799b0d15e887ca519f86d06cc1dffdd05aa983bea6811dbc5c2267b028828359aa84d91094e193a521a7278
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
data/lib/dronejob/command.rb
CHANGED
@@ -69,5 +69,43 @@ module Dronejob
|
|
69
69
|
Dronejob::Base.run_worker!
|
70
70
|
end
|
71
71
|
|
72
|
+
desc :archive, "Archive Completed Jobs"
|
73
|
+
method_option(:force, aliases: "-f", type: :boolean, default: false)
|
74
|
+
def archive
|
75
|
+
archive_dir = WorkspaceDir.new("archive")
|
76
|
+
archive_dir.create
|
77
|
+
WorkspaceDir.new("tmp/jobs").each_dir do |dir|
|
78
|
+
dronejob_variables = dir.file("dronejob.yml").read_yaml
|
79
|
+
if dronejob_variables[:dronejob_completed] == true
|
80
|
+
Dronejob::Base.log("info", "Archiving #{dir.name}")
|
81
|
+
archive_file = archive_dir.file("#{dir.name}.zip")
|
82
|
+
if archive_file.exists? and !options.force
|
83
|
+
Dronejob::Base.log("error", "Error: Archive '#{archive_file.full_path}' already exists. Use --force to replace.")
|
84
|
+
else
|
85
|
+
archive_file.delete! if archive_file.exists?
|
86
|
+
dir.compress(archive_file)
|
87
|
+
dir.delete!
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
desc :unarchive, "Unarchive Completed Job"
|
94
|
+
archives = WorkspaceDir.new("archive").children.map{|file| file.name.gsub(/\.zip$/, "")}
|
95
|
+
method_option(:archive, type: :string, required: true, enum: archives)
|
96
|
+
method_option(:force, aliases: "-f", type: :boolean, default: false)
|
97
|
+
def unarchive
|
98
|
+
archives_dir = WorkspaceDir.new("archive")
|
99
|
+
archive_file = archives_dir.file("#{options.archive}.zip")
|
100
|
+
Dronejob::Base.log("info", "Unarchiving '#{archive_file.full_path}'")
|
101
|
+
target_dir = WorkspaceDir.new("tmp/jobs").dir(options.archive)
|
102
|
+
if !options.force and target_dir.exists?
|
103
|
+
Dronejob::Base.log("error", "Error: Job directory already exists")
|
104
|
+
else
|
105
|
+
target_dir.delete! if target_dir.exists?
|
106
|
+
archive_file.extract(target_dir)
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
72
110
|
end
|
73
111
|
end
|
@@ -9,12 +9,12 @@ module Dronejob
|
|
9
9
|
|
10
10
|
module ClassMethods
|
11
11
|
def attr_store(*args)
|
12
|
-
@attr_stores ||= []
|
12
|
+
@attr_stores ||= [:dronejob_completed]
|
13
13
|
@attr_stores.push(*args)
|
14
14
|
end
|
15
15
|
|
16
16
|
def attr_stores
|
17
|
-
@attr_stores ||= []
|
17
|
+
@attr_stores ||= [:dronejob_completed]
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
data/lib/dronejob/version.rb
CHANGED
@@ -7,6 +7,10 @@ module Dronejob
|
|
7
7
|
@path = path
|
8
8
|
end
|
9
9
|
|
10
|
+
def name
|
11
|
+
File.basename(full_path)
|
12
|
+
end
|
13
|
+
|
10
14
|
def full_path
|
11
15
|
File.join(@workspace, @path)
|
12
16
|
end
|
@@ -31,5 +35,31 @@ module Dronejob
|
|
31
35
|
def dir(dir_path)
|
32
36
|
WorkspaceDir.new(@workspace, File.join(@path, dir_path))
|
33
37
|
end
|
38
|
+
|
39
|
+
def compress(target_file)
|
40
|
+
target_file.delete!
|
41
|
+
Zip::File.open(target_file.full_path, 'w') do |zipfile|
|
42
|
+
Dir["#{full_path}/**/**"].each do |file|
|
43
|
+
zipfile.add(file.sub("#{full_path}/",''), file)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
self
|
47
|
+
end
|
48
|
+
|
49
|
+
def children
|
50
|
+
entries = []
|
51
|
+
Dir.chdir(full_path) do
|
52
|
+
Dir["*"].each do |path|
|
53
|
+
entries.push(dir(path))
|
54
|
+
end
|
55
|
+
end
|
56
|
+
entries
|
57
|
+
end
|
58
|
+
|
59
|
+
def each_dir(&block)
|
60
|
+
children.each do |subdir|
|
61
|
+
block.call(subdir)
|
62
|
+
end
|
63
|
+
end
|
34
64
|
end
|
35
65
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tobias Strebitzer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-04-
|
11
|
+
date: 2016-04-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|