Class: Sylvia::Bot

Inherits:
Object
  • Object
show all
Defined in:
lib/sylvia/bot.rb

Class Method Summary collapse

Class Method Details

.copy_fallback_template(target) ⇒ Object



25
26
27
28
# File 'lib/sylvia/bot.rb', line 25

def self.copy_fallback_template(target)
  source = File.expand_path('../../templates/bot', __dir__)
  FileUtils.cp_r("#{source}/.", target)
end

.git_installed?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/sylvia/bot.rb', line 21

def self.git_installed?
  system('git --version > /dev/null 2>&1')
end

.new_project(target = 'bot-app') ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/sylvia/bot.rb', line 5

def self.new_project(target = 'bot-app')
  repo = 'https://github.com/spellbooks/ruby-discord-telegram-bot-boilerplate'

  if git_installed?
    puts '➡️  Git found, cloning repo...'
    system("git clone #{repo} #{target}")
  else
    puts '⚠️  Git not found, using fallback template...'
    copy_fallback_template(target)
  end

  puts "✅ Bot project created successfully in folder: #{target}"
end