lib/cryptoform.rb in cryptoform-0.4.0 vs lib/cryptoform.rb in cryptoform-0.5.0

- old
+ new

@@ -1,28 +1,31 @@ # frozen_string_literal: true -require "zeitwerk" require "logger" require "lockbox" -require "webrick" -require "rackup" require "sinatra" require "sinatra/json" +require "thor" +require "zeitwerk" loader = Zeitwerk::Loader.for_gem loader.setup module Cryptoform class Error < StandardError; end class ConfigValidationError < Cryptoform::Error; end class StateMissingError < Cryptoform::Error; end + class UnknownStateError < Cryptoform::Error; end class << self - def run(path) - config = Cryptoform::Config::Builder.new.tap { _1.instance_eval(File.read(path)) } - config.validate! - Cryptoform::Server.new(config.config).run + def run!(cryptofile) + config = load_cryptofile!(cryptofile) + Cryptoform::Server.run!(config.config) + end + + def load_cryptofile!(cryptofile) + Cryptoform::Config::Builder.new(cryptofile).tap(&:validate!) end end end