irb-kit 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3d780521bda1e340bf6982b990365702a0d1b25db6ab6f5d644ecd17aacbd388
4
- data.tar.gz: e5ba0a428a0572bfc79a34b034b225dc5f8a083f843f800b42786ec9666ca7e1
3
+ metadata.gz: bd95b94c3b604ba8c6c5c239475a99ab603815ba86d98587193063515b676fd2
4
+ data.tar.gz: e2082fe9b9e281291c2e67ec6b54e2ea7359c50178d625cf96faa05ce225ece8
5
5
  SHA512:
6
- metadata.gz: 2632b3438788d8eef27586a9b59fd9caf203edcbb1ce5399f24c6c2758aa545bb2a074e89380e0cb7986c4ef158cb6b87491f2ee0a5b9ddc959861ddc76ba1e9
7
- data.tar.gz: 39d38ee4db85954e6cb8616a31b7c087e9b9db1fcc9048f684d028fd1cfda0aa43d01ddb7d288e3eff0b989644862703490310a4fb136ec8d849b8ce4ffd5f2d
6
+ metadata.gz: a5bbb32382af12000c59e762774961637a00285f55355eed10d7feead6d6f015397661ec99a9ad0e29e7036a26cc938b89c3aa75ee6d96b1d2c0e6fd4c9f77bf
7
+ data.tar.gz: cc2472d1fd8069b751816de1f5c62574236dc999b59c380b886b5e2e0b1b5a8911935fe2c6b2fc9e9b738e9626f6c78699ae3d16d25bae5c5ff3ea63778b5837
checksums.yaml.gz.sig CHANGED
Binary file
data/README.adoc CHANGED
@@ -9,6 +9,7 @@
9
9
  :rails_link: link:https://rubyonrails.org[Rails]
10
10
  :ruby_link: link:https://www.ruby-lang.org[Ruby]
11
11
  :xdg_link: link:https://alchemists.io/projects/xdg[XDG]
12
+ :iterm_link: link:https://iterm2.com[iTerm2]
12
13
 
13
14
  = IRB Kit
14
15
 
@@ -160,11 +161,11 @@ Use this helper, short for _constant source_, to find the source location of a c
160
161
 
161
162
  [source,ruby]
162
163
  ----
163
- csource :RUBY_VERSION # ["<main>", 0]
164
- csource "RUBY_VERSION" # ["<main>", 0]
164
+ csource :RUBY_DESCRIPTION # "$HOME/.cache/frum/versions/3.3.2/bin/ruby:0"
165
+ csource "RUBY_DESCRIPTION" # "$HOME/.cache/frum/versions/3.3.2/bin/ruby:0"
165
166
  ----
166
167
 
167
- You can use a symbol or a string when looking up the source location of a constant.
168
+ You can use a symbol or a string when looking up the source location of a constant. The output is formatted so you can use pass:[<kbd>CONTROL</kbd>] + `<click>` to immediately view the source at the exact line number in consoles like {iterm_link}.
168
169
 
169
170
  ==== `msource`
170
171
 
@@ -172,11 +173,13 @@ Use this helper, short for _method source_, to find the source location of a met
172
173
 
173
174
  [source,ruby]
174
175
  ----
175
- msource IRB, :start # ["ruby/gems/3.3.0/gems/irb-1.13.1/lib/irb.rb", 893]
176
- msource IRB, "start" # ["ruby/gems/3.3.0/gems/irb-1.13.1/lib/irb.rb", 893]
176
+ msource IRB, :start # "$HOME/.cache/frum/versions/3.3.2/lib/ruby/3.3.0/irb.rb:893"
177
+ msource IRB, "start" # "$HOME/.cache/frum/versions/3.3.2/lib/ruby/3.3.0/irb.rb:893"
177
178
  ----
178
179
 
179
- The first argument is the object you want to message while the second argument is the object's method you want to find the source code location for. You'll get an array with the path and the line number of the method's source. You can also use a symbol or string for the method.
180
+ The first argument is the object you want to message while the second argument is the object's method you want to find the source code location for. You can also use a symbol or string for the method.
181
+
182
+ The output is formatted so you can use pass:[<kbd>CONTROL</kbd>] + `<click>` to immediately view the source at the exact line number in consoles like {iterm_link}.
180
183
 
181
184
  ==== `paste`
182
185
 
data/irb-kit.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "irb-kit"
5
- spec.version = "0.1.1"
5
+ spec.version = "0.2.0"
6
6
  spec.authors = ["Brooke Kuhlmann"]
7
7
  spec.email = ["brooke@alchemists.io"]
8
8
  spec.homepage = "https://alchemists.io/projects/irb-kit"
@@ -9,20 +9,21 @@ module IRB
9
9
 
10
10
  description "Find a constant's source location."
11
11
 
12
- def initialize object = Object
12
+ def initialize object = Object, delimiter: ":"
13
13
  super()
14
14
  @object = object
15
+ @delimiter = delimiter
15
16
  end
16
17
 
17
18
  def execute name
18
- object.const_source_location name
19
+ object.const_source_location(name).then { |details| details.join delimiter if details }
19
20
  rescue NameError
20
21
  "ERROR: Invalid constant (#{name.inspect})."
21
22
  end
22
23
 
23
24
  private
24
25
 
25
- attr_reader :object
26
+ attr_reader :object, :delimiter
26
27
  end
27
28
  end
28
29
  end
@@ -9,11 +9,20 @@ module IRB
9
9
 
10
10
  description "Find an object method's source location."
11
11
 
12
+ def initialize delimiter: ":"
13
+ super()
14
+ @delimiter = delimiter
15
+ end
16
+
12
17
  def execute object, name
13
- object.method(name).source_location
18
+ object.method(name).source_location.then { |details| details.join delimiter if details }
14
19
  rescue NameError => error
15
20
  "ERROR: #{error.message}"
16
21
  end
22
+
23
+ private
24
+
25
+ attr_reader :delimiter
17
26
  end
18
27
  end
19
28
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module IRB
4
4
  module Kit
5
- # Loads IRB extensions for namespace.
5
+ # Loads extensions for namespace.
6
6
  class Loader
7
7
  ALL = [:all].freeze
8
8
 
@@ -18,15 +18,15 @@ module IRB
18
18
 
19
19
  attr_reader :registrar, :namespace, :all
20
20
 
21
- def register_all = helpers.each { |helper| registrar.register helper::MONIKER, helper }
21
+ def register_all = constants.each { |helper| registrar.register helper::MONIKER, helper }
22
22
 
23
23
  def register_selected(*monikers)
24
- helpers.select { |helper| monikers.include? helper::MONIKER }
25
- .then { |selected| monikers.zip selected }
26
- .each { |moniker, helper| registrar.register moniker, helper }
24
+ constants.select { |helper| monikers.include? helper::MONIKER }
25
+ .then { |selected| monikers.zip selected }
26
+ .each { |moniker, helper| registrar.register moniker, helper }
27
27
  end
28
28
 
29
- def helpers = namespace.constants.sort.map { |name| namespace.const_get name }
29
+ def constants = namespace.constants.sort.map { |name| namespace.const_get name }
30
30
  end
31
31
  end
32
32
  end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: irb-kit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brooke Kuhlmann
@@ -35,7 +35,7 @@ cert_chain:
35
35
  3n5C8/6Zh9DYTkpcwPSuIfAga6wf4nXc9m6JAw8AuMLaiWN/r/2s4zJsUHYERJEu
36
36
  gZGm4JqtuSg8pYjPeIJxS960owq+SfuC+jxqmRA54BisFCv/0VOJi7tiJVY=
37
37
  -----END CERTIFICATE-----
38
- date: 2024-05-27 00:00:00.000000000 Z
38
+ date: 2024-05-31 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: irb
@@ -111,7 +111,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
111
111
  - !ruby/object:Gem::Version
112
112
  version: '0'
113
113
  requirements: []
114
- rubygems_version: 3.5.10
114
+ rubygems_version: 3.5.11
115
115
  signing_key:
116
116
  specification_version: 4
117
117
  summary: Extends IRB by providing additional productivity enhancements.
metadata.gz.sig CHANGED
Binary file