Sha256: 9ea2dd8c97f67085b043484060ed99b2eac35529b7a0f12686653150df8cf747
Contents?: true
Size: 1.93 KB
Versions: 16
Compression:
Stored size: 1.93 KB
Contents
# Author:: Eric Crane (mailto:eric.crane@mac.com) # Copyright:: Copyright (c) 2022 Eric Crane. All rights reserved. # # Disc based mechanism for files. # Provides interaction between the persistance classes and the OS # file and folder system. # This class might be overiden elsewhere to provide other mechanism. # For example, in gloo-web, there will be a db based mechanism. # module GlooLang module Persist class DiscMech # # Set up a disc based file mechanism. # def initialize( engine ) @engine = engine end # # Get the default file extention. # def file_ext return '.gloo' end # # Get all the gloo files in the folder (partial path). # def get_all_files_in( folder ) pns = [] dir = File.join( @engine.settings.project_path, folder ) Dir.glob( "#{dir}*.gloo" ).each do |f| pns << f end return pns end # # Check if a file exists. # def exist?( file ) File.exist?( file ) end # # Check to see if the file is valid. # def valid?( file ) return false unless file return false unless File.exist?( file ) return false unless File.file?( file ) return false unless file.end_with?( self.file_ext ) return true end # # Expand a single file path. # def expand( name ) ext_path = File.expand_path( name ) return [ ext_path ] if self.valid?( ext_path ) full_name = "#{name}#{file_ext}" return [ File.join( @engine.settings.project_path, full_name ) ] end # # Read in the contents of a single file. # def read( file ) return File.read( file ) end # # Write data to the file. # def write( pn, data ) File.write( pn, data ) end end end end
Version data entries
16 entries across 16 versions & 1 rubygems