Class: Listen::Record

Inherits:
Object
  • Object
show all
Defined in:
lib/faastruby/local/monkey_patch.rb

Instance Method Summary collapse

Instance Method Details

#_sub_dir_entries(rel_path) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/faastruby/local/monkey_patch.rb', line 24

def _sub_dir_entries(rel_path)
  result = {}
  tree.each do |path, meta|
    next if !path.start_with?(rel_path)
      if path == rel_path
      result.merge!(meta)
    else
      sub_path = path.sub(%r{\A#{rel_path}/?}, '')
      result[sub_path] = meta
    end
  end
  result
end

#dir_entries(rel_path) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/faastruby/local/monkey_patch.rb', line 5

def dir_entries(rel_path)
  subtree =
    if [nil, '', '.'].include? rel_path.to_s
      tree
    else
      # tree[rel_path.to_s] ||= _auto_hash
      # puts tree[rel_path.to_s]
      # tree[rel_path.to_s]
      _sub_dir_entries(rel_path)
    end

  result = {}
  subtree.each do |key, values|
    # only get data for file entries
    result[key] = values.key?(:mtime) ? values : {}
  end
  result
end