Module: Ftpmock::PutHelper
- Defined in:
- lib/ftpmock/helpers/put_helper.rb
Class Method Summary collapse
- .cached?(cache_path, remotefile) ⇒ Boolean
-
.compare(cache_path, localfile, remotefile) ⇒ Object
Array.
- .exist?(localfile) ⇒ Boolean
-
.path_for(cache_path, remotefile) ⇒ Object
def expire(cache_path, remotefile) path = path_for(cache_path, remotefile) path.exist? && path.delete end.
- .write(cache_path, localfile, remotefile) ⇒ Object
Class Method Details
.cached?(cache_path, remotefile) ⇒ Boolean
5 6 7 8 |
# File 'lib/ftpmock/helpers/put_helper.rb', line 5 def cached?(cache_path, remotefile) path = path_for(cache_path, remotefile) path.exist? end |
.compare(cache_path, localfile, remotefile) ⇒ Object
Array
20 21 22 23 24 25 26 |
# File 'lib/ftpmock/helpers/put_helper.rb', line 20 def compare(cache_path, localfile, remotefile) return [] unless cached?(cache_path, remotefile) path = path_for(cache_path, remotefile) diff = StringUtils.diff(localfile, path) diff.split("\n") end |
.exist?(localfile) ⇒ Boolean
10 11 12 |
# File 'lib/ftpmock/helpers/put_helper.rb', line 10 def exist?(localfile) File.exist?(localfile) end |
.path_for(cache_path, remotefile) ⇒ Object
def expire(cache_path, remotefile)
path = path_for(cache_path, remotefile)
path.exist? && path.delete
end
33 34 35 36 37 |
# File 'lib/ftpmock/helpers/put_helper.rb', line 33 def path_for(cache_path, remotefile) path = cache_path.join('put') FileUtils.mkdir_p(path) path.join(remotefile.tr('/', '-')) end |
.write(cache_path, localfile, remotefile) ⇒ Object
14 15 16 17 |
# File 'lib/ftpmock/helpers/put_helper.rb', line 14 def write(cache_path, localfile, remotefile) path = path_for(cache_path, remotefile) FileUtils.cp(localfile, path) end |