cartup 1.0.0 → 1.0.1
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 +4 -4
- data/Gemfile.lock +1 -1
- data/lib/CartBinaryUploader/version.rb +1 -1
- data/lib/cartup.rb +1 -1
- data/lib/storage/google_cloud_storage.rb +2 -9
- data/lib/storage/s3_cloud_storage.rb +3 -9
- data/lib/storage/storage_type.rb +50 -33
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 07ccbcdd9ed3075dbdc3c386e44d1b9e2d3acb05
|
4
|
+
data.tar.gz: accb83bb6d39c95b43281a3f1d450dac969d9f9c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e2c1282c12a805c0c5e598c499255ebf0f07f0532c2c32fba7b1c7013f5c697b687a7f328822c7bedd42c621f45fd086317455795c20488b001d27db0cb76cce
|
7
|
+
data.tar.gz: 590d99cb165314db8c92b71ec4cb195536bf4513a184ccd90c3c1cc3c5d9155c8ba8488fc20e8777153765c23ee8093ffdf4485bf60c235d351e4c9dc9384d97
|
data/Gemfile.lock
CHANGED
data/lib/cartup.rb
CHANGED
@@ -29,8 +29,8 @@ module CartBinaryUploader
|
|
29
29
|
@bucket = @storage.bucket @bucket_name
|
30
30
|
end
|
31
31
|
|
32
|
-
def
|
33
|
-
@bucket_object = @bucket.
|
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
|
47
|
-
|
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
|
-
|
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
|
data/lib/storage/storage_type.rb
CHANGED
@@ -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
|
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,
|
39
|
+
throw :not_implemented, 'The current method not implemented'
|
34
40
|
end
|
35
41
|
|
36
42
|
def create_bucket
|
37
|
-
throw :not_implemented,
|
43
|
+
throw :not_implemented, 'The current method not implemented'
|
38
44
|
end
|
39
45
|
|
40
|
-
def
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
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
|
-
|
47
|
-
CartLogger.log_info
|
48
|
-
CartLogger.log_info "
|
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
|
-
|
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
|
-
|
55
|
-
|
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
|
-
|
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
|
-
|
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
|
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
|
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.
|
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-
|
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
|