pry-bond 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 999919215a91009db9b039238fd250f41f7e5f71
4
+ data.tar.gz: 056b2517389789edce6ce34b5a76aceac5fe5f72
5
+ SHA512:
6
+ metadata.gz: f2dcbe2ad01006b5cc7ca4f0d1732534bc028010c298bcbe813c655ffdf86d222ffe65dc4b4ef15974dda6e823bbbf837cff3c95baedc161e27fbe64c83ef019
7
+ data.tar.gz: 0e70ce56a1a5ab54ce4fef99dd404556850a8b7d574a7c0d893e63db6e45457c3b0ec41c143500c8ea51b74ff2546d41e5a6810e55a705eeaa659f87cd1611fa
@@ -0,0 +1 @@
1
+ Gemfile.lock
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in pry-bond.gemspec
4
+ gemspec
5
+ gem "pry", git: "https://github.com/pry/pry.git"
6
+ gem "bond"
@@ -0,0 +1,25 @@
1
+ License
2
+ -------
3
+
4
+ (The MIT License)
5
+
6
+ Copyright (c) 2014 The Pry Team
7
+
8
+ Permission is hereby granted, free of charge, to any person obtaining
9
+ a copy of this software and associated documentation files (the
10
+ 'Software'), to deal in the Software without restriction, including
11
+ without limitation the rights to use, copy, modify, merge, publish,
12
+ distribute, sublicense, and/or sell copies of the Software, and to
13
+ permit persons to whom the Software is furnished to do so, subject to
14
+ the following conditions:
15
+
16
+ The above copyright notice and this permission notice shall be
17
+ included in all copies or substantial portions of the Software.
18
+
19
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
20
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
22
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
23
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
24
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
25
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,76 @@
1
+ __pry-bond__
2
+
3
+ pry-bond offers input completion in the [pry](https://github.com/pry/pry) repl through
4
+ the [bond](https://github.com/cldwalker/bond) rubygem. the default input completion for
5
+ pry has been inherited from IRB but bond offers more extensibility options through gems like
6
+ [bond-yard](https://github.com/cldwalker/bond-yard).
7
+
8
+ __Features__
9
+
10
+ - provides input completion in pry through the `bond` rubygem.
11
+ - provides `enable-bond!` command for switching to bond completion inside a repl session.
12
+ - provides `disable-bond!` command for switching back the pry default inside a repl session.
13
+ - provides a file for require to change pry default(`Pry::InputCompleter`) to `Pry::BondCompleter`.
14
+
15
+ __Examples__
16
+
17
+ enable/disable in a repl session
18
+
19
+ ```
20
+ [1] pry(main)> enable-bond!
21
+ bond input completion has been enabled and is ready to use!
22
+ --
23
+
24
+ [2] pry(main)> disable-bond!
25
+ bond input completion has been disabled and the pry default has been restored.
26
+ --
27
+ ```
28
+
29
+ __Dependencies__
30
+
31
+ pry-bond depends on:
32
+
33
+ - pry `~> 0.10` <br>
34
+ the repl!
35
+
36
+ - bond `~> 0.5` <br>
37
+ provides input completion
38
+
39
+ - rb-readline `~> 0.5` <br>
40
+ provides pure ruby implementation of readline that removes platform compatibility issues with C
41
+ version and editline(OSX).
42
+
43
+ __Contribute__
44
+
45
+ 1. [fork it](https://github.com/pry/pry-bond/fork)
46
+ 2. clone forked repository (`git clone https://github.com/your-name/pry-bond.git`)
47
+ 3. create feature branch (`git checkout -b new-feature`)
48
+ 4. commit your changes (`git commit -am 'Add new feature'`)
49
+ 5. push to the branch (`git push origin new-feature`)
50
+ 6. create new Pull Request
51
+
52
+ __Tips__
53
+
54
+ install runtime and development dependencies with bundler.
55
+
56
+ ```
57
+ $ git clone https://github.com/pry/pry-bond.git
58
+ $ cd pry-bond
59
+ $ bundle install
60
+ ```
61
+
62
+ run the tests.
63
+
64
+ ```
65
+ $ [bundle exec] rake test
66
+ ```
67
+
68
+ __Install__
69
+
70
+ ```
71
+ gem install pry-bond
72
+ ```
73
+
74
+ __License__
75
+
76
+ MIT. See LICENSE.txt.
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,3 @@
1
+ require "pry" unless defined?(Pry)
2
+ require "bond"
3
+ require "pry/bond"
@@ -0,0 +1,10 @@
1
+ require_relative "bond/version"
2
+ require_relative "bond/completer"
3
+ require_relative "bond/enable_command"
4
+ require_relative "bond/disable_command"
5
+ # Pry::Bond is not the best name for a namespace,
6
+ # because all references to Bond from Pry now
7
+ # pointing to the "wrong" module
8
+ class Pry::BondCompleter
9
+ end
10
+ Pry.config.completer = Pry::BondCompleter
@@ -0,0 +1,66 @@
1
+ class Pry
2
+ class BondCompleter
3
+
4
+ class << self
5
+ attr_reader :bond
6
+ end
7
+
8
+ class NoopReadline
9
+ def self.setup _
10
+ # do nothing as we let pry do the completion
11
+ end
12
+
13
+ def self.line_buffer
14
+ "" # we give the current line directly to bond
15
+ end
16
+ end
17
+
18
+ def self.setup(config={})
19
+ @lock = Mutex.new
20
+ @bond = Bond::M
21
+ @bond.config.merge!(config)
22
+ @bond.config[:readline] ||= NoopReadline
23
+ @current_pry_instance = nil
24
+ @bond.start(:eval_binding => lambda {@current_pry_instance.current_binding})
25
+ @bond.complete(:on => /^(.+)$/, :place => :last, :name => "pry-autocomplete", :action => lambda {|input|
26
+ Bond::DefaultMission.completions.map(&:to_s) + Pry.commands.complete(input.line,
27
+ :pry_instance => @current_pry_instance,
28
+ :target => @current_pry_instance.current_binding,
29
+ :command_set => @current_pry_instance.commands)
30
+ })
31
+ end
32
+
33
+ def self.with_pry instance
34
+ @lock.synchronize do
35
+ begin
36
+ @current_pry_instance = instance
37
+ yield
38
+ ensure
39
+ @current_pry_instance = nil
40
+ end
41
+ end
42
+ end
43
+
44
+ def initialize input, pry = nil
45
+ BondCompleter.setup if BondCompleter.bond.nil?
46
+ @pry = pry
47
+ @input = input
48
+ end
49
+
50
+ def call str, options
51
+ BondCompleter.with_pry(@pry) {BondCompleter.bond.agent.call(str, get_full_line_input || str)}
52
+ end
53
+
54
+ protected
55
+ def get_full_line_input
56
+ if @input.respond_to?(:line_buffer)
57
+ @input.line_buffer
58
+ elsif @input.respond_to? :line
59
+ @input.line
60
+ else
61
+ nil
62
+ end
63
+ end
64
+
65
+ end
66
+ end
@@ -0,0 +1,16 @@
1
+ class Pry::BondCompleter::DisableCommand < Pry::ClassCommand
2
+ match 'disable-bond!'
3
+ group 'bond'
4
+ description 'disable input completion through the `bond` rubygem.'
5
+ banner <<-BANNER
6
+ Usage: disable-bond!
7
+ disable input completion through the `bond` rubygem by restoring the
8
+ pry default.
9
+ BANNER
10
+
11
+ def process
12
+ _pry_.config.forget(:completer)
13
+ output.puts heading("bond input completion has been disabled and the pry default has been restored.")
14
+ end
15
+ Pry.commands.add_command(self)
16
+ end
@@ -0,0 +1,15 @@
1
+ class Pry::BondCompleter::EnableCommand < Pry::ClassCommand
2
+ match 'enable-bond!'
3
+ group 'bond'
4
+ description 'enable input completion through the `bond` rubygem.'
5
+ banner <<-BANNER
6
+ Usage: enable-bond!
7
+ enables input completion through the `bond` rubygem.
8
+ BANNER
9
+
10
+ def process
11
+ _pry_.config.completer = Pry::BondCompleter
12
+ output.puts heading("bond input completion has been enabled and is ready to use!")
13
+ end
14
+ Pry.commands.add_command(self)
15
+ end
@@ -0,0 +1,5 @@
1
+ class Pry
2
+ class BondCompleter
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,17 @@
1
+ require "./lib/pry/bond/version"
2
+ Gem::Specification.new do |spec|
3
+ spec.name = "pry-bond"
4
+ spec.version = Pry::BondCompleter::VERSION
5
+ spec.authors = ["MIT"]
6
+ spec.email = ["rpag@singletonclass.com"]
7
+ spec.description = "pry-bond provides input completion in pry through the `bond` rubygem."
8
+ spec.summary = spec.description
9
+ spec.homepage = "https://github.com/pry/pry-bond"
10
+ spec.license = "MIT"
11
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
12
+ spec.require_paths = ["lib"]
13
+ spec.required_ruby_version = ">= 1.9.2"
14
+ spec.files = `git ls-files`.split($/)
15
+ spec.add_runtime_dependency "bond", "~> 0.5"
16
+ spec.add_runtime_dependency "rb-readline", "~> 0.5"
17
+ end
metadata ADDED
@@ -0,0 +1,85 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pry-bond
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - MIT
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-06-04 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bond
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.5'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.5'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rb-readline
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.5'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.5'
41
+ description: pry-bond provides input completion in pry through the `bond` rubygem.
42
+ email:
43
+ - rpag@singletonclass.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".gitignore"
49
+ - Gemfile
50
+ - LICENSE.txt
51
+ - README.md
52
+ - Rakefile
53
+ - lib/pry-bond.rb
54
+ - lib/pry/bond.rb
55
+ - lib/pry/bond/completer.rb
56
+ - lib/pry/bond/disable_command.rb
57
+ - lib/pry/bond/enable_command.rb
58
+ - lib/pry/bond/version.rb
59
+ - pry-bond.gemspec
60
+ homepage: https://github.com/pry/pry-bond
61
+ licenses:
62
+ - MIT
63
+ metadata: {}
64
+ post_install_message:
65
+ rdoc_options: []
66
+ require_paths:
67
+ - lib
68
+ required_ruby_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: 1.9.2
73
+ required_rubygems_version: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ requirements: []
79
+ rubyforge_project:
80
+ rubygems_version: 2.4.7
81
+ signing_key:
82
+ specification_version: 4
83
+ summary: pry-bond provides input completion in pry through the `bond` rubygem.
84
+ test_files: []
85
+ has_rdoc: