s3archive 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/s3archive/config.rb +1 -1
- data/lib/tasks/s3archive.thor +19 -4
- metadata +1 -1
data/lib/s3archive/config.rb
CHANGED
data/lib/tasks/s3archive.thor
CHANGED
@@ -1,22 +1,37 @@
|
|
1
1
|
require 'thor'
|
2
2
|
$:.unshift File.join(File.dirname(__FILE__), '..')
|
3
3
|
require 's3archive/compress_and_upload'
|
4
|
+
require 's3archive/logging'
|
4
5
|
|
5
6
|
module S3Archive
|
6
7
|
class Cli < Thor
|
8
|
+
include Logging
|
7
9
|
namespace :s3archive
|
8
10
|
|
9
|
-
class_option
|
11
|
+
class_option :config,
|
10
12
|
:desc => "Path to config file",
|
11
13
|
:banner => "CONFIG_FILE",
|
12
14
|
:type => :string,
|
13
|
-
:aliases => "
|
15
|
+
:aliases => "-c",
|
14
16
|
:default => "/etc/s3archive.yml"
|
15
17
|
|
16
|
-
desc "upload PATH [PATH...]", "
|
18
|
+
desc "upload PATH [PATH...]", "Sleeps, compresses and uploads to s3://<bucket>/<year>/<month>/<day>/<filename>.gz"
|
19
|
+
method_option :sleep,
|
20
|
+
:aliases => "-s",
|
21
|
+
:default => 5,
|
22
|
+
:banner => "SECONDS",
|
23
|
+
:desc => "The number of seconds to sleep before uploading"
|
24
|
+
|
17
25
|
def upload (*paths)
|
18
|
-
|
26
|
+
unless File.exists?(options[:config])
|
27
|
+
logger.error("Could not find config file #{options[:config]}")
|
28
|
+
exit(1)
|
29
|
+
end
|
30
|
+
|
31
|
+
S3Archive.config_path = options[:config]
|
19
32
|
help(:upload) && exit if paths.empty?
|
33
|
+
|
34
|
+
logger.info("Sleeping for #{options[:sleep]} seconds") && sleep(options[:sleep])
|
20
35
|
paths.each do |path|
|
21
36
|
CompressAndUpload.run(path)
|
22
37
|
end
|