datapipe2 0.0.11 → 0.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/datapipe2.rb +1 -0
- data/lib/fns/db_to_db.rb +2 -2
- data/lib/fns/scp_to_local.rb +37 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9a4e42506c6c2a85e662dc284be5a740e4c81f39
|
4
|
+
data.tar.gz: 7f602f5afdd3d5821f1cb0ff50d4cb4cfe54e842
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: be6cca3b89a584fc0052a3331e5a162dfd37b272907f115ed9c2a131070c8ecec148b62d59ed3968b7f52ad1f33069b314ea807dfa5b235f35ed810cb9fe08f1
|
7
|
+
data.tar.gz: dc4d0532c05ba9b587facb7e96eed7a404fa9086ed1d3d0c7eecc2ec8d0597317f3974d25e779b8ea82a1c60e39d8b391091bb0d8be86e334fcb0d22c6eb363b
|
data/lib/datapipe2.rb
CHANGED
data/lib/fns/db_to_db.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
|
2
2
|
def db_to_db(select_sql, table_name, columns)
|
3
|
-
s = FluidDb::Db(ENV['SOURCE_DB']) # source
|
4
|
-
d = FluidDb::Db(ENV['DEST_DB']) # destination
|
3
|
+
s = FluidDb::Db(ENV['SOURCE_DB']) if s.nil? # source
|
4
|
+
d = FluidDb::Db(ENV['DEST_DB']) if d.nil? # destination
|
5
5
|
|
6
6
|
insert_cmd = %{
|
7
7
|
INSERT INTO #{table_name} (#{columns})
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'net/sftp'
|
2
|
+
require 'fileutils'
|
3
|
+
require 'uri'
|
4
|
+
|
5
|
+
def scp_to_local(scp_uri_string,
|
6
|
+
remote_done_path,
|
7
|
+
local_path,
|
8
|
+
local_working_path = nil)
|
9
|
+
scp_uri = URI.parse(scp_uri_string)
|
10
|
+
remote_ready_path = "#{scp_uri.path}"
|
11
|
+
|
12
|
+
local_working_path = "/tmp/#{local_path}" if local_working_path.nil?
|
13
|
+
FileUtils.mkdir_p local_working_path
|
14
|
+
# Check we can write to local path
|
15
|
+
|
16
|
+
Net::SFTP.start(scp_uri.host, scp_uri.user) do |sftp|
|
17
|
+
# Check we can read and write from remote_ready_path
|
18
|
+
# Check we can write to remote_done_path
|
19
|
+
# puts "remote_ready_path: #{sftp.lstat!('remote_ready_path').permissions}"
|
20
|
+
# puts "remote_done_path: #{sftp.lstat!('remote_done_path').permissions}"
|
21
|
+
sftp.dir.foreach(remote_ready_path) do |entry|
|
22
|
+
if entry.file?
|
23
|
+
puts entry.name
|
24
|
+
sftp.download!(
|
25
|
+
"#{remote_ready_path}/#{entry.name}",
|
26
|
+
"#{local_working_path}/#{entry.name}")
|
27
|
+
|
28
|
+
FileUtils.mv("#{local_working_path}/#{entry.name}", local_path)
|
29
|
+
|
30
|
+
sftp.rename!("#{remote_ready_path}/#{entry.name}",
|
31
|
+
"#{remote_done_path}/#{entry.name}")
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
FileUtils.rm_rf local_working_path
|
37
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: datapipe2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Guy Irvine
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-08-03 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: zero to one for moving data
|
14
14
|
email: guy@guyirvine.com
|
@@ -23,6 +23,7 @@ files:
|
|
23
23
|
- lib/fns/db_to_db.rb
|
24
24
|
- lib/fns/db_to_json.rb
|
25
25
|
- lib/fns/mssql_to_pgsql.rb
|
26
|
+
- lib/fns/scp_to_local.rb
|
26
27
|
- lib/fns/smb_to_local.rb
|
27
28
|
- lib/helper_functions.rb
|
28
29
|
- lib/host.rb
|