AirJD 焦点
AirJD

没有录音文件
00:00/00:00
加收藏

Ruby China背后的故事 by 李华顺

发布者 ruby
发布于 1446684895336  浏览 7036 关键词 Ruby, 开源 
分享到

第1页

Ruby China

ruby-china.org





第2页

- Ruby China - Rails - ruby.taobao.org



Gem



@huacnlee



第3页

“ Let's Party! — @Rei

2011-10-28



第5页

Ruby



第6页

• UCloud VPS



• 1 4 Core CPU VPS;



• 4GB



• MongoDB Cache



• UpYun



Assets



• 5M



+



Assets CDN



第7页

30000 27500 25000 22500 20000 17500 15000 12500 10000

7500 5000 2500









20K



30000 25000 20000 15000 10000

5000 0











Now





Now



300000 250000 200000 150000 100000

50000 0











Now



27K 270K



第8页

Topic.pluck(:user_id).uniq.count



Reply.pluck(:user_id).uniq.count







6500 6000





5500 5000





4500 4000









3000 2500





2000 1500





1000 500





rei huacnlee lgn21st luikore kgen bhuztez blacktulip chairy11 ibachue hooooopo



第9页

40,000 36,000 32,000 28,000 24,000 20,000 16,000 12,000

8,000 4,000

8 25



Google



8 30





13K





9 14



9 19



30K



9 24



第10页

() (GB)



8000000 7200000 6400000 5600000 4800000 4000000 3200000 2400000 1600000

800000 0

2013-05



UpYun



2013-11



2014-05



2014-11



















2015-05



2015-09



: 1.11 GB



第11页

900 Ruby

Topic.where(node_id: Node.jobs_id).pluck(:user_id).uniq.count



第12页

And…



第13页

Google



第18页

Homeland -

https://github.com/huacnlee/homeland/tree/single-app-rails-3.0



第19页

Shanghai on Rails



第20页

chinaonrails.com



第21页

“ chinaonrails Ruby China ”

– 2012-05-10

https://ruby-china.org/topics/3223#reply4



第23页

- 2010-8 - MySQL ; - Markdown

-



Ruby 1.9.2 Rails 3.0.0.rc2; simple_format



第27页

source 'http://rubygems.org'  gem 'rails', ‘3.0.0.rc2' gem 'mysql2'

gem ‘paperclip' gem 'authlogic'

gem 'will_paginate', '3.0.pre' gem 'memcache-client'







第28页

def index



@topics = Topic.last_actived.includes(:user,:node).limit(10)



@sections = Section.all.includes(:nodes)



end







def show



@topic = Topic.find(params[:id])



if current_user



Node.set_user_last_visited(current_user.id, @topic.node_id)



@topic.user_readed(current_user.id)



end



@node = @topic.node



@replies = @topic.replies.all



end







def reply



@topic = Topic.find(params[:id])



@reply = @topic.replies.build(params[:reply])







@reply.user_id = current_user.id



if @reply.save



flash[:notice] = "



"



else



flash[:notice] = @reply.errors.full_messages.join("<br />")



end



redirect_to topic_path(params[:id],:anchor => 'reply')



end



第29页

@lgn21st

Ruby Tuesday @ Hangzhou



第30页





第32页

@hooopo



@liuzihua



@chloerei



Twitter V2EX GitHub



Ruby



第33页

Design by @QCee

https://ruby-china.org/topics/8



第34页

GitCafe



第35页

source 'http://rubygems.org'  gem "rails", "3.1.1" gem "mongoid", "2.2.4" gem 'carrierwave', '0.5.6' gem 'mini_magick','3.3' gem 'mongoid_auto_increment_id', "0.2.2" gem "devise", "1.4.5" gem 'will_paginate', '3.0.pre2' gem 'omniauth', '0.3.0' gem "oa-openid", '0.3.0' gem 'dalli', '1.1.1' … gem "rails-i18n","0.1.8" gem 'redis-namespace','~> 1.0.2' gem "redis-objects", "0.5.2" gem "rdiscount","1.6.8" gem "settingslogic", "~> 2.0.6" gem "cells", "3.6.7" gem "resque", "~> 1.19.0", :require => "resque/server" gem "aws-ses", "~> 0.4.3" gem 'mail_view', :git => 'git://github.com/37signals/mail_view.git' gem "daemon-spawn", "~> 0.4.2" # gem "sprite-factory", "1.4.1" group :development do

gem 'capistrano', '2.9.0' gem 'chunky_png', “1.2.5" gem 'factory_girl_rails' end



第36页

def index @topics = Topic.last_actived.limit(10) @sections = Section.all render :stream => true

end  def show

@topic = Topic.find(params[:id]) @topic.hits.incr(1) @node = @topic.node @replies = @topic.replies.asc(:_id).all.cache if current_user

@topic.user_readed(current_user.id)

current_user.notifications.where(:reply_id.in =>

@replies.map(&:id), :read => false).update_all(:read => true)

end render :stream => true

end



第37页

• ruby-china.org



• Linode



• UI



• Markdown



• Wiki



• Devise



;



