如何将Ruby库添加到我的应用程序?

时间:2022-10-30 13:34:49

I've trying to use the sharefile-ruby library, which is a wrapper for the ShareFile API.

我试图使用sharefile-ruby库,它是ShareFile API的包装器。

There is no gem for it, so I believe I have to add the .rb file manually. Every library I've used I just install the gem, so I'm not sure what to do here.

它没有宝石,所以我相信我必须手动添加.rb文件。我使用的每个库我只是安装了gem,所以我不知道该怎么做。

Also, to use this library, would I just add require 'sharefile-ruby' in each controller I'm trying to use it in?

另外,要使用这个库,我是否只是在我试图使用它的每个控制器中添加require'harefile-ruby'?

1 个解决方案

#1


3  

The library is a single Ruby file. Just place the file somewhere in your app and require it with:

该库是一个单独的Ruby文件。只需将文件放在应用中的某个位置,并将其与以下内容一起使用

require 'sharefile-ruby'

Of course, if you place it in lib/foo/sharefile-ruby.rb then you'll need to use:

当然,如果你把它放在lib / foo / sharefile-ruby.rb中,那么你需要使用:

require 'foo/sharefile-ruby'

and so on.

等等。

#1


3  

The library is a single Ruby file. Just place the file somewhere in your app and require it with:

该库是一个单独的Ruby文件。只需将文件放在应用中的某个位置,并将其与以下内容一起使用

require 'sharefile-ruby'

Of course, if you place it in lib/foo/sharefile-ruby.rb then you'll need to use:

当然,如果你把它放在lib / foo / sharefile-ruby.rb中,那么你需要使用:

require 'foo/sharefile-ruby'

and so on.

等等。