SlideShare uma empresa Scribd logo
1 de 28
Baixar para ler offline
GEMS
Thursday, February 7, 13
@markbates
Thursday, February 7, 13
Thursday, February 7, 13
http://www.metacasts.tv
                           PROJNIGHT213


Thursday, February 7, 13
1. Konacha
                              http://www.metacasts.tv
                                  PROJNIGHT213
Thursday, February 7, 13
JavaScript/CoffeeScript
                               testing for Rails


                                http://www.metacasts.tv
                                    PROJNIGHT213
Thursday, February 7, 13
CoffeeScript                                                                     JavaScript
                           describe	
  "Calculator",	
  -­‐>                                     describe("Calculator",	
  function()	
  {
                           	
                                                                    	
  
                           	
  	
  beforeEach	
  -­‐>                                            	
  	
  beforeEach(function()	
  {
                           	
  	
  	
  	
  @calculator	
  =	
  new	
  Calculator()               	
  	
  	
  	
  this.calculator	
  =	
  new	
  Calculator();
                           	
                                                                    	
  	
  });
                           	
  	
  context	
  "add",	
  -­‐>                                     	
  
                           	
                                                                    	
  	
  context("add",	
  function()	
  {
                           	
  	
  	
  	
  it	
  "adds	
  two	
  numbers",	
  -­‐>               	
  
                           	
  	
  	
  	
  	
  	
  @calculator.add(2,	
  2).should.eql(4)        	
  	
  	
  	
  it("adds	
  two	
  numbers",	
  function()	
  {
                           	
                                                                    	
  	
  	
  	
  	
  	
  this.calculator.add(2,	
  2).should.eql(4);
                           	
  	
  	
  	
  context	
  "null	
  numbers",	
  -­‐>                 	
  	
  	
  	
  });
                           	
                                                                    	
  
                           	
  	
  	
  	
  	
  	
  it	
  "throws	
  an	
  exception",	
  -­‐>    	
  	
  	
  	
  context("null	
  numbers",	
  function()	
  {
                           	
  	
  	
  	
  	
  	
  	
  	
  expect(=>                             	
  
                           	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  @calculator.add(1,	
  null)   	
  	
  	
  	
  	
  	
  it("throws	
  an	
  exception",	
  function()	
  {
                           	
  	
  	
  	
  	
  	
  	
  	
  ).to.throw(NullNumberError)           	
  	
  	
  	
  	
  	
  	
  	
  var	
  _this	
  =	
  this;
                                                                                                 	
  	
  	
  	
  	
  	
  	
  	
  expect(function()	
  {
                                                                                                 	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  _this.calculator.add(1,	
  null);
                                                                                                 	
  	
  	
  	
  	
  	
  	
  	
  }).to["throw"](NullNumberError);
                                                                                                 	
  	
  	
  	
  	
  	
  });
                                                                                                 	
  
                                                                                                 	
  	
  	
  	
  });
                                                                                                 	
  
                                                                                                 	
  	
  });
                                                                                                 	
  
                                                                                                 });



                                                                     http://www.metacasts.tv
                                                                         PROJNIGHT213
Thursday, February 7, 13
More Info
                                     https://github.com/jfirebaugh/konacha
                                     http://visionmedia.github.com/mocha/
                                                http://chaijs.com/
                           http://www.metacasts.tv/casts/unit-testing-javascript-in-rails




                                           http://www.metacasts.tv
                                               PROJNIGHT213
Thursday, February 7, 13
2. SideKiq
                             http://www.metacasts.tv
                                 PROJNIGHT213
Thursday, February 7, 13
Super fast
                           background workers


                              http://www.metacasts.tv
                                  PROJNIGHT213
Thursday, February 7, 13
class	
  MyWorker
                           	
  	
  include	
  Sidekiq::Worker
                           	
  	
  sidekiq_options	
  unique:	
  true
                           	
  
                           	
  	
  def	
  perform(some_attributes)
                           	
  	
  	
  	
  #	
  do	
  some	
  work	
  here
                           	
  	
  end
                           	
  
                           end
                           	
  
                           MyWorker.perform_async(some_attributes)




                               http://www.metacasts.tv
                                   PROJNIGHT213
Thursday, February 7, 13
http://www.metacasts.tv
                               PROJNIGHT213
Thursday, February 7, 13
More Info
                                   http://sidekiq.org/
                           https://github.com/mperham/sidekiq




                               http://www.metacasts.tv
                                   PROJNIGHT213
Thursday, February 7, 13
3. SunSpot
                             http://www.metacasts.tv
                                 PROJNIGHT213
Thursday, February 7, 13
Simple full-text
                           search using Solr


                            http://www.metacasts.tv
                                PROJNIGHT213
Thursday, February 7, 13
class	
  Post	
  <	
  ActiveRecord::Base
                           	
  	
  searchable	
  do
                           	
  	
  	
  	
  text	
  :title,	
  :body
                           	
  	
  	
  	
  text	
  :comments	
  do
                                                                                                         Post.search	
  do
                           	
  	
  	
  	
  	
  	
  comments.map	
  {	
  |comment|	
  comment.body	
  }
                                                                                                         	
  	
  fulltext	
  'best	
  pizza'
                           	
  	
  	
  	
  end
                                                                                                         	
  	
  with	
  :blog_id,	
  1
                           	
  	
  	
  	
  integer	
  :blog_id
                                                                                                         	
  	
  with(:published_at).less_than	
  Time.now
                           	
  	
  	
  	
  integer	
  :author_id
                                                                                                         	
  	
  order_by	
  :published_at,	
  :desc
                           	
  	
  	
  	
  integer	
  :category_ids,	
  multiple:	
  true
                                                                                                         	
  	
  paginate	
  page:	
  2,	
  per_page:	
  15
                           	
  	
  	
  	
  time	
  :published_at
                                                                                                         	
  	
  facet	
  :category_ids,	
  :author_id
                           	
  	
  	
  	
  string	
  :sort_title	
  do
                                                                                                         end
                           	
  	
  	
  	
  	
  	
  title.downcase.gsub(/^(an?|the)b/,	
  '')
                           	
  	
  	
  	
  end
                           	
  	
  end
                           end




                                                                       http://www.metacasts.tv
                                                                           PROJNIGHT213
Thursday, February 7, 13
More Info
                               http://sunspot.github.com/
                           https://github.com/sunspot/sunspot
                             http://lucene.apache.org/solr/




                              http://www.metacasts.tv
                                  PROJNIGHT213
Thursday, February 7, 13
4. Sinatra
                             http://www.metacasts.tv
                                 PROJNIGHT213
Thursday, February 7, 13
A DSL for quickly
                           creating Ruby Web Apps


                               http://www.metacasts.tv
                                   PROJNIGHT213
Thursday, February 7, 13
require	
  'sinatra'
                              	
  
                              get	
  '/'	
  do
                              	
  	
  'Hello	
  world!'
                              end




                           http://www.metacasts.tv
                               PROJNIGHT213
Thursday, February 7, 13
require	
  'sinatra'
                             	
  
                             get	
  '/'	
  do
                             	
  	
  erb	
  :index
                             end
                             	
  
                             __END__
                             	
  
                             @@	
  index
                             <div>Hello	
  World!</div>




                           http://www.metacasts.tv
                               PROJNIGHT213
Thursday, February 7, 13
require	
  'sinatra/base'
                            require	
  './todo'
                            require	
  'sinatra/twitter-­‐bootstrap'
                            require	
  './url_helpers'
                            	
  
                            class	
  TodoApp	
  <	
  Sinatra::Base
                            	
  	
  register	
  Sinatra::Twitter::Bootstrap::Assets
                            	
  
                            	
  	
  helpers	
  UrlHelpers
                            	
  
                            	
  	
  get	
  "/todos"	
  do
                            	
  	
  	
  	
  @todos	
  =	
  Todo.all
                            	
  	
  	
  	
  erb	
  :index
                            	
  	
  end
                            	
  
                            	
  	
  get	
  "/todos/new"	
  do
                            	
  	
  	
  	
  @todo	
  =	
  Todo.new
                            	
  	
  	
  	
  erb	
  :form
                            	
  	
  end
                            	
  
                            	
  	
  get	
  "/todos/:id"	
  do
                            	
  	
  	
  	
  @todo	
  =	
  Todo.find(params[:id])
                            	
  	
  	
  	
  redirect	
  edit_todo_path(@todo)
                            	
  	
  end
                            	
  
                            	
  	
  get	
  "/todos/:id/edit"	
  do
                            	
  	
  	
  	
  @todo	
  =	
  Todo.find(params[:id])
                            	
  	
  	
  	
  erb	
  :form
                            	
  	
  end
                            	
  
                            	
  	
  post	
  "/todos"	
  do
                            	
  	
  	
  	
  Todo.create(params[:todo])
                            	
  	
  	
  	
  redirect	
  todos_path
                            	
  	
  end
                            	
  
                            	
  	
  put	
  "/todos/:id"	
  do
                            	
  	
  	
  	
  @todo	
  =	
  Todo.find(params[:id])
                            	
  	
  	
  	
  @todo.update_attributes(params[:todo])
                            	
  	
  	
  	
  redirect	
  todos_path
                            	
  	
  end
                            	
  
                            	
  	
  delete	
  "/todos/:id"	
  do
                            	
  	
  	
  	
  @todo	
  =	
  Todo.find(params[:id])
                            	
  	
  	
  	
  @todo.destroy
                            	
  	
  	
  	
  redirect	
  todos_path
                            	
  	
  end
                            	
  
                            end
                            	
  
                            use	
  Rack::MethodOverride
                            run	
  TodoApp




                           http://www.metacasts.tv
                               PROJNIGHT213
Thursday, February 7, 13
More Info
                                              http://www.sinatrarb.com/
                                           https://github.com/sinatra/sinatra
                           http://www.metacasts.tv/casts/building-a-sinatra-application-pt-1
                           http://www.metacasts.tv/casts/building-a-sinatra-application-pt-2
                              http://www.metacasts.tv/casts/gettings-started-with-sinatra




                                             http://www.metacasts.tv
                                                 PROJNIGHT213
Thursday, February 7, 13
5. Foreman
                             http://www.metacasts.tv
                                 PROJNIGHT213
Thursday, February 7, 13
Manage Application
                              Commands


                              http://www.metacasts.tv
                                  PROJNIGHT213
Thursday, February 7, 13
web:	
  bundle	
  exec	
  thin	
  start	
  -­‐p	
  3000
                           solr:	
  bundle	
  exec	
  rake	
  sunspot:solr:run
                           worker:	
  bundle	
  exec	
  sidekiq




                                      http://www.metacasts.tv
                                          PROJNIGHT213
Thursday, February 7, 13
More Info
                           https://github.com/ddollar/foreman




                              http://www.metacasts.tv
                                  PROJNIGHT213
Thursday, February 7, 13
@markbates
Thursday, February 7, 13

Mais conteúdo relacionado

Mais procurados

Say Hello To Ecmascript 5
Say Hello To Ecmascript 5Say Hello To Ecmascript 5
Say Hello To Ecmascript 5
Juriy Zaytsev
 
Exercícios Netbeans - Vera Cymbron
Exercícios Netbeans - Vera CymbronExercícios Netbeans - Vera Cymbron
Exercícios Netbeans - Vera Cymbron
cymbron
 
망고100 보드로 놀아보자 19
망고100 보드로 놀아보자 19망고100 보드로 놀아보자 19
망고100 보드로 놀아보자 19
종인 전
 
openFrameworks 007 - events
openFrameworks 007 - eventsopenFrameworks 007 - events
openFrameworks 007 - events
roxlu
 
Testing your javascript code with jasmine
Testing your javascript code with jasmineTesting your javascript code with jasmine
Testing your javascript code with jasmine
Rubyc Slides
 

Mais procurados (20)

Redux saga: managing your side effects. Also: generators in es6
Redux saga: managing your side effects. Also: generators in es6Redux saga: managing your side effects. Also: generators in es6
Redux saga: managing your side effects. Also: generators in es6
 
Say Hello To Ecmascript 5
Say Hello To Ecmascript 5Say Hello To Ecmascript 5
Say Hello To Ecmascript 5
 
Looping the Loop with SPL Iterators
Looping the Loop with SPL IteratorsLooping the Loop with SPL Iterators
Looping the Loop with SPL Iterators
 
