Sha256: cf7c900f114087fdd776b921e04aaab497821b09f8ff694323f27bd44fa2cc5c

Contents?: true

Size: 722 Bytes

Versions: 7

Compression:

Stored size: 722 Bytes

Contents

module WebResourceBundler
  class FileManager
    attr_accessor :resource_dir, :cache_dir

    def initialize(resource_dir, cache_dir)
      @resource_dir, @cache_dir = resource_dir, cache_dir
    end

    def full_path(relative_path)
      File.join(@resource_dir, relative_path)
    end

    def exist?(relative_path)
      File.exist? full_path(relative_path)
    end

    def get_content(relative_path)
      raise Exceptions::ResourceNotFoundError.new(full_path(relative_path)) unless exist?(relative_path)
      File.read(full_path(relative_path))
    end

    def create_cache_dir
      path = File.join(@resource_dir, @cache_dir)
      unless File.exist?(path)
        Dir.mkdir(path)
      end
    end

  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
web_resource_bundler-0.0.20 lib/web_resource_bundler/file_manager.rb
web_resource_bundler-0.0.19 lib/web_resource_bundler/file_manager.rb
web_resource_bundler-0.0.18 lib/web_resource_bundler/file_manager.rb
web_resource_bundler-0.0.16 lib/web_resource_bundler/file_manager.rb
web_resource_bundler-0.0.15 lib/web_resource_bundler/file_manager.rb
web_resource_bundler-0.0.14 lib/web_resource_bundler/file_manager.rb
web_resource_bundler-0.0.13 lib/web_resource_bundler/file_manager.rb