Skip to content

Commit

Permalink
Change base_path and destination_path to return Pathnames.
Browse files Browse the repository at this point in the history
  • Loading branch information
jrafanie committed Feb 6, 2015
1 parent ef2663d commit 39bf19c
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions vmdb/app/models/file_depot_ftp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,16 +107,18 @@ def destination_file_exists?(ftp, file)
end

def destination_file
File.join(destination_path, file.destination_file_name)
destination_path.join(file.destination_file_name).to_s
end

def destination_path
File.join(base_path, file.destination_directory)
base_path.join(file.destination_directory)
end

def base_path
# URI.split(URI.encode("ftp://ftp.example.com/incoming"))[5] => "/incoming"
URI.split(URI.encode(uri))[5]
# uri: "ftp://ftp.example.com/incoming" => #<Pathname:incoming>
path = URI.split(URI.encode(uri))[5]
path = Pathname.new(path)
path.relative_path_from(Pathname.new("/"))
end

def login_credentials
Expand Down

0 comments on commit 39bf19c

Please sign in to comment.