Sha256: 658b05fa4b3dbde98147fb0b1203f7e68c51cb1dae5d1a7b8034486e86b0d5e2

Contents?: true

Size: 1.9 KB

Versions: 4

Compression:

Stored size: 1.9 KB

Contents

module Fog
  module Local
    class Storage < Fog::Service

      requires :local_root
      recognizes :provider # remove post deprecation

      model_path 'fog/storage/models/local'
      collection  :directories
      model       :directory
      model       :file
      collection  :files

      class Mock

        def self.data
          @data ||= Hash.new do |hash, key|
            hash[key] = {}
          end
        end

        def initialize(options={})
          Fog::Mock.not_implemented

          require 'mime/types'
          unless options.delete(:provider)
            location = caller.first
            warning = "[yellow][WARN] Fog::Local::Storage.new is deprecated, use Fog::Storage.new(:provider => 'Local') instead[/]"
            warning << " [light_black](" << location << ")[/] "
            Formatador.display_line(warning)
          end

          @local_root = ::File.expand_path(options[:local_root])
          @data = self.class.data[@local_root]
        end

        def local_root
          @local_root
        end

        def path_to(partial)
          ::File.join(@local_root, partial)
        end

        def reset_data
          self.class.data.delete(@local_root)
          @data = self.class.data[@local_root]
        end

      end

      class Real

        def initialize(options={})
          unless options.delete(:provider)
            location = caller.first
            warning = "[yellow][WARN] Fog::Local::Storage.new is deprecated, use Fog::Storage.new(:provider => 'Local') instead[/]"
            warning << " [light_black](" << location << ")[/] "
            Formatador.display_line(warning)
          end

          require 'mime/types'
          @local_root = ::File.expand_path(options[:local_root])
        end

        def local_root
          @local_root
        end

        def path_to(partial)
          ::File.join(@local_root, partial)
        end
      end

    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
fog-0.8.1 lib/fog/storage/local.rb
fog-0.8.0 lib/fog/storage/local.rb
fog-0.7.2 lib/fog/storage/local.rb
fog-0.7.1 lib/fog/storage/local.rb