Using Redux-Saga for Handling Side Effects
Using Redux-Saga for Handling Side EffectsUsing Redux-Saga for Handling Side Effects
Using Redux-Saga for Handling Side Effects
 
Akka Typed (quick talk) - JFokus 2018
Akka Typed (quick talk) - JFokus 2018Akka Typed (quick talk) - JFokus 2018
Akka Typed (quick talk) - JFokus 2018
 
Testing Android apps based on Dagger and RxJava
Testing Android apps based on Dagger and RxJavaTesting Android apps based on Dagger and RxJava
Testing Android apps based on Dagger and RxJava
 
Architectures in the compose world
Architectures in the compose worldArchitectures in the compose world
Architectures in the compose world
 
The redux saga begins
The redux saga beginsThe redux saga begins
The redux saga begins
 
Spring3.0 JaxItalia09
Spring3.0 JaxItalia09Spring3.0 JaxItalia09
Spring3.0 JaxItalia09
 
TDC2018SP | Trilha Kotlin - Programacao assincrona utilizando Coroutines
TDC2018SP | Trilha Kotlin - Programacao assincrona utilizando CoroutinesTDC2018SP | Trilha Kotlin - Programacao assincrona utilizando Coroutines
TDC2018SP | Trilha Kotlin - Programacao assincrona utilizando Coroutines
 
Rxjava meetup presentation
Rxjava meetup presentationRxjava meetup presentation
Rxjava meetup presentation
 
Wait queue
Wait queueWait queue
Wait queue
 
Why react matters
Why react mattersWhy react matters
Why react matters
 
Lambdas and Streams Master Class Part 2
Lambdas and Streams Master Class Part 2Lambdas and Streams Master Class Part 2
Lambdas and Streams Master Class Part 2
 
Exercícios Netbeans - Vera Cymbron
Exercícios Netbeans - Vera CymbronExercícios Netbeans - Vera Cymbron
Exercícios Netbeans - Vera Cymbron
 
망고100 보드로 놀아보자 19
망고100 보드로 놀아보자 19망고100 보드로 놀아보자 19
망고100 보드로 놀아보자 19
 
Google Guava
Google GuavaGoogle Guava
Google Guava
 
openFrameworks 007 - events
openFrameworks 007 - eventsopenFrameworks 007 - events
openFrameworks 007 - events
 
Reactive Programming for a demanding world: building event-driven and respons...
Reactive Programming for a demanding world: building event-driven and respons...Reactive Programming for a demanding world: building event-driven and respons...
Reactive Programming for a demanding world: building event-driven and respons...
 
Testing your javascript code with jasmine
Testing your javascript code with jasmineTesting your javascript code with jasmine
Testing your javascript code with jasmine
 

