sink3 0.0.6 → 0.0.7

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ff3e1daf52d984a4a933a813cab8eb3062266358b3e11b3eeed34103cc7b80c3
4
- data.tar.gz: 3dc130fc49e9020effd4576f77fc979f2759c2d65a87aa44e1a6ba3965a2d123
3
+ metadata.gz: c38fc1886885c4b540758bfe360fbb3b104e42a58cf09089665e070aa748c116
4
+ data.tar.gz: df4199bae369d7186ba4337d0789e33a332c6ac925dcd3ae2d85ae9c4aa5df3c
5
5
  SHA512:
6
- metadata.gz: 33da8314c6d408ae31106123d3a3f3d6d7ce85ac209adf924da94fe06edb4c9e85619992b891bd089ae6f74bda9d54de2ea4b892287f85cd5c5b400ec0a384fe
7
- data.tar.gz: 463ec18e4df590604cca9c5bcda43dd32fa1c25e3c14c856a91b6d434ff2dab712eeeeafbf4024ac32fd8005dc0ce8de81440ba33bb0157b00a07585290305ae
6
+ metadata.gz: 61e0348ecb5cf342f3de7e69ff208fa6dc82f65a62572180cd157bc5a7cf910b9b176b66034e44815c0bc0574e9510484f9bd3a08c070d4fd3fb8f1b9d76c19f
7
+ data.tar.gz: 435085e039823346909ae1494acc924024a525d4a2a99c3c02f3bb1bd198e75fb90e8128a6a1da4343983eed571adc9f533559623fb2b847037ab9acbcf34f8d
data/lib/sink3.rb CHANGED
@@ -16,7 +16,9 @@ module Sink3
16
16
  class Configuration
17
17
  attr_accessor :delete_after_upload
18
18
  attr_accessor :skip_overwrite
19
+ attr_accessor :skip_date_partition
19
20
  attr_accessor :verbose
21
+ attr_accessor :skip_full_path
20
22
 
21
23
  def delete_after_upload
22
24
  !!@delete_after_upload
data/lib/sink3/main.rb CHANGED
@@ -16,6 +16,8 @@ module Sink3
16
16
  option :delete, type: :boolean, desc: "delete origin file on succesful send"
17
17
  option :skip_overwrite, type: :boolean, desc: "skip sending file if exists"
18
18
  option :verbose, type: :boolean, desc: "verbose"
19
+ option :skip_date_partition, type: :boolean, desc: "remove YYYY-MM-DD remote prefix"
20
+ option :skip_full_path, type: :boolean, desc: "don't archive file with full path prefix"
19
21
 
20
22
  def send(*paths)
21
23
  configure
@@ -24,10 +26,20 @@ module Sink3
24
26
 
25
27
  validate_env
26
28
 
29
+ prefix = nil
27
30
  [paths].flatten.each do |path|
28
31
  path = Pathname.new(path)
32
+
29
33
  raise "specified path does not exist" unless path.exist?
30
- prefix = path.realdirpath.basename
34
+ unless Sink3.config.skip_full_path
35
+ if (path.file?)
36
+ prefix = path.realdirpath.parent
37
+ puts "prefix is #{prefix}" if Sink3.config.verbose
38
+ else
39
+ prefix = path.realdirpath.parent.parent
40
+ puts "prefix is not set" if Sink3.config.verbose
41
+ end
42
+ end
31
43
 
32
44
  Sink3::PathCrawler.new(path, prefix).start
33
45
  end
@@ -42,6 +54,8 @@ module Sink3
42
54
  config.delete_after_upload = options[:delete]
43
55
  config.skip_overwrite = options[:skip_overwrite]
44
56
  config.verbose = options[:verbose]
57
+ config.skip_date_partition = options[:skip_date_partition]
58
+ config.skip_full_path = options[:skip_full_path]
45
59
  end
46
60
  end
47
61
 
@@ -57,7 +57,7 @@ module Sink3
57
57
  remote_file = bucket.objects[remote_path]
58
58
  if Sink3.config.skip_overwrite
59
59
  if ! check_exists(remote_file)
60
- puts "remote file does not exist" if Sink3.config.verbose
60
+ puts "remote file does not exist #{remote_path}" if Sink3.config.verbose
61
61
  remote_file.write(@path)
62
62
  else
63
63
  puts "skpping overwrite of #{remote_path}" if Sink3.config.verbose
@@ -72,7 +72,7 @@ module Sink3
72
72
  end
73
73
 
74
74
  def formatted_date
75
- if !ENV['SKIP_DATE_PARTITION']
75
+ if !Sink3.config.skip_date_partition
76
76
  return "#{Time.now.strftime "%Y-%m-%d"}/"
77
77
  else
78
78
  return ""
data/lib/sink3/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Sink3
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sink3
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fabrizio Regini