ver-command_t 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,76 @@
1
+ # Copyright 2010 Wincent Colaiuta. All rights reserved.
2
+ #
3
+ # Redistribution and use in source and binary forms, with or without
4
+ # modification, are permitted provided that the following conditions are met:
5
+ #
6
+ # 1. Redistributions of source code must retain the above copyright notice,
7
+ # this list of conditions and the following disclaimer.
8
+ # 2. Redistributions in binary form must reproduce the above copyright notice,
9
+ # this list of conditions and the following disclaimer in the documentation
10
+ # and/or other materials provided with the distribution.
11
+ #
12
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
13
+ # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
14
+ # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
15
+ # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
16
+ # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
17
+ # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
18
+ # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
19
+ # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
20
+ # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
21
+ # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
22
+ # POSSIBILITY OF SUCH DAMAGE.
23
+
24
+ require File.expand_path('../spec_helper', File.dirname(__FILE__))
25
+ require 'command_t/scanner'
26
+ require 'command_t/ext'
27
+
28
+ describe CommandT::Matcher do
29
+ describe 'initialization' do
30
+ it 'should raise an ArgumentError if passed nil' do
31
+ lambda { CommandT::Matcher.new nil }.
32
+ should raise_error(ArgumentError)
33
+ end
34
+ end
35
+
36
+ describe '#matches_for' do
37
+ before do
38
+ @scanner = Object.new
39
+ end
40
+
41
+ it 'raises an ArgumentError if passed nil' do
42
+ @matcher = CommandT::Matcher.new @scanner
43
+ lambda { @matcher.matches_for(nil) }.
44
+ should raise_error(ArgumentError)
45
+ end
46
+
47
+ it 'returns empty array when source array empty' do
48
+ stub(@scanner).paths { [] }
49
+ @no_paths = CommandT::Matcher.new @scanner
50
+ @no_paths.matches_for('foo').should == []
51
+ @no_paths.matches_for('').should == []
52
+ end
53
+
54
+ it 'returns empty array when no matches' do
55
+ stub(@scanner).paths { ['foo/bar', 'foo/baz', 'bing'] }
56
+ @no_matches = CommandT::Matcher.new @scanner
57
+ @no_matches.matches_for('xyz').should == []
58
+ end
59
+
60
+ it 'returns matching paths' do
61
+ stub(@scanner).paths { ['foo/bar', 'foo/baz', 'bing'] }
62
+ @foo_paths = CommandT::Matcher.new @scanner
63
+ matches = @foo_paths.matches_for('z')
64
+ matches.map { |m| m.to_s }.should == ['foo/baz']
65
+ matches = @foo_paths.matches_for('bg')
66
+ matches.map { |m| m.to_s }.should == ['bing']
67
+ end
68
+
69
+ it 'performs case-insensitive matching' do
70
+ stub(@scanner).paths { ['Foo'] }
71
+ @path = CommandT::Matcher.new @scanner
72
+ matches = @path.matches_for('f')
73
+ matches.map { |m| m.to_s }.should == ['Foo']
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,73 @@
1
+ # Copyright 2010 Wincent Colaiuta. All rights reserved.
2
+ #
3
+ # Redistribution and use in source and binary forms, with or without
4
+ # modification, are permitted provided that the following conditions are met:
5
+ #
6
+ # 1. Redistributions of source code must retain the above copyright notice,
7
+ # this list of conditions and the following disclaimer.
8
+ # 2. Redistributions in binary form must reproduce the above copyright notice,
9
+ # this list of conditions and the following disclaimer in the documentation
10
+ # and/or other materials provided with the distribution.
11
+ #
12
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
13
+ # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
14
+ # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
15
+ # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
16
+ # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
17
+ # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
18
+ # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
19
+ # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
20
+ # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
21
+ # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
22
+ # POSSIBILITY OF SUCH DAMAGE.
23
+
24
+ require File.expand_path('../spec_helper', File.dirname(__FILE__))
25
+ require 'command_t/scanner'
26
+
27
+ describe CommandT::Scanner do
28
+ before do
29
+ @dir = File.join(File.dirname(__FILE__), '..', 'fixtures')
30
+ @all_fixtures = \
31
+ %w(bar/abc bar/xyz baz bing foo/alpha/t1 foo/alpha/t2 foo/beta)
32
+ @scanner = CommandT::Scanner.new @dir
33
+ end
34
+
35
+ describe 'paths method' do
36
+ it 'should return a list of regular files' do
37
+ @scanner.paths.should =~ @all_fixtures
38
+ end
39
+ end
40
+
41
+ describe 'flush method' do
42
+ it 'should force a rescan on next call to paths method' do
43
+ first = @scanner.paths
44
+ @scanner.flush
45
+ @scanner.paths.object_id.should_not == first.object_id
46
+ end
47
+ end
48
+
49
+ describe 'path= method' do
50
+ it 'should allow repeated applications of scanner at different paths' do
51
+ @scanner.paths.should =~ @all_fixtures
52
+
53
+ # drill down 1 level
54
+ @scanner.path = File.join(@dir, 'foo')
55
+ @scanner.paths.should =~ %w(alpha/t1 alpha/t2 beta)
56
+
57
+ # and another
58
+ @scanner.path = File.join(@dir, 'foo', 'alpha')
59
+ @scanner.paths.should =~ %w(t1 t2)
60
+ end
61
+ end
62
+
63
+ describe "'wildignore' exclusion" do
64
+ pending
65
+ end
66
+
67
+ describe ':max_depth option' do
68
+ it 'should not descend below "max_depth" levels' do
69
+ @scanner = CommandT::Scanner.new @dir, :max_depth => 1
70
+ @scanner.paths.should =~ %w(bar/abc bar/xyz baz bing foo/beta)
71
+ end
72
+ end
73
+ end
@@ -0,0 +1 @@
1
+ .
@@ -0,0 +1 @@
1
+ .
data/spec/fixtures/baz ADDED
@@ -0,0 +1 @@
1
+ .
@@ -0,0 +1 @@
1
+ .
@@ -0,0 +1 @@
1
+ .
@@ -0,0 +1 @@
1
+ .
@@ -0,0 +1 @@
1
+ .
@@ -0,0 +1,37 @@
1
+ # Copyright 2010 Wincent Colaiuta. All rights reserved.
2
+ #
3
+ # Redistribution and use in source and binary forms, with or without
4
+ # modification, are permitted provided that the following conditions are met:
5
+ #
6
+ # 1. Redistributions of source code must retain the above copyright notice,
7
+ # this list of conditions and the following disclaimer.
8
+ # 2. Redistributions in binary form must reproduce the above copyright notice,
9
+ # this list of conditions and the following disclaimer in the documentation
10
+ # and/or other materials provided with the distribution.
11
+ #
12
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
13
+ # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
14
+ # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
15
+ # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
16
+ # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
17
+ # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
18
+ # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
19
+ # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
20
+ # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
21
+ # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
22
+ # POSSIBILITY OF SUCH DAMAGE.
23
+
24
+ if !Object.const_defined?('Bundler')
25
+ require 'rubygems'
26
+ require 'bundler'
27
+ Bundler.setup
28
+ end
29
+ require 'rspec'
30
+
31
+ lib = File.expand_path('../lib', File.dirname(__FILE__))
32
+ ext = File.expand_path('../ext', File.dirname(__FILE__))
33
+ $LOAD_PATH << lib << ext
34
+
35
+ RSpec.configure do |config|
36
+ config.mock_framework = :rr
37
+ end
@@ -0,0 +1,41 @@
1
+ require 'spec/runner/formatter/base_text_formatter'
2
+ require 'pathname'
3
+
4
+ # Format spec results for display in the Vim quickfix window
5
+ # Use this custom formatter like this:
6
+ # spec -r spec/vim_formatter.rb -f Spec::Runner::Formatter::VimFormatter spec
7
+ module Spec
8
+ module Runner
9
+ module Formatter
10
+ class VimFormatter < BaseTextFormatter
11
+
12
+ # TODO: handle pending issues
13
+ # TODO: vim-side function for printing progress
14
+ def dump_failure counter, failure
15
+ path = failure.exception.backtrace.find do |frame|
16
+ frame =~ %r{\bspec/.*_spec\.rb:\d+\z}
17
+ end
18
+ message = failure.exception.message.gsub("\n", ' ')
19
+ @output.puts "#{relativize_path(path)}: #{message}" if path
20
+ end
21
+
22
+ def dump_pending; end
23
+
24
+ def dump_summary duration, example_count, failure_count, pending_count
25
+ end
26
+
27
+ private
28
+
29
+ def relativize_path path
30
+ @wd ||= Pathname.new Dir.getwd
31
+ begin
32
+ return Pathname.new(path).relative_path_from(@wd)
33
+ rescue ArgumentError
34
+ # raised unless both paths relative, or both absolute
35
+ return path
36
+ end
37
+ end
38
+ end # class VimFormatter
39
+ end # module Formatter
40
+ end # module Runner
41
+ end # module Spec
metadata ADDED
@@ -0,0 +1,107 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ver-command_t
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 1
8
+ - 0
9
+ version: 0.1.0
10
+ platform: ruby
11
+ authors:
12
+ - Simon Hafner
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-08-24 00:00:00 +02:00
18
+ default_executable:
19
+ dependencies: []
20
+
21
+ description:
22
+ email: hafnersimon@gmail.com
23
+ executables: []
24
+
25
+ extensions:
26
+ - ext/command_t/extconf.rb
27
+ extra_rdoc_files: []
28
+
29
+ files:
30
+ - lib/command_t/settings.rb
31
+ - lib/command_t/finder.rb
32
+ - lib/command_t/scanner.rb
33
+ - lib/command_t/ex/command_t.rb
34
+ - lib/ver-command_t.rb
35
+ - ext/command_t/ruby_compat.h
36
+ - ext/command_t/mkmf.log
37
+ - ext/command_t/ext.so
38
+ - ext/command_t/ext.h
39
+ - ext/command_t/match.h
40
+ - ext/command_t/ext.c
41
+ - ext/command_t/depend
42
+ - ext/command_t/extconf.rb
43
+ - ext/command_t/match.c
44
+ - ext/command_t/matcher.h
45
+ - ext/command_t/matcher.c
46
+ - spec/command_t/scanner_spec.rb
47
+ - spec/command_t/matcher_spec.rb
48
+ - spec/command_t/match_spec.rb
49
+ - spec/command_t/finder_spec.rb
50
+ - spec/vim_formatter.rb
51
+ - spec/spec_helper.rb
52
+ - spec/fixtures/baz
53
+ - spec/fixtures/bing
54
+ - spec/fixtures/bar/abc
55
+ - spec/fixtures/bar/xyz
56
+ - spec/fixtures/foo/beta
57
+ - spec/fixtures/foo/alpha/t2
58
+ - spec/fixtures/foo/alpha/t1
59
+ - LICENSE
60
+ - README.md
61
+ has_rdoc: true
62
+ homepage: http://github.com/Tass/ver-command_t
63
+ licenses: []
64
+
65
+ post_install_message:
66
+ rdoc_options: []
67
+
68
+ require_paths:
69
+ - ext
70
+ - lib
71
+ required_ruby_version: !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ segments:
77
+ - 0
78
+ version: "0"
79
+ required_rubygems_version: !ruby/object:Gem::Requirement
80
+ none: false
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ segments:
85
+ - 0
86
+ version: "0"
87
+ requirements: []
88
+
89
+ rubyforge_project:
90
+ rubygems_version: 1.3.7
91
+ signing_key:
92
+ specification_version: 3
93
+ summary: ver adaptation of the CommandT plugin for vim
94
+ test_files:
95
+ - spec/command_t/scanner_spec.rb
96
+ - spec/command_t/matcher_spec.rb
97
+ - spec/command_t/match_spec.rb
98
+ - spec/command_t/finder_spec.rb
99
+ - spec/vim_formatter.rb
100
+ - spec/spec_helper.rb
101
+ - spec/fixtures/baz
102
+ - spec/fixtures/bing
103
+ - spec/fixtures/bar/abc
104
+ - spec/fixtures/bar/xyz
105
+ - spec/fixtures/foo/beta
106
+ - spec/fixtures/foo/alpha/t2
107
+ - spec/fixtures/foo/alpha/t1