pry-keybind 0.0.1 → 0.0.5

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: 2f20197ab18a878ac8e65bb6f86df1869eeb2f321688ca712b90dcd36549fa73
4
+ data.tar.gz: ae709287fb34edd6ac5f1f570db955a5858e513637e9fd686de2b2cdbb1cdd58
5
5
  SHA512:
6
- metadata.gz: f2124791242364158b5e3cb57f439f2633ddedce03c0c513befa979f49181ea75091d6357c115fff94b12ff17ed2ddf877856dc4846e35814313454c8412a987
7
- data.tar.gz: 8b50897bf6ff0a0bc448d40d7b1a81584e79571a318a7860d7f93ce983f0960d0425a3806efdeaa5563d04a215163f06b461a594424904a5b7a9e76e6698d088
6
+ metadata.gz: cd165df6561ae807056e96ff4e6834ba22b0b695df6c1a3dad91b23e9f8ddd8f4c0b77743494689f47ac4f9ce8365e0b305248ea225254bc7970892f1ce934f7
7
+ data.tar.gz: ea30a9527172b715a629f4452b519c2fe45a870d71152e7d4d9749f23a0eb96f6cec34a8f7c036e22bd748dba17a20e43e70bac54e8d36becb236b06c18355af
data/lib/hooks.rb CHANGED
@@ -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
data/lib/pry-keybind.rb CHANGED
@@ -1,8 +1,11 @@
1
1
  require "pryline"
2
+ require "pry_ext"
3
+ require "hooks"
2
4
  class PryKeybind
3
5
  class << self
4
6
  attr_accessor :registry
5
7
  attr_accessor :layers
8
+ attr_accessor :bound
6
9
  end
7
10
 
8
11
  attr_accessor :pry_instance
@@ -16,8 +19,13 @@ class PryKeybind
16
19
  self.registry[constant] = new(key, options, &block)
17
20
  end
18
21
 
22
+ def self.register_anonymous(key, options = {}, &block)
23
+ constant = format("BINDING_%09d", Random.random_number(1_000_000_000)).to_sym
24
+ register(constant, key, options, &block)
25
+ end
19
26
 
20
27
  def self.bind_all!(pry, source: nil)
28
+ @bound = true
21
29
  # puts "binding / layer size?: #{layers.size} / source: #{source}"
22
30
  layers << [*registry.values].map do |key_binding|
23
31
  key_binding.pry_instance = pry
@@ -28,6 +36,7 @@ class PryKeybind
28
36
  def self.unbind_all!(pry_instance, source: nil)
29
37
  # puts "unbinding / layer size?: #{layers.size} / source: #{source}"
30
38
  return unless layer = layers.pop
39
+ @bound = false
31
40
 
32
41
  layer.each do |key_binding|
33
42
  key_binding.pry_instance = pry_instance
data/lib/pry_ext.rb CHANGED
@@ -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
data/lib/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  class PryKeybind
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.5"
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.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Graham
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-01-09 00:00:00.000000000 Z
11
+ date: 2021-10-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pryline
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 0.0.1
19
+ version: 0.0.5
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.5
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: pry
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0.10'
33
+ version: '0.14'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0.10'
40
+ version: '0.14'
41
41
  description: Bind keys to execute commands in pry
42
42
  email: bcgraham+github@gmail.com
43
43
  executables: []
@@ -52,7 +52,7 @@ homepage: https://github.com/bcgraham/pry-keybind
52
52
  licenses:
53
53
  - MIT
54
54
  metadata: {}
55
- post_install_message:
55
+ post_install_message:
56
56
  rdoc_options: []
57
57
  require_paths:
58
58
  - lib
@@ -60,15 +60,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
60
60
  requirements:
61
61
  - - ">="
62
62
  - !ruby/object:Gem::Version
63
- version: 2.3.0
63
+ version: 2.7.0
64
64
  required_rubygems_version: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  requirements: []
70
- rubygems_version: 3.0.1
71
- signing_key:
70
+ rubygems_version: 3.1.4
71
+ signing_key:
72
72
  specification_version: 4
73
73
  summary: Use readline keybindings in pry
74
74
  test_files: []