s3archive 1.1.0 → 1.2.0

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.
@@ -7,7 +7,7 @@ module S3Archive
7
7
  end
8
8
 
9
9
  def self.config_path
10
- @config_path || "/etc/s3archive.yml"
10
+ @config_path
11
11
  end
12
12
 
13
13
  def self.config
@@ -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 "-c",
11
+ class_option :config,
10
12
  :desc => "Path to config file",
11
13
  :banner => "CONFIG_FILE",
12
14
  :type => :string,
13
- :aliases => "--config",
15
+ :aliases => "-c",
14
16
  :default => "/etc/s3archive.yml"
15
17
 
16
- desc "upload PATH [PATH...]", "Compresses PATH and uploads to s3://<bucket>/<year>/<month>/<day>/<filename>.gz"
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
- S3Archive.config_path = self.options["c"] if self.options["c"]
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: s3archive
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: