Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not follow standard filename convention #5

Open
samnang opened this issue May 2, 2012 · 6 comments
Open

Not follow standard filename convention #5

samnang opened this issue May 2, 2012 · 6 comments

Comments

@samnang
Copy link
Member

samnang commented May 2, 2012

Following Ruby standard filename convention, filename should be all in lowercase and separate each word by underscore, but I see some filenames break this rule:

commonlogger.rb      # CommonLogger
methodoverride.rb    # MethodOverride
showexceptions.rb    # ShowExceptions

I feel it should be

common_logger.rb     # CommonLogger
method_override.rb   # MethodOverride
show_exceptions.rb   # ShowExceptions

Do have any ideas why they have filenames like this?

@skade
Copy link

skade commented May 2, 2012

Historical reasons, I guess. Rack is a pretty old library and this naming convention wasn't as strict back then (I am not even sure whether it wasn't just considered a "Rails convention"). Changing the file name of commonlogger.rb would break a lot of stuff.

@tomykaira
Copy link

I noticed that Rack takes capitalized hash key like :Host, :Port, and :AccessLog(https://github.com/codereading/rack/blob/rack-1.4/lib/rack/server.rb#L43).

Are these historical, too? They are queer to me.

@skade
Copy link

skade commented May 2, 2012

I think the case here is a bit different:

https://github.com/codereading/rack/blob/rack-1.4/lib/rack/server.rb#L142-173

As you can see, most options are downcased, except the options that are directly passed to the Handler. I think its a kind of "namespacing".

@tomykaira
Copy link

I see. Thanks @skade !

@samnang
Copy link
Member Author

samnang commented May 4, 2012

Changing the file name of commonlogger.rb would break a lot of stuff.

Why that could be happen? I see it load by using autoload :CommonLogger, "rack/commonlogger" in lib/rack.rb, so other libraries could require 'rack' and use this middleware by calling its classname use Rack::CommonLogger without any problems. I don't see the point why other libraries require 'rack/commonlogger' directly like that.

@skade
Copy link

skade commented May 4, 2012

One reason might be that autoload is inherently thread-unsave and should not be used. It is also deprecated and flagged for removal[1]. Also, even if autoload hooks are in place, libs are still free to require commonlogger.rb by hand, which some do to ensure load order. I do so regularly to avoid autoload issues which blow up in my face in regular intervals and would recommend to do so in any case.

[1] http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/41149

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants