How to use an ax instead of a rake in a railtie

I would like to provide exact tasks instead of rake tasks in Railtie. There is a direct and well-documented way to provide rake scripts in Railties:

class MyRailtie < Rails::Railtie rake_tasks do load "path/to/my_railtie.tasks" end end 

How can I do the same for exact tasks?

+6
source share
1 answer

Thor is just a ruby. All you have to do is make sure the dependency is in your gemspec and then just the file from the main gem file is required.

Example:

Your gemspec gem should contain the following line:

 gem.add_dependency :thor 

Then in. /lib/kermit.rb include the following:

 require 'cli' 

Then create a file with the name. /lib/cli.rb and put the torus code there. For instance:

 require 'thor' class App < Thor # Your Code end 
0
source

Source: https://habr.com/ru/post/908601/


All Articles