简体   繁体   English

如何在 Ruby 中创建多模块项目(子项目)

[英]How to create a multi module project(subproject) in Ruby

In java, there are various ways to create multiple module project.在 java 中,有多种方法可以创建多模块项目。 Maven provides extensive support for it. Maven 为其提供了广泛的支持。

I am wondering if such a feature is available in ruby.我想知道 ruby 中是否有这样的功能。

Why we need it: A full-stack project has middle tier, front end html and js controller code.为什么我们需要它:一个全栈项目有中间层,前端 html 和 js controller 代码。 This will help in categorize each of them.这将有助于对它们中的每一个进行分类。

Modules and Gems模块和宝石

In Ruby, a Module is a class-like object that collects methods and constants, and can be mixed into other classes.在 Ruby 中, Module是一个类 object 收集方法和常量,可以混入其他类。 That's probably not what you're really asking about, but other solutions generally build on top of Ruby's Module and Class semantics.这可能不是您真正要问的,但其他解决方案通常建立在 Ruby 的 Module 和Class语义之上。

You're more likely to be looking for something like RubyGems and Bundler to manage libraries and dependencies.您更有可能寻找RubyGemsBundler之类的东西来管理库和依赖项。 The documentation for each is fairly extensive.每个文档都相当广泛。

Frameworks like Ruby on Rails also offer additional capabilities to inject gems and modules directly into the codebase, but it's arguably more common in Rails to build out these capabilities with gems and bundles.诸如 Ruby on Rails 之类的框架也提供了将 gems 和模块直接注入代码库的额外功能,但在 Rails 中使用 gems 和 bundles 构建这些功能可能更常见。 An exhaustive treatment of all the various ways to extend Rails (eg vendored gems, plugins, engines, etc.) is beyond the scope of a reasonable Stack Overflow answer, though.不过,对扩展 Rails 的所有各种方法(例如,供应的 gem、插件、引擎等)的详尽处理超出了合理的 Stack Overflow 答案的 scope 范围。 I mention some of them here in passing to help you search for the right documentation for your specific use cases.我在这里顺便提到了其中一些,以帮助您为您的特定用例搜索正确的文档。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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