<p>I'm starting to learn ruby. I'm also a day-to-day C++ dev.
For C++ projects I usually go with following dir structure</p>

<pre><code>/
 -/bin &lt;- built binaries
 -/build &lt;- build time temporary object (eg. .obj, cmake intermediates)
 -/doc &lt;- manuals and/or Doxygen docs
 -/src
 --/module-1
 --/module-2
 -- non module specific sources, like main.cpp
 - IDE project files (.sln), etc.
</code></pre>

<p>What dir layout for Ruby (non-Rails, non-Merb) would you suggest to keep it clean, simple and maintainable?</p>

[{'answer_id': 56377, 'author': 'ujh', 'author_id': 4936, 'author_profile': 'https://Stackoverflow.com/users/4936', 'pm_score': 1, 'selected': False, 'text': '<p>Why not use just the same layout? Normally you won\'t need build because there\'s no compilation step, but the rest seems OK to me.</p>\n\n<p>I\'m not sure what you mean by a module but if it\'s just a single class a separate folder wouldn\'t be necessary and if there\'s more than one file you normally write a module-1.rb file (at the name level as the module-1 folder) that does nothing more than require everything in module-1/.</p>\n\n<p>Oh, and I would suggest using <a href="http://rake.rubyforge.org/" rel="nofollow noreferrer">Rake</a> for the management tasks (instead of make).</p>\n'}, {'answer_id': 56448, 'author': 'James A. Rosen', 'author_id': 1190, 'author_profile': 'https://Stackoverflow.com/users/1190', 'pm_score': 2, 'selected': False, 'text': '<p>@<a href="https://stackoverflow.com/users/5731/dentharg">Dentharg</a>: your "include one to include all sub-parts" is a common pattern.  Like anything, it has its advantages (easy to get the things you want) and its disadvantages (the many includes can pollute namespaces and you have no control over them).  Your pattern looks like this:</p>\n\n<pre><code>- src/\n    some_ruby_file.rb:\n      require \'spider\'\n      Spider.do_something\n\n+ doc/\n\n- lib/\n  - spider/\n      spider.rb:\n        $: &lt;&lt; File.expand_path(File.dirname(__FILE__))\n        module Spider\n          # anything that needs to be done before including submodules\n        end\n\n        require \'spider/some_helper\'\n        require \'spider/some/other_helper\'\n        ...\n</code></pre>\n\n<p>I might recommend this to allow a little more control:</p>\n\n<pre><code>- src/\n    some_ruby_file.rb:\n      require \'spider\'\n      Spider.include_all\n      Spider.do_something\n\n+ doc/\n\n- lib\n  - spider/\n      spider.rb:\n        $: &lt;&lt; File.expand_path(File.dirname(__FILE__))\n        module Spider\n          def self.include_all\n            require \'spider/some_helper\'\n            require \'spider/some/other_helper\'\n            ...\n          end\n        end\n</code></pre>\n'}, {'answer_id': 62964, 'author': 'François Beausoleil', 'author_id': 7355, 'author_profile': 'https://Stackoverflow.com/users/7355', 'pm_score': 5, 'selected': True, 'text': '<p>Bundler includes the necessary infrastructure to generate a gem:</p>\n\n<pre><code>$ bundle gem --coc --mit --test=minitest --exe spider\nCreating gem \'spider\'...\nMIT License enabled in config\nCode of conduct enabled in config\n      create  spider/Gemfile\n      create  spider/lib/spider.rb\n      create  spider/lib/spider/version.rb\n      create  spider/spider.gemspec\n      create  spider/Rakefile\n      create  spider/README.md\n      create  spider/bin/console\n      create  spider/bin/setup\n      create  spider/.gitignore\n      create  spider/.travis.yml\n      create  spider/test/test_helper.rb\n      create  spider/test/spider_test.rb\n      create  spider/LICENSE.txt\n      create  spider/CODE_OF_CONDUCT.md\n      create  spider/exe/spider\nInitializing git repo in /Users/francois/Projects/spider\nGem \'spider\' was successfully created. For more information on making a RubyGem visit https://bundler.io/guides/creating_gem.html\n</code></pre>\n\n<p>Then, in lib/, you create modules as needed:</p>\n\n<pre><code>lib/\n  spider/\n    base.rb\n  crawler/\n    base.rb\n  spider.rb\n    require "spider/base"\n    require "crawler/base"\n</code></pre>\n\n<p>Read the manual page for <a href="https://bundler.io/man/bundle-gem.1.html" rel="nofollow noreferrer">bundle gem</a> for details on the <code>--coc</code>, <code>--exe</code> and <code>--mit</code> options.</p>\n'}, {'answer_id': 71564, 'author': '0124816', 'author_id': 11521, 'author_profile': 'https://Stackoverflow.com/users/11521', 'pm_score': 0, 'selected': False, 'text': "<p>I would stick to something similar to what you are familiar with: there's no point being a stranger in your own project directory. :-)</p>\n\n<p>Typical things I always have are lib|src, bin, test.</p>\n\n<p>(I dislike these monster generators: the first thing I want to do with a new project is get some code down, not write a README, docs, etc.!)</p>\n"}, {'answer_id': 82736, 'author': 'Marcin Gil', 'author_id': 5731, 'author_profile': 'https://Stackoverflow.com/users/5731', 'pm_score': 0, 'selected': False, 'text': "<p>So I went with newgem.\nI removed all unnecessary RubyForge/gem stuff (hoe, setup, etc.), created git repo, imported project into NetBeans. All took 20 minutes and everything's on green.\nThat even gave me a basic rake task for spec files.</p>\n\n<p>Thank you all.</p>\n"}, {'answer_id': 7061080, 'author': 'troutwine', 'author_id': 314318, 'author_profile': 'https://Stackoverflow.com/users/314318', 'pm_score': 4, 'selected': False, 'text': '<p>As of 2011, it is common to use <a href="https://github.com/technicalpickles/jeweler">jeweler</a> instead of newgem as the latter is effectively abandoned. </p>\n'}, {'answer_id': 14019444, 'author': 'trans', 'author_id': 1086638, 'author_profile': 'https://Stackoverflow.com/users/1086638', 'pm_score': 4, 'selected': False, 'text': '<p>The core structure of a standard Ruby project is basically:</p>\n\n<pre><code>  lib/\n    foo.rb\n    foo/\n  share/\n    foo/\n  test/\n    helper.rb\n    test_foo.rb\n  HISTORY.md (or CHANGELOG.md)\n  LICENSE.txt\n  README.md\n  foo.gemspec\n</code></pre>\n\n<p>The <code>share/</code> is rare and is sometimes called <code>data/</code> instead. It is for general purpose non-ruby files. Most projects don\'t need it, but even when they do many times everything is just kept in <code>lib/</code>, though that is probably not best practice.</p>\n\n<p>The <code>test/</code> directory might be called <code>spec/</code> if BDD is being used instead of TDD, though you might also see <code>features/</code> if Cucumber is used, or <code>demo/</code> if QED is used.</p>\n\n<p>These days <code>foo.gemspec</code> can just be <code>.gemspec</code> --especially if it is not manually maintained.</p>\n\n<p>If your project has command line executables, then add:</p>\n\n<pre><code>  bin/\n    foo\n  man/\n    foo.1\n    foo.1.md or foo.1.ronn\n</code></pre>\n\n<p>In addition, most Ruby project\'s have:</p>\n\n<pre><code>  Gemfile\n  Rakefile\n</code></pre>\n\n<p>The <code>Gemfile</code> is for using Bundler, and the <code>Rakefile</code> is for Rake build tool. But there are other options if you would like to use different tools.</p>\n\n<p>A few other not-so-uncommon files:</p>\n\n<pre><code>  VERSION\n  MANIFEST\n</code></pre>\n\n<p>The <code>VERSION</code> file just contains the current version number. And the <code>MANIFEST</code> (or <code>Manifest.txt</code>) contains a list of files to be included in the project\'s package file(s) (e.g. gem package).</p>\n\n<p>What else you might see, but usage is sporadic:</p>\n\n<pre><code>  config/\n  doc/ (or docs/)\n  script/\n  log/\n  pkg/\n  task/ (or tasks/)\n  vendor/\n  web/ (or site/)\n</code></pre>\n\n<p>Where <code>config/</code> contains various configuration files; <code>doc/</code> contains either generated documentation, e.g. RDoc, or sometimes manually maintained documentation; <code>script/</code> contains shell scripts for use by the project; <code>log/</code> contains generated project logs, e.g. test coverage reports; <code>pkg/</code> holds generated package files, e.g. <code>foo-1.0.0.gem</code>; <code>task/</code> could hold various task files such as <code>foo.rake</code> or <code>foo.watchr</code>; <code>vendor/</code> contains copies of the other projects, e.g. git submodules; and finally <code>web/</code> contains the project\'s website files.</p>\n\n<p>Then some tool specific files that are also relatively common:</p>\n\n<pre><code>  .document\n  .gitignore\n  .yardopts\n  .travis.yml\n</code></pre>\n\n<p>They are fairly self-explanatory.</p>\n\n<p>Finally, I will add that I personally add a <code>.index</code> file and a <code>var/</code> directory to build that file (search for "Rubyworks Indexer" for more about that) and often have a <code>work</code> directory, something like:</p>\n\n<pre><code>  work/\n    NOTES.md\n    consider/\n    reference/\n    sandbox/\n</code></pre>\n\n<p>Just sort of a scrapyard for development purposes. </p>\n'}]
['https://Stackoverflow.com/questions/56362', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/5731/']