Skip to content

Commit

Permalink
Add module Storage::FTP
Browse files Browse the repository at this point in the history
  • Loading branch information
RoxasShadow committed Aug 11, 2015
1 parent 72aa997 commit 6308a27
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
PATH
remote: .
specs:
edb (0.3.1)
edb (0.4)
aws-sdk (= 1.59.1)
ftp_sync (~> 0.4)

GEM
remote: https://rubygems.org/
Expand All @@ -13,8 +14,11 @@ GEM
json (~> 1.4)
nokogiri (>= 1.4.4)
diff-lcs (1.2.5)
ftp_sync (0.4.3)
net-ftp-list (>= 2.1.1)
json (1.8.3)
mini_portile (0.6.2)
net-ftp-list (3.2.8)
nokogiri (1.6.6.2)
mini_portile (~> 0.6.0)
rake (10.4.2)
Expand Down
1 change: 1 addition & 0 deletions edb.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ Gem::Specification.new { |s|
s.require_paths = ['lib']

s.add_dependency 'aws-sdk', '1.59.1'
s.add_dependency 'ftp_sync', '~> 0.4'
}
6 changes: 6 additions & 0 deletions example/edb.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,9 @@

:Filesystem:
:path: ~/Downloads

:FTP:
:host: ftp.example.xyz
:username: username
:password: password
:path: /home/username/
40 changes: 40 additions & 0 deletions lib/edb/storage/ftp.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#--
# Copyright(C) 2015 Giovanni Capuano <[email protected]>
#
# Redistribution and use in source and binary forms, with or without modification, are
# permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this list of
# conditions and the following disclaimer.
#
# THIS SOFTWARE IS PROVIDED BY Giovanni Capuano ''AS IS'' AND ANY EXPRESS OR IMPLIED
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL Giovanni Capuano OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
# The views and conclusions contained in the software and documentation are those of the
# authors and should not be interpreted as representing official policies, either expressed
# or implied, of Giovanni Capuano.
#++
require 'ftp_sync'

module EDB
module Storage
module FTP
class << self
def upload(source)
data = ::EDB.opts[:STORAGE][:FTP]
::EDB::Logger.log(:info, "Uploading #{source} to #{data[:username]}@#{data[:host]} via FTP...")

ftp = FtpSync.new(data[:host], data[:username], data[:password])
ftp.push_files('.', data[:path], [source])
end
end
end
end
end

0 comments on commit 6308a27

Please sign in to comment.