Class: BundlerBashCompletion
- Inherits:
-
Object
- Object
- BundlerBashCompletion
- Defined in:
- lib/bundler_bash_completion.rb
Constant Summary collapse
- TASKS =
{ 'check' => { '--dry-run' => :continue, '--gemfile' => :block, '--no-color' => :continue, '--no-no-color' => :continue, '--no-verbose' => :continue, '--path' => :block, '--retry' => :block, '--verbose' => :continue, }, 'clean' => { '--dry-run' => :continue, '--force' => :continue, '--no-color' => :continue, '--no-no-color' => :continue, '--no-verbose' => :continue, '--retry' => :block, '--verbose' => :continue, }, 'config' => {}, 'console' => { '--no-color' => :continue, '--no-no-color' => :continue, '--no-verbose' => :continue, '--retry' => :block, '--verbose' => :continue, }, 'exec' => { :bin => :continue, }, 'gem' => { '--bin' => :block, }, 'help' => { :task => :continue, }, 'init' => { '--no-color' => :continue, '--no-no-color' => :continue, '--no-verbose' => :continue, '--retry' => :block, '--verbose' => :continue, }, 'install' => { '--binstubs' => :continue, '--deployment' => :continue, '--gemfile' => :block, '--local' => :continue, '--no-cache' => :continue, '--no-color' => :continue, '--no-no-color' => :continue, '--no-verbose' => :continue, '--path' => :block, '--retry' => :block, '--shebang' => :block, '--standalone' => :block, '--system' => :continue, '--trust-policy' => :block, '--verbose' => :continue, '--with' => :block, '--without' => :block, }, 'list' => { '--no-color' => :continue, '--no-no-color' => :continue, '--no-verbose' => :continue, '--paths' => :continue, '--retry' => :block, '--verbose' => :continue, :gem => :continue, }, 'lock' => { '--full-index' => :continue, '--local' => :continue, '--lockfile' => :block, '--no-color' => :continue, '--no-no-color' => :continue, '--no-verbose' => :continue, '--print' => :continue, '--retry' => :block, '--update' => :continue, '--verbose' => :continue, }, 'open' => { :gem => :continue, }, 'outdated' => { '--local' => :continue, '--no-color' => :continue, '--no-no-color' => :continue, '--no-verbose' => :continue, '--pre' => :continue, '--retry' => :block, '--source' => :block, '--verbose' => :continue, :gem => :continue, }, 'package' => {}, 'platform' => { '--ruby' => :continue, }, 'show' => { '--no-color' => :continue, '--no-no-color' => :continue, '--no-outdated' => :continue, '--no-paths' => :continue, '--no-verbose' => :continue, '--outdated' => :continue, '--paths' => :continue, '--retry' => :block, '--verbose' => :continue, :gem => :continue, }, 'update' => { '--no-color' => :continue, '--no-no-color' => :continue, '--no-verbose' => :continue, '--retry' => :block, '--source' => :block, '--verbose' => :continue, :gems => :continue, }, 'viz' => { '--file' => :block, '--format' => :block, '--no-color' => :continue, '--no-no-color' => :continue, '--no-requirements' => :continue, '--no-verbose' => :continue, '--no-version' => :continue, '--requirements' => :block, '--requirements' => :continue, '--retry' => :block, '--verbose' => :continue, '--version' => :continue, '--without' => :block, }, }
- CONFIG_PATH =
'.bundle/config'
Instance Attribute Summary collapse
-
#line ⇒ Object
readonly
Returns the value of attribute line.
Instance Method Summary collapse
- #arguments ⇒ Object
- #bins ⇒ Object
- #command ⇒ Object
- #complete ⇒ Object
- #completion_word ⇒ Object
- #gems ⇒ Object
-
#initialize(line) ⇒ BundlerBashCompletion
constructor
A new instance of BundlerBashCompletion.
- #task ⇒ Object
- #task_options ⇒ Object
Constructor Details
#initialize(line) ⇒ BundlerBashCompletion
Returns a new instance of BundlerBashCompletion.
149 150 151 |
# File 'lib/bundler_bash_completion.rb', line 149 def initialize(line) @line = line.to_s.gsub(/^\s+/, '').freeze end |
Instance Attribute Details
#line ⇒ Object (readonly)
Returns the value of attribute line.
147 148 149 |
# File 'lib/bundler_bash_completion.rb', line 147 def line @line end |
Instance Method Details
#arguments ⇒ Object
153 154 155 |
# File 'lib/bundler_bash_completion.rb', line 153 def arguments @arguments ||= line.split(/\s+/) end |
#bins ⇒ Object
157 158 159 160 161 162 163 164 165 166 167 168 |
# File 'lib/bundler_bash_completion.rb', line 157 def bins @bins ||= begin gem_paths.map { |path| Dir.glob("#{path}/{bin,exe}/*") }.tap do |paths| paths.flatten! paths.reject! { |path| !File.executable?(path) } paths.map! { |path| File.basename(path) } paths.push('gem', 'ruby') paths.sort! paths.uniq! end end end |
#command ⇒ Object
170 171 172 |
# File 'lib/bundler_bash_completion.rb', line 170 def command arguments.first.to_s end |
#complete ⇒ Object
178 179 180 181 182 |
# File 'lib/bundler_bash_completion.rb', line 178 def complete return if return tasks_completion if tasks_completion? [] end |
#completion_word ⇒ Object
174 175 176 |
# File 'lib/bundler_bash_completion.rb', line 174 def completion_word @completion_word ||= (line =~ /\s+$/) ? '' : arguments.last end |
#gems ⇒ Object
184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 |
# File 'lib/bundler_bash_completion.rb', line 184 def gems @gems ||= begin gems = File.readlines("#{Dir.pwd}/Gemfile.lock").grep(/\(.+\)/).tap do |lines| lines.each do |line| line.gsub!(/\(.+/, '') line.gsub!(/\s+/, '') line.strip! end end.tap do |gems| gems.push('bundler') gems.sort! gems.uniq! end rescue Exception [] end end |
#task ⇒ Object
202 203 204 |
# File 'lib/bundler_bash_completion.rb', line 202 def task @task ||= (completion_step > 1) ? arguments[1].to_s : '' end |
#task_options ⇒ Object
206 207 208 |
# File 'lib/bundler_bash_completion.rb', line 206 def @task_options ||= (completion_step > 2) ? arguments[2..(completion_step - 1)] : [] end |