Module: Spigoter::CLI::Init
- Defined in:
- lib/spigoter/cli/cli_init.rb
Overview
Module for generating the necessary files.
Class Method Summary collapse
- .generate_empty ⇒ Object
- .generate_plugins ⇒ Object
- .generate_spigoter ⇒ Object
- .generate_with_plugins ⇒ Object
- .init ⇒ Object
- .main ⇒ Object
Class Method Details
.generate_empty ⇒ Object
52 53 54 55 56 57 58 59 60 |
# 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 ⇒ Object
32 33 34 35 36 37 38 |
# 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 ⇒ Object
21 22 23 24 25 26 27 28 29 30 |
# 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 ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 |
# 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 ⇒ Object
11 12 13 |
# File 'lib/spigoter/cli/cli_init.rb', line 11 def self.init ->(*) { main } end |
.main ⇒ Object
15 16 17 18 19 |
# 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 |