Class: Foundries::Recording::RakeTask

Inherits:
Object
  • Object
show all
Includes:
Rake::DSL
Defined in:
lib/foundries/recording/rake_task.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.install(output_path: Recording::DEFAULT_OUTPUT_PATH) ⇒ Object



11
12
13
# File 'lib/foundries/recording/rake_task.rb', line 11

def self.install(output_path: Recording::DEFAULT_OUTPUT_PATH)
  new.install_tasks(output_path: output_path)
end

.merge(files, output_path:) ⇒ Object



37
38
39
40
# File 'lib/foundries/recording/rake_task.rb', line 37

def self.merge(files, output_path:)
  summary = Reporter.merge_files(files, output_path: output_path)
  $stdout.puts summary
end

Instance Method Details

#install_tasks(output_path:) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/foundries/recording/rake_task.rb', line 15

def install_tasks(output_path:)
  namespace :foundries do
    namespace :recording do
      desc "Merge per-worker recording files into a single report"
      task :merge do
        dir = File.dirname(output_path)
        base = File.basename(output_path, File.extname(output_path))
        ext = File.extname(output_path)
        pattern = File.join(dir, "#{base}-*#{ext}")
        files = Dir.glob(pattern).sort

        if files.empty?
          $stdout.puts "[Foundries] No worker recording files found matching #{pattern}"
          next
        end

        Foundries::Recording::RakeTask.merge(files, output_path: output_path)
      end
    end
  end
end