• Mongoid, Assets Pipeline, Carrierwave, redis-objects, cells



• Notification



• mongoid_auto_increment_id



第38页

RubyConf China 2011

Ruby China



第40页

• RubyConf China



• Ruby Tuesday



• Ruby



T



• Wiki



• GitHub Ruby China



• Ruby



• RailsCast China TeaHour;



第43页

Ruby



rubybbs.com



shanghaionrails



rubycn.org



thoughtrails.com



ruby-lang.org.cn



chinaonrails.com



第44页

by XiaoBo Liu



第45页

GitHub



Ruby China



@ashchan



@huacnlee



@chloerei @lgn21st



第46页

huacnlee/ruby-china ruby-china/ruby-china



第47页

GitHub



第48页

1400 1225



1,394













huacnlee



xdite



Commits



88 83 40

chloerei ashchan forresty



37 23 19

doitian qichunren xiaods



fredwu



bachue





Commit, 105

5 Commit 21



第49页

>rakestats +----------------------+-------+-------+---------+---------+-----+-------+ |Name|Lines|LOC|Classes|Methods|M/C|LOC/M| +----------------------+-------+-------+---------+---------+-----+-------+ |Controllers|1793|1471|37|208|5|5| |Helpers|489|414|0|54|0|5| |Models|1841|1424|27|146|5|7| |Mailers|16|15|2|1|0|13| |Javascripts|7633|5866|1|694|694|6| |Libraries|708|500|8|46|5|8| |Apispecs|1024|886|0|1|0|884| |Controllerspecs|720|613|0|0|0|0| |Featurespecs|37|33|0|0|0|0| |Helperspecs|461|378|0|0|0|0| |Libspecs|620|470|3|0|0|0| |Modelspecs|1405|1185|3|0|0|0| |Requestspecs|51|40|0|0|0|0| |Routingspecs|21|17|0|0|0|0| |Viewspecs|35|27|0|0|0|0| +----------------------+-------+-------+---------+---------+-----+-------+ |Total|16854|13339|81|1150|14|9| +----------------------+-------+-------+---------+---------+-----+-------+ CodeLOC:9690TestLOC:3649CodetoTestRatio:1:0.4



第50页

GitHub Issues 2015



Open PR 3

Open Issue 30



Merged PR 127



Closed Issue 230



Closed PR 54



Open PR



Merged PR



Closed PR



Closed Issue



Open Issue



第51页

• Ruby



•@ • Markdown



• API • Bug



第52页

• •

• Internet Explorer

• •

• Vote Up / Down



第53页

PR

UI







第54页

Ruby China



“”



第57页

KeyNotes







第63页

Ruby



JRuby



Rubinius Faya



Rails Benchmark



第66页

Unicorn



11 212m



第68页

Rails



Ruby



第69页

100ms

50ms



第71页

Homeland (Rails 3.0) 2014-05 (Rails 4.1)



2011-11 (Rails 3.1) Now (Rails 4.2)



Ruby China



2013-05 (Rails 3.2)



2013-12 (Rails 4.0)



































Response Time (ms)



/



/topics



/topics/:id



/topics/node:id



/:login



第72页













View



Fragment Cache







• JavaScript



• Rails API



render collection: items



• MRI Ruby IO



Thread



• Gem



Changelog, PR;



• GC ;



• Gem



第74页

GC

TuneMyGC

https://tunemygc.com/



第75页

- evanphx/benchmark-ips -



Benchmark



- MiniProfiler/rack-mini-profiler -



- rails/rails-perftest -



- SamSaffron/memory_profiler -



allocated



Gem



- ruby-prof/ruby-prof -











第76页

IO

def index @threads = [] @threads << Thread.new do @suggest_topics = Topic.suggest.limit(3) end

 @threads << Thread.new do @topics = Topic.last_actived if current_user @topics = @topics.without_nodes(current_user.blocked_node_ids) @topics = @topics.without_users(current_user.blocked_user_ids) else @topics = @topics.without_hide_nodes end @topics = @topics.paginate(page: params[:page], per_page: 22) end @threads.each(&:join)

end



第77页

updated_at

irb> reply.cache_key "replies/256261-20150825031859640000000"

<% cache([reply]) do %> <div class="reply"> ... </div>

<% end %>



第78页

Ruby China -



Rails



Rails 3.0.0 … 4.2.x



Ruby 1.9.3 … 2.2.3



Gems Bootstrap



第79页

Homeland



第80页

2011-11 - v1



第81页

2013 - v1.1



第82页

2014-5 - V1.3



第83页

Now



第84页

• Rails Router URL Helper



CURD ERB)



Less SQL



• ActiveModel Scope Topic.last_actived.without_hide_nodes







Helper



View user_name_tag, user_avatar_tag



• Rails



4.x.0



• GitHub





Ruby



第86页

Ruby China



第87页

• Ruby Rails;

• • •



第88页

Ruby



第89页

END



第90页

QA

- @huacnlee - huacnlee@gmail.com



支持文件格式:*.pdf
上传最后阶段需要进行在线转换,可能需要1~2分钟,请耐心等待。