bundler_bash_completion 0.0.3 → 0.1.0

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 CHANGED
@@ -1,8 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bundler_bash_completion (0.0.3)
5
- bundler (>= 1.0.0)
4
+ bundler_bash_completion (0.1.0)
6
5
 
7
6
  GEM
8
7
  remote: http://rubygems.org/
data/README.mdown CHANGED
@@ -14,6 +14,6 @@ First, install gem:
14
14
 
15
15
  gem install bundler_bash_completion
16
16
 
17
- Then, add following line to your `~/.bashrc` file.
17
+ Then, add following line to your `~/.bashrc` file:
18
18
 
19
19
  complete -C /path/to/complete_bundle_bash_command -o default bundle
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.3
1
+ 0.1.0
@@ -15,8 +15,6 @@ Gem::Specification.new do |s|
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_dependency 'bundler', '>= 1.0.0'
19
-
20
18
  s.add_development_dependency 'rake', '~> 0.9.2.2'
21
19
  s.add_development_dependency 'rspec', '~> 2.9.0'
22
20
  end
@@ -1,3 +1,6 @@
1
+ require 'rubygems'
2
+ require 'yaml'
3
+
1
4
  class BundlerBashCompletion
2
5
 
3
6
  TASKS = {
@@ -91,10 +94,14 @@ class BundlerBashCompletion
91
94
 
92
95
  def bins
93
96
  @bins ||= begin
94
- require 'bundler'
95
- Bundler.setup.specs.map(&:executables).flatten + ['gem']
96
- rescue Exception
97
- ['gem']
97
+ gem_paths.map { |path| Dir.glob("#{path}/{bin,exe}/*") }.tap do |paths|
98
+ paths.flatten!
99
+ paths.reject! { |path| !File.executable?(path) }
100
+ paths.map! { |path| File.basename(path) }
101
+ paths.push('gem')
102
+ paths.sort!
103
+ paths.uniq!
104
+ end
98
105
  end
99
106
  end
100
107
 
@@ -114,8 +121,17 @@ class BundlerBashCompletion
114
121
 
115
122
  def gems
116
123
  @gems ||= begin
117
- require 'bundler'
118
- Bundler.setup.specs.map(&:name)
124
+ gems = File.readlines("#{Dir.pwd}/Gemfile.lock").grep(/\(.+\)/).tap do |lines|
125
+ lines.each do |line|
126
+ line.gsub!(/\(.+/, '')
127
+ line.gsub!(/\s+/, '')
128
+ line.strip!
129
+ end
130
+ end.tap do |gems|
131
+ gems.push('bundler')
132
+ gems.sort!
133
+ gems.uniq!
134
+ end
119
135
  rescue Exception
120
136
  []
121
137
  end
@@ -135,10 +151,32 @@ class BundlerBashCompletion
135
151
  command == 'bundle'
136
152
  end
137
153
 
154
+ def bundle_path
155
+ @bundle_path ||= begin
156
+ require 'yaml'
157
+ path = YAML.load_file('.bundle/config')['BUNDLE_PATH']
158
+ path && File.expand_path(path)
159
+ rescue
160
+ nil
161
+ end
162
+ end
163
+
138
164
  def completion_step
139
165
  @completion_step ||= arguments.size - (completion_word.empty? ? 0 : 1)
140
166
  end
141
167
 
168
+ def gem_paths
169
+ @gem_paths ||= begin
170
+ paths = Gem.path.map do |path|
171
+ Dir.glob("#{path}/gems/*")
172
+ end
173
+ paths << Dir.glob("#{bundle_path}/ruby/*/gems/*")
174
+ paths.flatten!
175
+ paths.uniq!
176
+ paths
177
+ end
178
+ end
179
+
142
180
  def tasks_completion
143
181
  TASKS.keys.select { |t| t.start_with?(completion_word) }
144
182
  end
@@ -17,7 +17,7 @@ describe BundlerBashCompletion do
17
17
  describe '#bins' do
18
18
 
19
19
  it 'is installed binaries' do
20
- completion.bins.should include('autospec', 'bundler_bash_completion', 'gem', 'ldiff', 'rake', 'rspec')
20
+ completion.bins.should include('autospec', 'gem', 'ldiff', 'rake', 'rspec')
21
21
  completion.bins.should_not include('rails')
22
22
  end
23
23
 
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.0.3
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,20 +11,9 @@ bindir: bin
11
11
  cert_chain: []
12
12
  date: 2012-03-28 00:00:00.000000000 Z
13
13
  dependencies:
14
- - !ruby/object:Gem::Dependency
15
- name: bundler
16
- requirement: &70157767591180 !ruby/object:Gem::Requirement
17
- none: false
18
- requirements:
19
- - - ! '>='
20
- - !ruby/object:Gem::Version
21
- version: 1.0.0
22
- type: :runtime
23
- prerelease: false
24
- version_requirements: *70157767591180
25
14
  - !ruby/object:Gem::Dependency
26
15
  name: rake
27
- requirement: &70157767590680 !ruby/object:Gem::Requirement
16
+ requirement: &70210066892200 !ruby/object:Gem::Requirement
28
17
  none: false
29
18
  requirements:
30
19
  - - ~>
@@ -32,10 +21,10 @@ dependencies:
32
21
  version: 0.9.2.2
33
22
  type: :development
34
23
  prerelease: false
35
- version_requirements: *70157767590680
24
+ version_requirements: *70210066892200
36
25
  - !ruby/object:Gem::Dependency
37
26
  name: rspec
38
- requirement: &70157767590200 !ruby/object:Gem::Requirement
27
+ requirement: &70210066889080 !ruby/object:Gem::Requirement
39
28
  none: false
40
29
  requirements:
41
30
  - - ~>
@@ -43,7 +32,7 @@ dependencies:
43
32
  version: 2.9.0
44
33
  type: :development
45
34
  prerelease: false
46
- version_requirements: *70157767590200
35
+ version_requirements: *70210066889080
47
36
  description: Provides bash completion for bundle command
48
37
  email: al@alweb.org
49
38
  executables:
@@ -78,7 +67,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
78
67
  version: '0'
79
68
  segments:
80
69
  - 0
81
- hash: -1269748206914996944
70
+ hash: -2647878609978954378
82
71
  required_rubygems_version: !ruby/object:Gem::Requirement
83
72
  none: false
84
73
  requirements:
@@ -87,7 +76,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
87
76
  version: '0'
88
77
  segments:
89
78
  - 0
90
- hash: -1269748206914996944
79
+ hash: -2647878609978954378
91
80
  requirements: []
92
81
  rubyforge_project: bundler_bash_completion
93
82
  rubygems_version: 1.8.17