列出 Merb::Slices 依赖项的最佳方法?
我正在 Merb 应用程序中创建切片列表,如下所示:
Merb::Slices.each_slice |slice|
我想获取每个切片的依赖项列表,知道如何访问它吗?
我仍在阅读 merb 代码,解决方案可能很快就会出现;)
I'm creating a list of the Slices in my Merb app, like this:
Merb::Slices.each_slice do |slice|
I'd like to get the list of dependencies for each of this slice, any idea how to access it?
I'm still reading merb code, solution might come soon ;)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
似乎不可能获取特定切片的依赖项列表。
下一个解决方案是解析切片 init.rb
在任务中发现的一些有趣的东西,全局依赖列表:
Seems impossible to get list of dependencies for a particular slice.
The next solution is to parse the slice init.rb
Something interesting found in the quest, the global list of dependencies:
我还没有使用过切片,但根据我的理解,它们本身就像一个迷你 merb 应用程序,因此每个切片不是都有一个
/config/dependency.rb
吗? 也许这会被解析到程序中并在某个地方可用。可能有一些东西这里文档。
另外,以下是 Merb 常量(您可以从中获取环境等信息)上可用的方法。 有一个称为依赖项的函数,它返回一个数组(当我在应用程序中使用
merb -i
运行时,该数组为空)。I haven't used slices yet, but from my understanding they are like a mini merb app in themself, therefore wouldn't each slice have a
/config/dependencies.rb
? Maybe this gets parsed into the program and is available somewhere.There may be something here in the docs.
Also, here are the methods available on the Merb constant (which you get things like the environment from). There's one called dependencies which returns an array (which is empty when I'm running with
merb -i
in an app).理论上,你的切片应该像宝石一样捆绑在一起。 因此,您可以直接从 gem 本身中提取依赖项
In theory your slice should be bundled up as a gem. As such, you can pull the dependencies out of the directly from the gem itself