Sha256: ccc0f96af78d783a9ef06c1361bd41cd420409dfc74324b5875fdb9a2fdd978a

Contents?: true

Size: 1.64 KB

Versions: 3

Compression:

Stored size: 1.64 KB

Contents

require "CartBinaryUploader/version"
require 'fileutils'
require 'yaml'
require 'json'
require 'ostruct'
require 'google_cloud_storage'
require 'git_helper'

module CartBinaryUploader
  def self.run
    config = getConfig

    projectId = config.project.google.project_id
    credentialsFile = config.project.google.credentials_file
    bucketName = config.project.google.bucket
    frameworkName = config.project.framework.name
    frameworkVersion = config.project.framework.version

    gitHelper = GitHelper.new

    googleCloudStorage = GoogleCloudStorage.new(projectId,
                                                credentialsFile,
                                                bucketName,
                                                frameworkName,
                                                frameworkVersion)
    googleCloudStorage.uploadFrameWork
    gitHelper.tagTo frameworkVersion
    gitHelper.push
  end

  def self.init
    CartBinaryUploader.copyTemplateYaml
  end

  def self.copyTemplateYaml
    fromSourceFile = "./lib/template.yaml"
    toDestinationFile = "./cart_uploader.yaml"
    CartBinaryUploader.copy_with_path fromSourceFile, toDestinationFile
  end

  def self.copy_with_path(src, dst)
    FileUtils.mkdir_p(File.dirname(dst))
    FileUtils.cp(src, dst)
  end

  def self.getConfig
    begin
      puts "Creating project config"
      path = FileUtils.pwd + '/cart_uploader.yaml'
      yamlFile = YAML.load_file(path)
      object = JSON.parse(yamlFile.to_json, object_class: OpenStruct)
      puts "project config Created"
      object
    rescue SystemCallError
      puts "Problem to find or pase yaml file"
      exit
    end

  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
cartup-0.1.5 lib/cartup.rb
cartup-0.1.4 lib/cartup.rb
cartup-0.1.2 lib/cartup.rb