ºÝºÝߣ

ºÝºÝߣShare a Scribd company logo
Scrip&ng	
 ?e	
 ?RailsEngines	
 ?possono	
 ?
             coesistere	
 ??	
 ?
   Ruby	
 ?Social	
 ?Club	
 ?
                                                       Raoul	
 ?J.P.	
 ?Bonnal	
 ?
                                                         r@bioruby.org	
 ?
                                           h=ps://github.com/helios/bioruby-?©\gem	
 ?
                                                     h=p://bioruby.open-?©\bio.org/	
 ?	
 ?
   Milano,	
 ?24	
 ?Febbraio	
 ?2011	
 ?
Ruby,	
 ?dove?	
 ?
                 Web	
 ?




              Ambien&	
 ?
                 di	
 ?
               U&lizzo	
 ?
Scienza	
 ?                  Admin	
 ?
Ruby,	
 ?dove?	
 ?

                          Web	
 ?
                             Web	
 ?


Rails	
 ?
                          Ambien&	
 ?
                             di	
 ?                  Cool.io	
 ?
                           U&lizzo	
 ?
            Scienza	
 ?                  Admin	
 ?




                 Sinatra	
 ?
Ruby,	
 ?dove?	
 ?
                      Web	
 ?




                   Ambien&	
 ?
                      di	
 ?
                    U&lizzo	
 ?
     Scienza	
 ?                  Admin	
 ?
                                   Admin	
 ?




Capistrano	
 ?
Ruby,	
 ?dove?	
 ?
                                Web	
 ?
                             BioRuby	
 ?

SciRuby	
 ?
                             Ambien&	
 ?
                                di	
 ?
                              U&lizzo	
 ?
              Scienza	
 ?
               Scienza	
 ?                    Admin	
 ?




                                            Graphics/
                                             PloPng	
 ?
BioRuby	
 ?
                               conceP	
 ?
?? La	
 ?bioinforma&ca	
 ?¨¨	
 ?una	
 ?disciplina	
 ?scien&?ca	
 ?
   dedicata	
 ?alla	
 ?risoluzione	
 ?di	
 ?problemi	
 ?biologici	
 ?a	
 ?
   livello	
 ?molecolare	
 ?con	
 ?metodo	
 ?informa&ci	
 ?	
 ?
?? BioRuby	
 ?¨¨	
 ?una	
 ?libreria,	
 ?scri=a	
 ?completamente	
 ?
   in	
 ?Ruby,	
 ?il	
 ?cui	
 ?scopo	
 ?¨¨	
 ?quello	
 ?di	
 ?ges&re	
 ?alcuni	
 ?
   aspeP	
 ?della	
 ?bioinforma&ca	
 ?

                                                     h=p://it.wikipedia.org/wiki/Bioinforma&ca	
 ?
                                                                   h=p://bioruby.open-?©\bio.org/	
 ?
BioRuby	
 ?
contribuire	
 ?
BioRuby	
 ?
                   contribuire	
 ?




       Sviluppatori	
 ?molto	
 ?conserva&vi	
 ?
in	
 ?realt¨¤	
 ?acce=ano	
 ?ma	
 ?ci	
 ?vuole	
 ?tempo	
 ?
Il	
 ?proge=o	
 ?BioGem	
 ?

Maggiore	
 ?necessit¨¤	
 ?di	
 ?apertura	
 ?verso	
 ?il	
 ?fresh	
 ?
 code,	
 ?che	
 ?non	
 ?sar¨¤	
 ?bug	
 ?free	
 ?ma	
 ?almeno	
 ?c¡¯¨¨	
 ?
Script	
 ?e	
 ?Engine	
 ?
In	
 ?BioInforma&ca	
 ?spesso	
 ?chi	
 ?produce	
 ?da&	
 ?non	
 ?si	
 ?
	
 ?preoccupa	
 ?di	
 ?come	
 ?ques&	
 ?verranno	
 ?visualizza&	
 ?
Script	
 ?e	
 ?Engine	
 ?
In	
 ?BioInforma&ca	
 ?spesso	
 ?chi	
 ?produce	
 ?da&	
 ?non	
 ?si	
 ?
	
 ?preoccupa	
 ?di	
 ?come	
 ?ques&	
 ?verranno	
 ?visualizza&,	
 ?
	
 ?almeno	
 ?non	
 ?subito¡­	
 ?
geek.take_rest if boss.watch? results!
class Boss!
  def watch?(result)!
     result.fancy?!
  end!
end!
class Result!
  def fancy?!
   (kind_of? GorgeousImage) || has_cool_interface? !
  end!
end!
Script	
 ?e	
 ?Engine	
 ?
Oppure	
 ?li	
 ?analizza	
 ?con	
 ?strumen&	
 ?di?eren&,	
 ?che	
 ?
 per¨°	
 ?spesso	
 ?non	
 ?o?rono	
 ?molta	
 ??essibilit¨¤	
 ?
Script	
 ?e	
 ?Engine	
 ?
                             Quindi	
 ?che	
 ?fare	
 ??	
 ?
                               30	
 ?+	
 ?1	
 ?=	
 ?31	
 ?

Solo	
 ?che	
 ?quell¡¯	
 ?UNO	
 ?crea	
 ?mol&	
 ?pi¨´	
 ?problemi	
 ?di	
 ?
  quanto	
 ?si	
 ?pensi	
 ?
    ¨C? Web	
 ?Applica&on,	
 ?che	
 ?richiede	
 ?tempo	
 ?
    ¨C? Riusabilit¨¤:	
 ?possibile	
 ?proliferazione	
 ?di	
 ?applicazioni	
 ?
    ¨C? Mantenibilit¨¤	
 ?
    ¨C? E¡¯	
 ?slegato	
 ?dalla	
 ?libreria	
 ?che	
 ?produce/ges&sce	
 ?i	
 ?da&?	
 ?
Perch¨¦	
 ?mischiare	
 ?Script	
 ?e	
 ?Engine?	
 ?
?? U&lizzare	
 ?database	
 ?sia	
 ?da	
 ?parte	
 ?di	
 ?script	
 ?che	
 ?da	
 ?
   parte	
 ?di	
 ?uten&	
 ?¡°web¡±.	
 ?
    ¨C? script:	
 ?solitamente	
 ?macinano	
 ?da&	
 ?
    ¨C? web:	
 ?	
 ?
         ?? vuole	
 ?esplorare	
 ?i	
 ?da&	
 ?sia	
 ?quelli	
 ?in	
 ?input	
 ?che	
 ?il	
 ?risultato	
 ?
         ?? Services	
 ?	
 ?
?? Credo	
 ?che	
 ?mantenere	
 ?tu=o	
 ?in	
 ?un	
 ?unico	
 ?posto	
 ?sia	
 ?
   meno	
 ?dispersivo	
 ?e	
 ?di	
 ?solito	
 ?chi	
 ?sviluppa	
 ?il	
 ?livello	
 ?di	
 ?
   analisi/database	
 ?POI	
 ?si	
 ?preoccupa	
 ?anche	
 ?di	
 ?
   sviluppare	
 ?l¡¯interfaccia	
 ?
Il	
 ?Generatore1	
 ?
Il	
 ?Generatore1	
 ?
Il	
 ?Generatore1	
 ?




 Bundler,	
 ?Jeweler	
 ?	
 ?
        +	
 ?
    Hacking	
 ?
Il	
 ?Generatore2	
 ?

$ biogem --with-engine=joke fake!                                                      !create !config/routes.rb!
   !create !.gitignore!                                                             Jeweler has prepared your gem in bioruby-fake!
   !create !Rakefile!                                                               Fetching source index for http://rubygems.org/!
   !create !Gemfile!                                                                Could not reach rubygems repository http://
   !create !LICENSE.txt!                                                                rubygems.org/!
   !create !README.rdoc!                                                            Using rake (0.8.7) !
   !create !.document!                                                              Using bio (1.4.1) !
   !create !lib!                                                                    Using bundler (1.0.10) !
   !create !lib/bio-fake.rb!                                                        Using git (1.2.5) !
   !create !test!                                                                   Using jeweler (1.5.2) !
   !create !test/helper.rb!                                                         Using rcov (0.9.9) !
   !create !test/test_bio-fake.rb!                                                  Using shoulda (2.11.3) !
   !create !db!                                                                     Your bundle is complete! Use `bundle show
                                                                                        [gemname]` to see where a bundled gem is
   !create !app!                                                                        installed.!
   !create !app/controllers!                                                        rake version:write!
   !create !app/views!                                                              (in /Users/bonnalraoul/Documents/Develop/
   !create !app/helpers!                                                                prototypes/bioruby-fake)!
   !create !config!                                                                 Updated version: 0.0.0!
   !create !lib/bio-fake-engine.rb!                                                 rake gemspec!
   !create !lib/bio-fake.rb!                                                        (in /Users/bonnalraoul/Documents/Develop/
!       prototypes/bioruby-fake)!
*                                                                              *!
*    Remember to require this library in the Gemfile of your Rails applicat    *!   Generated: bio-fake.gemspec!
*    ion.                                                                      *!   bio-fake.gemspec is valid.!
*    Please take a look at bioruby-fake/lib/bio-fake-engine.rb file for an     *!
*    example of how integrate your engine into a rails application.            *!
*    Thanks!                                                                   *!
*                                                                              *!
!
Engine	
 ?
require 'bio-fake'!
require 'rails'!

module BioFake!
  class Engine < Rails::Engine!
  # Config defaults!
       config.widget_factory_name = "default factory name"!
       config.mount_at = '/'!

  # # Load rake tasks!
  # rake_tasks do!
  #   load File.join(File.dirname(__FILE__), 'rails/railties/tasks.rake')!
  # end   !
  # Check the gem config!

       initializer "check config" do |app|!
       # make sure mount_at ends with trailing slash!
         config.mount_at += '/'               unless config.mount_at.last == '/'!
       end!

    initializer "static assets" do |app|!
       app.middleware.use ::ActionDispatch::Static, "#{root}/public"!
    end!
    paths.app.models            << "lib"!
  end!
end!                                                                 h=p://keithschacht.com/crea&ng-?©\a-?©\rails-?©\3-?©\engine-?©\plugin-?©\gem/	
 ?
Engine	
 ?Rou&ng	
 ?
Rails.application.routes.draw do |map|!

    mount_at = BioFake::Engine.config.mount_at!

#ROUTES from code below:!
# YourPathToTheControllerFiles = ¡°bio/kb/gex¡±!
# OtherControllerName = slice!
# !
#               gex     /gex(.:format)                          {:controller=>"bio/kb/gex/populations", :action=>"index"}!
# filter_population GET /gex/populations/:id/filter(.:format)   {:action=>"filter", :controller=>"bio/kb/gex/populations"}!
#       populations GET /gex/populations(.:format)              {:action=>"index", :controller=>"bio/kb/gex/populations"}!
#        population GET /gex/populations/:id(.:format)          {:action=>"show", :controller=>"bio/kb/gex/populations"}!
#           samples GET /gex/samples(.:format)                  {:action=>"index", :controller=>"bio/kb/gex/samples"}!
#            sample GET /gex/samples/:id(.:format)              {:action=>"show", :controller=>"bio/kb/gex/samples"}!
#            slices GET /gex/slices(.:format)                   {:action=>"index", :controller=>"bio/kb/gex/slices"}!
#             slice GET /gex/slices/:id(.:format)               {:action=>"show", :controller=>"bio/kb/gex/slices¡±}!

  scope mount_at, :module=>'SUBSITITUTE YourPathToTheControllerFiles'do                                           !
     resources :ControllerName, :only => [ :index, :show] do !
       member do !
         get :example!
       end #member      !
     end #resource!
     resources :SUBSTITUTEOtherControllerName, :only => [ :index, :show]!
  end #scope!
end!
Rails	
 ?Ini&alizer	
 ?
Codice	
 ?che	
 ?deve	
 ?essere	
 ?aggiunto	
 ?all¡¯applicazione                                       	
 ?

# config/initializers/bio-fake.rb!
#   create a file called bio-fake.rb!
#   you can change the mount point of you engine, using option!
#   --with_engine=namespace like http://YourDomain:port/YourMountPoint!
#   Otherwise, if you want your RailsEngine to be called at root level, leave everything as it now,
     without that file.!

 module BioFake!
    class Engine < Rails::Engine!
      config.mount_at = '/joke¡¯!
    end!
 end!
Scrip&ng	
 ?e	
 ?RailsEngines	
 ?possono	
 ?
             coesistere	
 ??	
 ?
                    SI	
 ?
Da	
 ?risolvere	
 ?
?? Come	
 ?posso	
 ?ges&re	
 ?le	
 ?interdipendenze	
 ?tra	
 ?
   database	
 ?in	
 ?gemme	
 ?di?eren&?	
 ?
?? I/O	
 ?di	
 ?da&	
 ?in	
 ?formato	
 ?tabellare:	
 ?tab,	
 ?csv	
 ?
    ¨C? Conviene	
 ?me=ere	
 ?in	
 ?db	
 ?classici	
 ??	
 ?
    ¨C? NOSQL	
 ??	
 ?
    ¨C? Tenere	
 ?I	
 ??le?	
 ?
?? I	
 ?database	
 ?spesso	
 ?sono	
 ?legacy	
 ?e	
 ?devono	
 ?
   interagire	
 ?tramite	
 ?le	
 ?gemme	
 ?
    ¨C? SQLite3	
 ?per	
 ?la	
 ?distribuzione	
 ?
Ringraziamen&	
 ?
Bioruby	
 ?                      P.T.P.	
 ?
?? Toshiaki	
 ?Katayama	
 ?      ?? Francesco	
 ?Strozzi	
 ?
?? Pjotr	
 ?Prins	
 ?

Fondazione	
 ?INGM	
 ?
?? Massimiliano	
 ?Pagani	
 ?
?? Riccardo	
 ?L.	
 ?Rossi	
 ?
?? Valeria	
 ?Ranzani	
 ?
Domande	
 ??	
 ?

More Related Content

