Sha256: e5acbda43a0a111d687be047b257d00809ee9041b71866c1a20dcc8b6ca63609

Contents?: true

Size: 817 Bytes

Versions: 21

Compression:

Stored size: 817 Bytes

Contents

require 'fog/collection'
require 'fog/local/models/directory'

module Fog
  module Local

    class Real
      def directories
        Fog::Local::Directories.new(:connection => self)
      end
    end

    class Mock
      def directories
        Fog::Local::Directories.new(:connection => self)
      end
    end

    class Directories < Fog::Collection

      model Fog::Local::Directory

      def all
        data = Dir.entries(connection.local_root).select do |entry|
          entry[0...1] != '.' && ::File.directory?(connection.path_to(entry))
        end.map do |entry| 
          {:key => entry}
        end
        load(data)
      end

      def get(key)
        if ::File.directory?(connection.path_to(key))
          new(:key => key)
        else
          nil
        end
      end

    end

  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
fog-0.0.89 lib/fog/local/models/directories.rb