a little bit more work done

This commit is contained in:
capitaomorte 2009-11-19 17:09:01 +00:00
parent 3108399930
commit 295972897f
26 changed files with 95 additions and 25 deletions

View File

@ -1,17 +1,16 @@
(defvar yas/rails-root-cache nil)
(make-local-variable 'yas/rails-root-cache)
;; stolen from rinari-mode's rinari-root
(defun yas/rails-root (&optional dir)
(or dir (setq dir default-directory))
(or yas/rails-root-cache
(or dir (setq dir default-directory))
(if (file-exists-p (expand-file-name
"environment.rb" (expand-file-name "config" dir)))
(setq yas/rails-root-cache dir)
(set (make-local-variable 'yas/rails-root-cache) dir)
(let ((new-dir (expand-file-name (file-name-as-directory "..") dir)))
;; regexp to match windows roots, tramp roots, or regular posix roots
(unless (string-match "\\(^[[:alpha:]]:/$\\|^/[^\/]+:\\|^/$\\)" dir)
(rinari-root new-dir))))))
(yas/rails-root new-dir))))))
;; stolen from rinari-mode's rinari-extract-partial
(defun yas/rails-extract-partial (begin end partial-name)
@ -135,10 +134,9 @@
(and (yas/rails-root)
(string-match "db/migrate/" default-directory)))
(defadvice cd (after yas/rails-on-cd-activate)
"Active/Deactive rinari-merb-minor-node when changing into and out
of raills project directories."
(defadvice cd (after yas/rails-on-cd-activate activate)
"Set `yas/mode-symbol' to `rails-mode' so that rails snippets
are recognized"
(setq yas/rails-root-cache nil)
(when (yas/rails-root)
(setq (make-local-variable 'yas/mode-symbol) 'rails-mode)))
(set (make-local-variable 'yas/mode-symbol) 'rails-mode)))

View File

@ -2,7 +2,7 @@
# key: tre
# contributor: Translated from TextMate Snippet
# name: Table column(s) rename
## condition: "meta.rails.migration.create_table, meta.rails.migration.change_table"
# condition: (and (yas/rails-migration-p) (or (yas/rails-in-create-table-p) (yas/rails-in-change-table-p)))
# --
t.rename(:${1:old_column_name}, :${2:new_column_name})
$0

View File

@ -2,7 +2,7 @@
# key: t.
# contributor: Translated from TextMate Snippet
# name: t.rename (tre)
# condition: (and (yas/rails-migration-p) (yas/rails-in-create-table))
# condition: (and (yas/rails-migration-p) (or (yas/rails-in-create-table) (yas/rails-in-change-table-p)))
# --
t.rename(:${1:old_column_name}, :${2:new_column_name})
t.$0

View File

@ -0,0 +1,8 @@
# -*- mode: snippet -*-
# type: command
# key: mcol
# contributor: Translated from TextMate Snippet
# name: Add / Remove Column
# condition: (yas/rails-intelligent-migration-snippet-condition-p)
# --
(yas/rails-intelligent-migration-snippet :add_remove_column)

View File

@ -0,0 +1,8 @@
# -*- mode: snippet -*-
# type: command
# key: marcc
# contributor: Translated from TextMate Snippet
# name: Add / Remove Several Columns (marcc)
# condition: (yas/rails-intelligent-migration-snippet-condition-p)
# --
(yas/rails-intelligent-migration-snippet :add_remove_column_continue)

View File

@ -0,0 +1,8 @@
# -*- mode: snippet -*-
# type: command
# key: mcol
# contributor: Translated from TextMate Snippet
# name: Add / Remove Several Columns
# condition: (yas/rails-intelligent-migration-snippet-condition-p)
# --
(yas/rails-intelligent-migration-snippet :add_remove_column_continue)

View File

@ -0,0 +1,8 @@
# -*- mode: snippet -*-
# type: command
# key: mncc
# contributor: Translated from TextMate Snippet
# name: Rename / Rename Several Columns (mncc)
# condition: (yas/rails-intelligent-migration-snippet-condition-p)
# --
(yas/rails-intelligent-migration-snippet :rename_column_continue)

View File

@ -0,0 +1,8 @@
# -*- mode: snippet -*-
# type: command
# key: mcol
# contributor: Translated from TextMate Snippet
# name: Rename / Rename Several Columns
# condition: (yas/rails-intelligent-migration-snippet-condition-p)
# --
(yas/rails-intelligent-migration-snippet :rename_column_continue)

View File

@ -0,0 +1,8 @@
# -*- mode: snippet -*-
# type: command
# key: mcol
# contributor: Translated from TextMate Snippet
# name: Rename / Rename Column
# condition: (yas/rails-intelligent-migration-snippet-condition-p)
# --
(yas/rails-intelligent-migration-snippet :rename_column)

View File

@ -2,7 +2,7 @@
# key: tcbi
# contributor: Translated from TextMate Snippet
# name: Table column binary
## condition: "meta.rails.migration.create_table, meta.rails.migration.change_table"
# condition: (and (yas/rails-migration-p) (or (yas/rails-in-create-table-p) (yas/rails-in-change-table-p)))
# --
t.binary :${1:title}${2:, :limit => ${3:2}.megabytes}
$0

View File

@ -2,7 +2,7 @@
# key: tcb
# contributor: Translated from TextMate Snippet
# name: Table column boolean
## condition: "meta.rails.migration.create_table, meta.rails.migration.change_table"
# condition: (and (yas/rails-migration-p) (or (yas/rails-in-create-table-p) (yas/rails-in-change-table-p)))
# --
t.boolean :${1:title}
$0

View File

@ -2,7 +2,7 @@
# key: tcda
# contributor: Translated from TextMate Snippet
# name: Table column date
## condition: "meta.rails.migration.create_table, meta.rails.migration.change_table"
# condition: (and (yas/rails-migration-p) (or (yas/rails-in-create-table-p) (yas/rails-in-change-table-p)))
# --
t.date :${1:title}
$0

View File

@ -2,7 +2,7 @@
# key: tcdt
# contributor: Translated from TextMate Snippet
# name: Table column datetime
## condition: "meta.rails.migration.create_table, meta.rails.migration.change_table"
# condition: (and (yas/rails-migration-p) (or (yas/rails-in-create-table-p) (yas/rails-in-change-table-p)))
# --
t.datetime :${1:title}
$0

View File

@ -2,7 +2,7 @@
# key: tcd
# contributor: Translated from TextMate Snippet
# name: Table column decimal
## condition: "meta.rails.migration.create_table, meta.rails.migration.change_table"
# condition: (and (yas/rails-migration-p) (or (yas/rails-in-create-table-p) (yas/rails-in-change-table-p)))
# --
t.decimal :${1:title}${2:${3:, :precision => ${4:10}}${5:, :scale => ${6:2}}}
$0

View File

@ -2,7 +2,7 @@
# key: tcf
# contributor: Translated from TextMate Snippet
# name: Table column float
## condition: "meta.rails.migration.create_table, meta.rails.migration.change_table"
# condition: (and (yas/rails-migration-p) (or (yas/rails-in-create-table-p) (yas/rails-in-change-table-p)))
# --
t.float :${1:title}
$0

View File

@ -2,7 +2,7 @@
# key: tci
# contributor: Translated from TextMate Snippet
# name: Table column integer
## condition: "meta.rails.migration.create_table, meta.rails.migration.change_table"
# condition: (and (yas/rails-migration-p) (or (yas/rails-in-create-table-p) (yas/rails-in-change-table-p)))
# --
t.integer :${1:title}
$0

View File

@ -2,7 +2,7 @@
# key: tcl
# contributor: Translated from TextMate Snippet
# name: Table column lock_version
## condition: "meta.rails.migration.create_table, meta.rails.migration.change_table"
# condition: (and (yas/rails-migration-p) (or (yas/rails-in-create-table-p) (yas/rails-in-change-table-p)))
# --
t.integer :lock_version, :null => false, :default => 0
$0

View File

@ -2,7 +2,7 @@
# key: tcr
# contributor: Translated from TextMate Snippet
# name: Table column(s) references
## condition: "meta.rails.migration.create_table, meta.rails.migration.change_table"
# condition: (and (yas/rails-migration-p) (or (yas/rails-in-create-table-p) (yas/rails-in-change-table-p)))
# --
t.references :${1:taggable}${2:, :polymorphic => ${3:{ :default => '${4:Photo}' \}}}
$0

View File

@ -2,7 +2,7 @@
# key: tcs
# contributor: Translated from TextMate Snippet
# name: Table column string
## condition: "meta.rails.migration.create_table, meta.rails.migration.change_table"
# condition: (and (yas/rails-migration-p) (or (yas/rails-in-create-table-p) (yas/rails-in-change-table-p)))
# --
t.string :${1:title}
$0

View File

@ -2,7 +2,7 @@
# key: tct
# contributor: Translated from TextMate Snippet
# name: Table column text
## condition: "meta.rails.migration.create_table, meta.rails.migration.change_table"
# condition: (and (yas/rails-migration-p) (or (yas/rails-in-create-table-p) (yas/rails-in-change-table-p)))
# --
t.text :${1:title}
$0

View File

@ -2,7 +2,7 @@
# key: tcti
# contributor: Translated from TextMate Snippet
# name: Table column time
## condition: "meta.rails.migration.create_table, meta.rails.migration.change_table"
# condition: (and (yas/rails-migration-p) (or (yas/rails-in-create-table-p) (yas/rails-in-change-table-p)))
# --
t.time :${1:title}
$0

View File

@ -2,7 +2,7 @@
# key: tcts
# contributor: Translated from TextMate Snippet
# name: Table column timestamp
## condition: "meta.rails.migration.create_table, meta.rails.migration.change_table"
# condition: (and (yas/rails-migration-p) (or (yas/rails-in-create-table-p) (yas/rails-in-change-table-p)))
# --
t.timestamp :${1:title}
$0

View File

@ -2,7 +2,7 @@
# key: tctss
# contributor: Translated from TextMate Snippet
# name: Table column timestamps
## condition: "meta.rails.migration.create_table, meta.rails.migration.change_table"
# condition: (and (yas/rails-migration-p) (or (yas/rails-in-create-table-p) (yas/rails-in-change-table-p)))
# --
t.timestamps
$0

View File

@ -0,0 +1,8 @@
# -*- mode: snippet -*-
# type: command
# key: mtab
# contributor: Translated from TextMate Snippet
# name: Change / Change Table
# condition: (yas/rails-intelligent-migration-snippet-condition-p)
# --
(yas/rails-intelligent-migration-snippet :change_change_table)

View File

@ -0,0 +1,8 @@
# -*- mode: snippet -*-
# type: command
# key: mtab
# contributor: Translated from TextMate Snippet
# name: Create / Drop Table
# condition: (yas/rails-intelligent-migration-snippet-condition-p)
# --
(yas/rails-intelligent-migration-snippet :add_remove_column)

View File

@ -0,0 +1,8 @@
# -*- mode: snippet -*-
# type: command
# key: mtab
# contributor: Translated from TextMate Snippet
# name: Rename / Rename Table
# condition: (yas/rails-intelligent-migration-snippet-condition-p)
# --
(yas/rails-intelligent-migration-snippet :rename_table)