petasos 0.2.0 → 0.3.0
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/lib/petasos/location.rb +45 -39
- 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: bb6d3349efb1d5df1e59fb199b7ee742462e25ba5b0637b3d96ae837bfddbe6a
|
4
|
+
data.tar.gz: 055bbda229afefba11e1bdc79ce3d0b32cdce8fbfb9d62d6a2ba2f7663d0608a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9b683fe0a0cecf5685fbfaf459335b97bea7e69a34207ea90967235a415facdb996c8e0614d71417ce9dfc632df7b6a2e9121a43ad339cf83506e7094a014f5a
|
7
|
+
data.tar.gz: 8d73c62519cc0b98c566e8b27d51be01c3ca071488f21be3999a0ba407be4e212bf252af5c8e974b89dedcca6ed28f8528506c0d85c3d376d106874ef25c7614
|
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,42 @@ 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
|
+
unless config["disable_seen"]
|
50
|
+
update_seen_pool_files(pool, seen_pool_files + new_files)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
55
54
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
eval("#{pool_hook}(\"#{file}\")")
|
61
|
-
end
|
62
|
-
end
|
55
|
+
def process_lifecycle_hooks(hook_prefix, pool, files)
|
56
|
+
if File.file?("petasos_after-hooks.rb")
|
57
|
+
require "./petasos_after-hooks"
|
58
|
+
end
|
63
59
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
new_files.each do |file|
|
68
|
-
eval("#{location_and_pool_hook}(\"#{file}\")")
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
60
|
+
# after seen for every file in this pool in this location
|
61
|
+
location_and_pool_hook = "#{hook_prefix}_#{methodize(config["name"])}_#{methodize(pool["name"])}"
|
62
|
+
check_if_defined_and_eval(location_and_pool_hook, files)
|
72
63
|
|
73
|
-
|
74
|
-
|
64
|
+
# after seen for every file in this pool
|
65
|
+
pool_hook = "#{hook_prefix}_#{methodize(pool["name"])}"
|
66
|
+
check_if_defined_and_eval(pool_hook, files)
|
67
|
+
|
68
|
+
# after seen for every file in this location
|
69
|
+
location_hook = "#{hook_prefix}_#{methodize(config["name"])}"
|
70
|
+
check_if_defined_and_eval(location_hook, files)
|
71
|
+
|
72
|
+
# after seen for all files
|
73
|
+
check_if_defined_and_eval("#{hook_prefix}_all", files)
|
74
|
+
end
|
75
|
+
|
76
|
+
def check_if_defined_and_eval(lifecycle_hook, files)
|
77
|
+
if eval("defined?(#{lifecycle_hook})")
|
78
|
+
files.each do |file|
|
79
|
+
eval("#{lifecycle_hook}(\"#{file}\")")
|
80
|
+
end
|
75
81
|
end
|
76
82
|
end
|
77
83
|
|