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_workers ⇒ 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 ===
51 52 53 |
# File 'lib/telegrator/generators/bot/generator.rb', line 51 def create_app_dir empty_directory 'app' end |
#create_bin_dir ⇒ Object
bin/ directory ===
79 80 81 |
# File 'lib/telegrator/generators/bot/generator.rb', line 79 def create_bin_dir directory 'bin', mode: :preserve end |
#create_commands ⇒ Object
55 56 57 58 |
# File 'lib/telegrator/generators/bot/generator.rb', line 55 def create_commands template 'app/commands.rb' directory 'app/commands' end |
#create_config_dir ⇒ Object
config/ directory ===
84 85 86 87 88 89 90 91 92 |
# File 'lib/telegrator/generators/bot/generator.rb', line 84 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 ===
95 96 97 98 |
# File 'lib/telegrator/generators/bot/generator.rb', line 95 def create_db_dir return if mongodb? directory 'db' end |
#create_keyboards ⇒ Object
TODO: inline keyboards
62 63 64 65 66 |
# File 'lib/telegrator/generators/bot/generator.rb', line 62 def create_keyboards return if [:skip_keyboards] template 'app/keyboards.rb' directory 'app/keyboards' end |
#create_lib_dir ⇒ Object
lib/ directory ===
101 102 103 104 |
# File 'lib/telegrator/generators/bot/generator.rb', line 101 def create_lib_dir directory 'lib' remove_file 'lib/tasks/db.rake' if mongodb? end |
#create_log_dir ⇒ Object
log/ directory ===
107 108 109 110 |
# File 'lib/telegrator/generators/bot/generator.rb', line 107 def create_log_dir empty_directory 'log' create_file 'log/.keep' end |
#create_models ⇒ Object
68 69 70 71 |
# File 'lib/telegrator/generators/bot/generator.rb', line 68 def create_models template 'app/models.rb' directory 'app/models' end |
#create_root_files ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/telegrator/generators/bot/generator.rb', line 38 def create_root_files template 'gitignore.tt', '.gitignore' inside { run 'git init' } template 'env.tt', '.env.sample' template 'env.tt', '.env' template 'Gemfile.tt' template 'Rakefile.tt' template 'Capfile.tt' unless [:skip_capistrano] end |
#create_workers ⇒ Object
73 74 75 76 |
# File 'lib/telegrator/generators/bot/generator.rb', line 73 def create_workers template 'app/workers.rb' directory 'app/workers' end |