Sha256: ff47862b7909f2e034aff419ae14db733e9fd87f407184f457c44fe49137b764
Contents?: true
Size: 503 Bytes
Versions: 3
Compression:
Stored size: 503 Bytes
Contents
require 'fileutils' require 'yaml' # TODO: Support JSON class RSpec::OpenAPI::SchemaFile # @param [String] path def initialize(path) @path = path end def edit(&block) spec = read block.call(spec) ensure write(spec) end private # @return [Hash] def read return {} unless File.exist?(@path) YAML.load(File.read(@path)) end # @param [Hash] spec def write(spec) FileUtils.mkdir_p(File.dirname(@path)) File.write(@path, YAML.dump(spec)) end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
rspec-openapi-0.1.2 | lib/rspec/openapi/schema_file.rb |
rspec-openapi-0.1.1 | lib/rspec/openapi/schema_file.rb |
rspec-openapi-0.1.0 | lib/rspec/openapi/schema_file.rb |