bond 0.3.4 → 0.3.5

Sign up to get free protection for your applications and to get access to all the features.
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'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."
12
+ s.description = "Bond is on a mission to improve autocompletion in ruby, especially for ripl/irb. 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 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'
@@ -1,3 +1,6 @@
1
+ == 0.3.5
2
+ * Move yard-related functionality to bond-yard gem
3
+
1
4
  == 0.3.4
2
5
  * Add gem plugin completion
3
6
  * Add jruby support thanks to @headius
@@ -2,13 +2,14 @@ Note: To read a linked version of this README, {click here}[http://tagaholic.me/
2
2
 
3
3
  == Description
4
4
 
5
- Bond is on a mission to improve irb's autocompletion. Aside from doing everything irb's can do and fixing its quirks,
6
- Bond can autocomplete argument(s) to methods, uniquely completing per module, per method and per argument. Bond brings
7
- irb's completion closer to bash/zsh as it provides a configuration system and a DSL for creating custom completions
8
- and completion rules. With this configuration system, users can customize their irb autocompletions and share
9
- it with others. Bond can also generate completions from yard documentation and load completions that ship with gems.
10
- Bond is able to offer more than irb's completion since it uses a Readline C extension to get the full
11
- line of input when completing as opposed to irb's last-word approach.
5
+ Bond is on a mission to improve autocompletion in ruby, especially for ripl/irb. Aside from doing
6
+ everything irb's can do and fixing its quirks, Bond can autocomplete argument(s) to methods,
7
+ uniquely completing per module, per method and per argument. Bond brings irb's completion closer to
8
+ bash/zsh as it provides a configuration system and a DSL for creating custom completions and
9
+ completion rules. With this configuration system, users can customize their irb autocompletions and
10
+ share it with others. Bond can also load completions that ship with gems. Bond is able to offer
11
+ more than irb's completion since it uses a Readline C extension to get the full line of input when
12
+ completing as opposed to irb's last-word approach.
12
13
 
13
14
  == Install
14
15
 
@@ -23,6 +24,8 @@ To start off, replace irb's completion (require 'irb/completion') with Bond's en
23
24
  require 'bond'
24
25
  Bond.start
25
26
 
27
+ If you're using {ripl}[http://github.com/cldwalker/ripl], bond is used by default.
28
+
26
29
  This gives you more consistent method completion on any object, customizable completions
27
30
  and argument completion of some 80+ methods including Hash#[], Kernel#system, Kernel#require and some Rails methods.
28
31
 
@@ -30,7 +33,7 @@ and argument completion of some 80+ methods including Hash#[], Kernel#system, Ke
30
33
 
31
34
  By default, Bond autocompletes arguments for a number of core methods:
32
35
 
33
- $ irb
36
+ $ ripl
34
37
  # require completes gems and anything in $LOAD_PATH
35
38
  >> require 'rb[TAB]
36
39
  rbconfig.rb rbconfig/
@@ -151,6 +154,7 @@ There are a number of incorrect completions irb gives for object methods. Bond f
151
154
 
152
155
  Irb completes anything surrounded with '{}' the same:
153
156
 
157
+ $ irb
154
158
  >> proc {}.c[TAB]
155
159
  }.call }.class }.clear }.clone }.collect
156
160
  >> %w{ab bc}.c[TAB]
@@ -216,7 +220,6 @@ has good instructions for reinstalling ruby with the official Readline.
216
220
  * http://tagaholic.me/2009/07/23/mini-irb-and-mini-script-console.html
217
221
 
218
222
  == Todo
219
- * Generate method autocompletions for any arguments based on yardoc documentation.
220
223
  * Make completion actions more synonymous with argument types.
221
224
  * Cache expensive completion actions.
222
225
  * Ensure completions work when there is additional, unrelated text to the right of a completion.
@@ -12,7 +12,6 @@ require 'bond/missions/method_mission'
12
12
  require 'bond/missions/object_mission'
13
13
  require 'bond/missions/anywhere_mission'
14
14
  require 'bond/missions/operator_method_mission'
15
- require 'bond/yard'
16
15
 
17
16
  module Bond
18
17
  extend self
@@ -77,7 +76,7 @@ module Bond
77
76
 
78
77
  # Starts Bond with a default set of completions that replace and improve irb's completion. Loads completions
79
78
  # in this order: lib/bond/completion.rb, lib/bond/completions/*.rb and the following optional completions:
80
- # completions from :gems, completions from :yard_gems, ~/.bondrc, ~/.bond/completions/*.rb and from block. See
79
+ # completions from :gems, ~/.bondrc, ~/.bond/completions/*.rb and from block. See
81
80
  # {Rc} for the DSL to use in completion files and in the block.
82
81
  #
83
82
  # ==== Examples:
@@ -90,7 +89,6 @@ module Bond
90
89
  # @option options [Array<String>] :gems Gems which have their completions loaded from
91
90
  # @gem_source/lib/bond/completions/*.rb. If gem is a plugin gem i.e. ripl-plugin, completion will be loaded
92
91
  # from @gem_source/lib/ripl/completions/plugin.rb.
93
- # @option options [Array<String>] :yard_gems Gems using yard documentation to generate completions. See {Yard}.
94
92
  # @option options [Module] :readline_plugin (Bond::Readline) Specifies a Bond plugin to interface with a Readline-like
95
93
  # library. Available plugins are Bond::Readline and Bond::Rawline.
96
94
  # @option options [Proc] :default_mission (DefaultMission) Sets default completion to use when no missions match.
@@ -118,12 +116,6 @@ module Bond
118
116
  # Loads completions for gems that ship with them under lib/bond/completions/, relative to the gem's base directory.
119
117
  def load_gems(*gems); M.load_gems(*gems); end
120
118
 
121
- # Generates and loads completions for yardoc documented gems.
122
- # @param *gems Gem(s) with optional options hash at the end
123
- # @option *gems :verbose[Boolean] (false) Displays additional information when building yardoc.
124
- # @option *gems :reload[Boolean] (false) Rebuilds yard databases. Use when gems have changed versions.
125
- def load_yard_gems(*gems); Yard.load_yard_gems(*gems); end
126
-
127
119
  # An Agent who saves all Bond.complete missions and executes the correct one when a completion is called.
128
120
  def agent; M.agent; end
129
121
 
@@ -2,8 +2,5 @@ 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
- %w{gems yard_gems readline_plugin default_mission default_search eval_binding debug eval_debug bare}
6
- }
7
- complete(:method=>'Bond.load_yard_gems') {
8
- ["verbose", "reload"]
5
+ %w{gems readline_plugin default_mission default_search eval_binding debug eval_debug bare}
9
6
  }
@@ -129,7 +129,6 @@ module Bond
129
129
  load_file File.join(File.dirname(__FILE__), 'completion.rb') unless config[:bare]
130
130
  load_dir File.dirname(__FILE__) unless config[:bare]
131
131
  load_gems *config[:gems] if config[:gems]
132
- Yard.load_yard_gems *config[:yard_gems] if config[:yard_gems]
133
132
  load_file(File.join(home,'.bondrc')) if File.exists?(File.join(home, '.bondrc')) && !config[:bare]
134
133
  load_dir File.join(home, '.bond') unless config[:bare]
135
134
  end
@@ -1,3 +1,3 @@
1
1
  module Bond
2
- VERSION = '0.3.4'
2
+ VERSION = '0.3.5'
3
3
  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: 27
4
+ hash: 25
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 4
10
- version: 0.3.4
9
+ - 5
10
+ version: 0.3.5
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-12-23 00:00:00 -05:00
18
+ date: 2011-01-07 00:00:00 -05: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: 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.
81
+ description: Bond is on a mission to improve autocompletion in ruby, especially for ripl/irb. 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 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
 
@@ -111,7 +111,6 @@ files:
111
111
  - lib/bond/readline.rb
112
112
  - lib/bond/search.rb
113
113
  - lib/bond/version.rb
114
- - lib/bond/yard.rb
115
114
  - lib/bond.rb
116
115
  - test/agent_test.rb
117
116
  - test/anywhere_mission_test.rb
@@ -125,7 +124,6 @@ files:
125
124
  - test/operator_method_mission_test.rb
126
125
  - test/search_test.rb
127
126
  - test/test_helper.rb
128
- - test/yard_test.rb
129
127
  - LICENSE.txt
130
128
  - CHANGELOG.rdoc
131
129
  - README.rdoc
@@ -134,14 +132,14 @@ files:
134
132
  - test/deps.rip
135
133
  - Rakefile
136
134
  - .gemspec
137
- has_rdoc: true
135
+ has_rdoc: yard
138
136
  homepage: http://tagaholic.me/bond/
139
137
  licenses:
140
138
  - MIT
141
139
  post_install_message:
142
140
  rdoc_options:
143
141
  - --title
144
- - Bond 0.3.4 Documentation
142
+ - Bond 0.3.5 Documentation
145
143
  require_paths:
146
144
  - lib
147
145
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -1,73 +0,0 @@
1
- module Bond
2
- # Generates method autocompletions for gems that use {yard}[http://yardoc.org] documentation. Currently
3
- # generates completions for methods that take a hash of options and have been documented with @option.
4
- module Yard
5
- extend self
6
-
7
- # Loads completions for yard gem(s)
8
- def load_yard_gems(*gems)
9
- @options = gems[-1].is_a?(Hash) ? gems.pop : {}
10
- require 'yard'
11
- raise LoadError unless YARD::VERSION >= '0.5.2'
12
- gems.select {|e| load_yard_gem(e) }
13
- rescue LoadError
14
- $stderr.puts "Bond Error: yard gem (version >= 0.5.2) not installed "
15
- end
16
-
17
- protected
18
- def load_yard_gem(rubygem)
19
- raise("Unable to find gem.") unless (yardoc = find_yardoc(rubygem))
20
- completion_file = File.join(dir('yard_completions'), rubygem+'.rb')
21
- create_completion_file(yardoc, completion_file) if !File.exists?(completion_file) || @options[:reload]
22
- M.load_file completion_file
23
- rescue
24
- $stderr.puts "Bond Error: Didn't load yard completions for gem '#{rubygem}'. #{$!.message}"
25
- end
26
-
27
- def create_completion_file(yardoc, completion_file)
28
- YARD::Registry.load!(yardoc)
29
- methods_hash = find_methods_with_options
30
- body = generate_method_completions(methods_hash)
31
- File.open(completion_file, 'w') {|e| e.write body }
32
- end
33
-
34
- def find_yardoc(rubygem)
35
- (file = YARD::Registry.yardoc_file_for_gem(rubygem) rescue nil) and return(file)
36
- if (file = M.find_gem_file(rubygem, rubygem+'.rb'))
37
- output_dir = File.join(dir('.yardocs'), rubygem)
38
- cmd = ['yardoc', '-n', '-b', output_dir]
39
- cmd << '-q' unless @options[:verbose]
40
- cmd += ['-c', output_dir] unless @options[:reload]
41
- cmd += [file, File.expand_path(file+'/..')+"/#{rubygem}/**/*.rb"]
42
- puts "Bond: "+cmd.join(' ') if @options[:verbose]
43
- puts "Bond: Building/loading #{rubygem}'s .yardoc database ..."
44
- system *cmd
45
- output_dir
46
- end
47
- end
48
-
49
- def dir(subdir)
50
- (@dirs ||= {})[subdir] ||= begin
51
- require 'fileutils'
52
- FileUtils.mkdir_p File.join(M.home, '.bond', subdir)
53
- File.join(M.home, '.bond', subdir)
54
- end
55
- end
56
-
57
- def find_methods_with_options
58
- YARD::Registry.all(:method).inject({}) {|a,m|
59
- opts = m.tags.select {|e| e.is_a?(YARD::Tags::OptionTag) }.map {|e| e.pair.name }
60
- a[m.path] = opts if !opts.empty? && m.path
61
- a
62
- }
63
- end
64
-
65
- def generate_method_completions(methods_hash)
66
- methods_hash.map do |meth, options|
67
- options.map! {|e| e.sub(/^:/, '') }
68
- meth = meth.sub(/#initialize$/, '.new')
69
- %Q[complete(:method=>'#{meth}') {\n #{options.inspect}\n}]
70
- end.join("\n")
71
- end
72
- end
73
- end
@@ -1,117 +0,0 @@
1
- require File.join(File.dirname(__FILE__), 'test_helper')
2
-
3
- module YARD; VERSION = '0.5.2'; module Registry; end; end
4
-
5
- describe 'Bond.load_yard_gems' do
6
- def load_yard_gems(*args)
7
- args = ['blah'] if args.empty?
8
- Bond.load_yard_gems(*args)
9
- end
10
-
11
- it 'prints error if unable to require yard' do
12
- Yard.expects(:require).with('yard').raises(LoadError)
13
- capture_stderr { load_yard_gems }.should =~ /yard.*not installed/
14
- end
15
-
16
- it 'prints error if old version of yard' do
17
- YARD.send :remove_const, :VERSION
18
- YARD::VERSION = '0.5.0'
19
- Yard.expects(:require).with('yard')
20
- capture_stderr { load_yard_gems }.should =~ /yard.*not installed/
21
- YARD.send :remove_const, :VERSION
22
- YARD::VERSION = '0.5.2'
23
- end
24
-
25
- it 'prints error if no yardoc found' do
26
- Yard.expects(:require).with('yard')
27
- Yard.expects(:find_yardoc).returns(nil)
28
- capture_stderr { load_yard_gems('bond') }.should =~ /Didn't.*'bond'.* Unable to find/
29
- end
30
-
31
- describe 'loads yardoc found by' do
32
- before {
33
- Yard.expects(:require).at_least(1).with { require 'fileutils'; true }
34
- Yard.expects(:create_completion_file)
35
- M.expects(:load_file)
36
- }
37
-
38
- it 'registry' do
39
- YARD::Registry.expects(:yardoc_file_for_gem).returns('/dir/.yardoc')
40
- load_yard_gems
41
- end
42
-
43
- describe 'find_gem_file and' do
44
- before {
45
- YARD::Registry.expects(:yardoc_file_for_gem).returns(nil)
46
- M.expects(:find_gem_file).returns('/dir/blah.rb')
47
- }
48
-
49
- it 'prints building message' do
50
- Yard.expects(:system)
51
- capture_stdout { load_yard_gems('bond') }.should =~ /Building.*bond's/
52
- end
53
-
54
- it "caches yardoc by default" do
55
- Yard.expects(:system).with {|*args| args.include?('-c') }
56
- capture_stdout { load_yard_gems }
57
- end
58
-
59
- it "doesn't cache yardoc with :reload option" do
60
- Yard.expects(:system).with {|*args| !args.include?('-c') }
61
- capture_stdout { load_yard_gems('blah', :reload=>true) }
62
- end
63
-
64
- it "prints multiple messages with :verbose option" do
65
- Yard.expects(:system).with {|*args| !args.include?('-q') }
66
- capture_stdout { load_yard_gems('blah', :verbose=>true) }.should =~ /yardoc -n/
67
- end
68
- end
69
- end
70
-
71
- describe 'creates completion file' do
72
- before {
73
- Yard.expects(:require).at_least(1).with { require 'fileutils'; true }
74
- Yard.expects(:find_yardoc).returns('/dir/.yardoc')
75
- M.expects(:load_file)
76
- }
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]
80
- it "with :reload option" do
81
- File.expects(:exists?).returns(true)
82
- Yard.expects(:create_completion_file)
83
- load_yard_gems 'blah', :reload=>true
84
- end
85
-
86
- it "with new completion file" do
87
- File.expects(:exists?).returns(false)
88
- Yard.expects(:create_completion_file)
89
- load_yard_gems
90
- end
91
- end
92
-
93
- describe 'which has' do
94
- before { YARD::Registry.expects(:load!) }
95
-
96
- it 'methods' do
97
- Yard.expects(:find_methods_with_options).returns({"Bond::M.start"=>[':one', 'two']})
98
- expected_body = %[complete(:method=>'Bond::M.start') {\n ["one", "two"]\n}]
99
- File.expects(:open).yields mock('block') { expects(:write).with(expected_body) }
100
- load_yard_gems
101
- end
102
-
103
- it 'no methods' do
104
- Yard.expects(:find_methods_with_options).returns({})
105
- File.expects(:open).yields mock('block') { expects(:write).with('') }
106
- load_yard_gems
107
- end
108
-
109
- it 'methods that map from #initialize to .new' do
110
- Yard.expects(:find_methods_with_options).returns({"Bond::Agent#initialize"=>[':one', 'two']})
111
- expected_body = %[complete(:method=>'Bond::Agent.new') {\n ["one", "two"]\n}]
112
- File.expects(:open).yields mock('block') { expects(:write).with(expected_body) }
113
- load_yard_gems
114
- end
115
- end
116
- end
117
- end