Class: Telegrator::Generators::Bot
- Includes:
- Thor::Actions
- Defined in:
- lib/telegrator/generators/bot/generator.rb
Constant Summary collapse
- DATABASES =
%w[postgresql mongodb].freeze
Class Method Summary collapse
-
.source_root ⇒ Object
TODO: move to Base class.
Instance Method Summary collapse
-
#create_app_dir ⇒ Object
app/ directory ===.
-
#create_bin_dir ⇒ Object
bin/ directory ===.
- #create_commands ⇒ Object
-
#create_config_dir ⇒ Object
config/ directory ===.
-
#create_db_dir ⇒ Object
db/ directory ===.
-
#create_keyboards ⇒ Object
TODO: inline keyboards.
-
#create_lib_dir ⇒ Object
lib/ directory ===.
-
#create_log_dir ⇒ Object
log/ directory ===.
- #create_models ⇒ Object
- #create_root_files ⇒ Object
- #create_services ⇒ Object
- #create_workers ⇒ Object
- #init ⇒ Object
-
#initialize(args = [], options = {}, config = {}) ⇒ Bot
constructor
A new instance of Bot.
Methods inherited from Base
Constructor Details
#initialize(args = [], options = {}, config = {}) ⇒ Bot
Returns a new instance of Bot.
13 14 15 16 |
# File 'lib/telegrator/generators/bot/generator.rb', line 13 def initialize(args = [], = {}, config = {}) config[:destination_root] ||= args.first super end |
Class Method Details
.source_root ⇒ Object
TODO: move to Base class
9 10 11 |
# File 'lib/telegrator/generators/bot/generator.rb', line 9 def self.source_root File.('../templates', __FILE__) end |
Instance Method Details
#create_app_dir ⇒ Object
app/ directory ===
54 55 56 |
# File 'lib/telegrator/generators/bot/generator.rb', line 54 def create_app_dir empty_directory 'app' end |
#create_bin_dir ⇒ Object
bin/ directory ===
87 88 89 |
# File 'lib/telegrator/generators/bot/generator.rb', line 87 def create_bin_dir directory 'bin', mode: :preserve end |
#create_commands ⇒ Object
58 59 60 61 |
# File 'lib/telegrator/generators/bot/generator.rb', line 58 def create_commands template 'app/commands.rb' directory 'app/commands' end |
#create_config_dir ⇒ Object
config/ directory ===
92 93 94 95 96 97 98 99 100 |
# File 'lib/telegrator/generators/bot/generator.rb', line 92 def create_config_dir directory 'config' if [:skip_capistrano] remove_file 'config/deploy/' remove_file 'config/deploy.rb' end remove_file 'config/initializers/sequel.rb' if mongodb? end |
#create_db_dir ⇒ Object
db/ directory ===
103 104 105 106 |
# File 'lib/telegrator/generators/bot/generator.rb', line 103 def create_db_dir return if mongodb? directory 'db' end |
#create_keyboards ⇒ Object
TODO: inline keyboards
65 66 67 68 69 |
# File 'lib/telegrator/generators/bot/generator.rb', line 65 def create_keyboards return if [:skip_keyboards] template 'app/keyboards.rb' directory 'app/keyboards' end |
#create_lib_dir ⇒ Object
lib/ directory ===
109 110 111 112 |
# File 'lib/telegrator/generators/bot/generator.rb', line 109 def create_lib_dir directory 'lib' remove_file 'lib/tasks/db.rake' if mongodb? end |
#create_log_dir ⇒ Object
log/ directory ===
115 116 117 118 |
# File 'lib/telegrator/generators/bot/generator.rb', line 115 def create_log_dir empty_directory 'log' create_file 'log/.keep' end |
#create_models ⇒ Object
71 72 73 74 |
# File 'lib/telegrator/generators/bot/generator.rb', line 71 def create_models template 'app/models.rb' directory 'app/models' end |
#create_root_files ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/telegrator/generators/bot/generator.rb', line 41 def create_root_files template 'gitignore.tt', '.gitignore' template 'env.tt', '.env.sample' template 'env.tt', '.env' template 'Gemfile.tt' template 'Rakefile.tt' template 'Capfile.tt' unless [:skip_capistrano] template 'config.ru.tt' unless [:skip_webhook] end |
#create_services ⇒ Object
76 77 78 79 |
# File 'lib/telegrator/generators/bot/generator.rb', line 76 def create_services template 'app/services.rb' directory 'app/services' end |
#create_workers ⇒ Object
81 82 83 84 |
# File 'lib/telegrator/generators/bot/generator.rb', line 81 def create_workers template 'app/workers.rb' directory 'app/workers' end |
#init ⇒ Object
120 121 122 123 |
# File 'lib/telegrator/generators/bot/generator.rb', line 120 def init inside { run 'git init' } inside { run 'bundle install' } unless [:skip_bundler] end |