mirror of
https://github.com/wahyd4/one-knowledge.git
synced 2026-08-09 05:06:40 +10:00
Initial import: links posts + github knowledge
This commit is contained in:
@@ -0,0 +1,127 @@
|
||||
---
|
||||
title: Ruby
|
||||
created: 2018-06-14
|
||||
updated: 2018-06-14
|
||||
type: summary
|
||||
tags: [tech, reference]
|
||||
external: https://github.com/wahyd4/knowledge/blob/master/categories/ruby.md
|
||||
---
|
||||
|
||||
# Objects inheritances
|
||||
|
||||

|
||||
|
||||
# Background jobs
|
||||
- Resque
|
||||
- Single threaded process
|
||||
- Delayed Job
|
||||
- Single process
|
||||
- Sidekiq
|
||||
- Redis and multiple threaded process
|
||||
```ruby
|
||||
while(!empty(queue)) {
|
||||
= get(queue); //从任务队列中取一个(涉及加锁等)
|
||||
q->callback(); //执行该任务
|
||||
}
|
||||
```
|
||||
|
||||
# Test
|
||||
- Unit Test
|
||||
- Mini Test
|
||||
- RSpec
|
||||
- Browser Test
|
||||
- Capybara
|
||||
- Cucumber
|
||||
- Mock
|
||||
- Mocha
|
||||
|
||||
# Auth
|
||||
- OmniAuth
|
||||
- Devise
|
||||
|
||||
# Web Server
|
||||
- Thin
|
||||
- Unicorn
|
||||
- Puma
|
||||
- Passenger
|
||||
- Pow
|
||||
|
||||
# Language
|
||||
- Syntax
|
||||
- lambda
|
||||
- yield
|
||||
- respond_to
|
||||
- send
|
||||
- <=>
|
||||
- return 1,0, -1
|
||||
- * before array
|
||||
- splat operator: split an array into a list of arguments
|
||||
- array << obj
|
||||
- append obj to new arry
|
||||
- block {} do end
|
||||
- Block is not object
|
||||
- use yield pass block
|
||||
- Proc
|
||||
- Proc is object
|
||||
- greeting = Proc.new { puts "hello, world" } greeting.call
|
||||
- Module
|
||||
- Can't be new
|
||||
- include
|
||||
- can't extend
|
||||
- Class
|
||||
|
||||
# Code analysis
|
||||
- Rubocop
|
||||
|
||||
# GC
|
||||
- Minor GC
|
||||
- Major GC
|
||||
- GC.stat
|
||||
|
||||
# Bundler
|
||||
|
||||
## Use groups in bundler
|
||||
|
||||
```ruby
|
||||
# These gems are in the :default group
|
||||
gem 'nokogiri'
|
||||
gem 'sinatra'
|
||||
|
||||
gem 'wirble', :group => :development
|
||||
|
||||
group :test do
|
||||
gem 'faker'
|
||||
gem 'rspec'
|
||||
end
|
||||
|
||||
group :test, :development do
|
||||
gem 'capybara'
|
||||
gem 'rspec-rails'
|
||||
end
|
||||
|
||||
gem 'cucumber', :group => [:cucumber, :test]
|
||||
```
|
||||
when you install bundles, you can do
|
||||
|
||||
```bash
|
||||
bundle install --without test development
|
||||
```
|
||||
# Web frameworks
|
||||
## Sintra
|
||||
|
||||
## Ruby on Rails
|
||||
|
||||
### How Rails application works
|
||||
|
||||

|
||||
|
||||
- ORM
|
||||
- Active record
|
||||
- Mongoid
|
||||
- Websocket
|
||||
- Assets pipeline
|
||||
- Rails console
|
||||
|
||||
# Gem mirrors
|
||||
- [http://mirrors.aliyun.com/rubygems/](http://mirrors.aliyun.com/rubygems/)
|
||||
- [https://gems.ruby-china.org](https://gems.ruby-china.org)
|
||||
Reference in New Issue
Block a user