rails_complete 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.mkd CHANGED
@@ -13,6 +13,13 @@ line to your `.bashrc`
13
13
  complete -C rails-complete -o default rails
14
14
 
15
15
 
16
+ Contributors
17
+ ------------
18
+
19
+ * Daniel Schierbeck ([dasch](http://github.com/dasch))
20
+ * Joshua Nussbaum ([joshnuss](https://github.com/joshnuss))
21
+
22
+
16
23
  License
17
24
  -------
18
25
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.0
1
+ 0.5.0
data/bin/rails-complete CHANGED
@@ -1,19 +1,39 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- COMMANDS = %w(server generate destroy plugin benchmarker profiler
4
- console dbconsole application runner new)
3
+ COMMANDS = {
4
+ 'server' => %w(-p --port= -b --binding= -c --config -d --daemon -u --debugger -e --environment= -P --pid= -h --help),
5
+ 'generate' => %w(-h --help -p --pretend -f --force -s --skip -q --quiet),
6
+ 'destroy' => %w(-h --help -p --pretend -f --force -s --skip -q --quiet),
7
+ 'plugin' => %w(install remove -r --root= -s --source= -v --verbose -h --help),
8
+ 'benchmarker' => %w(),
9
+ 'profiler' => %w(flat graph graph_html),
10
+ 'console' => %w(-s --sandbox --debugger),
11
+ 'dbconsole' => %w(-p --include-password --mode -h --header),
12
+ 'application' => %w(),
13
+ 'runner' => %w(-e --environment= -h --help),
14
+ 'new' => %w(--skip-prototype -J --skip-test-unit -T --dev -m --template= --skip-git -G --builder= -b --edge --skip-gemfile --database= -d --quiet -q --pretend -p --skip -s --force -f --help -h --version -v),
15
+ '--version' => [],
16
+ '-v' => [],
17
+ '--help' => [],
18
+ '-h' => []
19
+ }
5
20
 
6
- def complete(string)
7
- string = string.chomp
21
+ def complete(parts, ends_with_space)
22
+ if COMMANDS.key?(parts.first)
23
+ ends_with_space ? COMMANDS[parts.first] : find_commands(COMMANDS[parts.first], parts.last)
24
+ else
25
+ find_commands(COMMANDS.keys, parts.first || '')
26
+ end
27
+ end
8
28
 
9
- COMMANDS.select {|cmd| cmd[0, string.length] == string }
29
+ def find_commands(commands, pattern)
30
+ commands.grep /^#{pattern}/
10
31
  end
11
32
 
12
33
  comp_line = ENV["COMP_LINE"]
13
34
  exit -1 if comp_line.nil?
14
35
 
15
- parts = comp_line.scan(/\w+/)
16
-
17
- prefix = parts[1] || ""
36
+ parts = comp_line.split(' ')
37
+ parts.shift
18
38
 
19
- puts complete(prefix)
39
+ puts complete(parts, comp_line.end_with?(' '))
@@ -1,15 +1,15 @@
1
1
  # Generated by jeweler
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{rails_complete}
8
- s.version = "0.4.0"
8
+ s.version = "0.5.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Daniel Schierbeck"]
12
- s.date = %q{2010-09-28}
12
+ s.date = %q{2011-01-14}
13
13
  s.default_executable = %q{rails-complete}
14
14
  s.description = %q{Tab completion for the rails command-line tool.}
15
15
  s.email = %q{daniel.schierbeck@gmail.com}
@@ -18,17 +18,15 @@ Gem::Specification.new do |s|
18
18
  "README.mkd"
19
19
  ]
20
20
  s.files = [
21
- ".gitignore",
22
- "MIT-LICENSE",
23
- "README.mkd",
24
- "Rakefile",
25
- "VERSION",
26
- "bin/rails-complete",
27
- "rails_complete.gemspec",
28
- "test/test_executable.rb"
21
+ "MIT-LICENSE",
22
+ "README.mkd",
23
+ "Rakefile",
24
+ "VERSION",
25
+ "bin/rails-complete",
26
+ "rails_complete.gemspec",
27
+ "test/test_executable.rb"
29
28
  ]
30
29
  s.homepage = %q{http://github.com/dasch/rails-complete}
31
- s.rdoc_options = ["--charset=UTF-8"]
32
30
  s.require_paths = ["lib"]
33
31
  s.rubygems_version = %q{1.3.6}
34
32
  s.summary = %q{Bash completion for the rails command}
@@ -4,18 +4,34 @@ require 'test/unit'
4
4
  BIN_DIR = File.join(File.dirname(__FILE__), '..', 'bin')
5
5
 
6
6
  COMMANDS = %w(server generate destroy plugin benchmarker profiler
7
- new console dbconsole application runner)
7
+ new console dbconsole application runner --help -h --version -v )
8
8
 
9
9
  class TestExecutable < Test::Unit::TestCase
10
10
  def test_should_complete_commands
11
11
  assert_equal %w(server), complete("ser")
12
- assert_equal %w(plugin profiler), complete("p")
12
+ assert_equal %w(plugin profiler), complete("p").sort
13
+ end
14
+
15
+ def test_should_complete_flags
16
+ assert_equal %w(--help --version), complete('--').sort
13
17
  end
14
18
 
15
19
  def test_should_list_commands_when_no_prefix_is_given
16
20
  assert_equal COMMANDS.sort, complete("").sort
17
21
  end
18
22
 
23
+ def test_should_not_list_command_if_prefix_already_given
24
+ assert_equal [], complete('new')
25
+ end
26
+
27
+ def test_should_list_flags_after_command_provided
28
+ assert_not_equal [], complete('new ').sort
29
+ end
30
+
31
+ def test_should_list_flags_after_command_provided_and_part_of_flag_provided
32
+ assert_equal %w(--skip-gemfile --skip-git), complete('new --skip-g').sort
33
+ end
34
+
19
35
  protected
20
36
 
21
37
  def complete(prefix)
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 4
7
+ - 5
8
8
  - 0
9
- version: 0.4.0
9
+ version: 0.5.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Daniel Schierbeck
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-09-28 00:00:00 +02:00
17
+ date: 2011-01-14 00:00:00 +01:00
18
18
  default_executable: rails-complete
19
19
  dependencies: []
20
20
 
@@ -27,7 +27,6 @@ extensions: []
27
27
  extra_rdoc_files:
28
28
  - README.mkd
29
29
  files:
30
- - .gitignore
31
30
  - MIT-LICENSE
32
31
  - README.mkd
33
32
  - Rakefile
@@ -40,8 +39,8 @@ homepage: http://github.com/dasch/rails-complete
40
39
  licenses: []
41
40
 
42
41
  post_install_message:
43
- rdoc_options:
44
- - --charset=UTF-8
42
+ rdoc_options: []
43
+
45
44
  require_paths:
46
45
  - lib
47
46
  required_ruby_version: !ruby/object:Gem::Requirement
data/.gitignore DELETED
@@ -1,2 +0,0 @@
1
- pkg
2
- .yardoc