cartup 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4b529da15184419a5a526234a6fc53217ed14555
4
- data.tar.gz: 6bf24022197f7ca8bf0fc3103ed6c9eef194329a
3
+ metadata.gz: 07ccbcdd9ed3075dbdc3c386e44d1b9e2d3acb05
4
+ data.tar.gz: accb83bb6d39c95b43281a3f1d450dac969d9f9c
5
5
  SHA512:
6
- metadata.gz: d14623ba35b5b2b389bef2e477e3b62276be420534b6948980b0dc65813ad3dfa7e3d3df7fa08fe314b77803c4df25e19a07eaeb6b62d28b8701677053e1b92a
7
- data.tar.gz: 91db41918a0847b6aed2f71da4ee53aba8736d72ff8529971a452afd2b40c3ee2ad7eb920b14263621f3533825a1ef138048f480bda65d0be36737862ec4b573
6
+ metadata.gz: e2c1282c12a805c0c5e598c499255ebf0f07f0532c2c32fba7b1c7013f5c697b687a7f328822c7bedd42c621f45fd086317455795c20488b001d27db0cb76cce
7
+ data.tar.gz: 590d99cb165314db8c92b71ec4cb195536bf4513a184ccd90c3c1cc3c5d9155c8ba8488fc20e8777153765c23ee8093ffdf4485bf60c235d351e4c9dc9384d97
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cartup (1.0.0)
4
+ cartup (1.0.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -1,3 +1,3 @@
1
1
  module CartBinaryUploader
2
- VERSION = '1.0.0'.freeze
2
+ VERSION = '1.0.1'.freeze
3
3
  end
@@ -25,7 +25,7 @@ module CartBinaryUploader
25
25
  end
26
26
 
27
27
  def self.setup config
28
- if !config.project.google?
28
+ if !config.project.google.nil?
29
29
  CartLogger.log_info 'Starting with google cloud'
30
30
  setup_google_cloud config
31
31
  else
@@ -29,8 +29,8 @@ module CartBinaryUploader
29
29
  @bucket = @storage.bucket @bucket_name
30
30
  end
31
31
 
32
- def create_file(file_path)
33
- @bucket_object = @bucket.create_file(file_path, file_path)
32
+ def upload_file(file_path)
33
+ @bucket_object = @bucket.upload_file(file_path, file_path)
34
34
  @bucket_object.signed_url(method: 'GET', expires: 3.154e+8)
35
35
  end
36
36
 
@@ -44,13 +44,6 @@ module CartBinaryUploader
44
44
  json_file.download from_file
45
45
  json_file
46
46
  end
47
-
48
- def upload_json(json_path)
49
- CartLogger.log_info 'Starting upload file to google cloud'
50
- @bucket.create_file(json_path, json_path)
51
- CartLogger.log_info 'Uploaded complete'
52
- end
53
-
54
47
  end
55
48
  end
56
49
 
@@ -43,11 +43,11 @@ module CartBinaryUploader
43
43
  @bucket = @storage.bucket(@bucket_name)
44
44
  end
45
45
 
46
- def create_file(file_path)
47
- puts "Creating #{file_path} on s3"
46
+ def upload_file(file_path)
47
+ CartLogger.log_info "Creating #{file_path} on s3"
48
48
  @bucket_object = @bucket.object(file_path)
49
49
  @bucket_object.upload_file("./#{file_path}", acl:'public-read')
50
- puts "Object #{file_path} created with url #{@bucket_object.public_url}"
50
+ CartLogger.log_info "Object #{file_path} created with url #{@bucket_object.public_url}"
51
51
  @bucket_object.public_url
52
52
  end
53
53
 
@@ -64,11 +64,5 @@ module CartBinaryUploader
64
64
  def download_config_json_file(from_file)
65
65
  @bucket.object(from_file)
66
66
  end
67
-
68
- def upload_json(json_path)
69
- CartLogger.log_info 'Starting upload json file to s3 cloud'
70
- create_file(json_path)
71
- CartLogger.log_info 'Uploaded complete'
72
- end
73
67
  end
74
68
  end
@@ -16,6 +16,10 @@ module CartBinaryUploader
16
16
  attr_accessor :json_file
17
17
  attr_accessor :bucket_object
18
18
 
19
+ attr_accessor :framework_name_source
20
+ attr_accessor :framework_name_destination
21
+ attr_accessor :json_file_path
22
+
19
23
  def initialize(bucket_name,
20
24
  framework_name,
21
25
  framework_version)
@@ -23,62 +27,75 @@ module CartBinaryUploader
23
27
  @framework_name = framework_name
24
28
  @framework_version = framework_version
25
29
 
26
- CartLogger.log_info "Creating storage"
30
+ CartLogger.log_info 'Updating storage resource file names'
31
+ create_files_names_resource
32
+ CartLogger.log_info 'Creating storage'
27
33
  create_storage
28
34
  CartLogger.log_info "Creating bucket name: #{@bucket_name}"
29
35
  create_bucket
30
36
  end
31
37
 
32
38
  def create_storage
33
- throw :not_implemented, "The current method not implemented"
39
+ throw :not_implemented, 'The current method not implemented'
34
40
  end
35
41
 
36
42
  def create_bucket
37
- throw :not_implemented, "The current method not implemented"
43
+ throw :not_implemented, 'The current method not implemented'
38
44
  end
39
45
 
40
- def upload_framework
41
- CartLogger.log_info "Prepering to upload file to cloud"
42
- framework_name_source = @framework_name + FRAMEWORK_EXTENSION_NAME + JSON_EXTENSION_ZIP
43
- framework_name_destination = @framework_name + FRAMEWORK_EXTENSION_NAME + "." + @framework_version + JSON_EXTENSION_ZIP
44
- json_path = @framework_name + JSON_EXTENSION_NAME
46
+ def create_files_names_resource
47
+ @framework_name_source = @framework_name + FRAMEWORK_EXTENSION_NAME + JSON_EXTENSION_ZIP
48
+ @framework_name_destination = @framework_name + FRAMEWORK_EXTENSION_NAME + "." + @framework_version + JSON_EXTENSION_ZIP
49
+ @json_file_path = @framework_name + JSON_EXTENSION_NAME
50
+ end
45
51
 
46
- CartLogger.log_info "Framework Source: #{framework_name_source}"
47
- CartLogger.log_info "Framework Destination: #{framework_name_destination}"
48
- CartLogger.log_info "JSON Path: #{json_path}"
52
+ def upload_framework
53
+ CartLogger.log_info 'Prepering to upload file to cloud'
54
+ CartLogger.log_info "Framework Source: #{@framework_name_source}"
55
+ CartLogger.log_info "Framework Destination: #{@framework_name_destination}"
56
+ CartLogger.log_info "JSON Path: #{@json_file_path}"
57
+ CartLogger.log_info "Verifying if the version file #{@framework_name_destination} already exists"
49
58
 
50
- CartLogger.log_info "Verifying if the version file #{framework_name_destination} already exists"
51
- unless file_on_storage_cloud framework_name_destination
59
+ unless file_on_storage_cloud(@framework_name_destination)
52
60
  CartLogger.log_info "File version #{@framework_version} not exists yet, starting generate file on cloud"
61
+ sync_json_framework_version
62
+ create_framework_with_version_name
53
63
 
54
- if file_on_storage_cloud(json_path)
55
- @json_file = download_config_json_file(json_path)
56
- if @json_file.nil?
57
- throw :could_not_download_json_file, "JSON With name: #{json_path}"
58
- end
59
- else
60
- CartLogger.log_warn "Creating empty json because it not exsits yet on cloud"
61
- create_empty_json_file(json_path)
62
- end
63
-
64
- copy_local_file(framework_name_source, framework_name_destination)
65
-
66
- shared_url = create_file(framework_name_destination)
67
-
68
- json_object = load_json_object json_path
69
- json_object[@framework_version] = shared_url
64
+ shared_url = upload_file(@framework_name_destination)
65
+ json_object = load_json_object(@json_file_path)
70
66
 
71
- save_json_object(json_path, json_object)
67
+ update_json_with_url(json_object, shared_url)
68
+ save_json_object(@json_file_path, json_object)
72
69
 
73
70
  CartLogger.log_info 'Starting upload file to storage cloud'
74
- upload_json json_path
71
+ upload_file(@json_file_path)
75
72
  CartLogger.log_info 'Uploaded complete'
76
73
  else
77
74
  throw :the_version_file_already_exists, "The current version: #{@framework_version} already exists on cloud"
78
75
  end
79
76
  end
80
77
 
81
- def create_file(file_path)
78
+ def update_json_with_url(json_object, url)
79
+ json_object[@framework_version] = url
80
+ end
81
+
82
+ def create_framework_with_version_name
83
+ copy_local_file(@framework_name_source, @framework_name_destination)
84
+ end
85
+
86
+ def sync_json_framework_version
87
+ if file_on_storage_cloud(@json_file_path)
88
+ @json_file = download_config_json_file(@json_file_path)
89
+ if @json_file.nil?
90
+ throw :could_not_download_json_file, "JSON With name: #{@json_file_path}"
91
+ end
92
+ else
93
+ CartLogger.log_warn "Creating empty json because it not exsits yet on cloud"
94
+ create_empty_json_file(@json_file_path)
95
+ end
96
+ end
97
+
98
+ def upload_file(file_path)
82
99
  throw :not_implemented, "The current method not implemented"
83
100
  end
84
101
 
@@ -98,7 +115,7 @@ module CartBinaryUploader
98
115
  throw :not_implemented, "The current method not implemented"
99
116
  end
100
117
 
101
- def upload_json jsonPath
118
+ def upload_json(json_path)
102
119
  throw :not_implemented, "The current method not implemented"
103
120
  end
104
121
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cartup
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Douglas Mendes
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2018-03-21 00:00:00.000000000 Z
12
+ date: 2018-03-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: aws-sdk-s3