Sha256: 05dec4b9523d6558460ee524fca5897d5f90d538fd4d3a0abef4b0e695aa8c16

Contents?: true

Size: 782 Bytes

Versions: 3

Compression:

Stored size: 782 Bytes

Contents

# frozen_string_literal: true

require "async/process"
require "ptools" # file File.which

require "zeitwerk"

loader = Zeitwerk::Loader.for_gem

loader.setup

module Rustic
  class Error < StandardError; end
  class ValidationError < Error; end

  class << self
    def define(run: true, &block)
      Sync do
        config = Rustic::Config.new
        config.instance_eval(&block)
        validate!(config)
        Rustic::Application.new(config).tap do |app|
          app.run(ARGV) if run
        end
      end
    end

    private

    def validate!(config)
      errors, warnings = Rustic::Validator.new(config).validate
      warnings.each do |warning|
        # TODO: print warning
      end

      raise ValidationError, errors.join("\n") if errors.any?
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rustic-0.3.2 lib/rustic.rb
rustic-0.3.1 lib/rustic.rb
rustic-0.3.0 lib/rustic.rb