petasos 0.2.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/petasos/location.rb +50 -41
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b7bd8aa04cae7535d319a4b2d9141e2f40bb95b8342613541fe605022735c9b3
|
4
|
+
data.tar.gz: d418dabaf63b7a0b6b2777cd30a3a333bcbc2ee59a60cbd63ceceda9cb78485d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 51ad7a4fb5de50153261a857597836cb302c1f6f8263ab850e25dfac91a1b3c8dab751e4222da75c597f259360d9cf7894dc9185fc7034c8046d98e0068cdccb
|
7
|
+
data.tar.gz: 7acb74142c0bf285cad8d715505fb27625dd18ec90cab3f9763c7068ca393bbbb8a01fbd840ce3070721dd323be0ead3b4a1a6fc122154924ae5df4227de3d70
|
data/lib/petasos/location.rb
CHANGED
@@ -13,13 +13,20 @@ class Petasos::Location
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def run
|
16
|
-
# delete exports file if completed file exists
|
17
|
-
FileList.new(File.join(Dir.pwd, "exports_#{@config["name"]}*.yaml")).each do |export_file_path|
|
18
|
-
completed_export_file_path = "completed-" + export_file_path
|
19
|
-
`rm #{export_file_path}` if File.file?(completed_export_file_path)
|
20
|
-
end
|
21
|
-
|
22
16
|
pools.each do |pool|
|
17
|
+
# delete exports file if completed file exists
|
18
|
+
FileList.new(File.join(Dir.pwd, "exports_#{@config["name"]}_#{pool["name"]}_*.yaml")).each do |export_file_path|
|
19
|
+
completed_export_file_path = File.join(File.dirname(export_file_path), "completed-" + File.basename(export_file_path))
|
20
|
+
if File.file?(completed_export_file_path)
|
21
|
+
completed_files = YAML.load_file(completed_export_file_path)
|
22
|
+
|
23
|
+
process_lifecycle_hooks("after_export", pool, completed_files)
|
24
|
+
end
|
25
|
+
`mkdir -p logs`
|
26
|
+
`mv #{export_file_path} logs/`
|
27
|
+
`mv #{completed_export_file_path} logs/`
|
28
|
+
end
|
29
|
+
|
23
30
|
# get all filenames in this location that belong to this pool
|
24
31
|
current_files = current_pool_files(pool)
|
25
32
|
|
@@ -35,43 +42,43 @@ class Petasos::Location
|
|
35
42
|
create_file_export_list(pool, new_files.to_a) if new_files.length > 0
|
36
43
|
end
|
37
44
|
|
38
|
-
|
39
|
-
if File.file?("petasos_after-seen.rb")
|
40
|
-
require "./petasos_after-seen"
|
41
|
-
# after seen for all files
|
42
|
-
if defined?(after_seen_all)
|
43
|
-
new_files.each do |file|
|
44
|
-
after_seen_all(file)
|
45
|
-
end
|
46
|
-
end
|
45
|
+
process_lifecycle_hooks("after_seen", pool, new_files)
|
47
46
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
47
|
+
# update list of seen files
|
48
|
+
# unless the location opts out
|
49
|
+
# or the pool opts out
|
50
|
+
unless config["disable_seen"] or pool["disable_seen"]
|
51
|
+
update_seen_pool_files(pool, seen_pool_files + new_files)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
55
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
eval("#{pool_hook}(\"#{file}\")")
|
61
|
-
end
|
62
|
-
end
|
56
|
+
def process_lifecycle_hooks(hook_prefix, pool, files)
|
57
|
+
if File.file?("petasos_after-hooks.rb")
|
58
|
+
require "./petasos_after-hooks"
|
59
|
+
end
|
63
60
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
new_files.each do |file|
|
68
|
-
eval("#{location_and_pool_hook}(\"#{file}\")")
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
61
|
+
# after seen for every file in this pool in this location
|
62
|
+
location_and_pool_hook = "#{hook_prefix}_#{methodize(config["name"])}_#{methodize(pool["name"])}"
|
63
|
+
check_if_defined_and_eval(location_and_pool_hook, files)
|
72
64
|
|
73
|
-
|
74
|
-
|
65
|
+
# after seen for every file in this pool
|
66
|
+
pool_hook = "#{hook_prefix}_#{methodize(pool["name"])}"
|
67
|
+
check_if_defined_and_eval(pool_hook, files)
|
68
|
+
|
69
|
+
# after seen for every file in this location
|
70
|
+
location_hook = "#{hook_prefix}_#{methodize(config["name"])}"
|
71
|
+
check_if_defined_and_eval(location_hook, files)
|
72
|
+
|
73
|
+
# after seen for all files
|
74
|
+
check_if_defined_and_eval("#{hook_prefix}_all", files)
|
75
|
+
end
|
76
|
+
|
77
|
+
def check_if_defined_and_eval(lifecycle_hook, files)
|
78
|
+
if eval("defined?(#{lifecycle_hook})")
|
79
|
+
files.each do |file|
|
80
|
+
eval("#{lifecycle_hook}(\"#{file}\")")
|
81
|
+
end
|
75
82
|
end
|
76
83
|
end
|
77
84
|
|
@@ -125,8 +132,10 @@ class Petasos::Location
|
|
125
132
|
|
126
133
|
def initialize_all_seen_pool_files
|
127
134
|
pools.each do |pool|
|
128
|
-
|
129
|
-
|
135
|
+
unless config["disable_seen"] or pool["disable_seen"]
|
136
|
+
yaml_path = "seen_#{config["name"]}_#{pool["name"]}.yaml"
|
137
|
+
write_yaml(yaml_path, []) unless File.file?(yaml_path)
|
138
|
+
end
|
130
139
|
end
|
131
140
|
end
|
132
141
|
|