aws_docker_utils 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,29 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ aws_docker_utils (0.0.4)
5
+ aws-sdk
6
+ docopt
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ aws-sdk (2.2.34)
12
+ aws-sdk-resources (= 2.2.34)
13
+ aws-sdk-core (2.2.34)
14
+ jmespath (~> 1.0)
15
+ aws-sdk-resources (2.2.34)
16
+ aws-sdk-core (= 2.2.34)
17
+ docopt (0.5.0)
18
+ jmespath (1.2.4)
19
+ json_pure (>= 1.8.1)
20
+ json_pure (1.8.3)
21
+
22
+ PLATFORMS
23
+ ruby
24
+
25
+ DEPENDENCIES
26
+ aws_docker_utils!
27
+
28
+ BUNDLED WITH
29
+ 1.11.2
@@ -0,0 +1,4 @@
1
+ require "aws_docker_utils/version"
2
+
3
+ module AwsDockerUtils
4
+ end
@@ -0,0 +1,33 @@
1
+ require "aws_docker_utils/utils"
2
+ require "aws_docker_utils/docker_compose/client"
3
+ require "aws_docker_utils/s3/client"
4
+
5
+ module AwsDockerUtils
6
+ module Collectors
7
+ class ToS3
8
+
9
+ def initialize(opts={})
10
+ @bucket_name = opts.fetch('<s3_bucket_name>')
11
+ @task_name = opts.fetch('<as_task>', "file")
12
+ @container_name = opts.fetch('<container_name>')
13
+ @cmd = opts.fetch('<cmd>')
14
+
15
+ @file_name = "#{`date '+#{@task_name}_%y-%m-%d_%H-%M'`.chop}.sql"
16
+ end
17
+
18
+ def push
19
+ DockerCompose::Client.new(container_name: @container_name, cmd: "#{@cmd} > #{@file_name}").exec
20
+ file_name = Utils.compress(@file_name)
21
+
22
+ s3 = S3::Client.new(file_name: file_name, bucket_name: @bucket_name)
23
+ if s3.put(file_name)
24
+ Utils.rm(file_name)
25
+ puts "Pushed to S3."
26
+ else
27
+ puts "Unable to do the job."
28
+ end
29
+ end
30
+
31
+ end
32
+ end
33
+ end
File without changes
File without changes
@@ -0,0 +1,3 @@
1
+ module AwsDockerUtils
2
+ VERSION = '0.0.4'
3
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aws_docker_utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -51,12 +51,16 @@ extensions: []
51
51
  extra_rdoc_files: []
52
52
  files:
53
53
  - .gitignore
54
+ - Gemfile
55
+ - Gemfile.lock
54
56
  - aws_docker_utils.gemspec
55
57
  - bin/aws_docker_utils
56
- - lib/collectors/to_s3.rb
57
- - lib/docker_compose/client.rb
58
- - lib/s3/client.rb
59
- - lib/utils.rb
58
+ - lib/aws_docker_utils.rb
59
+ - lib/aws_docker_utils/collectors/to_s3.rb
60
+ - lib/aws_docker_utils/docker_compose/client.rb
61
+ - lib/aws_docker_utils/s3/client.rb
62
+ - lib/aws_docker_utils/utils.rb
63
+ - lib/aws_docker_utils/version.rb
60
64
  homepage: http://rubygems.org/gems/aws_docker_utils
61
65
  licenses:
62
66
  - MIT
@@ -1,31 +0,0 @@
1
- require "./../lib/utils"
2
- require "./../lib/docker_compose/client"
3
- require "./../lib/s3/client"
4
-
5
- module Collectors
6
- class ToS3
7
-
8
- def initialize(opts={})
9
- @bucket_name = opts.fetch('<s3_bucket_name>')
10
- @task_name = opts.fetch('<as_task>', "file")
11
- @container_name = opts.fetch('<container_name>')
12
- @cmd = opts.fetch('<cmd>')
13
-
14
- @file_name = "#{`date '+#{@task_name}_%y-%m-%d_%H-%M'`.chop}.sql"
15
- end
16
-
17
- def push
18
- DockerCompose::Client.new(container_name: @container_name, cmd: "#{@cmd} > #{@file_name}").exec
19
- file_name = Utils.compress(@file_name)
20
-
21
- s3 = S3::Client.new(file_name: file_name, bucket_name: @bucket_name)
22
- if s3.put(file_name)
23
- Utils.rm(file_name)
24
- puts "Pushed to S3."
25
- else
26
- puts "Unable to do the job."
27
- end
28
- end
29
-
30
- end
31
- end