diff --git a/.gitignore b/.gitignore
index 6e92f57..a9bc329 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,2 @@
tags
+.vim-flavor/
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..a325cc2
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,4 @@
+language: ruby
+rvm:
+ - 1.9.3
+script: rake ci
diff --git a/Gemfile b/Gemfile
new file mode 100644
index 0000000..18e836e
--- /dev/null
+++ b/Gemfile
@@ -0,0 +1,4 @@
+source 'https://rubygems.org'
+
+gem 'rake'
+gem 'vim-flavor', '~> 1.1'
diff --git a/Gemfile.lock b/Gemfile.lock
new file mode 100644
index 0000000..3238b2d
--- /dev/null
+++ b/Gemfile.lock
@@ -0,0 +1,18 @@
+GEM
+ remote: https://rubygems.org/
+ specs:
+ blankslate (2.1.2.4)
+ parslet (1.5.0)
+ blankslate (~> 2.0)
+ rake (10.1.0)
+ thor (0.18.1)
+ vim-flavor (1.1.2)
+ parslet (~> 1.0)
+ thor (~> 0.14)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ rake
+ vim-flavor (~> 1.1)
diff --git a/Rakefile b/Rakefile
new file mode 100644
index 0000000..557fee1
--- /dev/null
+++ b/Rakefile
@@ -0,0 +1,13 @@
+#!/usr/bin/env rake
+
+task :ci => [:dump, :test]
+
+task :dump do
+ sh 'vim --version'
+end
+
+task :test do
+ sh 'bundle exec vim-flavor test'
+end
+
+task :default => :test
diff --git a/VimFlavor.lock b/VimFlavor.lock
new file mode 100644
index 0000000..d021597
--- /dev/null
+++ b/VimFlavor.lock
@@ -0,0 +1 @@
+kana/vim-vspec (1.1.2)
diff --git a/autoload/tablemode.vim b/autoload/tablemode.vim
index e11efee..8abde89 100644
--- a/autoload/tablemode.vim
+++ b/autoload/tablemode.vim
@@ -4,7 +4,7 @@
" Author: Dhruva Sagar
" License: MIT (http://www.opensource.org/licenses/MIT)
" Website: http://github.com/dhruvasagar/vim-table-mode
-" Version: 3.1
+" Version: 3.2
" Note: This plugin was heavily inspired by the 'CucumberTables.vim'
" (https://gist.github.com/tpope/287147) plugin by Tim Pope and
" uses a small amount of code from it.
@@ -571,6 +571,15 @@ endfunction
" Public API {{{1
+function! tablemode#sid() "{{{2
+ return maparg('', 'n')
+endfunction
+nnoremap
+
+function! tablemode#scope() "{{{2
+ return s:
+endfunction
+
function! tablemode#GetLastRow(line) "{{{2
return s:GetLastRow(a:line)
endfunction
@@ -680,6 +689,18 @@ function! tablemode#IsATableRow(line) "{{{2
return getline(a:line) =~# (s:StartExpr() . g:table_mode_separator)
endfunction
+
+function! tablemode#LineNr(row) "{{{2
+ if tablemode#IsATableRow('.')
+ let line = s:Line('.')
+ let row = tablemode#RowNr('.')
+ if a:row != row
+ let line += a:row - row
+ endif
+ return line
+ endif
+endfunction
+
function! tablemode#RowCount(line) "{{{2
let line = s:Line(a:line)
diff --git a/doc/table-mode.txt b/doc/table-mode.txt
index ea1e41a..20095db 100644
--- a/doc/table-mode.txt
+++ b/doc/table-mode.txt
@@ -1,7 +1,7 @@
-*table-mode.txt* Table Mode for easy table formatting. v3.1
+*table-mode.txt* Table Mode for easy table formatting. v3.2
===============================================================================
Table Mode, THE AWESOME AUTOMATIC TABLE CREATOR & FORMATTER
- VERSION 3.1
+ VERSION 3.2
Author: Dhruva Sagar
License: MIT
diff --git a/plugin/table-mode.vim b/plugin/table-mode.vim
index 8f4369b..90cd719 100644
--- a/plugin/table-mode.vim
+++ b/plugin/table-mode.vim
@@ -4,7 +4,7 @@
" Author: Dhruva Sagar
" License: MIT (http://www.opensource.org/licenses/MIT)
" Website: http://github.com/dhruvasagar/vim-table-mode
-" Version: 3.1
+" Version: 3.2
" Note: This plugin was heavily inspired by the 'CucumberTables.vim'
" (https://gist.github.com/tpope/287147) plugin by Tim Pope and
" uses a small amount of code from it.
diff --git a/t/tablemode.vim b/t/tablemode.vim
new file mode 100644
index 0000000..76aa3a7
--- /dev/null
+++ b/t/tablemode.vim
@@ -0,0 +1,162 @@
+let g:table_mode_corner = '+'
+let g:table_mode_separator = '|'
+let g:table_mode_fillchar = '-'
+let g:table_mode_map_prefix = 't'
+let g:table_mode_toggle_map = 'm'
+let g:table_mode_always_active = 0
+let g:table_mode_delimiter = ','
+let g:table_mode_tableize_map = 't'
+let g:table_mode_tableize_op_map = 'T'
+let g:table_mode_realign_map = 'r'
+let g:table_mode_cell_text_object = 'tc'
+let g:table_mode_delete_row_map = 'dd'
+let g:table_mode_delete_column_map = 'dc'
+let g:table_mode_add_formula_map = 'fa'
+let g:table_mode_eval_expr_map = 'fe'
+
+call vspec#hint({'scope': 'tablemode#scope()', 'sid': 'tablemode#sid()'})
+
+describe 'tablemode'
+ describe 'Activation'
+ describe 'tablemode#TableModeEnable()'
+ before
+ call tablemode#TableModeEnable()
+ end
+
+ it 'should enable table mode'
+ Expect b:table_mode_active to_be_true
+ end
+ end
+
+ describe 'tablemode#TableModeDisable()'
+ before
+ call tablemode#TableModeDisable()
+ end
+
+ it 'should disable table mode'
+ Expect b:table_mode_active to_be_false
+ end
+ end
+
+ describe 'tablemode#TableModeToggle()'
+ it 'should toggle table mode'
+ call tablemode#TableModeToggle()
+ Expect b:table_mode_active to_be_true
+ call tablemode#TableModeToggle()
+ Expect b:table_mode_active to_be_false
+ end
+ end
+ end
+
+ describe 'API'
+ before
+ normal! ggdG
+ call tablemode#TableModeEnable()
+ normal! i
|test11|test12|
|test21|test22|
+ end
+
+ it 'should return true when inside a table'
+ Expect tablemode#IsATableRow(2) to_be_true
+ end
+
+ it 'should return false when outside a table'
+ Expect tablemode#IsATableRow(4) to_be_false
+ end
+
+ it 'should return the row count'
+ Expect tablemode#RowCount(2) == 2
+ Expect tablemode#RowCount(3) == 2
+ end
+
+ it 'should return the row number'
+ Expect tablemode#RowNr(2) == 1
+ Expect tablemode#RowNr(3) == 2
+ end
+
+ it 'should return the column count'
+ Expect tablemode#ColumnCount(2) == 2
+ Expect tablemode#ColumnCount(3) == 2
+ end
+
+ it 'should return the line number of the first row'
+ Expect tablemode#GetFirstRow(2) == 2
+ Expect tablemode#GetFirstRow(3) == 2
+ end
+
+ it 'should return the line nuber of the last row'
+ Expect tablemode#GetLastRow(2) == 3
+ Expect tablemode#GetLastRow(3) == 3
+ end
+
+ it 'should return the cells'
+ Expect Call('s:GetCells', 2, 1, 1) ==# 'test11'
+ " Get Rows
+ Expect Call('s:GetCells', 2, 1) == ['test11', 'test12']
+ Expect Call('s:GetCells', 2, 2) == ['test21', 'test22']
+ " Get Columns
+ Expect Call('s:GetCells', 2, 0, 1) == ['test11', 'test21']
+ Expect Call('s:GetCells', 2, 0, 2) == ['test12', 'test22']
+ end
+
+ it 'should return the cells in a range'
+ " Entire table as range
+ Expect Call('s:GetCellRange', '1,1:2,2', 2, 1) == [['test11', 'test21'], ['test12', 'test22']]
+
+ " Get Rows given different seed lines and columns
+ Expect Call('s:GetCellRange', '1,1:1,2', 2, 1) == ['test11', 'test12']
+ Expect Call('s:GetCellRange', '1,1:1,2', 2, 2) == ['test11', 'test12']
+ Expect Call('s:GetCellRange', '1,1:1,2', 3, 1) == ['test11', 'test12']
+ Expect Call('s:GetCellRange', '1,1:1,2', 3, 2) == ['test11', 'test12']
+ Expect Call('s:GetCellRange', '2,1:2,2', 2, 1) == ['test21', 'test22']
+ Expect Call('s:GetCellRange', '2,1:2,2', 2, 2) == ['test21', 'test22']
+ Expect Call('s:GetCellRange', '2,1:2,2', 3, 1) == ['test21', 'test22']
+ Expect Call('s:GetCellRange', '2,1:2,2', 3, 2) == ['test21', 'test22']
+
+ " Get Columns given different seed lines and column
+ Expect Call('s:GetCellRange', '1:2', 2, 1) == ['test11', 'test21']
+ Expect Call('s:GetCellRange', '1:2', 2, 2) == ['test12', 'test22']
+ Expect Call('s:GetCellRange', '1:2', 3, 1) == ['test11', 'test21']
+ Expect Call('s:GetCellRange', '1:2', 3, 2) == ['test12', 'test22']
+
+ " Get Column given negative values in range for representing rows from
+ " the end, -1 being the second last row.
+ Expect Call('s:GetCellRange', '1:-1', 2, 1) == ['test11']
+ Expect Call('s:GetCellRange', '1:-1', 3, 1) == ['test11']
+ Expect Call('s:GetCellRange', '1:-1', 2, 2) == ['test12']
+ Expect Call('s:GetCellRange', '1:-1', 3, 2) == ['test12']
+ end
+ end
+
+ describe 'Tableize'
+ before
+ normal! ggdG
+ normal! i
asd,asd;asd,asd
asd,asd;asd,asd
+ end
+
+ it 'should tableize with default delimiter'
+ :2,3call tablemode#TableizeRange('')
+ Expect tablemode#IsATableRow(2) to_be_true
+ Expect tablemode#RowCount(2) == 2
+ Expect tablemode#ColumnCount(2) == 3
+ end
+
+ it 'should tableize with given delimiter'
+ :2,3call tablemode#TableizeRange('/;')
+ Expect tablemode#IsATableRow(2) to_be_true
+ Expect tablemode#RowCount(2) == 2
+ Expect tablemode#ColumnCount(2) == 2
+ end
+ end
+
+ describe 'Motions'
+ it 'should work'
+ TODO
+ end
+ end
+
+ describe 'Manipulations'
+ it 'should work'
+ TODO
+ end
+ end
+end