Class: Kybus::CLI::Bot::FileProvider

Inherits:
Object
  • Object
show all
Defined in:
lib/kybus/cli/bot/file_provider.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, config) ⇒ FileProvider

Returns a new instance of FileProvider.



7
8
9
10
11
# File 'lib/kybus/cli/bot/file_provider.rb', line 7

def initialize(name, config)
  @file_writer = Kybus::CLI::FileWriter.new(name)
  @config = config
  @name = name
end

Class Method Details

.autoregister!Object



28
29
30
# File 'lib/kybus/cli/bot/file_provider.rb', line 28

def self.autoregister!
  Kybus::CLI::Bot::ProjectGenerator.register_file_provider(self)
end

Instance Method Details

#bot_nameObject



32
33
34
# File 'lib/kybus/cli/bot/file_provider.rb', line 32

def bot_name
  @name
end

#bot_name_classObject



36
37
38
# File 'lib/kybus/cli/bot/file_provider.rb', line 36

def bot_name_class
  @name.split('_').map(&:capitalize).join
end

#bot_name_constantizeObject



40
41
42
# File 'lib/kybus/cli/bot/file_provider.rb', line 40

def bot_name_constantize
  bot_name_snake_case.upcase
end

#bot_name_snake_caseObject



44
45
46
# File 'lib/kybus/cli/bot/file_provider.rb', line 44

def bot_name_snake_case
  @name.gsub(' ', '_').downcase
end

#generateObject



21
22
23
24
25
26
# File 'lib/kybus/cli/bot/file_provider.rb', line 21

def generate
  @file_writer.write(saving_path, make_contents) unless skip_file?
  keep_files.each do |file|
    @file_writer.write(file, '')
  end
end

#keep_filesObject



17
18
19
# File 'lib/kybus/cli/bot/file_provider.rb', line 17

def keep_files
  []
end

#skip_file?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/kybus/cli/bot/file_provider.rb', line 13

def skip_file?
  false
end