Mostrando entradas con la etiqueta ror. Mostrar todas las entradas
Mostrando entradas con la etiqueta ror. Mostrar todas las entradas

martes, 13 de abril de 2010

Improve your code with Haml/Mejora tu código con Haml






In English

Hamles un lenguaje de marcado que me gusto mucho por dos o tres motivos principales.

1 - Escribis menos: cada tag que generes, ya sea un form, div, span, etc no necesita
ser cerrado como cuando utilizas html.

2 - Correcta identacion: te obliga a tener el código ordenado por lo que podría ser
bueno si trabajas con un diseñador gráfico que tenga el coraje/ganas de aprender
este markup. No debería llevar tanto tiempo de aprendizaje y los beneficios tanto
para diseñador como desarrollador van a ser grandes a la hora de leer y entender el
código en vistas, partials, layouts, etc.

3 - Consecuencia de los dos puntos anteriores: Tu código sera menos extenso, tendras
una lectura mas rápida y clara, llegaras al punto que quieras en menos tiempo y con
menos esfuerzo de escritura/corrección de código, menos posibles bugs por mal cierre
de tags, codigo más limpio. En una palabra, te ayuda a ser un mejor programador,
aunque tu puedes hacer y deshacer algo que quizás otro programador lo haría de forma
mas simple, pero eso ya es otro problema.

Yo estoy utilizando este lenguaje en aplicaciónes Rails desde hace un corto tiempo,
pero pienzo seguir implementandolo para futuros desarrollos mientras no haya un
diseñador/jefe que se oponga o resista al cambio. Sino, sera cuestión de demostrar
cuales son las razones por las que sería bueno utilizarlo.

Por lo que vi existen para otros lenguajes algunas herramientas inspiradas en Haml
como Ghrml para Python, Fammel para Php, Scalate para Scala o NHaml
para .Net






En español

Haml is a markup language that likes me for two or three mainly reasons.

1 - Write less: each tag that you make, whatever be, a form, div, span, etc doesn't
need be closed like when you use html.

2 - Correct indentation: you must have ordered code,thing that could be good if you
work with a graphic designer that has the courage/intentions of learn this markup
language. It should not take too much time of learning and the benefits for the
designer as the programmer too could be a big thing at the hour of read and understand
the code in views, partials, layouts, etc.

3 - As consequence of the first two points: Your code will be less extensive, a major
speed to read, reach the point that you want in less time and with less efforts of
write code, less possible bugs for bad close of tags, clean code. In one word, it
helps you to be a better programmer, although you could do and undo something that
maybe another programmer would be doing in a easier way, but this is another problem
for resolve, not a Haml problem.

I am using this language in Rails applications since a couple of weeks ago, but I
think I'll continue using this for future applications while there aren't
designers/bosses that reject to the change. But, i think that it will be only a
question of show the reasons 'why?' this is a good choice.

I saw that exist for another languages some tools inspired in Haml like Ghrml for
Python, Fammel for Php, Scalate for Scala or NHaml for .Net





First Pict: A form with .haml/Un formulario con Haml:





Second Pict: And with html.erb it should be write like this/ Y con html.erb debería
ser escrito así:


































Como puedes ver, en la segunda imagen tiene 10 lineas mas de codigo que en la primer
imagen y el código en la primer imagen solo funciona si esta identado, una buena
razon para ser ordenado no?!

As you can see, the second picture has ten lines more of code than first picture and
the code in first picture is indented or it won't work, a good reason to be ordered
to write code, no?!


lunes, 6 de abril de 2009

Attending 'LocosxRails' in Buenos Aires




I went to Buenos Aires for two days(three and four of April) to
take part
in
an misterious first event
about Rails called LocosXRails("cracy for Rails in english") and
it was a great event,
I think that it was the first event related and dedicated to Ruby On Rails in
Argentina with international speakers( if I do not stay in a mistake!! ).
I found some others Rails developer. Some people that does not develop applications on
Rails actually, but their bosses send there to see what happen with
this 'misterious new' framework
or their personal interest in Rails is rounding in their heads.

The presentations were interesting,
I liked the presentation of Fabio Akita
(about internationalization),Obie Fernandez(experiences
in his company),Luis Lavena(talking
about the proyect 'One-Click Ruby Installer'),
Evan Henshaw-Plath (talking about OAuth)
Evan Phoenix(talking about good manners to coding in ruby),
Emilio Tagua(talking about'testing'
rails applications) and other presentation about Rails + Sequel by Adrian
Mugnolo, all the presentations had something interesting(without offence).
Here is the list of speakers for this event

The organizers said that they are thinking just now in working to organize
a similar event in 2010 and those are a good news

PS: They excuse my errors for English or also they can correct to me if
you want

jueves, 26 de marzo de 2009

Graficos estadisticos con flash en Rails


Bueno, estuve buscando diferentes alternativas para agregar graficos chart a una aplicacion que estoy desarrollando con el framework Ruby on Rails y en primera instancia utilize la api de google chart para agregar algunos graficos, pero me parecieron bastante estaticos a la vista por lo que queria buscar otras bibliotecas o plugins. Entonces, luego decidi buscar algo un poco mas llamativo o lindo a la vista y encontre el plugin open flash chart que lo instale desde github.com.

Bueno, los pasos que di en la instalacion fueron los siguientes.

Desde el directorio raiz se instala el plugin



script/plugin install git://github.com/pullmonkey/open_flash_chart.git
y copio dos archivos desde la instalacion del plugin al directorio public de la aplicacion

cp vendor/plugins/open_flash_chart/assets/open-flash-chart.swf   public/open-flash-chart.swf

cp vendor/plugins/open_flash_chart/assets/javascripts/swfobject.js public/javascripts/swfobject.js

Luego en el controlador del modulo donde quiero mostrar el grafico cree los siguientes metodos



def stats
@graph = open_flash_chart_object(600,300,"/my_controller/graph_statistics/")
end

def graph_statistics
pie_values
title = Title.new('Title of the graph')

pie = Pie.new
pie.start_angle = 35
pie.animate = true
pie.tooltip = '#val# de #total# #percent# del 100%'
pie.colours = ["#5858FA", "#FF0080"]
pie.values = @pie_values

chart = OpenFlashChart.new
chart.title = title
chart.add_element(pie)

chart.x_axis = nil

render :text => chart.to_s
end

private

def pie_values
@pie_values = []
if not Controller.some_values.empty?
Controller.some_values unless @pie_values << Controller.some_values
end

if not Controller.other_values.empty?
Controller.other_values unless @pie_values << Controller.other_values
end
end


y en la vista stats.html.erb agregue lo siguiente


<%= javascript_include_tag('swfobject') %>
<%= @graph %>


lo que al arrancar la aplicacion y llamar en mi vista de estadísticas para el modulo que implemente el chart me muestra un interesante gráfico un poco mas lindo que lo que se obtiene con los graficos chart de la api de google


Esta bueno el plugin este, si no los utilizaron recomiendo que lo prueben, queda bastante bien y tiene graficos para todos los gustos. Ademas por lo que vi en la pagina oficial de esta libreria teethgrinder.co.uk esta misma se puede utilizar en varios lenguajes de programacion como Java, Perl, Python, Php o .NET ademas del framework Ruby on Rails

lunes, 17 de diciembre de 2007

rescue Exceptions en Rails


sábado, 15 de diciembre de 2007

Selenium on Rails!

Selenium es una buena herramienta para realizar testing de paginas web.

Bueno, se puede usar agregando como plugin de rails .. los pasos que dí para instalarlo fueron estos: