Questa ¨¨ una intro.
Volendo utilizzare la libreria BioRuby per analisi ¨¨ possibile creare anche degli Engine di Rails che vengano innestati in applicazioni Rails per presentare direttamente i dati ?
Si.
Questo approccio ¨¨ anche utilizzabile in altri contesti.
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! *!
* *!
!
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!