4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/dsl_folder_watcher.rb', line 4
def self.watch(folder_path)
puts "Watching: #{folder_path}"
listener = Listen.to(folder_path) do |modified, added, _removed|
changes = (modified + added).uniq
changes.each do |file_path|
next unless File.extname(file_path) == '.klue'
puts file_path
base_name = file_path.gsub(/\.klue$/, '')
input_file = "#{base_name}.klue"
output_file = "#{base_name}.json"
interpreter = DSLInterpreter.new
if interpreter.process('', input_file, output_file)
dsl_processor = DSLProcessData.new
dsl_processor.process('', output_file, output_file)
else
puts 'Skipping further processing due to errors in DSL interpretation.'
end
end
end
listener.start
puts "Wait for changes: #{folder_path}"
sleep
end
|