bundler_bash_completion 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile.lock +18 -9
- data/VERSION +1 -1
- data/bundler_bash_completion.gemspec +3 -2
- data/lib/bundler_bash_completion.rb +22 -22
- data/spec/bundler_bash_completion_spec.rb +64 -40
- data/spec/spec_helper.rb +1 -1
- metadata +20 -9
data/Gemfile.lock
CHANGED
@@ -1,26 +1,35 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
bundler_bash_completion (0.1.
|
4
|
+
bundler_bash_completion (0.1.1)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: http://rubygems.org/
|
8
8
|
specs:
|
9
|
+
columnize (0.3.6)
|
10
|
+
debugger (1.1.3)
|
11
|
+
columnize (>= 0.3.1)
|
12
|
+
debugger-linecache (~> 1.1.1)
|
13
|
+
debugger-ruby_core_source (~> 1.1.2)
|
14
|
+
debugger-linecache (1.1.1)
|
15
|
+
debugger-ruby_core_source (>= 1.1.1)
|
16
|
+
debugger-ruby_core_source (1.1.2)
|
9
17
|
diff-lcs (1.1.3)
|
10
18
|
rake (0.9.2.2)
|
11
|
-
rspec (2.
|
12
|
-
rspec-core (~> 2.
|
13
|
-
rspec-expectations (~> 2.
|
14
|
-
rspec-mocks (~> 2.
|
15
|
-
rspec-core (2.
|
16
|
-
rspec-expectations (2.
|
19
|
+
rspec (2.10.0)
|
20
|
+
rspec-core (~> 2.10.0)
|
21
|
+
rspec-expectations (~> 2.10.0)
|
22
|
+
rspec-mocks (~> 2.10.0)
|
23
|
+
rspec-core (2.10.0)
|
24
|
+
rspec-expectations (2.10.0)
|
17
25
|
diff-lcs (~> 1.1.3)
|
18
|
-
rspec-mocks (2.
|
26
|
+
rspec-mocks (2.10.1)
|
19
27
|
|
20
28
|
PLATFORMS
|
21
29
|
ruby
|
22
30
|
|
23
31
|
DEPENDENCIES
|
24
32
|
bundler_bash_completion!
|
33
|
+
debugger (~> 1.1.0)
|
25
34
|
rake (~> 0.9.2.2)
|
26
|
-
rspec (~> 2.
|
35
|
+
rspec (~> 2.10.0)
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.1
|
@@ -14,7 +14,8 @@ Gem::Specification.new do |s|
|
|
14
14
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
15
15
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
16
16
|
s.require_paths = ['lib']
|
17
|
-
|
17
|
+
|
18
|
+
s.add_development_dependency 'debugger', '~> 1.1.0'
|
18
19
|
s.add_development_dependency 'rake', '~> 0.9.2.2'
|
19
|
-
s.add_development_dependency 'rspec', '~> 2.
|
20
|
+
s.add_development_dependency 'rspec', '~> 2.10.0'
|
20
21
|
end
|
@@ -81,44 +81,44 @@ class BundlerBashCompletion
|
|
81
81
|
'--version' => :block,
|
82
82
|
},
|
83
83
|
}
|
84
|
-
|
84
|
+
|
85
85
|
attr_reader :line
|
86
86
|
|
87
87
|
def initialize(line)
|
88
88
|
@line = line.to_s.gsub(/^\s+/, '').freeze
|
89
89
|
end
|
90
|
-
|
90
|
+
|
91
91
|
def arguments
|
92
92
|
@arguments ||= line.split(/\s+/)
|
93
93
|
end
|
94
|
-
|
94
|
+
|
95
95
|
def bins
|
96
96
|
@bins ||= begin
|
97
97
|
gem_paths.map { |path| Dir.glob("#{path}/{bin,exe}/*") }.tap do |paths|
|
98
98
|
paths.flatten!
|
99
99
|
paths.reject! { |path| !File.executable?(path) }
|
100
100
|
paths.map! { |path| File.basename(path) }
|
101
|
-
paths.push('gem')
|
101
|
+
paths.push('gem', 'ruby')
|
102
102
|
paths.sort!
|
103
103
|
paths.uniq!
|
104
104
|
end
|
105
105
|
end
|
106
106
|
end
|
107
|
-
|
107
|
+
|
108
108
|
def command
|
109
109
|
arguments.first.to_s
|
110
110
|
end
|
111
|
-
|
111
|
+
|
112
112
|
def completion_word
|
113
113
|
@completion_word ||= (line =~ /\s+$/) ? '' : arguments.last
|
114
114
|
end
|
115
|
-
|
115
|
+
|
116
116
|
def complete
|
117
117
|
return tasks_completion if tasks_completion?
|
118
118
|
return task_options_completion if task_options_completion?
|
119
119
|
[]
|
120
120
|
end
|
121
|
-
|
121
|
+
|
122
122
|
def gems
|
123
123
|
@gems ||= begin
|
124
124
|
gems = File.readlines("#{Dir.pwd}/Gemfile.lock").grep(/\(.+\)/).tap do |lines|
|
@@ -136,21 +136,21 @@ class BundlerBashCompletion
|
|
136
136
|
[]
|
137
137
|
end
|
138
138
|
end
|
139
|
-
|
139
|
+
|
140
140
|
def task
|
141
141
|
@task ||= (completion_step > 1) ? arguments[1].to_s : ''
|
142
142
|
end
|
143
|
-
|
143
|
+
|
144
144
|
def task_options
|
145
145
|
@task_options ||= (completion_step > 2) ? arguments[2..(completion_step - 1)] : []
|
146
146
|
end
|
147
|
-
|
147
|
+
|
148
148
|
private
|
149
|
-
|
149
|
+
|
150
150
|
def bundle_command?
|
151
151
|
command == 'bundle'
|
152
152
|
end
|
153
|
-
|
153
|
+
|
154
154
|
def bundle_path
|
155
155
|
@bundle_path ||= begin
|
156
156
|
require 'yaml'
|
@@ -160,11 +160,11 @@ class BundlerBashCompletion
|
|
160
160
|
nil
|
161
161
|
end
|
162
162
|
end
|
163
|
-
|
163
|
+
|
164
164
|
def completion_step
|
165
165
|
@completion_step ||= arguments.size - (completion_word.empty? ? 0 : 1)
|
166
166
|
end
|
167
|
-
|
167
|
+
|
168
168
|
def gem_paths
|
169
169
|
@gem_paths ||= begin
|
170
170
|
paths = Gem.path.map do |path|
|
@@ -176,15 +176,15 @@ class BundlerBashCompletion
|
|
176
176
|
paths
|
177
177
|
end
|
178
178
|
end
|
179
|
-
|
179
|
+
|
180
180
|
def tasks_completion
|
181
181
|
TASKS.keys.select { |t| t.start_with?(completion_word) }
|
182
182
|
end
|
183
|
-
|
183
|
+
|
184
184
|
def tasks_completion?
|
185
185
|
bundle_command? && completion_step == 1
|
186
186
|
end
|
187
|
-
|
187
|
+
|
188
188
|
def task_options_completion
|
189
189
|
options = TASKS[task] || {}
|
190
190
|
return [] if options[task_options.last] == :block
|
@@ -192,11 +192,11 @@ class BundlerBashCompletion
|
|
192
192
|
if key == :task
|
193
193
|
(task_options & TASKS.keys).empty? ? TASKS.keys : nil
|
194
194
|
elsif key == :gem
|
195
|
-
|
195
|
+
task_options.empty? ? gems : nil
|
196
196
|
elsif key == :gems
|
197
197
|
gems - task_options
|
198
198
|
elsif key == :bin
|
199
|
-
|
199
|
+
task_options.empty? ? bins : nil
|
200
200
|
else
|
201
201
|
key
|
202
202
|
end
|
@@ -205,9 +205,9 @@ class BundlerBashCompletion
|
|
205
205
|
completion.compact!
|
206
206
|
completion.select { |c| c.start_with?(completion_word) }
|
207
207
|
end
|
208
|
-
|
208
|
+
|
209
209
|
def task_options_completion?
|
210
210
|
bundle_command? && completion_step > 1 && TASKS.key?(task)
|
211
211
|
end
|
212
|
-
|
212
|
+
|
213
213
|
end
|
@@ -1,11 +1,11 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe BundlerBashCompletion do
|
4
|
-
|
4
|
+
|
5
5
|
def completion(line = nil)
|
6
6
|
BundlerBashCompletion.new(line)
|
7
7
|
end
|
8
|
-
|
8
|
+
|
9
9
|
describe '#arguments' do
|
10
10
|
|
11
11
|
it 'is given line splitted by whitespaces' do
|
@@ -13,31 +13,35 @@ describe BundlerBashCompletion do
|
|
13
13
|
end
|
14
14
|
|
15
15
|
end
|
16
|
-
|
16
|
+
|
17
17
|
describe '#bins' do
|
18
18
|
|
19
19
|
it 'is installed binaries' do
|
20
20
|
completion.bins.should include('autospec', 'gem', 'ldiff', 'rake', 'rspec')
|
21
21
|
completion.bins.should_not include('rails')
|
22
22
|
end
|
23
|
-
|
23
|
+
|
24
|
+
it 'includes ruby' do
|
25
|
+
completion.bins.should include('ruby')
|
26
|
+
end
|
27
|
+
|
24
28
|
end
|
25
|
-
|
29
|
+
|
26
30
|
describe '#command' do
|
27
31
|
|
28
32
|
it 'is first argument' do
|
29
33
|
completion('bundle exec').command.should == 'bundle'
|
30
34
|
completion('rake').command.should == 'rake'
|
31
35
|
end
|
32
|
-
|
36
|
+
|
33
37
|
it 'is empty string if line is blank' do
|
34
38
|
completion(nil).command.should == ''
|
35
39
|
end
|
36
40
|
|
37
41
|
end
|
38
|
-
|
42
|
+
|
39
43
|
describe '#complete' do
|
40
|
-
|
44
|
+
|
41
45
|
context 'with "foo"' do
|
42
46
|
|
43
47
|
it 'is an empty array' do
|
@@ -45,7 +49,7 @@ describe BundlerBashCompletion do
|
|
45
49
|
end
|
46
50
|
|
47
51
|
end
|
48
|
-
|
52
|
+
|
49
53
|
context 'with "bundle"' do
|
50
54
|
|
51
55
|
it 'is an empty array' do
|
@@ -53,7 +57,7 @@ describe BundlerBashCompletion do
|
|
53
57
|
end
|
54
58
|
|
55
59
|
end
|
56
|
-
|
60
|
+
|
57
61
|
context 'with "bundle "' do
|
58
62
|
|
59
63
|
it 'is all tasks' do
|
@@ -61,7 +65,7 @@ describe BundlerBashCompletion do
|
|
61
65
|
end
|
62
66
|
|
63
67
|
end
|
64
|
-
|
68
|
+
|
65
69
|
context 'with "bundle "' do
|
66
70
|
|
67
71
|
it 'is all tasks' do
|
@@ -69,7 +73,7 @@ describe BundlerBashCompletion do
|
|
69
73
|
end
|
70
74
|
|
71
75
|
end
|
72
|
-
|
76
|
+
|
73
77
|
context 'with "bundle in"' do
|
74
78
|
|
75
79
|
it 'is "init" & "install" tasks' do
|
@@ -77,7 +81,7 @@ describe BundlerBashCompletion do
|
|
77
81
|
end
|
78
82
|
|
79
83
|
end
|
80
|
-
|
84
|
+
|
81
85
|
context 'with "bundle in "' do
|
82
86
|
|
83
87
|
it 'is an empty array' do
|
@@ -85,7 +89,7 @@ describe BundlerBashCompletion do
|
|
85
89
|
end
|
86
90
|
|
87
91
|
end
|
88
|
-
|
92
|
+
|
89
93
|
context 'with "bundle foo"' do
|
90
94
|
|
91
95
|
it 'is an empty array' do
|
@@ -93,7 +97,7 @@ describe BundlerBashCompletion do
|
|
93
97
|
end
|
94
98
|
|
95
99
|
end
|
96
|
-
|
100
|
+
|
97
101
|
context 'with "bundle foo "' do
|
98
102
|
|
99
103
|
it 'is an empty array' do
|
@@ -101,7 +105,7 @@ describe BundlerBashCompletion do
|
|
101
105
|
end
|
102
106
|
|
103
107
|
end
|
104
|
-
|
108
|
+
|
105
109
|
context 'with "bundle install "' do
|
106
110
|
|
107
111
|
it 'is "--local", "--path", "--verbose", "--without", etc.' do
|
@@ -109,7 +113,7 @@ describe BundlerBashCompletion do
|
|
109
113
|
end
|
110
114
|
|
111
115
|
end
|
112
|
-
|
116
|
+
|
113
117
|
context 'with "bundle install --p"' do
|
114
118
|
|
115
119
|
it 'is "--path"' do
|
@@ -117,7 +121,7 @@ describe BundlerBashCompletion do
|
|
117
121
|
end
|
118
122
|
|
119
123
|
end
|
120
|
-
|
124
|
+
|
121
125
|
context 'with "bundle install --path "' do
|
122
126
|
|
123
127
|
it 'is an empty array' do
|
@@ -125,7 +129,7 @@ describe BundlerBashCompletion do
|
|
125
129
|
end
|
126
130
|
|
127
131
|
end
|
128
|
-
|
132
|
+
|
129
133
|
context 'with "bundle install --local "' do
|
130
134
|
|
131
135
|
it 'is "--local", "--path", "--without", etc.' do
|
@@ -133,7 +137,7 @@ describe BundlerBashCompletion do
|
|
133
137
|
end
|
134
138
|
|
135
139
|
end
|
136
|
-
|
140
|
+
|
137
141
|
context 'with "bundle help in"' do
|
138
142
|
|
139
143
|
it 'is "init" and "install"' do
|
@@ -141,7 +145,7 @@ describe BundlerBashCompletion do
|
|
141
145
|
end
|
142
146
|
|
143
147
|
end
|
144
|
-
|
148
|
+
|
145
149
|
context 'with "bundle help install "' do
|
146
150
|
|
147
151
|
it 'is an empty array' do
|
@@ -149,7 +153,7 @@ describe BundlerBashCompletion do
|
|
149
153
|
end
|
150
154
|
|
151
155
|
end
|
152
|
-
|
156
|
+
|
153
157
|
context 'with "bundle show "' do
|
154
158
|
|
155
159
|
it 'is gems and "--verbose", etc.' do
|
@@ -157,7 +161,7 @@ describe BundlerBashCompletion do
|
|
157
161
|
end
|
158
162
|
|
159
163
|
end
|
160
|
-
|
164
|
+
|
161
165
|
context 'with "bundle show rspec "' do
|
162
166
|
|
163
167
|
it 'is "--paths", "--no-color" and "--verbose"' do
|
@@ -165,7 +169,15 @@ describe BundlerBashCompletion do
|
|
165
169
|
end
|
166
170
|
|
167
171
|
end
|
168
|
-
|
172
|
+
|
173
|
+
context 'with "bundle show foo "' do
|
174
|
+
|
175
|
+
it 'is "--paths", "--no-color" and "--verbose"' do
|
176
|
+
completion('bundle show foo ').complete.should == ['--no-color', '--paths', '--verbose']
|
177
|
+
end
|
178
|
+
|
179
|
+
end
|
180
|
+
|
169
181
|
context 'with "bundle update "' do
|
170
182
|
|
171
183
|
it 'is gems and "--verbose", etc.' do
|
@@ -173,7 +185,7 @@ describe BundlerBashCompletion do
|
|
173
185
|
end
|
174
186
|
|
175
187
|
end
|
176
|
-
|
188
|
+
|
177
189
|
context 'with "bundle update rake rspec "' do
|
178
190
|
|
179
191
|
it 'is gems (without rake & rspec) and "--verbose", etc.' do
|
@@ -182,7 +194,7 @@ describe BundlerBashCompletion do
|
|
182
194
|
end
|
183
195
|
|
184
196
|
end
|
185
|
-
|
197
|
+
|
186
198
|
context 'with "bundle exec "' do
|
187
199
|
|
188
200
|
it 'is bins' do
|
@@ -190,8 +202,12 @@ describe BundlerBashCompletion do
|
|
190
202
|
completion('bundle exec ').complete.should_not include('--verbose')
|
191
203
|
end
|
192
204
|
|
205
|
+
it 'includes gem & ruby commands' do
|
206
|
+
completion('bundle exec ').complete.should include('gem', 'ruby')
|
207
|
+
end
|
208
|
+
|
193
209
|
end
|
194
|
-
|
210
|
+
|
195
211
|
context 'with "bundle exec rake "' do
|
196
212
|
|
197
213
|
it 'is an empty array' do
|
@@ -199,22 +215,30 @@ describe BundlerBashCompletion do
|
|
199
215
|
end
|
200
216
|
|
201
217
|
end
|
202
|
-
|
218
|
+
|
219
|
+
context 'with "bundle exec foo "' do
|
220
|
+
|
221
|
+
it 'is an empty array' do
|
222
|
+
completion('bundle exec foo ').complete.should == []
|
223
|
+
end
|
224
|
+
|
225
|
+
end
|
226
|
+
|
203
227
|
end
|
204
|
-
|
228
|
+
|
205
229
|
describe '#completion_word' do
|
206
230
|
|
207
231
|
it 'is last word on line' do
|
208
232
|
completion('bundle instal').completion_word.should == 'instal'
|
209
233
|
end
|
210
|
-
|
234
|
+
|
211
235
|
it 'is an empty string if line ends with a white space' do
|
212
236
|
completion('bundle install ').completion_word.should == ''
|
213
237
|
completion('bundle install ').completion_word.should == ''
|
214
238
|
end
|
215
239
|
|
216
240
|
end
|
217
|
-
|
241
|
+
|
218
242
|
describe '#gems' do
|
219
243
|
|
220
244
|
it 'is installed gems' do
|
@@ -225,7 +249,7 @@ describe BundlerBashCompletion do
|
|
225
249
|
end
|
226
250
|
|
227
251
|
describe '#line' do
|
228
|
-
|
252
|
+
|
229
253
|
it 'is line given at initializion' do
|
230
254
|
completion('hello').line.should == 'hello'
|
231
255
|
end
|
@@ -235,35 +259,35 @@ describe BundlerBashCompletion do
|
|
235
259
|
completion('hello').line.gsub!('l', 'w')
|
236
260
|
}.to raise_error(/can't modify frozen String/)
|
237
261
|
end
|
238
|
-
|
262
|
+
|
239
263
|
it 'is converted to string' do
|
240
264
|
completion(:hello).line.should == 'hello'
|
241
265
|
end
|
242
|
-
|
266
|
+
|
243
267
|
it 'first whitespaces are removed' do
|
244
268
|
completion(' hello').line.should == 'hello'
|
245
269
|
end
|
246
|
-
|
270
|
+
|
247
271
|
it 'last whitespaces are preserved' do
|
248
272
|
completion('hello ').line.should == 'hello '
|
249
273
|
end
|
250
274
|
|
251
275
|
end
|
252
|
-
|
276
|
+
|
253
277
|
describe '#task' do
|
254
|
-
|
278
|
+
|
255
279
|
it 'is an empty string when not ending with a whitespace' do
|
256
280
|
completion('bundle install').task.should == ''
|
257
281
|
end
|
258
|
-
|
282
|
+
|
259
283
|
it 'is task given by second argument if ending with a whitespace' do
|
260
284
|
completion('bundle install ').task.should == 'install'
|
261
285
|
completion('bundle foo ').task.should == 'foo'
|
262
286
|
completion('bundle help install ').task.should == 'help'
|
263
287
|
end
|
264
|
-
|
288
|
+
|
265
289
|
end
|
266
|
-
|
290
|
+
|
267
291
|
describe '#task_options' do
|
268
292
|
|
269
293
|
it 'is correct' do
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bundler_bash_completion
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,22 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-05-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: debugger
|
16
|
+
requirement: &70322947658360 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 1.1.0
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70322947658360
|
14
25
|
- !ruby/object:Gem::Dependency
|
15
26
|
name: rake
|
16
|
-
requirement: &
|
27
|
+
requirement: &70322947657840 !ruby/object:Gem::Requirement
|
17
28
|
none: false
|
18
29
|
requirements:
|
19
30
|
- - ~>
|
@@ -21,18 +32,18 @@ dependencies:
|
|
21
32
|
version: 0.9.2.2
|
22
33
|
type: :development
|
23
34
|
prerelease: false
|
24
|
-
version_requirements: *
|
35
|
+
version_requirements: *70322947657840
|
25
36
|
- !ruby/object:Gem::Dependency
|
26
37
|
name: rspec
|
27
|
-
requirement: &
|
38
|
+
requirement: &70322947653000 !ruby/object:Gem::Requirement
|
28
39
|
none: false
|
29
40
|
requirements:
|
30
41
|
- - ~>
|
31
42
|
- !ruby/object:Gem::Version
|
32
|
-
version: 2.
|
43
|
+
version: 2.10.0
|
33
44
|
type: :development
|
34
45
|
prerelease: false
|
35
|
-
version_requirements: *
|
46
|
+
version_requirements: *70322947653000
|
36
47
|
description: Provides bash completion for bundle command
|
37
48
|
email: al@alweb.org
|
38
49
|
executables:
|
@@ -67,7 +78,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
67
78
|
version: '0'
|
68
79
|
segments:
|
69
80
|
- 0
|
70
|
-
hash: -
|
81
|
+
hash: -2345535026189476707
|
71
82
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
72
83
|
none: false
|
73
84
|
requirements:
|
@@ -76,7 +87,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
76
87
|
version: '0'
|
77
88
|
segments:
|
78
89
|
- 0
|
79
|
-
hash: -
|
90
|
+
hash: -2345535026189476707
|
80
91
|
requirements: []
|
81
92
|
rubyforge_project: bundler_bash_completion
|
82
93
|
rubygems_version: 1.8.17
|