Sha256: c01ec199341ba7419dfd4a0e4b005abf80c11d5ce5e73512d8c7ef2f3daf904b

Contents?: true

Size: 1.38 KB

Versions: 8

Compression:

Stored size: 1.38 KB

Contents

require_relative "./template/functions_app"
require_relative "./template/functions_gemfile"
require_relative "./template/functions_env_yaml"
module Souls
  class Create < Thor
    desc "functions", "Create SOULs functions"
    def functions
      create_app_file
      create_gemfile
      create_env_yaml
    end

    private

    def create_app_file
      file_dir = "./apps/functions"
      FileUtils.mkdir_p(file_dir) unless Dir.exist?(file_dir)
      file_path = "#{file_dir}/app.rb"
      raise(StandardError, "Already Exist!") if File.exist?(file_path)

      File.write(file_path, Template.functions_app)
      Souls::Painter.create_file(file_path)
      file_path
    end

    def create_gemfile
      file_dir = "./apps/functions"
      FileUtils.mkdir_p(file_dir) unless Dir.exist?(file_dir)
      file_path = "#{file_dir}/Gemfile"
      raise(StandardError, "Already Exist!") if File.exist?(file_path)

      File.write(file_path, Template.functions_gemfile)
      Souls::Painter.create_file(file_path)
      file_path
    end

    def create_env_yaml
      file_dir = "./apps/functions"
      FileUtils.mkdir_p(file_dir) unless Dir.exist?(file_dir)
      file_path = "#{file_dir}/.env.yaml"
      raise(StandardError, "Already Exist!") if File.exist?(file_path)

      File.write(file_path, Template.functions_env_yaml)
      Souls::Painter.create_file(file_path)
      file_path
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
souls-1.15.5 lib/souls/cli/create/functions.rb
souls-1.15.4 lib/souls/cli/create/functions.rb
souls-1.15.3 lib/souls/cli/create/functions.rb
souls-1.15.2 lib/souls/cli/create/functions.rb
souls-1.15.1 lib/souls/cli/create/functions.rb
souls-1.15.0 lib/souls/cli/create/functions.rb
souls-1.14.3 lib/souls/cli/create/functions.rb
souls-1.14.2 lib/souls/cli/create/functions.rb