Oracle + Rails = Rebranded happy developer 5
Acabo de tener una alegria de esas gordas, orondas, de las que te hacen sonreir. Acabo de poner Rails on Oracle. XD.
El adaptador para oracle salio hace unos meses. En cuanto lo vi intenté montar una pequeña aplicacion de test sobre él. Utilizando este magnifico howto empecé a preparar el entorno y todo iba bien hasta que llegue a la compilación del driver oci8. No consegui compilar y me quede triste y ad portas, es decir como Anibal pero sin entrar.
Hoy me he percatado de que habia salido una versión nueva del driver (la 0.1.12) y he decidido probar suerte, aunque sin mucho entusiasmo. Cual ha sido mi sorpresa cuando he visto:
aitor@edoras:~/tmp/ruby-oci8-0.1.12> irb
irb(main):001:0> require 'oci8'
=> true
irb(main):002:0> exitYahoooo!. Ahí si he empezado a salivar de verdad. Un script/generate scaffold Aparato y def self.table_name() “t_aparatos” end despues tenia ante mi primera instalación rails sobre oracle.
Obviamente aun he de probar muchas cosas (para empezar al no estar mi DB schema adaptado a las convenciones Rails tengo que sobreescribirlas para poder editar/crear registros) pero ya he descubierto la primera cosa que no cita el tutorial original y que es imprescindible para poder usar rails en Oracle por defecto: una secuencia llamada rails_sequence que debe existir en vuestro tablespace y que se puede crear asi:CREATE SEQUENCE rails_sequence
MINVALUE 1
START WITH 1
INCREMENT BY 1;A veces la informática mola.
PS: Creo que este era el empujoncito que me faltaba para terminar el articulo que le habia prometido a lasterra sobre “Convention over configuration”.
Sobre como evolucionar un API
xml.title('1<2') => <title>1<2</title>
@xml.a(:title => '1<2') => <a title="1<2"/>El tema es que Sam ha realizado un parche que ilustra muy bien la naturaleza abierta en runtime de las clases en Ruby.
Por instructivo y pedagogico que resulte todo esto no es el punto al que me quiero referir en el post. Casualmente Jim Weirich, que mantiene esta libreria, la habia actualizado el fin de semana anterior porque otra persona se habia percatado del mismo bug. El software estaba corregido en el CVS. Curiosamente el enfoque que habia tomado Jim no era el que yo (y parece que tampoco Sam) esperaba: xml = Builder::XmlMarkup.new(:escape_attrs => true)An early user of builder was using entities explicitly in attribute values. Escaping attribute values would make that use very difficult. On the flip side 99% of the users don’t care about that use case, so that was probably a bad call early on.
Y aqui es donde queria llegar. Sam en otro comentario aporta unos razonamientos excelentes sobre cómo y por qué tomar decisiones en la evolución de un API:
Several counterpoints:
- This just moves the problem. Rails automatically instantiates the builder object, and generally eschews configuration. Requiring configuration for an option that 99% of the users will want (or equivalently — will be prone to error if not set) just doesn’t make good sense.
- Apparently, the API changed for builder 1.0, so there is precedent for making incompatible changes.
- As was previously stated, 99% of the users would find it surprising if they were told that they were responsible for escaping — but only in the case of attributes. Most of these people won’t notice the change, except for the fact that the documents that they produce are not only more often well formed, but also that these documents actually convey the information that they expect.
- The users that expect to have control over escaping are more likely to have unit tests that will fail if the default changed – and therefore, would more likely be in a better position to react (i.e., discover and make the one line change).
Net: in real life, I tend to find that there are rarely any absolutes. Every bug is potentially a feature, and therefore every bug fix is potentially a breaking change. That doesn’t mean that bug fixes shouldn’t be made. Both builder and rails are comparatively young and — at the moment at least — fairly free from the cruft that this option is an example of. Three years from now, is this the way we all would like to see this API look?
Finalmente Jim ha aceptado que las argumentaciones de Sam son acertadas e introducirá el arreglo dentro del funcionamiento por defecto del XML Builder. Todo un ejemplo del buen hacer de dos monstruos del mundo del Open Source que toman las decisiones adecuadas con esa herramienta tan devaluada hoy en dia que se llama diálogo.
Look Ma'! I've mounted the Rails! 1
Now, run mkdir /railsmnt. Then, script/filesys /railsmnt. The rules are as follows:
- ls /railsmnt will give you a list of tables.
- ls /railsmnt/table will list IDs from the table.
- cat /railsmnt/table/id will display a record in YAML.
- vim /railsmnt/table/id to edit the record in YAML!
OMFG . I just came in my pants.
Update: Desgraciadamente no puedo montar FUSE en mi Linux porque no tengo los fuentes del kernel instalados… ¡Maldita sea!. Ya habia instalado xcruiser y esta preparado para navegar la galaxia de Rails. Shame on me!.
Update II: Estoy a punto de la neurisma total con las ideas sobre este concepto que plantean en HURD . Particularmente la de Source Code y Birthday.
Tirando de la manta del tren
Al final de la ya archiconocida, archilinkada y architrackbackeada entrevista de DHH en O’Reilly, el camarada deja caer una de esas frases que le dejan a uno con una ceja enarcada:
Acto seguido unos cuantos nos hemos dirigido al repositorio de Subversion de Rails y nos hemos encontrado con unas pocas pero intrigantes clases y una extension a la ruby de ActionController :After that, we do have a ton of plans, though. I’m especially excited about The Conductor. But I’ll keep that guy under wraps for a little while longer.
module ActionController
class Base
# Profile each request and append the results to the response body.
# Requires the ruby-prof C extension by Shugo Maeda which requires
# Ruby 1.8 younger than 2005-03-22 (this means CVS.)
#
# TODO: Prof.started? to test whether profiling has begun
# and Prof.clock_mode to read clock mode.
#
# Timing modes:
# :clock Use clock(3). Default for compatibility.
# :gettimeofday Use gettimeofday(2).
# :cpu Use the CPU clock counter like RDTSC on Pentium.
# Available on Pentium and PowerPC only.
def self.profile_requests(timing_mode = :clock)
if ProfilerFilter.available?
ProfilerFilter.timing_mode = timing_mode
around_filter ProfilerFilter
end
end
end
endAnd it should be: this is something I’m very passionate about. Developer productivity is not to be dismissed lightly. Ruby has a leg up on Java right now because it is inherently a better language. But it is far from a better platform right now, which is unfortunate. So the question is: Which will happen first? Will Ruby get the tools, or will Java get its act together and catch up to Ruby? One, if not both, are bound to happen soon, and no matter what the developers will win.
Esta es una de las caracteristicas principales que definiran la evolución final de Rails y su adopción por parte del mundo empresarial…
El principio CAN 2
Asi de sencillo. Esta mañana estoy perdiendo más tiempo del recomendable leyendo sobre el tema:Components Aren’t Necessary.