bond 0.3.3 → 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.rdoc +5 -0
- data/README.rdoc +1 -0
- data/ext/readline_line_buffer/extconf.rb +1 -1
- data/lib/bond.rb +5 -2
- data/lib/bond/completions/bond.rb +1 -1
- data/lib/bond/m.rb +20 -8
- data/lib/bond/readline.rb +16 -3
- data/lib/bond/version.rb +1 -1
- data/test/completion_test.rb +3 -3
- data/test/completions_test.rb +3 -3
- data/test/m_test.rb +34 -0
- metadata +6 -5
data/CHANGELOG.rdoc
CHANGED
data/README.rdoc
CHANGED
@@ -207,6 +207,7 @@ has good instructions for reinstalling ruby with the official Readline.
|
|
207
207
|
* Takao Kouji for {commiting}[http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ext/readline/readline.c?view=diff&r1=24018&r2=24019] this Readline enhancement to ruby 1.9.2.
|
208
208
|
* pd for compatibility with emacs' inf-ruby mode.
|
209
209
|
* timcharper for improving extconf.rb.
|
210
|
+
* headius for jruby support
|
210
211
|
|
211
212
|
== Links
|
212
213
|
* http://tagaholic.me/2010/05/07/screencast-of-argument-autocompletion-for-methods-in-irb.html
|
data/lib/bond.rb
CHANGED
@@ -88,7 +88,8 @@ module Bond
|
|
88
88
|
#
|
89
89
|
# @param [Hash] options Sets global keys in {#config}, some which specify what completions to load.
|
90
90
|
# @option options [Array<String>] :gems Gems which have their completions loaded from
|
91
|
-
# @gem_source/lib/bond/completions/*.rb.
|
91
|
+
# @gem_source/lib/bond/completions/*.rb. If gem is a plugin gem i.e. ripl-plugin, completion will be loaded
|
92
|
+
# from @gem_source/lib/ripl/completions/plugin.rb.
|
92
93
|
# @option options [Array<String>] :yard_gems Gems using yard documentation to generate completions. See {Yard}.
|
93
94
|
# @option options [Module] :readline_plugin (Bond::Readline) Specifies a Bond plugin to interface with a Readline-like
|
94
95
|
# library. Available plugins are Bond::Readline and Bond::Rawline.
|
@@ -102,7 +103,9 @@ module Bond
|
|
102
103
|
# @option options [Boolean] :debug (false) Shows the stacktrace when autocompletion fails and raises exceptions
|
103
104
|
# in Rc.eval.
|
104
105
|
# @option options [Boolean] :eval_debug (false) Raises eval errors occuring when finding a matching completion.
|
105
|
-
# Useful to debug an incorrect completion
|
106
|
+
# Useful to debug an incorrect completion
|
107
|
+
# @option options [Boolean] :bare (false) Doesn't load default ruby completions and completions in
|
108
|
+
# ~/.bond*. Useful for non-ruby completions
|
106
109
|
def start(options={}, &block); M.start(options, &block); end
|
107
110
|
|
108
111
|
# Restarts completions with given options, ensuring to delete current completions.
|
@@ -2,7 +2,7 @@ complete(:methods=>%w{Bond.complete Bond.recomplete}) {
|
|
2
2
|
["on", "method", "methods", "class", "object", "anywhere", "prefix", "search", "action", "place", "name"]
|
3
3
|
}
|
4
4
|
complete(:methods=>['Bond.start', 'Bond.restart']) {
|
5
|
-
|
5
|
+
%w{gems yard_gems readline_plugin default_mission default_search eval_binding debug eval_debug bare}
|
6
6
|
}
|
7
7
|
complete(:method=>'Bond.load_yard_gems') {
|
8
8
|
["verbose", "reload"]
|
data/lib/bond/m.rb
CHANGED
@@ -91,9 +91,15 @@ module Bond
|
|
91
91
|
def load_dir(base_dir)
|
92
92
|
if File.exists?(dir = File.join(base_dir, 'completions'))
|
93
93
|
Dir[dir + '/*.rb'].each {|file| load_file(file) }
|
94
|
+
true
|
94
95
|
end
|
95
96
|
end
|
96
97
|
|
98
|
+
# Loads completions from gems
|
99
|
+
def load_gems(*gems)
|
100
|
+
gems.select {|e| load_gem_completion(e) }
|
101
|
+
end
|
102
|
+
|
97
103
|
# Find a user's home in a cross-platform way
|
98
104
|
def home
|
99
105
|
['HOME', 'USERPROFILE'].each {|e| return ENV[e] if ENV[e] }
|
@@ -105,21 +111,27 @@ module Bond
|
|
105
111
|
|
106
112
|
protected
|
107
113
|
def load_gem_completion(rubygem)
|
108
|
-
(dir = find_gem_file(rubygem, File.join(rubygem, '..', 'bond'))) ?
|
109
|
-
|
114
|
+
(dir = find_gem_file(rubygem, File.join(rubygem, '..', 'bond'))) ? load_dir(dir) :
|
115
|
+
rubygem[/\/|-/] ? load_plugin_file(rubygem) :
|
116
|
+
$stderr.puts("Bond Error: No completions found for gem '#{rubygem}'.")
|
110
117
|
end
|
111
118
|
|
112
|
-
def
|
113
|
-
|
119
|
+
def load_plugin_file(rubygem)
|
120
|
+
namespace, file = rubygem.split(/\/|-/, 2)
|
121
|
+
file += '.rb' unless file[/\.rb$/]
|
122
|
+
if (dir = $:.find {|e| File.exists?(File.join(e, namespace, 'completions', file)) })
|
123
|
+
load_file File.join(dir, namespace, 'completions', file)
|
124
|
+
true
|
125
|
+
end
|
114
126
|
end
|
115
127
|
|
116
128
|
def load_completions
|
117
|
-
load_file File.join(File.dirname(__FILE__), 'completion.rb')
|
118
|
-
load_dir File.dirname(__FILE__)
|
129
|
+
load_file File.join(File.dirname(__FILE__), 'completion.rb') unless config[:bare]
|
130
|
+
load_dir File.dirname(__FILE__) unless config[:bare]
|
119
131
|
load_gems *config[:gems] if config[:gems]
|
120
132
|
Yard.load_yard_gems *config[:yard_gems] if config[:yard_gems]
|
121
|
-
load_file(File.join(home,'.bondrc')) if File.exists?(File.join(home, '.bondrc'))
|
122
|
-
load_dir File.join(home, '.bond')
|
133
|
+
load_file(File.join(home,'.bondrc')) if File.exists?(File.join(home, '.bondrc')) && !config[:bare]
|
134
|
+
load_dir File.join(home, '.bond') unless config[:bare]
|
123
135
|
end
|
124
136
|
end
|
125
137
|
end
|
data/lib/bond/readline.rb
CHANGED
@@ -7,7 +7,9 @@ module Bond
|
|
7
7
|
# Loads the readline-like library and sets the completion_proc to the given agent.
|
8
8
|
def setup(agent)
|
9
9
|
require 'readline'
|
10
|
-
|
10
|
+
unless ::Readline.respond_to?(:line_buffer)
|
11
|
+
RUBY_PLATFORM =~ /java/ ? load_jruby_extension : load_extension
|
12
|
+
end
|
11
13
|
|
12
14
|
# Reinforcing irb defaults
|
13
15
|
::Readline.completion_append_character = nil
|
@@ -21,10 +23,21 @@ module Bond
|
|
21
23
|
end
|
22
24
|
end
|
23
25
|
|
26
|
+
def load_jruby_extension
|
27
|
+
require 'jruby'
|
28
|
+
|
29
|
+
class << Readline
|
30
|
+
ReadlineExt = org.jruby.ext.Readline
|
31
|
+
def line_buffer
|
32
|
+
ReadlineExt.s_get_line_buffer(JRuby.runtime.current_context, JRuby.reference(self))
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
24
37
|
def load_extension
|
25
38
|
require 'readline_line_buffer'
|
26
39
|
rescue LoadError
|
27
|
-
$stderr.puts "Bond Error: Failed to load readline_line_buffer.
|
40
|
+
$stderr.puts "Bond Error: Failed to load readline_line_buffer. Ensure that it exists and was built correctly."
|
28
41
|
end
|
29
42
|
|
30
43
|
# Returns full line of what the user has typed.
|
@@ -32,4 +45,4 @@ module Bond
|
|
32
45
|
::Readline.line_buffer
|
33
46
|
end
|
34
47
|
end
|
35
|
-
end
|
48
|
+
end
|
data/lib/bond/version.rb
CHANGED
data/test/completion_test.rb
CHANGED
@@ -14,8 +14,8 @@ describe "Completion" do
|
|
14
14
|
end
|
15
15
|
|
16
16
|
it "completes absolute constants anywhere" do
|
17
|
-
tab("blah ::
|
18
|
-
tab("h[::
|
17
|
+
tab("blah ::Has").should == ["::Hash"]
|
18
|
+
tab("h[::Has").should == ["h[::Hash"]
|
19
19
|
end
|
20
20
|
|
21
21
|
it "completes invalid constants safely" do
|
@@ -145,4 +145,4 @@ describe "Completion" do
|
|
145
145
|
behaves_like "objects"
|
146
146
|
end
|
147
147
|
end
|
148
|
-
end
|
148
|
+
end
|
data/test/completions_test.rb
CHANGED
@@ -43,9 +43,9 @@ describe "completions for" do
|
|
43
43
|
|
44
44
|
describe "Object" do
|
45
45
|
it "#instance_of?" do
|
46
|
-
expectations = ['
|
47
|
-
expectations = ["
|
48
|
-
tab("[].instance_of?
|
46
|
+
expectations = ['Hash']
|
47
|
+
expectations = ["Hash", "Hash::"] if Config::CONFIG["RUBY_SO_NAME"].to_s[/rubinius/i]
|
48
|
+
tab("[].instance_of? Has").should == expectations
|
49
49
|
end
|
50
50
|
|
51
51
|
it "#is_a?" do
|
data/test/m_test.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'test_helper')
|
2
|
+
|
3
|
+
describe "M" do
|
4
|
+
describe "#load_gems" do
|
5
|
+
before { $: << '/dir' }
|
6
|
+
after { $:.pop }
|
7
|
+
|
8
|
+
def mock_file_exists(file)
|
9
|
+
File.expects(:exists?).at_least(1).returns(false).with {|e| e != file }
|
10
|
+
File.expects(:exists?).times(1).returns(true).with {|e| e == file }
|
11
|
+
end
|
12
|
+
|
13
|
+
it "loads gem" do
|
14
|
+
M.expects(:gem)
|
15
|
+
mock_file_exists '/dir/boom/../bond'
|
16
|
+
M.expects(:load_dir).with('/dir/boom/../bond').returns(true)
|
17
|
+
Bond.load_gems('boom').should == ['boom']
|
18
|
+
end
|
19
|
+
|
20
|
+
it "loads plugin gem in gem format" do
|
21
|
+
M.expects(:find_gem_file).returns(false)
|
22
|
+
mock_file_exists '/dir/boom/completions/what.rb'
|
23
|
+
M.expects(:load_file).with('/dir/boom/completions/what.rb')
|
24
|
+
Bond.load_gems('boom-what').should == ['boom-what']
|
25
|
+
end
|
26
|
+
|
27
|
+
it "loads plugin gem in file format" do
|
28
|
+
M.expects(:find_gem_file).returns(false)
|
29
|
+
mock_file_exists '/dir/boom/completions/what.rb'
|
30
|
+
M.expects(:load_file).with('/dir/boom/completions/what.rb')
|
31
|
+
Bond.load_gems('boom/what.rb').should == ['boom/what.rb']
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bond
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 0.3.
|
9
|
+
- 4
|
10
|
+
version: 0.3.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Gabriel Horner
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-
|
18
|
+
date: 2010-12-23 00:00:00 -05:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -118,6 +118,7 @@ files:
|
|
118
118
|
- test/bond_test.rb
|
119
119
|
- test/completion_test.rb
|
120
120
|
- test/completions_test.rb
|
121
|
+
- test/m_test.rb
|
121
122
|
- test/method_mission_test.rb
|
122
123
|
- test/mission_test.rb
|
123
124
|
- test/object_mission_test.rb
|
@@ -140,7 +141,7 @@ licenses:
|
|
140
141
|
post_install_message:
|
141
142
|
rdoc_options:
|
142
143
|
- --title
|
143
|
-
- Bond 0.3.
|
144
|
+
- Bond 0.3.4 Documentation
|
144
145
|
require_paths:
|
145
146
|
- lib
|
146
147
|
required_ruby_version: !ruby/object:Gem::Requirement
|