rvm-completion 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/.document ADDED
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
data/.gitignore ADDED
@@ -0,0 +1,21 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## PROJECT::GENERAL
17
+ coverage
18
+ rdoc
19
+ pkg
20
+
21
+ ## PROJECT::SPECIFIC
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2010 Christoph Olszowka
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,28 @@
1
+ = Ruby Version Manager bash completion
2
+
3
+ Provides you with bash completion for the Ruby Version Manager by Wayne Seguin,
4
+ including completion of installed Rubies and available gemsets for currently active
5
+ Ruby.
6
+
7
+ == Install
8
+
9
+ $ gem install rvm-completion
10
+ $ install-rvm-completion
11
+
12
+ Then add the following line to your bash profile (~/.profile or ~/.bashrc):
13
+ complete -C $rvm_scripts_path/rvm-completion.rb -o default rvm
14
+
15
+
16
+ == Note on Patches/Pull Requests
17
+
18
+ * Fork the project.
19
+ * Make your feature addition or bug fix.
20
+ * Add tests for it. This is important so I don't break it in a
21
+ future version unintentionally.
22
+ * Commit, do not mess with rakefile, version, or history.
23
+ (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
24
+ * Send me a pull request. Bonus points for topic branches.
25
+
26
+ == Copyright
27
+
28
+ Copyright (c) 2010 Christoph Olszowka. See LICENSE for details.
data/Rakefile ADDED
@@ -0,0 +1,57 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "rvm-completion"
8
+ gem.summary = %Q{bash completion for Ruby Version Manager}
9
+ gem.description = %Q{bash completion for Ruby Version Manager including installed rubies and gemsets for current ruby}
10
+ gem.email = "christoph at olszowka de"
11
+ gem.homepage = "http://github.com/colszowka/rvm-completion"
12
+ gem.authors = ["Christoph Olszowka"]
13
+ gem.bindir = 'bin'
14
+ gem.executables = ['install-rvm-completion']
15
+ gem.default_executable = 'install-rvm-completion'
16
+ gem.add_development_dependency "shoulda", ">= 0"
17
+ gem.post_install_message = "\nTo install rvm completion v#{File.read('VERSION').strip.chomp}, please run 'install-rvm-completion' in your terminal now!\n\n"
18
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
19
+ end
20
+ Jeweler::GemcutterTasks.new
21
+ rescue LoadError
22
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
23
+ end
24
+
25
+ require 'rake/testtask'
26
+ Rake::TestTask.new(:test) do |test|
27
+ test.libs << 'lib' << 'test'
28
+ test.pattern = 'test/**/test_*.rb'
29
+ test.verbose = true
30
+ end
31
+
32
+ begin
33
+ require 'rcov/rcovtask'
34
+ Rcov::RcovTask.new do |test|
35
+ test.libs << 'test'
36
+ test.pattern = 'test/**/test_*.rb'
37
+ test.verbose = true
38
+ end
39
+ rescue LoadError
40
+ task :rcov do
41
+ abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
42
+ end
43
+ end
44
+
45
+ task :test => :check_dependencies
46
+
47
+ task :default => :test
48
+
49
+ require 'rake/rdoctask'
50
+ Rake::RDocTask.new do |rdoc|
51
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
52
+
53
+ rdoc.rdoc_dir = 'rdoc'
54
+ rdoc.title = "rvm-completion #{version}"
55
+ rdoc.rdoc_files.include('README*')
56
+ rdoc.rdoc_files.include('lib/**/*.rb')
57
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ rvm_scripts_path = ENV['rvm_scripts_path']
4
+ completion_source = File.expand_path(File.join(File.dirname(__FILE__), '../lib/rvm-completion.rb'))
5
+ completion_target = File.join(rvm_scripts_path, 'rvm-completion.rb')
6
+
7
+ if rvm_scripts_path.nil? or not (File.exist?(rvm_scripts_path) and File.directory?(rvm_scripts_path))
8
+ puts "Failed to find rvm scripts path - is rvm installed correctly?"
9
+ exit 1
10
+ end
11
+
12
+ if system "cp #{completion_source} #{completion_target}"
13
+ puts "Success! rvm completion v#{File.read(File.expand_path(File.join(File.dirname(__FILE__), '../VERSION'))).chomp} installed to #{completion_target}", ""
14
+
15
+ puts "If you didn't do so before, please add the following line at the end of your ~/.profile or ~/.bashrc"
16
+ puts " complete -C $rvm_scripts_path/#{File.basename(completion_target)} -o default rvm"
17
+ else
18
+ puts "Failed to copy the completion script to #{rvm_scripts_path}!"
19
+ exit 1
20
+ end
@@ -0,0 +1,109 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ #
4
+ # Bash completion for Ruby Version Manager commands, Rubies and gemsets
5
+ #
6
+ # Add the following line to your ~/.profile or ~/.bashrc:
7
+ # complete -C PATH/TO/rvm_completion.rb -o default rvm
8
+ # Don't forget to make the completion script executable with chmod +x!
9
+ #
10
+ # Written by Christoph Olszowka, based upon Project Completion script by Ryan Bates
11
+ # (see http://github.com/ryanb/dotfiles/blob/master/bash/completion_scripts/project_completion)
12
+ #
13
+ class RVMCompletion
14
+ def initialize(comp_line)
15
+ @comp_line = comp_line
16
+ end
17
+
18
+ # Find a match for the current command line input
19
+ def matches
20
+ # Completion for root level rvm commands
21
+ if rvm_command_incomplete?(shell_argument)
22
+ return select(rvm_commands, shell_argument)
23
+ end
24
+
25
+ case shell_argument
26
+ when /^use|uninstall|remove/
27
+ return [] if shell_argument(3).length > 0
28
+ select(rubies, shell_argument(2))
29
+ when /^install/
30
+ select(rvm_ruby_aliases, shell_argument(2))
31
+
32
+ when /^gemset/
33
+ case shell_argument(2)
34
+ when /use|copy|clear|delete|export/
35
+ select(gemsets, shell_argument(3))
36
+ else
37
+ select(gemset_commands, shell_argument(2))
38
+ end
39
+ else
40
+ []
41
+ end
42
+
43
+ end
44
+
45
+ # Retrieves the shell argument at the specified position, defaults to first argument
46
+ def shell_argument(level=1)
47
+ @comp_line.split(' ')[level] || ''
48
+ end
49
+
50
+ # Checks whether the first rvm command is complete
51
+ def rvm_command_incomplete?(cmd)
52
+ not rvm_commands.include?(cmd.strip)
53
+ end
54
+
55
+ # Matches the given (partial?) command against the given collection
56
+ def select(collection, command)
57
+ collection.select do |item|
58
+ item[0, command.length] == command or item =~ /#{command}/
59
+ end.sort
60
+ end
61
+
62
+ # Retrieves the current rvm ruby
63
+ def current_ruby
64
+ @current_ruby ||= `which ruby`.strip.chomp.gsub(ENV['rvm_rubies_path']+'/', '').split('/').first
65
+ end
66
+
67
+ # Retrieves all available rubies
68
+ def rubies
69
+ @rubies ||= Dir[File.join(ENV['rvm_rubies_path'], '*')].map {|r| File.basename(r) } + %w(system)
70
+ end
71
+
72
+ # Retrieves all available gemsets for the current ruby active in rvm
73
+ def gemsets
74
+ @gemsets ||= Dir[File.join(ENV['rvm_gems_path'], "#{current_ruby}#{ENV['rvm_gemset_separator']}*")].map do |r|
75
+ File.basename(r).split(ENV['rvm_gemset_separator']).last
76
+ end
77
+ end
78
+
79
+ def rvm_commands
80
+ %w(usage version use reload implode update reset info debug install uninstall remove wrapper ruby gem rake tests specs monitor gemset gemdir srcdir list fetch package notes)
81
+ end
82
+
83
+ def gemset_commands
84
+ %w(import export create copy empty delete name dir list gemdir install pristine clear use)
85
+ end
86
+
87
+ def rvm_ruby_aliases
88
+ %w(ruby jruby rbx ree macruby maglev ironruby mput)
89
+ end
90
+ end
91
+
92
+ # A simple logger for debugging the completion
93
+ def log(msg)
94
+ File.open(File.dirname(__FILE__) + "/log.txt", "a+") do |f|
95
+ f.puts msg
96
+ end
97
+ end
98
+
99
+ # Debug output
100
+ # File.open(File.dirname(__FILE__) + "/log.txt", "a+") do |f|
101
+ # f.puts
102
+ # f.puts ENV["COMP_LINE"]
103
+ # f.puts RVMCompletion.new(ENV["COMP_LINE"]).shell_argument.inspect
104
+ # f.puts RVMCompletion.new(ENV["COMP_LINE"]).shell_argument(2).inspect
105
+ # f.puts RVMCompletion.new(ENV["COMP_LINE"]).matches.inspect
106
+ # end
107
+
108
+ puts RVMCompletion.new(ENV["COMP_LINE"]).matches
109
+ exit 0
@@ -0,0 +1,61 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{rvm-completion}
8
+ s.version = "0.1.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Christoph Olszowka"]
12
+ s.date = %q{2010-07-20}
13
+ s.default_executable = %q{install-rvm-completion}
14
+ s.description = %q{bash completion for Ruby Version Manager including installed rubies and gemsets for current ruby}
15
+ s.email = %q{christoph at olszowka de}
16
+ s.executables = ["install-rvm-completion"]
17
+ s.extra_rdoc_files = [
18
+ "LICENSE",
19
+ "README.rdoc"
20
+ ]
21
+ s.files = [
22
+ ".document",
23
+ ".gitignore",
24
+ "LICENSE",
25
+ "README.rdoc",
26
+ "Rakefile",
27
+ "VERSION",
28
+ "bin/install-rvm-completion",
29
+ "lib/rvm-completion.rb",
30
+ "rvm-completion.gemspec",
31
+ "test/helper.rb",
32
+ "test/test_rvm-completion.rb"
33
+ ]
34
+ s.homepage = %q{http://github.com/colszowka/rvm-completion}
35
+ s.post_install_message = %q{
36
+ To install rvm completion v0.1.0, please run 'install-rvm-completion' in your terminal now!
37
+
38
+ }
39
+ s.rdoc_options = ["--charset=UTF-8"]
40
+ s.require_paths = ["lib"]
41
+ s.rubygems_version = %q{1.3.7}
42
+ s.summary = %q{bash completion for Ruby Version Manager}
43
+ s.test_files = [
44
+ "test/helper.rb",
45
+ "test/test_rvm-completion.rb"
46
+ ]
47
+
48
+ if s.respond_to? :specification_version then
49
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
50
+ s.specification_version = 3
51
+
52
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
53
+ s.add_development_dependency(%q<shoulda>, [">= 0"])
54
+ else
55
+ s.add_dependency(%q<shoulda>, [">= 0"])
56
+ end
57
+ else
58
+ s.add_dependency(%q<shoulda>, [">= 0"])
59
+ end
60
+ end
61
+
data/test/helper.rb ADDED
@@ -0,0 +1,10 @@
1
+ require 'rubygems'
2
+ require 'test/unit'
3
+ require 'shoulda'
4
+
5
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
6
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
7
+ require 'rvm-completion'
8
+
9
+ class Test::Unit::TestCase
10
+ end
@@ -0,0 +1,7 @@
1
+ require 'helper'
2
+
3
+ class TestRvmCompletion < Test::Unit::TestCase
4
+ should "probably rename this file and start testing for real" do
5
+ flunk "hey buddy, you should probably rename this file and start testing for real"
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,95 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rvm-completion
3
+ version: !ruby/object:Gem::Version
4
+ hash: 27
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 0
10
+ version: 0.1.0
11
+ platform: ruby
12
+ authors:
13
+ - Christoph Olszowka
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-07-20 00:00:00 +02:00
19
+ default_executable: install-rvm-completion
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: shoulda
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 3
30
+ segments:
31
+ - 0
32
+ version: "0"
33
+ type: :development
34
+ version_requirements: *id001
35
+ description: bash completion for Ruby Version Manager including installed rubies and gemsets for current ruby
36
+ email: christoph at olszowka de
37
+ executables:
38
+ - install-rvm-completion
39
+ extensions: []
40
+
41
+ extra_rdoc_files:
42
+ - LICENSE
43
+ - README.rdoc
44
+ files:
45
+ - .document
46
+ - .gitignore
47
+ - LICENSE
48
+ - README.rdoc
49
+ - Rakefile
50
+ - VERSION
51
+ - bin/install-rvm-completion
52
+ - lib/rvm-completion.rb
53
+ - rvm-completion.gemspec
54
+ - test/helper.rb
55
+ - test/test_rvm-completion.rb
56
+ has_rdoc: true
57
+ homepage: http://github.com/colszowka/rvm-completion
58
+ licenses: []
59
+
60
+ post_install_message: |+
61
+
62
+ To install rvm completion v0.1.0, please run 'install-rvm-completion' in your terminal now!
63
+
64
+ rdoc_options:
65
+ - --charset=UTF-8
66
+ require_paths:
67
+ - lib
68
+ required_ruby_version: !ruby/object:Gem::Requirement
69
+ none: false
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ hash: 3
74
+ segments:
75
+ - 0
76
+ version: "0"
77
+ required_rubygems_version: !ruby/object:Gem::Requirement
78
+ none: false
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ hash: 3
83
+ segments:
84
+ - 0
85
+ version: "0"
86
+ requirements: []
87
+
88
+ rubyforge_project:
89
+ rubygems_version: 1.3.7
90
+ signing_key:
91
+ specification_version: 3
92
+ summary: bash completion for Ruby Version Manager
93
+ test_files:
94
+ - test/helper.rb
95
+ - test/test_rvm-completion.rb