Skip to content
Browse files

nicer usage

  • Loading branch information...
1 parent 490a7e9 commit 8c95f97657eaaf9495651f00e750cfb13bf79310 Irina Dumitrascu committed Apr 17, 2009
View
4 example.rb
@@ -0,0 +1,4 @@
+require 'lib/vimmish'
+
+vimtalk = 'iabcde fghij klmn 123<ESC>^2wBc2wbetter now<ESC><RIGHT>Da.<ESC>II can underst<ESC><RIGHT><RIGHT>c<RIGHT>n<ESC>'
+p Vimmish.humanize(vimtalk)
View
10 lib/vim_parser_factory.rb → lib/vimmish.rb
@@ -10,18 +10,20 @@
require 'lib/grammar/viminsert'
require 'lib/grammar/vim'
-require 'pp'
-
class Treetop::Runtime::SyntaxNode
def inspect
self.eval.map{|command, translation| "#{sprintf("%20s => %s",command, translation)}"}.join("\n")
end
end
-class VimParserFactory
+class Vimmish
@@parser = nil
- def self.get_vim_parser
+ def self.parser
@@parser = @@parser || VimParser.new
end
+
+ def self.humanize(vim)
+ parser.parse(vim)
+ end
end
View
2 test/command_mode_test.rb
@@ -1,5 +1,5 @@
require File.join(File.dirname(__FILE__), 'test_helper.rb')
-parser = VimParserFactory.get_vim_parser
+parser = Vimmish.parser
describe "command_mode" do
include Assertions
View
2 test/insert_test.rb
@@ -1,5 +1,5 @@
require File.join(File.dirname(__FILE__), 'test_helper.rb')
-parser = VimParserFactory.get_vim_parser
+parser = Vimmish.parser
describe 'insert commands' do
include Assertions
View
2 test/motions_test.rb
@@ -1,5 +1,5 @@
require File.join(File.dirname(__FILE__), 'test_helper.rb')
-parser = VimParserFactory.get_vim_parser
+parser = Vimmish.parser
describe 'motions' do
describe 'arrows' do
View
2 test/normal_mode_test.rb
@@ -1,5 +1,5 @@
require File.join(File.dirname(__FILE__), 'test_helper.rb')
-parser = VimParserFactory.get_vim_parser
+parser = Vimmish.parser
describe 'normal mode commands' do
include Assertions
View
2 test/smoke_test.rb
@@ -1,5 +1,5 @@
require File.join(File.dirname(__FILE__), 'test_helper.rb')
-parser = VimParserFactory.get_vim_parser
+parser = Vimmish.parser
describe "smoke tests" do
["d", "y"].each do |command|
View
2 test/test_helper.rb
@@ -2,7 +2,7 @@
require 'test/spec'
require 'mocha'
-require 'lib/vim_parser_factory'
+require 'lib/vimmish'
require 'test/assertions'
View
2 test/visual_mode_test.rb
@@ -1,5 +1,5 @@
require File.join(File.dirname(__FILE__), 'test_helper.rb')
-parser = VimParserFactory.get_vim_parser
+parser = Vimmish.parser
describe 'visual mode' do
include Assertions

0 comments on commit 8c95f97

Please sign in to comment.
Something went wrong with that request. Please try again.