Method: Ftpmock::Cache#put

Defined in:
lib/ftpmock/core/cache.rb

#put(localfile, remotefile = File.basename(localfile)) ⇒ Object



117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# File 'lib/ftpmock/core/cache.rb', line 117

def put(localfile, remotefile = File.basename(localfile))
  tag = _put_tag_for(localfile)

  _put_alert_exists(tag)
  PutHelper.exist?(localfile) || _put_raise_not_found(remotefile, localfile)

  if PutHelper.cached?(path, remotefile)
    _put_cached(tag, path, localfile, remotefile)
  else
    _put_alert_miss(tag)
    yield

    _put_alert_storing(tag, remotefile)
    PutHelper.write(path, localfile, remotefile)
  end

  true
end