Semelhante a 5 Favorite Gems (Lightning Talk(

Programming with ZooKeeper - A basic tutorial
Programming with ZooKeeper - A basic tutorialProgramming with ZooKeeper - A basic tutorial
Programming with ZooKeeper - A basic tutorial
Jeff Smith
 
Programming with ZooKeeper - A basic tutorial
Programming with ZooKeeper - A basic tutorialProgramming with ZooKeeper - A basic tutorial
Programming with ZooKeeper - A basic tutorial
Jeff Smith
 
----------Evaluator-java---------------- package evaluator- import j.docx
----------Evaluator-java---------------- package evaluator-   import j.docx----------Evaluator-java---------------- package evaluator-   import j.docx
----------Evaluator-java---------------- package evaluator- import j.docx
janettjz6sfehrle
 
Concurrent talk
Concurrent talkConcurrent talk
Concurrent talk
rahulrevo
 
Introduction aux Macros
Introduction aux MacrosIntroduction aux Macros
Introduction aux Macros
univalence
 

Semelhante a 5 Favorite Gems (Lightning Talk( (20)

Nantes Jug - Java 7
Nantes Jug - Java 7Nantes Jug - Java 7
Nantes Jug - Java 7
 
Programming with ZooKeeper - A basic tutorial
Programming with ZooKeeper - A basic tutorialProgramming with ZooKeeper - A basic tutorial
Programming with ZooKeeper - A basic tutorial
 
Programming with ZooKeeper - A basic tutorial
Programming with ZooKeeper - A basic tutorialProgramming with ZooKeeper - A basic tutorial
Programming with ZooKeeper - A basic tutorial
 
----------Evaluator-java---------------- package evaluator- import j.docx
----------Evaluator-java---------------- package evaluator-   import j.docx----------Evaluator-java---------------- package evaluator-   import j.docx
----------Evaluator-java---------------- package evaluator- import j.docx
 
Java9 Beyond Modularity - Java 9 más allá de la modularidad
Java9 Beyond Modularity - Java 9 más allá de la modularidadJava9 Beyond Modularity - Java 9 más allá de la modularidad
Java9 Beyond Modularity - Java 9 más allá de la modularidad
 
Testowanie JavaScript
Testowanie JavaScriptTestowanie JavaScript
Testowanie JavaScript
 
比XML更好用的Java Annotation
比XML更好用的Java Annotation比XML更好用的Java Annotation
比XML更好用的Java Annotation
 
The Mayans Lost Guide to RxJava on Android
The Mayans Lost Guide to RxJava on AndroidThe Mayans Lost Guide to RxJava on Android
The Mayans Lost Guide to RxJava on Android
 
Java Boilerplate Busters
Java Boilerplate BustersJava Boilerplate Busters
Java Boilerplate Busters
 
Beacons, Raspberry Pi & Node.js
Beacons, Raspberry Pi & Node.jsBeacons, Raspberry Pi & Node.js
Beacons, Raspberry Pi & Node.js
 
MiamiJS - The Future of JavaScript
MiamiJS - The Future of JavaScriptMiamiJS - The Future of JavaScript
MiamiJS - The Future of JavaScript
 
OSGi World Congress Workshop Exercise - P Kriens
OSGi World Congress Workshop Exercise - P KriensOSGi World Congress Workshop Exercise - P Kriens
OSGi World Congress Workshop Exercise - P Kriens
 
Workshop 5: JavaScript testing
Workshop 5: JavaScript testingWorkshop 5: JavaScript testing
Workshop 5: JavaScript testing
 
Concurrent talk
Concurrent talkConcurrent talk
Concurrent talk
 
Saving lives with rx java
Saving lives with rx javaSaving lives with rx java
Saving lives with rx java
 
JavaScript Editions ES7, ES8 and ES9 vs V8
JavaScript Editions ES7, ES8 and ES9 vs V8JavaScript Editions ES7, ES8 and ES9 vs V8
JavaScript Editions ES7, ES8 and ES9 vs V8
 
Let's go Developer 2011 sendai Let's go Java Developer (Programming Language ...
Let's go Developer 2011 sendai Let's go Java Developer (Programming Language ...Let's go Developer 2011 sendai Let's go Java Developer (Programming Language ...
Let's go Developer 2011 sendai Let's go Java Developer (Programming Language ...
 
Implementing pattern-matching in JavaScript (short version)
Implementing pattern-matching in JavaScript (short version)Implementing pattern-matching in JavaScript (short version)
Implementing pattern-matching in JavaScript (short version)
 
JUnit & Mockito, first steps
JUnit & Mockito, first stepsJUnit & Mockito, first steps
JUnit & Mockito, first steps
 
Introduction aux Macros
Introduction aux MacrosIntroduction aux Macros
Introduction aux Macros
 

Mais de Mark

Mais de Mark (19)

Building Go Web Apps
Building Go Web AppsBuilding Go Web Apps
Building Go Web Apps
 
Angular.js Fundamentals
Angular.js FundamentalsAngular.js Fundamentals
Angular.js Fundamentals
 
Go(lang) for the Rubyist
Go(lang) for the RubyistGo(lang) for the Rubyist
Go(lang) for the Rubyist
 
Mangling Ruby with TracePoint
Mangling Ruby with TracePointMangling Ruby with TracePoint
Mangling Ruby with TracePoint
 
AngularJS vs. Ember.js vs. Backbone.js
AngularJS vs. Ember.js vs. Backbone.jsAngularJS vs. Ember.js vs. Backbone.js
AngularJS vs. Ember.js vs. Backbone.js
 
A Big Look at MiniTest
A Big Look at MiniTestA Big Look at MiniTest
A Big Look at MiniTest
 
A Big Look at MiniTest
A Big Look at MiniTestA Big Look at MiniTest
A Big Look at MiniTest
 
GET /better
GET /betterGET /better
GET /better
 
CoffeeScript
CoffeeScriptCoffeeScript
CoffeeScript
 
Testing Your JavaScript & CoffeeScript
Testing Your JavaScript & CoffeeScriptTesting Your JavaScript & CoffeeScript
Testing Your JavaScript & CoffeeScript
 
Building an API in Rails without Realizing It
Building an API in Rails without Realizing ItBuilding an API in Rails without Realizing It
Building an API in Rails without Realizing It
 
CoffeeScript for the Rubyist
CoffeeScript for the RubyistCoffeeScript for the Rubyist
CoffeeScript for the Rubyist
 
RubyMotion
RubyMotionRubyMotion
RubyMotion
 
Testing JavaScript/CoffeeScript with Mocha and Chai
Testing JavaScript/CoffeeScript with Mocha and ChaiTesting JavaScript/CoffeeScript with Mocha and Chai
Testing JavaScript/CoffeeScript with Mocha and Chai
 
CoffeeScript for the Rubyist
CoffeeScript for the RubyistCoffeeScript for the Rubyist
CoffeeScript for the Rubyist
 
Testing Rich Client Side Apps with Jasmine
Testing Rich Client Side Apps with JasmineTesting Rich Client Side Apps with Jasmine
Testing Rich Client Side Apps with Jasmine
 
DRb and Rinda
DRb and RindaDRb and Rinda
DRb and Rinda
 
CoffeeScript - A Rubyist's Love Affair
CoffeeScript - A Rubyist's Love AffairCoffeeScript - A Rubyist's Love Affair
CoffeeScript - A Rubyist's Love Affair
 
Distributed Programming with Ruby/Rubyconf 2010
Distributed Programming with Ruby/Rubyconf 2010Distributed Programming with Ruby/Rubyconf 2010
Distributed Programming with Ruby/Rubyconf 2010
 

5 Favorite Gems (Lightning Talk(

  • 4. http://www.metacasts.tv PROJNIGHT213 Thursday, February 7, 13
  • 5. 1. Konacha http://www.metacasts.tv PROJNIGHT213 Thursday, February 7, 13
  • 6. JavaScript/CoffeeScript testing for Rails http://www.metacasts.tv PROJNIGHT213 Thursday, February 7, 13
  • 7. CoffeeScript JavaScript describe  "Calculator",  -­‐> describe("Calculator",  function()  {        beforeEach  -­‐>    beforeEach(function()  {        @calculator  =  new  Calculator()        this.calculator  =  new  Calculator();      });    context  "add",  -­‐>        context("add",  function()  {        it  "adds  two  numbers",  -­‐>              @calculator.add(2,  2).should.eql(4)        it("adds  two  numbers",  function()  {              this.calculator.add(2,  2).should.eql(4);        context  "null  numbers",  -­‐>        });                it  "throws  an  exception",  -­‐>        context("null  numbers",  function()  {                expect(=>                      @calculator.add(1,  null)            it("throws  an  exception",  function()  {                ).to.throw(NullNumberError)                var  _this  =  this;                expect(function()  {                    _this.calculator.add(1,  null);                }).to["throw"](NullNumberError);            });          });      });   }); http://www.metacasts.tv PROJNIGHT213 Thursday, February 7, 13
  • 8. More Info https://github.com/jfirebaugh/konacha http://visionmedia.github.com/mocha/ http://chaijs.com/ http://www.metacasts.tv/casts/unit-testing-javascript-in-rails http://www.metacasts.tv PROJNIGHT213 Thursday, February 7, 13
  • 9. 2. SideKiq http://www.metacasts.tv PROJNIGHT213 Thursday, February 7, 13
  • 10. Super fast background workers http://www.metacasts.tv PROJNIGHT213 Thursday, February 7, 13
  • 11. class  MyWorker    include  Sidekiq::Worker    sidekiq_options  unique:  true      def  perform(some_attributes)        #  do  some  work  here    end   end   MyWorker.perform_async(some_attributes) http://www.metacasts.tv PROJNIGHT213 Thursday, February 7, 13
  • 12. http://www.metacasts.tv PROJNIGHT213 Thursday, February 7, 13
  • 13. More Info http://sidekiq.org/ https://github.com/mperham/sidekiq http://www.metacasts.tv PROJNIGHT213 Thursday, February 7, 13
  • 14. 3. SunSpot http://www.metacasts.tv PROJNIGHT213 Thursday, February 7, 13
  • 15. Simple full-text search using Solr http://www.metacasts.tv PROJNIGHT213 Thursday, February 7, 13
  • 16. class  Post  <  ActiveRecord::Base    searchable  do        text  :title,  :body        text  :comments  do Post.search  do            comments.map  {  |comment|  comment.body  }    fulltext  'best  pizza'        end    with  :blog_id,  1        integer  :blog_id    with(:published_at).less_than  Time.now        integer  :author_id    order_by  :published_at,  :desc        integer  :category_ids,  multiple:  true    paginate  page:  2,  per_page:  15        time  :published_at    facet  :category_ids,  :author_id        string  :sort_title  do end            title.downcase.gsub(/^(an?|the)b/,  '')        end    end end http://www.metacasts.tv PROJNIGHT213 Thursday, February 7, 13
  • 17. More Info http://sunspot.github.com/ https://github.com/sunspot/sunspot http://lucene.apache.org/solr/ http://www.metacasts.tv PROJNIGHT213 Thursday, February 7, 13
  • 18. 4. Sinatra http://www.metacasts.tv PROJNIGHT213 Thursday, February 7, 13
  • 19. A DSL for quickly creating Ruby Web Apps http://www.metacasts.tv PROJNIGHT213 Thursday, February 7, 13
  • 20. require  'sinatra'   get  '/'  do    'Hello  world!' end http://www.metacasts.tv PROJNIGHT213 Thursday, February 7, 13
  • 21. require  'sinatra'   get  '/'  do    erb  :index end   __END__   @@  index <div>Hello  World!</div> http://www.metacasts.tv PROJNIGHT213 Thursday, February 7, 13
  • 22. require  'sinatra/base' require  './todo' require  'sinatra/twitter-­‐bootstrap' require  './url_helpers'   class  TodoApp  <  Sinatra::Base    register  Sinatra::Twitter::Bootstrap::Assets      helpers  UrlHelpers      get  "/todos"  do        @todos  =  Todo.all        erb  :index    end      get  "/todos/new"  do        @todo  =  Todo.new        erb  :form    end      get  "/todos/:id"  do        @todo  =  Todo.find(params[:id])        redirect  edit_todo_path(@todo)    end      get  "/todos/:id/edit"  do        @todo  =  Todo.find(params[:id])        erb  :form    end      post  "/todos"  do        Todo.create(params[:todo])        redirect  todos_path    end      put  "/todos/:id"  do        @todo  =  Todo.find(params[:id])        @todo.update_attributes(params[:todo])        redirect  todos_path    end      delete  "/todos/:id"  do        @todo  =  Todo.find(params[:id])        @todo.destroy        redirect  todos_path    end   end   use  Rack::MethodOverride run  TodoApp http://www.metacasts.tv PROJNIGHT213 Thursday, February 7, 13
  • 23. More Info http://www.sinatrarb.com/ https://github.com/sinatra/sinatra http://www.metacasts.tv/casts/building-a-sinatra-application-pt-1 http://www.metacasts.tv/casts/building-a-sinatra-application-pt-2 http://www.metacasts.tv/casts/gettings-started-with-sinatra http://www.metacasts.tv PROJNIGHT213 Thursday, February 7, 13
  • 24. 5. Foreman http://www.metacasts.tv PROJNIGHT213 Thursday, February 7, 13
  • 25. Manage Application Commands http://www.metacasts.tv PROJNIGHT213 Thursday, February 7, 13
  • 26. web:  bundle  exec  thin  start  -­‐p  3000 solr:  bundle  exec  rake  sunspot:solr:run worker:  bundle  exec  sidekiq http://www.metacasts.tv PROJNIGHT213 Thursday, February 7, 13
  • 27. More Info https://github.com/ddollar/foreman http://www.metacasts.tv PROJNIGHT213 Thursday, February 7, 13