# in my_gem.rb
module MyGem
def self.setup_files(project_root)
File.write(File.join(project_root, 'my_gem.txt'), 'The content of file')
# or
FileUtils.cp_r("#{__dir__}/templates/", project_root)
end
end
# in your project
require 'my_gem'
MyGem.setup_files(Dir.pwd)
# or in Rails project
MyGem.setup_files(Rails.root)
1条答案
按热度按时间tsm1rwdh1#
UPD:
假设你有一个
my_gem
gem项目,里面有/templates
文件夹:字符串