Sha256: bca4249034c197a2f3e95cddeffa504fad5ec1b876599b22207582bff1112d2b

Contents?: true

Size: 931 Bytes

Versions: 1

Compression:

Stored size: 931 Bytes

Contents

module JunitTimingSplitter
  class Schema
    attr_reader :path, :buckets

    def initialize(path)
      @path = path
      validate_file
      @buckets = JSON.parse(File.read(path))
    end

    # Retrieve files from a specific bucket
    def files_for_bucket(bucket_number)
      bucket = buckets[bucket_number]
      bucket ? bucket['files'] : []
    end

    # Retrieve all parsed files across all buckets
    def all_parsed_files
      buckets.flat_map { |bucket| bucket['files'] }
    end

    # Scan for missing files in a specified glob path
    def scan_missing_files(glob_path)
      parsed_files = all_parsed_files.map { |file| File.expand_path(file) }
      all_files = Dir.glob(glob_path).map { |file| File.expand_path(file) }
      all_files - parsed_files
    end

    private

    def validate_file
      unless File.exist?(path)
        raise IOError, "Schema file not found: #{path}"
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
junit_timing_splitter-1.0.0 lib/junit_timing_splitter/schema.rb