File: directories.rb

package info (click to toggle)
ruby-fog-local 0.8.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 212 kB
  • sloc: ruby: 709; makefile: 2
file content (32 lines) | stat: -rw-r--r-- 787 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
module Fog
  module Local
    class Storage
      class Directories < Fog::Collection
        model Directory

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

        def get(key, options = {})
          create_directory(key, options) if ::File.directory?(service.path_to(key))
        end

        private

        def create_directory(key, options)
          options[:path] ? new(key: key + options[:path]) : new(key: key)
        end
      end
    end
  end
end