Method: HP::Cloud::SharedResource#foreach

Defined in:
lib/hpcloud/shared_resource.rb

#foreach(&block) ⇒ Object

Add the capability to iterate through all the matching files for copy. Use different regular expressions for a directory where we want to recursively copy things vs a regular file



94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# File 'lib/hpcloud/shared_resource.rb', line 94

def foreach(&block)
  return false unless container_head()
  case @ftype
  when :shared_directory
    regex = "^" + path + ".*"
  else
    regex = "^" + path + '$'
  end
  @directory.files.each { |x|
    name = x.key.to_s
    if ! name.match(regex).nil?
      yield ResourceFactory.create(@storage, @container + '/' + name)
    end
  }
end