movie_organizer 0.1.8 → 0.1.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +4 -0
- data/lib/movie_organizer/file_copier.rb +21 -8
- data/lib/movie_organizer/movie.rb +1 -1
- data/lib/movie_organizer/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7f54c3650fd6f47604caa55e65e6849c3e205dbf56682c1a4e152992bde76ddd
|
4
|
+
data.tar.gz: 62dac5e6ffc9548d7f7560a3246bdd304d122c0bafd9a98e4f6a2d34b39ac769
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e3663b3c36305f0c5f8906c9273be61764dec2d1e57e5bc9d9b5e81fbf9427522c84b5f244a3b2282c0f045e283ac92d9856a8d75d97442498ca86e73646583c
|
7
|
+
data.tar.gz: 000717141ad377bf135acad6ba2b88a1abb14e9c6cc21c07d2d91cf9130182cb05beba1bcc9d6f1bc4607a8185d468d0062ea79eb30cef3127cfc2dd05276af5
|
data/CHANGELOG
CHANGED
@@ -3,12 +3,13 @@
|
|
3
3
|
module MovieOrganizer
|
4
4
|
class FileCopier
|
5
5
|
attr_accessor :filename, :target_file, :options
|
6
|
-
attr_reader :username, :hostname, :remote_filename
|
6
|
+
attr_reader :username, :hostname, :remote_filename, :logger
|
7
7
|
|
8
8
|
def initialize(filename, target_file, options)
|
9
9
|
@filename = filename
|
10
10
|
@target_file = target_file
|
11
11
|
@options = options
|
12
|
+
@logger = Logger.instance
|
12
13
|
end
|
13
14
|
|
14
15
|
def copy
|
@@ -29,12 +30,8 @@ module MovieOrganizer
|
|
29
30
|
def remote_copy
|
30
31
|
parse_target
|
31
32
|
return do_dry_run if options[:dry_run]
|
32
|
-
|
33
|
-
|
34
|
-
end
|
35
|
-
Net::SCP.start(hostname, username) do |scp|
|
36
|
-
scp.upload!(filename, remote_filename)
|
37
|
-
end
|
33
|
+
create_remote_dir
|
34
|
+
copy_file_to_remote
|
38
35
|
end
|
39
36
|
|
40
37
|
def do_dry_run
|
@@ -58,12 +55,28 @@ module MovieOrganizer
|
|
58
55
|
@hostname = md[2]
|
59
56
|
@remote_filename = md[3]
|
60
57
|
if @username.nil? || @hostname.nil? || @remote_filename.nil?
|
61
|
-
|
58
|
+
raise 'SSH path not formatted properly. Use [ssh://username@hostname/absolute/path]'
|
62
59
|
end
|
63
60
|
end
|
64
61
|
|
65
62
|
def ssh?
|
66
63
|
target_file.match?(/^ssh:/)
|
67
64
|
end
|
65
|
+
|
66
|
+
def create_remote_dir
|
67
|
+
Net::SSH.start(hostname, username, timeout: 5) do |ssh|
|
68
|
+
ssh.exec("mkdir -p '#{target_dir}'")
|
69
|
+
end
|
70
|
+
rescue Net::SSH::ConnectionTimeout, Errno::EHOSTUNREACH, Errno::EHOSTDOWN
|
71
|
+
logger.error("ConnectionTimeout: the host '#{hostname}' is unreachable.".red)
|
72
|
+
end
|
73
|
+
|
74
|
+
def copy_file_to_remote
|
75
|
+
Net::SCP.start(hostname, username) do |scp|
|
76
|
+
scp.upload!(filename, remote_filename)
|
77
|
+
end
|
78
|
+
rescue Net::SSH::ConnectionTimeout, Errno::EHOSTUNREACH, Errno::EHOSTDOWN
|
79
|
+
logger.error("ConnectionTimeout: the host '#{hostname}' is unreachable.".red)
|
80
|
+
end
|
68
81
|
end
|
69
82
|
end
|
@@ -12,7 +12,7 @@ module MovieOrganizer
|
|
12
12
|
def process!
|
13
13
|
target_dir = File.join(MovieOrganizer.movie_directory, "#{title} (#{year})")
|
14
14
|
target_file = File.join(target_dir, processed_filename)
|
15
|
-
logger.info(" target dir: [#{target_dir}]")
|
15
|
+
# logger.info(" target dir: [#{target_dir}]")
|
16
16
|
logger.info(" target file: [#{target_file.green.bold}]")
|
17
17
|
fc = FileCopier.new(filename, target_file, options)
|
18
18
|
fc.copy
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: movie_organizer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Blackburn
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-03-
|
11
|
+
date: 2018-03-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|