简体   繁体   中英

How to add gem dependency to my ruby gem

I think I am fundamentally missing something. I am learning ruby, and have been playing with Lita lately, and wrote(my first) a simple little gem to get some directions/distance from the bot. The problem I am having is where to put a gem dependency in my gem. To work, my gem requires the 'rest-client' gem. Where do I put this in my code so that it is available to my Directions class? Currently, to get it to run, I am requiring the gem in my bots actual gemfile. And when I bundle exec lita, it apparently becomes available for my gem to use... but if I remove it from there, I can't get it to work anywhere in my gem.. what am I missing? It is here if anyone wants to read the code and tell me where I should be adding it:

https://github.com/cashman04/lita-directions

EDIT: I added the dependency like spickermann suggested. Then had to add require 'rest-client'to my directions.rb. Not entirely sure if this is the correct way, but it works now. Thanks for the help spickermann

lita-directions.gemspec下行放在您的lita-directions.gemspec旁边,该行旁边定义了对lita的依赖关系:

spec.add_runtime_dependency 'rest-client'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM