bond 0.2.2 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gemspec +2 -3
- data/CHANGELOG.rdoc +7 -0
- data/lib/bond.rb +4 -3
- data/lib/bond/completion.rb +2 -2
- data/lib/bond/mission.rb +4 -7
- data/lib/bond/missions/default_mission.rb +9 -7
- data/lib/bond/version.rb +1 -1
- data/test/agent_test.rb +2 -2
- data/test/bond_test.rb +8 -1
- data/test/completions_test.rb +5 -3
- data/test/test_helper.rb +1 -0
- data/test/yard_test.rb +4 -1
- metadata +8 -8
data/.gemspec
CHANGED
@@ -9,7 +9,7 @@ Gem::Specification.new do |s|
|
|
9
9
|
s.email = "gabriel.horner@gmail.com"
|
10
10
|
s.homepage = "http://tagaholic.me/bond/"
|
11
11
|
s.summary = "Mission: Easy custom autocompletion for arguments, methods and beyond. Accomplished for irb and any other readline-like console environments."
|
12
|
-
s.description = "Bond is on a mission to improve irb
|
12
|
+
s.description = "Bond is on a mission to improve irb's autocompletion. Aside from doing everything irb's can do and fixing its quirks, Bond can autocomplete argument(s) to methods, uniquely completing per module, per method and per argument. Bond brings irb's completion closer to bash/zsh as it provides a configuration system and a DSL for creating custom completions and completion rules. With this configuration system, users can customize their irb autocompletions and share it with others. Bond can also generate completions from yard documentation and load completions that ship with gems. Bond is able to offer more than irb's completion since it uses a Readline C extension to get the full line of input when completing as opposed to irb's last-word approach."
|
13
13
|
s.required_rubygems_version = ">= 1.3.6"
|
14
14
|
s.rubyforge_project = 'tagaholic'
|
15
15
|
s.has_rdoc = 'yard'
|
@@ -18,8 +18,7 @@ Gem::Specification.new do |s|
|
|
18
18
|
s.add_development_dependency 'mocha', '>= 0.9.8'
|
19
19
|
s.add_development_dependency 'mocha-on-bacon'
|
20
20
|
s.add_development_dependency 'bacon-bits'
|
21
|
-
s.files = Dir.glob(%w[{lib,test}/**/*.rb bin/* [A-Z]*.{txt,rdoc} ext/**/*.{rb,c}]) + %w{Rakefile .gemspec}
|
22
|
-
s.files += Dir.glob('**/*.rip')
|
21
|
+
s.files = Dir.glob(%w[{lib,test}/**/*.rb bin/* [A-Z]*.{txt,rdoc} ext/**/*.{rb,c} **/deps.rip]) + %w{Rakefile .gemspec}
|
23
22
|
s.extra_rdoc_files = ["README.rdoc", "LICENSE.txt"]
|
24
23
|
s.extensions = ["ext/readline_line_buffer/extconf.rb"]
|
25
24
|
s.license = 'MIT'
|
data/CHANGELOG.rdoc
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
== 0.3.0
|
2
|
+
* Fixes for tests to pass in rubinius and 1.9.2.
|
3
|
+
* Add support for a proc :eval_binding.
|
4
|
+
* Add instance variables to default completion.
|
5
|
+
* Add DefaultMission.completions to make default completions reusable
|
6
|
+
* Remove unused Mission#eval_binding.
|
7
|
+
|
1
8
|
== 0.2.2
|
2
9
|
* Moved documentation to yard.
|
3
10
|
* Better extconf.rb thanks to @timcharper
|
data/lib/bond.rb
CHANGED
@@ -96,8 +96,9 @@ module Bond
|
|
96
96
|
# See {Agent#default_mission}.
|
97
97
|
# @option options [Symbol] :default_search (:underscore) Name of a *_search method in Rc to use as the default
|
98
98
|
# search in completions. See {#complete}'s :search option for valid values.
|
99
|
-
# @option options [Binding] :eval_binding (TOPLEVEL_BINDING) Binding to use when evaluating objects in
|
100
|
-
# ObjectMission and MethodMission. When in irb, defaults to irb's current binding.
|
99
|
+
# @option options [Binding, Proc] :eval_binding (TOPLEVEL_BINDING) Binding to use when evaluating objects in
|
100
|
+
# ObjectMission and MethodMission. When in irb, defaults to irb's current binding. When proc,
|
101
|
+
# binding is evaluated each time by calling proc.
|
101
102
|
# @option options [Boolean] :debug (false) Shows the stacktrace when autocompletion fails and raises exceptions
|
102
103
|
# in Rc.eval.
|
103
104
|
# @option options [Boolean] :eval_debug (false) Raises eval errors occuring when finding a matching completion.
|
@@ -118,4 +119,4 @@ module Bond
|
|
118
119
|
|
119
120
|
# Lists all methods that have argument completion.
|
120
121
|
def list_methods; MethodMission.all_methods; end
|
121
|
-
end
|
122
|
+
end
|
data/lib/bond/completion.rb
CHANGED
@@ -7,10 +7,10 @@ complete :all_operator_methods=>true
|
|
7
7
|
complete(:name=>:constants, :anywhere=>'([A-Z][^. \(]*)::([^: .]*)') {|e|
|
8
8
|
receiver = e.matched[2]
|
9
9
|
candidates = eval("#{receiver}.constants | #{receiver}.methods") || []
|
10
|
-
normal_search(e.matched[3], candidates).map {|e| receiver
|
10
|
+
normal_search(e.matched[3], candidates).map {|e| "#{receiver}::#{e}" }
|
11
11
|
}
|
12
12
|
# absolute constants
|
13
13
|
complete(:prefix=>'::', :anywhere=>'[A-Z][^:\.\(]*') {|e| Object.constants }
|
14
14
|
complete(:anywhere=>':[^:\s.]*') {|e| Symbol.all_symbols.map {|f| ":#{f}" } rescue [] }
|
15
15
|
complete(:anywhere=>'\$[^\s.]*') {|e| global_variables }
|
16
|
-
complete(:name=>:quoted_files, :on=>/[\s(]["']([^'"]*)$/, :search=>false, :place=>:last) {|e| files(e.matched[1]) }
|
16
|
+
complete(:name=>:quoted_files, :on=>/[\s(]["']([^'"]*)$/, :search=>false, :place=>:last) {|e| files(e.matched[1]) }
|
data/lib/bond/mission.rb
CHANGED
@@ -26,7 +26,8 @@ module Bond
|
|
26
26
|
end
|
27
27
|
|
28
28
|
# Calls eval with either the irb's current workspace binding or TOPLEVEL_BINDING.
|
29
|
-
def current_eval(string, ebinding=eval_binding)
|
29
|
+
def current_eval(string, ebinding=Mission.eval_binding)
|
30
|
+
ebinding = ebinding.call if ebinding.is_a?(Proc)
|
30
31
|
eval(string, ebinding)
|
31
32
|
end
|
32
33
|
|
@@ -62,7 +63,7 @@ module Bond
|
|
62
63
|
|
63
64
|
# Returns a boolean indicating if a mission matches the given Input and should be executed for completion.
|
64
65
|
def matches?(input)
|
65
|
-
@matched = @input = @completion_prefix =
|
66
|
+
@matched = @input = @completion_prefix = nil
|
66
67
|
(match = do_match(input)) && after_match(@line = input)
|
67
68
|
!!match
|
68
69
|
end
|
@@ -132,17 +133,13 @@ module Bond
|
|
132
133
|
end
|
133
134
|
|
134
135
|
def eval_object(obj)
|
135
|
-
@evaled_object = self.class.current_eval(obj
|
136
|
+
@evaled_object = self.class.current_eval(obj)
|
136
137
|
true
|
137
138
|
rescue Exception
|
138
139
|
raise FailedMissionError.new(self), "Match failed during eval of '#{obj}'." if Bond.config[:eval_debug]
|
139
140
|
false
|
140
141
|
end
|
141
142
|
|
142
|
-
def eval_binding
|
143
|
-
@eval_binding ||= self.class.eval_binding
|
144
|
-
end
|
145
|
-
|
146
143
|
def unique_id
|
147
144
|
@on.inspect
|
148
145
|
end
|
@@ -6,14 +6,16 @@ class Bond::DefaultMission < Bond::Mission
|
|
6
6
|
"then", "true", "undef", "unless", "until", "when", "while", "yield"
|
7
7
|
]
|
8
8
|
|
9
|
+
|
10
|
+
# Default action which generates methods, private methods, reserved words, local variables and constants.
|
11
|
+
def self.completions(input=nil)
|
12
|
+
Bond::Mission.current_eval("methods | private_methods | local_variables | " +
|
13
|
+
"self.class.constants | instance_variables") | ReservedWords
|
14
|
+
end
|
15
|
+
|
9
16
|
def initialize(options={}) #@private
|
10
|
-
options[:action] ||= method(:
|
17
|
+
options[:action] ||= self.class.method(:completions)
|
11
18
|
super
|
12
19
|
end
|
13
20
|
def default_on; end #@private
|
14
|
-
|
15
|
-
# Default action which generates methods, private methods, reserved words, local variables and constants.
|
16
|
-
def default(input)
|
17
|
-
Bond::Mission.current_eval("methods | private_methods | local_variables | self.class.constants") | ReservedWords
|
18
|
-
end
|
19
|
-
end
|
21
|
+
end
|
data/lib/bond/version.rb
CHANGED
data/test/agent_test.rb
CHANGED
@@ -61,7 +61,7 @@ describe "Agent" do
|
|
61
61
|
|
62
62
|
it 'for completion action failing with Rc.eval and debug completes error' do
|
63
63
|
complete(:on=>/blah/) { Rc.eval('{[}') || [] }
|
64
|
-
tab('blah').should complete_error(/Bond Error: Failed.*action.*(
|
64
|
+
tab('blah').should complete_error(/Bond Error: Failed.*action.*(syntax|expect)/m)
|
65
65
|
end
|
66
66
|
|
67
67
|
it "for completion action raising SyntaxError in eval completes error" do
|
@@ -231,4 +231,4 @@ describe "Agent" do
|
|
231
231
|
capture_stdout { Bond.spy('blah')}.should =~ /Doesn't match/
|
232
232
|
end
|
233
233
|
end
|
234
|
-
end
|
234
|
+
end
|
data/test/bond_test.rb
CHANGED
@@ -35,6 +35,13 @@ describe "Bond" do
|
|
35
35
|
tab('blah all').should == ["all_quiet"]
|
36
36
|
end
|
37
37
|
|
38
|
+
it "sets proc eval_binding" do
|
39
|
+
bdg = binding
|
40
|
+
start :eval_binding => lambda { bdg }
|
41
|
+
Mission.expects(:eval).with(anything, bdg).returns([])
|
42
|
+
tab("'blah'.").should == []
|
43
|
+
end
|
44
|
+
|
38
45
|
after_all { M.debrief :readline_plugin=>valid_readline_plugin; M.reset }
|
39
46
|
end
|
40
47
|
|
@@ -95,4 +102,4 @@ describe "Bond" do
|
|
95
102
|
M.reset
|
96
103
|
Bond.agent.missions.size.should == 0
|
97
104
|
end
|
98
|
-
end
|
105
|
+
end
|
data/test/completions_test.rb
CHANGED
@@ -43,7 +43,9 @@ describe "completions for" do
|
|
43
43
|
|
44
44
|
describe "Object" do
|
45
45
|
it "#instance_of?" do
|
46
|
-
|
46
|
+
expectations = ['Array']
|
47
|
+
expectations = ["Array", "Array::"] if Config::CONFIG["RUBY_SO_NAME"].to_s[/rubinius/i]
|
48
|
+
tab("[].instance_of? Arr").should == expectations
|
47
49
|
end
|
48
50
|
|
49
51
|
it "#is_a?" do
|
@@ -51,7 +53,7 @@ describe "completions for" do
|
|
51
53
|
end
|
52
54
|
|
53
55
|
it "#send" do
|
54
|
-
tab("Object.send :
|
56
|
+
tab("Object.send :ne").should == [':new']
|
55
57
|
end
|
56
58
|
|
57
59
|
it "#send and additional arguments" do
|
@@ -93,4 +95,4 @@ describe "completions for" do
|
|
93
95
|
tab("Object > Bon").should == %w{Bond Bond::}
|
94
96
|
end
|
95
97
|
end
|
96
|
-
end
|
98
|
+
end
|
data/test/test_helper.rb
CHANGED
data/test/yard_test.rb
CHANGED
@@ -75,6 +75,8 @@ describe 'Bond.load_yard_gems' do
|
|
75
75
|
M.expects(:load_file)
|
76
76
|
}
|
77
77
|
|
78
|
+
# rubinius implements Kernel#require with File.exists? which is different than MRI
|
79
|
+
unless Config::CONFIG["RUBY_SO_NAME"].to_s[/rubinius/i]
|
78
80
|
it "with :reload option" do
|
79
81
|
File.expects(:exists?).returns(true)
|
80
82
|
Yard.expects(:create_completion_file)
|
@@ -86,6 +88,7 @@ describe 'Bond.load_yard_gems' do
|
|
86
88
|
Yard.expects(:create_completion_file)
|
87
89
|
load_yard_gems
|
88
90
|
end
|
91
|
+
end
|
89
92
|
|
90
93
|
describe 'which has' do
|
91
94
|
before { YARD::Registry.expects(:load!) }
|
@@ -111,4 +114,4 @@ describe 'Bond.load_yard_gems' do
|
|
111
114
|
end
|
112
115
|
end
|
113
116
|
end
|
114
|
-
end
|
117
|
+
end
|
metadata
CHANGED
@@ -5,9 +5,9 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
8
|
+
- 3
|
9
|
+
- 0
|
10
|
+
version: 0.3.0
|
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-09-27 00:00:00 -04:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -78,7 +78,7 @@ dependencies:
|
|
78
78
|
version: "0"
|
79
79
|
type: :development
|
80
80
|
version_requirements: *id004
|
81
|
-
description:
|
81
|
+
description: Bond is on a mission to improve irb's autocompletion. Aside from doing everything irb's can do and fixing its quirks, Bond can autocomplete argument(s) to methods, uniquely completing per module, per method and per argument. Bond brings irb's completion closer to bash/zsh as it provides a configuration system and a DSL for creating custom completions and completion rules. With this configuration system, users can customize their irb autocompletions and share it with others. Bond can also generate completions from yard documentation and load completions that ship with gems. Bond is able to offer more than irb's completion since it uses a Readline C extension to get the full line of input when completing as opposed to irb's last-word approach.
|
82
82
|
email: gabriel.horner@gmail.com
|
83
83
|
executables: []
|
84
84
|
|
@@ -130,17 +130,17 @@ files:
|
|
130
130
|
- README.rdoc
|
131
131
|
- ext/readline_line_buffer/extconf.rb
|
132
132
|
- ext/readline_line_buffer/readline_line_buffer.c
|
133
|
+
- test/deps.rip
|
133
134
|
- Rakefile
|
134
135
|
- .gemspec
|
135
|
-
|
136
|
-
has_rdoc: yard
|
136
|
+
has_rdoc: true
|
137
137
|
homepage: http://tagaholic.me/bond/
|
138
138
|
licenses:
|
139
139
|
- MIT
|
140
140
|
post_install_message:
|
141
141
|
rdoc_options:
|
142
142
|
- --title
|
143
|
-
- Bond 0.
|
143
|
+
- Bond 0.3.0 Documentation
|
144
144
|
require_paths:
|
145
145
|
- lib
|
146
146
|
required_ruby_version: !ruby/object:Gem::Requirement
|