Module: CartBinaryUploader
- Defined in:
- lib/cartup.rb,
lib/cart_logger.rb,
lib/git_tools/git_helper.rb,
lib/storage/storage_type.rb,
lib/cartup_command_helper.rb,
lib/storage/s3_cloud_storage.rb,
lib/CartBinaryUploader/version.rb,
lib/storage/google_cloud_storage.rb
Defined Under Namespace
Classes: CartLogger, CartupCommandHelper, GitHelper, GoogleCloudStorage, S3CloudStorage, Storage
Constant Summary
collapse
- VERSION =
'1.0.1'.freeze
Class Method Summary
collapse
Class Method Details
.copy_template_yaml ⇒ Object
58
59
60
61
62
63
64
65
66
67
|
# File 'lib/cartup.rb', line 58
def self.copy_template_yaml
from_source_file = './lib/template.yaml'.freeze
to_destination_file = './cart_uploader.yaml'.freeze
if File.file?(to_destination_file)
throw :cart_up_already_initialized
end
CartBinaryUploader.copy_with_path from_source_file, to_destination_file
end
|
.copy_with_path(src, dst) ⇒ Object
69
70
71
72
|
# File 'lib/cartup.rb', line 69
def self.copy_with_path(src, dst)
FileUtils.mkdir_p(File.dirname(dst))
FileUtils.cp(src, dst)
end
|
.get_config ⇒ Object
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
# File 'lib/cartup.rb', line 74
def self.get_config
begin
CartLogger.log_info 'Creating project config'
path = FileUtils.pwd + '/cart_uploader.yaml'
yaml_file = YAML.load_file(path)
object = JSON.parse(yaml_file.to_json, object_class: OpenStruct)
CartLogger.log_info 'project config Created'
object
rescue SystemCallError
CartLogger.log_error 'Problem to find or pase yaml file'
exit
end
end
|
.run ⇒ Object
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/cartup.rb', line 14
def self.run
config = get_config
framework_version = config.project.framework.version
git_helper = GitHelper.new
cloud_storage = setup config
cloud_storage.upload_framework
git_helper.tag_to framework_version
git_helper.push
end
|
.setup(config) ⇒ Object
27
28
29
30
31
32
33
34
35
|
# File 'lib/cartup.rb', line 27
def self.setup config
if !config.project.google.nil?
CartLogger.log_info 'Starting with google cloud'
setup_google_cloud config
else
CartLogger.log_info 'Starting with s3 cloud'
setup_s3_cloud config
end
end
|
.setup_google_cloud(config) ⇒ Object
37
38
39
40
41
42
43
|
# File 'lib/cartup.rb', line 37
def self.setup_google_cloud(config)
GoogleCloudStorage.new(config.project.google.project_id,
config.project.google.credentials_file,
config.project.google.bucket,
config.project.framework.name,
config.project.framework.version)
end
|
.setup_s3_cloud(config) ⇒ Object
45
46
47
48
49
50
51
52
|
# File 'lib/cartup.rb', line 45
def self.setup_s3_cloud(config)
S3CloudStorage.new(config.project.s3.bucket_name,
config.project.s3.bucket_access_key,
config.project.s3.bucket_secret_key,
config.project.s3.region,
config.project.framework.name,
config.project.framework.version)
end
|