Sha256: 38e3483a46d5a3da0a676f45dfc8de6974ef44d4ed928ab38e1a8d625518f3da

Contents?: true

Size: 938 Bytes

Versions: 1

Compression:

Stored size: 938 Bytes

Contents

# frozen_string_literal: true

module Appifier
  class Configuration
    def self.setup(force: false)
      if File.exist?(File.expand_path(Appifier::DEFAULT_CONFIG_PATH)) && !force
        puts 'Appifier already configured'
      else
        config_file = search_file_in_gem('appifier', 'config/settings.yml')
        path = File.expand_path(Appifier::DEFAULT_TEMPLATES_PATH)
        [Appifier::DEFAULT_TEMPLATES_PATH, Appifier::DEFAULT_LOGS_PATH, Appifier::DEFAULT_CONFIG_PATH, Appifier::DEFAULT_DATASETS_PATH].each do |path|
          FileUtils.mkdir_p File.expand_path(path)
        end
        File.open(File.expand_path("#{Appifier::DEFAULT_LOGS_PATH}/#{Appifier::DEFAULT_LOG_FILENAME}"), 'w') { |file| file.write("# Appifier : beginning of log file") }
        FileUtils.cp config_file, File.expand_path(Appifier::DEFAULT_CONFIG_PATH)
        puts '[OK] Building config folder and initialize settings'
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
appifier-0.1.2 lib/appifier/setup.rb