Ecossistema Ruby - versão SCTI UNF 2013

1,408 views

Published on

Palestra sobre alguns aspectos do ecossistema Ruby e Rails apresentada na SCTI UNF 2013 em Campos dos Goytacazes

Published in: Technology

Ecossistema Ruby - versão SCTI UNF 2013

  1. 1. Ecossistema Ruby Fabio Akita @akitaonrails codeminer42.com
  2. 2. www.codeminer42.com
  3. 3. www.codeminer42.com
  4. 4. www.codeminer42.com
  5. 5. www.codeminer42.com
  6. 6. www.codeminer42.com
  7. 7. www.codeminer42.com
  8. 8. www.codeminer42.com
  9. 9. www.codeminer42.com
  10. 10. www.codeminer42.com
  11. 11. www.codeminer42.com
  12. 12. www.codeminer42.com
  13. 13. www.codeminer42.com
  14. 14. http://u.akita.ws/ sctiunf2013
  15. 15. 9 ANOS!
  16. 16. Rails 3.2.15 Rails 4.0.1
  17. 17. Ruby 1.9.3 p448 Ruby 2.0.0 p247 JRuby 1.7.6 (Java 7)
  18. 18. Ruby 1.9.3 p448 Ruby 2.0.0 p247 JRuby 1.7.6 (Java 7)
  19. 19. http://u.akita.ws/ruby_usage
  20. 20. gem install rails
  21. 21. gem install rails bundle install
  22. 22. • Filosofia (Agilistas)
  23. 23. • Filosofia (Agilistas) • Polarização do Rails (Ecossistema)
  24. 24. • Filosofia (Agilistas) • Polarização do Rails (Ecossistema) • Escolha das Startups (Economia)
  25. 25. • Filosofia (Agilistas) • Polarização do Rails (Ecossistema) • Escolha das Startups (Economia) • Cloud Computing (Infraestrutura)
  26. 26. Repositórios
  27. 27. http://u.akita.ws/git
  28. 28. git checkout master
  29. 29. git checkout master git checkout -b new_branch
  30. 30. git checkout master git checkout -b new_branch git commit -a -m “new change”
  31. 31. git checkout master git checkout -b new_branch git commit -a -m “new change” git push origin new_branch
  32. 32. Desenvolvimento
  33. 33. vagrant init precise32 http:// files.vagrantup.com/precise32.box
  34. 34. vagrant init precise32 http:// files.vagrantup.com/precise32.box vagrant up
  35. 35. vagrant init precise32 http:// files.vagrantup.com/precise32.box vagrant up vagrant ssh
  36. 36. vagrant init precise32 http:// files.vagrantup.com/precise32.box vagrant up vagrant ssh vagrant halt
  37. 37. brew install ack ctags git macvim wget zsh
  38. 38. sh -c "`curl -fsSL https:// raw.github.com/skwp/dotfiles/ master/install.sh`"
  39. 39. sh -c "`curl -fsSL https:// raw.github.com/skwp/dotfiles/ master/install.sh`" cd ~/.yadr; rake update
  40. 40. http://u.akita.ws/vim
  41. 41. Continuous Integration (CI)
  42. 42. Exceptions Tracking
  43. 43. # Gemfile
 group :production do
 gem 'airbrake'
 end
 
 # config/initializers/errbit.rb
 if defined?(Airbrake)
 Airbrake.configure do |config|
 config.api_key = 'SUA_CHAVE'
 config.host = 'errbit.cm42.io'
 config.port = 80
 config.secure = config.port == 443
 end
 end
  44. 44. MyApp::Application.config.middleware.use ExceptionNotification::Rack,
 :email => {
 :email_prefix => "[MyApp] ",
 :sender_address => %{"notifier" <notifier@mycompany.com>},
 :exception_recipients => %w{developers@mycompany.com}
 }
  45. 45. Code Quality
  46. 46. gem install brakeman brakeman -o report.html
  47. 47. gem install rails_best_practices rails_best_practices -f html .
  48. 48. gem install excellent excellent -o excellent.html .
  49. 49. # spec/spec_helper.rb
 require 'simplecov'
 SimpleCov.start 'rails'
  50. 50. http://u.akita.ws/assets
  51. 51. # Gemfile
 gem 'sunspot_rails'
 gem "sunspot_with_kaminari"
 group :development do
 gem 'sunspot_solr'
 gem 'progress_bar'
 end
  52. 52. # config/sunspot.yml
 production:
 solr:
 hostname: index.websolr.com
 port: 80
 log_level: WARNING
 path: /solr/69xxxxxxx39
 # read_timeout: 2
 # open_timeout: 0.5
 
 development:
 solr:
 hostname: localhost
 port: 8982
 log_level: INFO
 
 test:
 solr:
 hostname: localhost
 port: 8981
 log_level: WARNING

  53. 53. # app/models/document.rb
 class Document < ActiveRecord::Base
 searchable do
 text :title, :more_like_this => true
 text :excerpt_html, :more_like_this => true
 text :body_html, :more_like_this => true
 string :cached_tag_list
 time :published_at
 end
 end
  54. 54. <form id="formsearch" method="get" action="<%= searches_url %>">
 <input type="text" name="q" />
 </form>
  55. 55. class SearchesController < ApplicationController
 def index
 page = params[:page] || 1
 query = (params[:q] || "").strip
 @posts = Sunspot.search(Post) do
 fulltext query do
 query_phrase_slop 1
 phrase_fields :title => 2.0
 phrase_slop 1
 end
 paginate :page => page,
 :per_page => Post::DEFAULT_LIMIT
 order_by :score, :desc
 end
 end
 end
  56. 56. Mensagens Assíncronas
  57. 57. <script src="http://js.pusher.com/2.1/pusher.min.js"></script>
 <script>
 var pusher = new Pusher('SUA_CHAVE');
 var channel = pusher.subscribe('meu-canal');
 channel.bind('meu-evento', function(data) {
 alert('Chegou um evento com a mensagem: ' + data.message);
 });
 </script>
  58. 58. require 'pusher'
 
 Pusher.app_id = 'APP_ID'
 Pusher.key = 'APP_KEY'
 Pusher.secret = 'APP_SECRET' 
 
 class HelloWorldController < ApplicationController
 def hello_world
 Pusher['meu-canal'].trigger('meu-evento', {:message => 'hello world'})
 end
 end
  59. 59. Web Servers
  60. 60. gem install passenger sudo passenger-install-nginxmodule
  61. 61. http://u.akita.ws/ubuntu1204
  62. 62. heroku create git push heroku master
  63. 63. gem install af
  64. 64. gem install af af push --runtime ruby193
  65. 65. gem install af af push --runtime ruby193 af update sua_aplicacao
  66. 66. gem install af af push --runtime ruby193 af update sua_aplicacao af restart sua_aplicacao
  67. 67. gem install helios helios new myapp createdb -h localhost myapp cd myapp && helios start
  68. 68. # Gemfile
 gem 'helios'
 gem 'pg'
 
 # config/application.rb
 config.middleware.use Helios::Application do
 service :data, model: 'path/to/DataModel.xcdatamodel'
 service :push_notification, 
 apn_certificate: 'path/to/apple_push_notification.pem', 
 apn_environment: 'development'
 service :in_app_purchase
 service :passbook
 end
  69. 69. Educação
  70. 70. Thanks! @akitaonrails

×