Common structure of gem

As we all know, the common structure of rubygem assumes presence of lib directory. I noticed, that generally in this directory are two items: gem_name.rb and gem_name/ directory. The gem_name/ directory hold main sources of project. It is heart of application. So, the question is about gem_name.rb file. What does it stand for?

-------------Problems Reply------------

The reason it's structured like that is if you had files other than gem_name.rb in the lib/ directory (say another_file_name.rb), you'd be liable to cause problems if there was a gem with the name another_file_name and someone did require another_file_name - it'd load your file, rather than the other gem's file.

If your code is small enough it can all fit into gem_name.rb, then put it there, otherwise put it into gem_name/other_file_name.rb.

Typically that just requires everything from the gem_name/ directory that's needed. It's used to keep all the requires in a central location and separate from the actual code

Category:ruby Views:0 Time:2011-03-07

Related post

  • why semaphore, message queues are based on a common structure 2011-11-12

    I am reading through These three (Shared Memory, Semaphores and Message Queues) seeming unrelated topics are presented together in they are based on a common structure Why would they use same str

  • Refer to common structure from other structures 2012-04-02

    I need to define copybook, describing my file format. In my file, there are rows of different format, but the first part of all rows is the same. How can I define the common structure only once and refer to it from other structures? I need something

  • Website Listing Commonly Used Ruby Gems, Including Alternatives 2010-03-22

    I know that I've seen this site before, but cannot remember it for the life of me. Basically, it is a listing of commonly used gems, like XML parsing or ORM libraries. For the ORM case, it lists ActiveRecord, DataMapper, and the like, stating the adv

  • Typical names for common structural/semantic classes/ids on html page? 2011-06-23

    I'm wondering about standards or commonalities for various common elements on webpages that have no specific element already associated with them. I often struggle to name certain elements of a page. I know about the ones included in html 5 for sure:

  • best practice for dealing with common "structural" elements of pages? 2009-12-28

    Very basic question: I am coding a web app that has a handful of pages. These pages have the usual shared elements: eg, the site's header/masthead and a side-bar are present on all pages. The HTML is static (not dynamically generated, its "ajaxy-ness

  • Best way to structure a repository in Subversion for Visual Studio projects? 2008-08-19

    I have a few C# .dll projects which are common to many applications. Currently, I have one big repository. I have each DLL stored as a separate project within the repository and every application project stored as a project within the same repository

  • Structure of a C++ Object in Memory Vs a Struct 2009-01-08

    If I have a class as follows class Example_Class { private: int x; int y; public: Example_Class() { x = 8; y = 9; } ~Example_Class() { } }; And a struct as follows struct { int x; int y; } example_struct; Is the structure in memory of the example_str

  • What is the best data structure for representing nodes in 3D space? 2009-02-13

    ... and thanks for reading... I'm still learning the ropes so please be forgiving... ;-) I am writing a function that meshes a solid in space. The mesh is done by using objects of a "Node" class and each node is represented by: int id double p double

  • What are the benefits of sticking with maven's default project directory structure? 2009-05-11

    Simply put, if you're using maven, should you treat the maven layout as the gold standard, or should you convert your layout to fit your tooling (WASD, myEclipse, RAD, etc.)? Realizing that maven is configurable and you can override the defaults in t

  • Need way to alter common fields in different structs 2009-09-18

    I'm programming in C here, for Windows and various Unix platforms. I have a set of structs that have common fields, but also fields that are different. For example: typedef struct { char street[10]; char city[10]; char lat[10]; char long[10]; } ADDR_

  • What structured text format is the best supported in Python? 2010-10-02

    This question may be seen as subjective, but I'd like to ask SO users which common structured textual data format is best supported in Python. My initial choices are: XML JSON and YAML Which of these three is easiest to work with in Python (ie. has t

  • Recommended program structure 2010-10-22

    as a beginner, I have formulated some ideas, but wanted to ask the community about the best way to implement the following program: It decodes 8 different types of data file. They are all different, but most are similar (contain a lot of similar fiel

  • Parallel relationship data structure 2010-10-25

    i'm not sure of the term for this problem i'm having, or if it's even an issue to worry about at all. let's say i have a hypothetical situation like this: it seems as though having the link from remix objects back to the the original objects makes fo

  • The new file/directory structure of Pyramid (Pylons) is causing me some confusion 2010-11-09

    I've been developing in Pylons for a little while now and have recently learned they're merging with another framework to create Pyramid. I've been looking over example code to see the differences and it's causing a bit of confusion... For example, C

  • $ bundle install: Failed to build gem native extension 2011-01-17

    Using Snow leopard, Rails 3.0.3, ruby 1.9.2p0 and RVM. When trying to install bundle I get: [first_app]$ bundle install Fetching source index for Using rake (0.8.7) Using abstract (1.0.0) Using activesupport (3.0.3) Using builder

  • tool to extract data structures from unclean data 2011-03-28

    I have unstructured geneally unclean data in a database field. There are common structures which are consistent in the data namely: field: name:value fieldset: nombre <FieldSet> field, . . . field(n) table nombre <table> head(1)... head(n

  • Creating a valid function declaration from a complex tuple/list structure 2011-06-14

    Is there a generic way, given a complex object in Erlang, to come up with a valid function declaration for it besides eyeballing it? I'm maintaining some code previously written by someone who was a big fan of giant structures, and it's proving to be

  • Passing structures using UDP 2011-08-06

    I have been trying to send and receive structures on the same machine using UDP and the server and client in this case run on the same machine and share common structure definitions (using a header file). Hostent structure defn(UNIX built-in type) :

  • Difference between gem and require (require open-uri) 2011-12-03

    I just wanted to understand for my self. I'm using the nokogiri gem (for parsing HTML). If I got it right to open URLs I need to use a method from the gem 'open-uri'. But when I include it in my Gemfile (on Windows developer's machine): gem 'open-uri

Copyright (C), All Rights Reserved.

processed in 0.175 (s). 11 q(s)