module Spigoter::CLI::Init

Module for generating the necessary files. @author Daniel Ramos Acosta <danielramosacosta@hotmail.com>

Public Class Methods

generate_empty() click to toggle source
# File lib/spigoter/cli/cli_init.rb, line 52
def self.generate_empty
  open('plugins.yml', 'w+') do |f|
    f << "---\n"
    f << "Plugins:\n"
    f << "  # Plugin1:\n"
    f << "    # type: {curse|devbukkit|....}\n"
    f << "    # url: http://something.com\n"
  end
end
generate_plugins() click to toggle source
# File lib/spigoter/cli/cli_init.rb, line 32
def self.generate_plugins
  if Dir.exist?('plugins') && !Dir['plugins/*.jar'].empty?
    generate_with_plugins
  else
    generate_empty
  end
end
generate_spigoter() click to toggle source
# File lib/spigoter/cli/cli_init.rb, line 21
def self.generate_spigoter
  open('spigoter.yml', 'w+') do |f|
    f << "---\n"
    f << "Spigoter:\n"
    f << "  build_dir: build\n"
    f << "  plugins_dir: plugins\n"
    f << "  javaparams: \"-Xms1G -Xmx2G\"\n"
    f << "  spigot_version: latest\n"
  end
end
generate_with_plugins() click to toggle source
# File lib/spigoter/cli/cli_init.rb, line 40
def self.generate_with_plugins
  open('plugins.yml', 'w+') do |f|
    f << "---\n"
    f << "Plugins:\n"
    Dir['plugins/*.jar'].each do |plg|
      f << "  #{File.basename(plg).gsub(/.jar/, '')}:\n"
      f << "    # type: {curse|devbukkit|....}\n"
      f << "    # url: http://something.com\n"
    end
  end
end
init() click to toggle source
# File lib/spigoter/cli/cli_init.rb, line 11
def self.init
  ->(*) { main }
end
main(*) click to toggle source
# File lib/spigoter/cli/cli_init.rb, line 15
def self.main(*)
  Log.info 'Generating files!'
  File.exist?('spigoter.yml') ? Log.warn('spigoter.yml alredy exists') : generate_spigoter
  File.exist?('plugins.yml')  ? Log.warn('plugins.yml alredy exists')  : generate_plugins
end