pry-keybind 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: aceb85b89e00be8dd28c0dbe9ac9bcdb18ea08e97356cacbcb83ce819e1a0164
4
- data.tar.gz: 12d9408dc40927397d17c3eaf4c0710e65e96d43e579b12606cc1fc492a35cef
3
+ metadata.gz: 9881fbdae7b700f088d63e4ab96b142a7e7e75ef6ee238cffbba3496c25a3cbf
4
+ data.tar.gz: f44b55dbd2c07a568d347050feeb4a773279e4588baa1fbe6fc1dd7cd68686c1
5
5
  SHA512:
6
- metadata.gz: f2124791242364158b5e3cb57f439f2633ddedce03c0c513befa979f49181ea75091d6357c115fff94b12ff17ed2ddf877856dc4846e35814313454c8412a987
7
- data.tar.gz: 8b50897bf6ff0a0bc448d40d7b1a81584e79571a318a7860d7f93ce983f0960d0425a3806efdeaa5563d04a215163f06b461a594424904a5b7a9e76e6698d088
6
+ metadata.gz: '0901aca7a87b840ecf76417660b0ca90f7f664bd92b9267b216f12827d79129f31459b58f21f3519c1b8f2a868e2d77a702fd488e7d0c6f475e65ba72f5c3239'
7
+ data.tar.gz: 48ee0e4a39a91be513ec0761a2e7d37345a649543cc007d353da96fb57727b805005aaf548551d32f24117e679d6bc6a965ad0499585bcf848d48e8f5cb8de64
@@ -1,13 +1,19 @@
1
- Pry.hooks.add_hook(:when_started, "initialize input states for keybindings") do |_output, binding, pry|
1
+ Pry.hooks.add_hook(:when_started, "initialize input states for keybindings") do |_output, binding, pry_instance|
2
2
  Pry.config.input_states ||= []
3
3
  end
4
4
 
5
- Pry.hooks.add_hook(:before_session, "custom_keybindings") do |output, binding, pry|
5
+ Pry.hooks.add_hook(:before_session, "restore input state & bind keybindings") do |output, binding, pry_instance|
6
6
  if (input_state = Pry.config.input_states.pop)
7
7
  input_state.restore!(readline_buffer: false)
8
8
  end
9
- PryKeybind.bind_all!(pry)
9
+ PryKeybind.bind_all!(pry_instance, source: :before_session)
10
10
  end
11
- Pry.hooks.add_hook(:after_session, "custom keybindings") do |output, _binding, pry|
12
- PryKeybind.unbind_all!(pry)
11
+
12
+ Pry.hooks.add_hook(:after_session, "unbind keybindings") do |output, _binding, pry_instance|
13
+ PryKeybind.unbind_all!(pry_instance, source: :after_session)
14
+ end
15
+
16
+ Pry.hooks.add_hook(:after_eval, "reset keybindings") do |output, pry_instance|
17
+ PryKeybind.unbind_all!(pry_instance, source: :after_eval)
18
+ PryKeybind.bind_all!(pry_instance, source: :after_eval)
13
19
  end
@@ -1,4 +1,6 @@
1
1
  require "pryline"
2
+ require "pry_ext"
3
+ require "hooks"
2
4
  class PryKeybind
3
5
  class << self
4
6
  attr_accessor :registry
@@ -16,6 +18,10 @@ class PryKeybind
16
18
  self.registry[constant] = new(key, options, &block)
17
19
  end
18
20
 
21
+ def self.register_anonymous(key, options = {}, &block)
22
+ constant = format("BINDING_%09d", Random.random_number(1_000_000_000)).to_sym
23
+ register(constant, key, options, &block)
24
+ end
19
25
 
20
26
  def self.bind_all!(pry, source: nil)
21
27
  # puts "binding / layer size?: #{layers.size} / source: #{source}"
@@ -1,9 +1,7 @@
1
1
  class Pry
2
- def bind_key(key, options = {}, &block)
3
- @anonymous_binding_count ||= 0
4
- @anonymous_binding_count = @anonymous_binding_count + 1
2
+ def self.bind_key(key, options = {}, &block)
5
3
  PryKeybind.unbind_all!(self)
6
- PryKeybind.register("BINDING_#{@anonymous_binding_count}", key, options, &block)
4
+ PryKeybind.register_anonymous(key, options, &block)
7
5
  PryKeybind.bind_all!(self)
8
6
 
9
7
  true
@@ -1,3 +1,3 @@
1
1
  class PryKeybind
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pry-keybind
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Graham
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-01-09 00:00:00.000000000 Z
11
+ date: 2020-01-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pryline
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 0.0.1
19
+ version: 0.0.2
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 0.0.1
26
+ version: 0.0.2
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: pry
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -67,7 +67,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  requirements: []
70
- rubygems_version: 3.0.1
70
+ rubygems_version: 3.0.3
71
71
  signing_key:
72
72
  specification_version: 4
73
73
  summary: Use readline keybindings in pry