Textmate Ruby/rails Cheat Sheet

  • Uploaded by: Flo
  • 0
  • 0
  • April 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Textmate Ruby/rails Cheat Sheet as PDF for free.

More details

  • Words: 618
  • Pages:
TextMate Ruby/Rails/SQL/YAML Cheat Sheet RUBY COMMANDS Ruby rcode completion

⌃⌥⇧R ⌥⎋

RUBY SNIPPETS

RUBY CLASSES

require “..”

req⇥

New Ruby (Rails) class

File⇥

def self.name .. end

Run rake task

⌃⇧R

File (foreach, read, open)

Run current UnitTest

⌘⇧R

Option parser block

Open require

⌘⇧D

Add option

optp⇥ opt⇥

Insert missing requires

⌃#

Execute Line/Selection

⌃⇧E

def test_name .. end

deft⇥

SQL COMMANDS

⌃⌥⇧S

assert test, message

as⇥

Database browser

⌥⌘⇧D

assert_(([a-z])[a-z]+_?)+

Execute line/selection

⌃⇧Q

RUBY CODE

UnitTest, TestCase block

New rdoc block

⌃:

when, while] block

Toggle do .. end / { .. }

⌃{

If .. else .. end

Insert/toggle ERb (select.)

⌃>

New module

Add ! to method in line Begin .. rescue .. end Hash pointer ʻ => ʻ Embed select. code #{..}

⌃! ⌃⇧W ⌃L #

TextMate Ruby/Rails/SQL/YAML Cheat Sheet

attr_[read,write,access] ..

am⇥ [r,w,rw]⇥

as[a-z]+⇥ =b⇥

RUBY FUNCTIONAL Array.new(..) { |i| .. }

Array⇥

Hash.new { |h,k| h[k] = .. }

Hash⇥

[all,any]? { |e| .. } each { |e| .. }

[...⇥ ife⇥ mod⇥

each_(([a-z])[a-z]+_?)+ reverse_each { |e| .. } inject(init) { |mem, var| .. }

:key => “value”[,]

:⇥

lambda { |args| .. }

:yieds: arguments

y⇥

map { |e| .. }

{ |variables| .. }

{⇥

map_with_index { |e, i| .. }

do |variables| .. end

defs⇥

tc⇥

[case, elsif, if, unless,

Toggle string/symbol

alias_method :new, :old

cla⇥

do⇥

zip(enums) { |row| .. }

[all,any]⇥ ea⇥ ea[a-z]+⇥ reve⇥ inj⇥ lam⇥ map⇥ mapwi⇥ zip⇥

TextMate Ruby/Rails/SQL/YAML Cheat Sheet RAILS COMMANDS

⌃⌥⇧R

RAILS SNIPPETS

Show classʼ DB schema

⌃⌘⇧S

“session[:user]” snippet

⌃J

logger.level

⌥⌘↓

“params[:id]” snippet

⌃P

returning do |var| .. end

returning⇥

⌥⌘⇧↓

flash[:notice] = “msg”

flash⇥

xhr [get,post,put,delete]

x[…]⇥

Goto alternate file Goto specific file Goto file on current line Generators, migrations,

⌥⌘↑ ⌃| (pipe)

fixtures, schema cmds Generate a migration Test ... (rake test tasks)

[c,m]attr_accessor :name

[c,m]rw⇥

redirect_to ([something]+)

re[s]+⇥

render ([something]+)

r[s]+⇥

⌃⇧M

verify [redirect, render]

verify⇥

⌃\

assert(v = assigns(:v))

asg⇥

assert_response YAML COMMANDS Autocomplete FK fixture

⌃⌥⇧Y ⌥[⇧]⎋

reference [habtm] key: value snippet Convert to Ruby Syntax cheat sheet Add list item Sort keys alphabetically

find([:all,:first,id])

⌃: ⌃⇧H ⌃H ⌅ F5

TextMate Ruby/Rails/SQL/YAML Cheat Sheet

assert_rjs associations: use initials

asre⇥ asrj⇥ ...⇥

CONTROLLER respond to (sel. text) def create method block CUCUMBER Feature Scenario, Outline [Given, When, Then] step

hmd⇥

Autocomplete step

has_many :through

hmt⇥

Create all undef. steps

(w/o “_of”, add “if” for :if)

Goto current step v[a-z]+⇥

logl⇥

SCOPE REFERENCE

has_many :dependent

validates_(([a-z])[a-z]+_?)+

fin[a,f,i]⇥

Run feature

before_[a-z][a-z]+

bef[cdus]⇥

Run single scenario

after_[a-z][a-z]+

aft[cdus]⇥

Align table cells

⌘⇧H defcreate⇥

⌃⌥⇧C fea⇥ sc[e,o]⇥ [giv,whe,the]⇥

⌥⎋ ⌃⌥⌘⇧↓ ⌃⌥⇧↓ ⌘R ⌘⇧R ⌥⌘\

TextMate Ruby/Rails/SQL/YAML Cheat Sheet MIGRATIONS

RSPEC

Manipulate table

mtab⇥[⇥]

Run focused example

Manipulate colum[s]

mcol⇥[⇥]

Run behaviour descript.

Story block ⌘⇧R ⌘R

VIEW Refactor select. to partial

⌃⇧H ff[e]⇥

Create columns

mccc⇥

Run BD of select. files/dir

⌥⌘R

form_for [with errors]

Rename column[s]

mncc⇥

describe “description”

des⇥

f.method (snippet name)

Manipulate index

mind⇥

describe Type

dest⇥

[form, submit,

t.column (snippet name)

t.⇥

RJS page.hide

hide⇥

descript Type, “descript.”

dests⇥

image_submit]_tag

describe Controller

desc⇥

link_to [something]+

describe REST Controller

desrc⇥

st⇥

If .. for .. end else .. end

[f,s,is]t⇥ li[s]+⇥ for⇥

page.insert_html

ins⇥

it “should ..” do .. end

page.replace

rep⇥

before :each do .. end

bef⇥

javascript_include_tag

jit⇥

after :each do .. end

aft⇥

stylesheet_link_tag

slt⇥

page.replace_html page.show

reph⇥ show⇥

Custom matcher block

it⇥

mat⇥

page.toggle

tog⇥

target.should [someth]+

sh[=s]+⇥

page.visual_effect

vis⇥

target.should_not [sth]+

shn[=s]+⇥

ROUTES map [resources, resource with_options, catch_all]

map[rs,r, wo,ca]?⇥

TextMate Ruby/Rails/SQL/YAML Cheat Sheet

<% end %>

f.⇥

end⇥

WEBRAT attach_file name, “path”

atf⇥

click_… ʻ…ʼ

cli⇥ fil⇥

var = mock(“name”)

moc⇥

fill_in ʻnameʼ, :with ʻvalueʼ

Require spec_helper

resh⇥

save_and_open_page

sav⇥

controller_name :name

conn⇥

select ʻ..ʼ {.., :from => ʻ..ʼ}

sel⇥

Related Documents


More Documents from ".xml"

Tetris_-_kopan
June 2020 12
December 2019 13
December 2019 16