BioRuby e gli Engines di Rails -ITA-

  • 1. Scrip&ng ?e ?RailsEngines ?possono ? coesistere ?? ? Ruby ?Social ?Club ? Raoul ?J.P. ?Bonnal ? r@bioruby.org ? h=ps://github.com/helios/bioruby-?©\gem ? h=p://bioruby.open-?©\bio.org/ ? ? Milano, ?24 ?Febbraio ?2011 ?
  • 2. Ruby, ?dove? ? Web ? Ambien& ? di ? U&lizzo ? Scienza ? Admin ?
  • 3. Ruby, ?dove? ? Web ? Web ? Rails ? Ambien& ? di ? Cool.io ? U&lizzo ? Scienza ? Admin ? Sinatra ?
  • 4. Ruby, ?dove? ? Web ? Ambien& ? di ? U&lizzo ? Scienza ? Admin ? Admin ? Capistrano ?
  • 5. Ruby, ?dove? ? Web ? BioRuby ? SciRuby ? Ambien& ? di ? U&lizzo ? Scienza ? Scienza ? Admin ? Graphics/ PloPng ?
  • 6. BioRuby ? conceP ? ?? La ?bioinforma&ca ?¨¨ ?una ?disciplina ?scien&?ca ? dedicata ?alla ?risoluzione ?di ?problemi ?biologici ?a ? livello ?molecolare ?con ?metodo ?informa&ci ? ? ?? BioRuby ?¨¨ ?una ?libreria, ?scri=a ?completamente ? in ?Ruby, ?il ?cui ?scopo ?¨¨ ?quello ?di ?ges&re ?alcuni ? aspeP ?della ?bioinforma&ca ? h=p://it.wikipedia.org/wiki/Bioinforma&ca ? h=p://bioruby.open-?©\bio.org/ ?
  • 8. BioRuby ? contribuire ? Sviluppatori ?molto ?conserva&vi ? in ?realt¨¤ ?acce=ano ?ma ?ci ?vuole ?tempo ?
  • 9. Il ?proge=o ?BioGem ? Maggiore ?necessit¨¤ ?di ?apertura ?verso ?il ?fresh ? code, ?che ?non ?sar¨¤ ?bug ?free ?ma ?almeno ?c¡¯¨¨ ?
  • 10. Script ?e ?Engine ? In ?BioInforma&ca ?spesso ?chi ?produce ?da& ?non ?si ? ?preoccupa ?di ?come ?ques& ?verranno ?visualizza& ?
  • 11. Script ?e ?Engine ? In ?BioInforma&ca ?spesso ?chi ?produce ?da& ?non ?si ? ?preoccupa ?di ?come ?ques& ?verranno ?visualizza&, ? ?almeno ?non ?subito¡­ ? geek.take_rest if boss.watch? results! class Boss! def watch?(result)! result.fancy?! end! end! class Result! def fancy?! (kind_of? GorgeousImage) || has_cool_interface? ! end! end!
  • 12. Script ?e ?Engine ? Oppure ?li ?analizza ?con ?strumen& ?di?eren&, ?che ? per¨° ?spesso ?non ?o?rono ?molta ??essibilit¨¤ ?
  • 13. Script ?e ?Engine ? Quindi ?che ?fare ?? ? 30 ?+ ?1 ?= ?31 ? Solo ?che ?quell¡¯ ?UNO ?crea ?mol& ?pi¨´ ?problemi ?di ? quanto ?si ?pensi ? ¨C? Web ?Applica&on, ?che ?richiede ?tempo ? ¨C? Riusabilit¨¤: ?possibile ?proliferazione ?di ?applicazioni ? ¨C? Mantenibilit¨¤ ? ¨C? E¡¯ ?slegato ?dalla ?libreria ?che ?produce/ges&sce ?i ?da&? ?
  • 14. Perch¨¦ ?mischiare ?Script ?e ?Engine? ? ?? U&lizzare ?database ?sia ?da ?parte ?di ?script ?che ?da ? parte ?di ?uten& ?¡°web¡±. ? ¨C? script: ?solitamente ?macinano ?da& ? ¨C? web: ? ? ?? vuole ?esplorare ?i ?da& ?sia ?quelli ?in ?input ?che ?il ?risultato ? ?? Services ? ? ?? Credo ?che ?mantenere ?tu=o ?in ?un ?unico ?posto ?sia ? meno ?dispersivo ?e ?di ?solito ?chi ?sviluppa ?il ?livello ?di ? analisi/database ?POI ?si ?preoccupa ?anche ?di ? sviluppare ?l¡¯interfaccia ?
  • 17. Il ?Generatore1 ? Bundler, ?Jeweler ? ? + ? Hacking ?
  • 18. Il ?Generatore2 ? $ biogem --with-engine=joke fake! !create !config/routes.rb! !create !.gitignore! Jeweler has prepared your gem in bioruby-fake! !create !Rakefile! Fetching source index for http://rubygems.org/! !create !Gemfile! Could not reach rubygems repository http:// !create !LICENSE.txt! rubygems.org/! !create !README.rdoc! Using rake (0.8.7) ! !create !.document! Using bio (1.4.1) ! !create !lib! Using bundler (1.0.10) ! !create !lib/bio-fake.rb! Using git (1.2.5) ! !create !test! Using jeweler (1.5.2) ! !create !test/helper.rb! Using rcov (0.9.9) ! !create !test/test_bio-fake.rb! Using shoulda (2.11.3) ! !create !db! Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is !create !app! installed.! !create !app/controllers! rake version:write! !create !app/views! (in /Users/bonnalraoul/Documents/Develop/ !create !app/helpers! prototypes/bioruby-fake)! !create !config! Updated version: 0.0.0! !create !lib/bio-fake-engine.rb! rake gemspec! !create !lib/bio-fake.rb! (in /Users/bonnalraoul/Documents/Develop/ ! prototypes/bioruby-fake)! * *! * Remember to require this library in the Gemfile of your Rails applicat *! Generated: bio-fake.gemspec! * ion. *! bio-fake.gemspec is valid.! * Please take a look at bioruby-fake/lib/bio-fake-engine.rb file for an *! * example of how integrate your engine into a rails application. *! * Thanks! *! * *! !
  • 19. Engine ? require 'bio-fake'! require 'rails'! module BioFake! class Engine < Rails::Engine! # Config defaults! config.widget_factory_name = "default factory name"! config.mount_at = '/'! # # Load rake tasks! # rake_tasks do! # load File.join(File.dirname(__FILE__), 'rails/railties/tasks.rake')! # end ! # Check the gem config! initializer "check config" do |app|! # make sure mount_at ends with trailing slash! config.mount_at += '/' unless config.mount_at.last == '/'! end! initializer "static assets" do |app|! app.middleware.use ::ActionDispatch::Static, "#{root}/public"! end! paths.app.models << "lib"! end! end! h=p://keithschacht.com/crea&ng-?©\a-?©\rails-?©\3-?©\engine-?©\plugin-?©\gem/ ?
  • 20. Engine ?Rou&ng ? Rails.application.routes.draw do |map|! mount_at = BioFake::Engine.config.mount_at! #ROUTES from code below:! # YourPathToTheControllerFiles = ¡°bio/kb/gex¡±! # OtherControllerName = slice! # ! # gex /gex(.:format) {:controller=>"bio/kb/gex/populations", :action=>"index"}! # filter_population GET /gex/populations/:id/filter(.:format) {:action=>"filter", :controller=>"bio/kb/gex/populations"}! # populations GET /gex/populations(.:format) {:action=>"index", :controller=>"bio/kb/gex/populations"}! # population GET /gex/populations/:id(.:format) {:action=>"show", :controller=>"bio/kb/gex/populations"}! # samples GET /gex/samples(.:format) {:action=>"index", :controller=>"bio/kb/gex/samples"}! # sample GET /gex/samples/:id(.:format) {:action=>"show", :controller=>"bio/kb/gex/samples"}! # slices GET /gex/slices(.:format) {:action=>"index", :controller=>"bio/kb/gex/slices"}! # slice GET /gex/slices/:id(.:format) {:action=>"show", :controller=>"bio/kb/gex/slices¡±}! scope mount_at, :module=>'SUBSITITUTE YourPathToTheControllerFiles'do ! resources :ControllerName, :only => [ :index, :show] do ! member do ! get :example! end #member ! end #resource! resources :SUBSTITUTEOtherControllerName, :only => [ :index, :show]! end #scope! end!
  • 21. Rails ?Ini&alizer ? Codice ?che ?deve ?essere ?aggiunto ?all¡¯applicazione ? # config/initializers/bio-fake.rb! # create a file called bio-fake.rb! # you can change the mount point of you engine, using option! # --with_engine=namespace like http://YourDomain:port/YourMountPoint! # Otherwise, if you want your RailsEngine to be called at root level, leave everything as it now, without that file.! module BioFake! class Engine < Rails::Engine! config.mount_at = '/joke¡¯! end! end!
  • 22. Scrip&ng ?e ?RailsEngines ?possono ? coesistere ?? ? SI ?
  • 23. Da ?risolvere ? ?? Come ?posso ?ges&re ?le ?interdipendenze ?tra ? database ?in ?gemme ?di?eren&? ? ?? I/O ?di ?da& ?in ?formato ?tabellare: ?tab, ?csv ? ¨C? Conviene ?me=ere ?in ?db ?classici ?? ? ¨C? NOSQL ?? ? ¨C? Tenere ?I ??le? ? ?? I ?database ?spesso ?sono ?legacy ?e ?devono ? interagire ?tramite ?le ?gemme ? ¨C? SQLite3 ?per ?la ?distribuzione ?
  • 24. Ringraziamen& ? Bioruby ? P.T.P. ? ?? Toshiaki ?Katayama ? ?? Francesco ?Strozzi ? ?? Pjotr ?Prins ? Fondazione ?INGM ? ?? Massimiliano ?Pagani ? ?? Riccardo ?L. ?Rossi ? ?? Valeria ?Ranzani ?