Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
translate to ObjectSpace? (Ruby/Smalltalk
Giles Bowkett
10/15/2007 6:33:00 PM
Here's a cool Smalltalk code snippet:
(Smalltalk allClasses
select:[:each | each category beginsWith: 'Todo-'])
inject: 0 into: [:sum :each | sum + each linesOfCode]
It comes from a blog:
http://blog.teksol.info/2007/10/15/todoapp-on-seaside-in...
What it does is grep the Smalltalk equivalent of ObjectSpace for code
in the author's application. It's pretty easy to do because Smalltalk
objects have categories, and the app uses a simple convention where
everything in it is in a Todo-Xyz category.
Anyway, having grabbed each object, it then sums all the lines of code.
Is this possible in Ruby? I think you'd have to graft something onto Object:
class Object
def lines_of_code
File.open("directory_where_all_my_ruby_stuff_will_be/#{self.name}").lines
end
end
Obviously this is pseudocode. Obviously it also depends on a
"convention over configuration" situation, where you can predictably
locate your files. But is it possible? Any ideas for an elegant
implementation?
--
Giles Bowkett
Blog:
http://gilesbowkett.bl...
Portfolio:
http://www.gilesg...
Tumblelog:
http://giles.t...
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
translate to ObjectSpace? (Ruby/Smalltalk
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password