Sha256: 7b912e1668d7dd0ed721265a8884a451af16d262717d55066b5c1003a396cd6f
Contents?: true
Size: 1 KB
Versions: 26
Compression:
Stored size: 1 KB
Contents
# frozen_string_literal: true require "refinements/pathnames" module SublimeTextKit module Metadata # Handles the creation, deletion, and recreation of metadata. class Handler using Refinements::Pathnames def self.with_project project_dir, metadata_dir new "sublime-project", serializer: Serializers::Project.new(Pathway[project_dir:, metadata_dir:]) end def self.with_workspace project_dir, metadata_dir new "sublime-workspace", serializer: Serializers::Workspace.new(Pathway[project_dir:, metadata_dir:]) end def initialize extension, serializer: @extension = extension @serializer = serializer end def create = path.exist? ? path : path.write(JSON.dump(serializer.to_h)) def delete = path.exist? ? path.delete : path def recreate = delete && create private attr_reader :extension, :serializer def path = serializer.pathway.metadata_file(extension) end end end
Version data entries
26 entries across 26 versions & 1 rubygems