irb-kit 0.0.0 → 0.1.0

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: d4a5907eebfaf893e3124cdc4e0377b7fbca4c5b574275cdda768cc57d8cd729
4
- data.tar.gz: 84043d9813d5e9731305f7630b93393644b746a3b3410641bdcae8d19945b663
3
+ metadata.gz: c77d7eb5845448c9e3050a2106ba4fd1a032f4027f7de2ee1209dfaa12aef203
4
+ data.tar.gz: '0281f3ab1ab7f7f3d9f0da865b795b8d6d65703d1d70eac18b047269c9345fab'
5
5
  SHA512:
6
- metadata.gz: 5c1e6591d55b4f59324265e0f86ebaf034907e707640b4d3678e0d23091a973b184d3c1122b619da83deb1b876b63a6dd69f9e9990631f13c8b50f0e81f45cf4
7
- data.tar.gz: d584db7f831d24d84f55aec04cf1f27e8ced2754f33b5d7101adcf67c8d5db7064fac27e6ad5dbd1cdcae79959acfe0d845759b7d924cd878a9fd36394ba7045
6
+ metadata.gz: 68577f28ddbadd851506efd218f4f8fa9fb755fa80a92b1617712d75494c081bc0251bc087dbe72161a6171ac48a10efb7e6c116d06ffbf63466c89f19f334b4
7
+ data.tar.gz: 7a1e64278796fa5b7685eae916f5b44b078501b38f89ea124dc0d103b2ffaeb20118486d33132f29aa4e192c802aecfea7256f3a4b39f53bae7e3c9112cb5414
checksums.yaml.gz.sig CHANGED
Binary file
data/README.adoc CHANGED
@@ -65,10 +65,14 @@ To use, add the following to your `~/.config/irb/irbrc` configuration (or `~/.ir
65
65
 
66
66
  [source,ruby]
67
67
  ----
68
- require "irb/kit"
68
+ begin
69
+ require "irb/kit"
70
+ rescue LoadError => error
71
+ puts "ERROR: #{error.message.capitalize}."
72
+ end
69
73
  ----
70
74
 
71
- This ensures this gem is fully loaded in order to enhance {irb_link} further. To customize, read on.
75
+ This ensures this gem is fully loaded in order to enhance {irb_link} further. Otherwise, an error is displayed if you are in a Ruby project that doesn't have this gem as a dependency. To customize, read on.
72
76
 
73
77
  === Quick Start
74
78
 
@@ -76,19 +80,25 @@ If you'd like all the bells and whistles fully enabled, add the following to you
76
80
 
77
81
  [source,ruby]
78
82
  ----
79
- require "irb/kit"
83
+ begin
84
+ require "irb/kit"
80
85
 
81
- IRB::Kit.register_helpers :all
86
+ IRB::Kit.register_helpers :all
82
87
 
83
- IRB.conf[:PROMPT][:DEMO] = {
84
- PROMPT_I: "[#{IRB::Kit.prompt}]> ",
85
- PROMPT_N: "[#{IRB::Kit.prompt}]| ",
86
- PROMPT_C: "[#{IRB::Kit.prompt}]| ",
87
- PROMPT_S: "[#{IRB::Kit.prompt}]%l ",
88
- RETURN: "=> %s\n"
89
- }
88
+ IRB.conf[:PROMPT] ||= {}
90
89
 
91
- IRB.conf[:PROMPT_MODE] = :DEMO
90
+ IRB.conf[:PROMPT][:DEMO] = {
91
+ PROMPT_I: "[#{IRB::Kit.prompt}]> ",
92
+ PROMPT_N: "[#{IRB::Kit.prompt}]| ",
93
+ PROMPT_C: "[#{IRB::Kit.prompt}]| ",
94
+ PROMPT_S: "[#{IRB::Kit.prompt}]%l ",
95
+ RETURN: "=> %s\n"
96
+ }
97
+
98
+ IRB.conf[:PROMPT_MODE] = :DEMO
99
+ rescue LoadError => error
100
+ puts "ERROR: #{error.message.capitalize}."
101
+ end
92
102
  ----
93
103
 
94
104
  The above enables all helpers and configures your prompt for {ruby_link}, {hanami_link}, and {rails_link} environments.
@@ -241,19 +251,23 @@ The following screenshots demonstrate what the prompt looks like in different en
241
251
 
242
252
  *Ruby (with Git)*
243
253
 
244
- image::https://alchemists.io/images/projects/irb-kit/screenshots/prompt-with_git.png[Screenshot,459,108,role=focal_point]
254
+ image::https://alchemists.io/images/projects/irb-kit/screenshots/prompt-with_git.png[Screenshot,651,150,role=focal_point]
245
255
 
246
256
  *Ruby (without Git)*
247
257
 
248
- image::https://alchemists.io/images/projects/irb-kit/screenshots/prompt-without_git.png[Screenshot,292,116,role=focal_point]
258
+ image::https://alchemists.io/images/projects/irb-kit/screenshots/prompt-without_git.png[Screenshot,400,146,role=focal_point]
259
+
260
+ *Hanami (development)*
261
+
262
+ image::https://alchemists.io/images/projects/irb-kit/screenshots/prompt-hanami-development.png[Screenshot,690,146,role=focal_point]
249
263
 
250
- *Hanami*
264
+ *Hanami (production)*
251
265
 
252
- image::https://alchemists.io/images/projects/irb-kit/screenshots/prompt-hanami.png[Screenshot,520,120,role=focal_point]
266
+ image::https://alchemists.io/images/projects/irb-kit/screenshots/prompt-hanami-production.png[Screenshot,910,169,role=focal_point]
253
267
 
254
268
  *Rails*
255
269
 
256
- image::https://alchemists.io/images/projects/irb-kit/screenshots/prompt-rails.png[Screenshot,541,137,role=focal_point]
270
+ image::https://alchemists.io/images/projects/irb-kit/screenshots/prompt-rails.png[Screenshot,756,170,role=focal_point]
257
271
 
258
272
  == Development
259
273
 
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.0.0"
5
+ spec.version = "0.1.0"
6
6
  spec.authors = ["Brooke Kuhlmann"]
7
7
  spec.email = ["brooke@alchemists.io"]
8
8
  spec.homepage = "https://alchemists.io/projects/irb-kit"
@@ -14,7 +14,7 @@ Gem::Specification.new do |spec|
14
14
  "changelog_uri" => "https://alchemists.io/projects/irb-kit/versions",
15
15
  "documentation_uri" => "https://alchemists.io/projects/irb-kit",
16
16
  "funding_uri" => "https://github.com/sponsors/bkuhlmann",
17
- "label" => "Irb Kit",
17
+ "label" => "IRB Kit",
18
18
  "rubygems_mfa_required" => "true",
19
19
  "source_code_uri" => "https://github.com/bkuhlmann/irb-kit"
20
20
  }
@@ -5,11 +5,10 @@ module IRB
5
5
  module Helpers
6
6
  # Copies input to macOS clipboard.
7
7
  class Clip < IRB::HelperMethod::Base
8
- description "Copy input to macOS clipboard."
8
+ MONIKER = :clip
9
9
 
10
- def self.moniker = :clip
10
+ description "Copy input to macOS clipboard."
11
11
 
12
- # :nocov:
13
12
  def initialize io = IO
14
13
  super()
15
14
  @io = io
@@ -17,6 +16,8 @@ module IRB
17
16
 
18
17
  def execute(*lines)
19
18
  io.popen("pbcopy", "w") { |clipboard| clipboard.write lines.join("\n") }
19
+ rescue Errno::ENOENT
20
+ "ERROR: Unable to copy since `pbcopy` is only supported on macOS."
20
21
  end
21
22
 
22
23
  private
@@ -5,9 +5,9 @@ module IRB
5
5
  module Helpers
6
6
  # Finds constant's source location.
7
7
  class ConstantSource < IRB::HelperMethod::Base
8
- description "Find a constant's source location."
8
+ MONIKER = :csource
9
9
 
10
- def self.moniker = :csource
10
+ description "Find a constant's source location."
11
11
 
12
12
  def initialize object = Object
13
13
  super()
@@ -5,9 +5,9 @@ module IRB
5
5
  module Helpers
6
6
  # Find an object method's source location.
7
7
  class MethodSource < IRB::HelperMethod::Base
8
- description "Find an object method's source location."
8
+ MONIKER = :msource
9
9
 
10
- def self.moniker = :msource
10
+ description "Find an object method's source location."
11
11
 
12
12
  def execute object, name
13
13
  object.method(name).source_location
@@ -5,17 +5,20 @@ module IRB
5
5
  module Helpers
6
6
  # Pastes last entry from macOS clipboard.
7
7
  class Paste < IRB::HelperMethod::Base
8
- description "Paste last entry from macOS clipboard."
8
+ MONIKER = :paste
9
9
 
10
- def self.moniker = :paste
10
+ description "Paste last entry from macOS clipboard."
11
11
 
12
- # :nocov:
13
12
  def initialize io = IO
14
13
  super()
15
14
  @io = io
16
15
  end
17
16
 
18
- def execute = io.popen "pbpaste", "r", &:read
17
+ def execute
18
+ io.popen "pbpaste", "r", &:read
19
+ rescue Errno::ENOENT
20
+ "ERROR: Unable to paste since `pbpaste` is only supported on macOS."
21
+ end
19
22
 
20
23
  private
21
24
 
@@ -5,9 +5,9 @@ module IRB
5
5
  module Helpers
6
6
  # Search an object's methods by pattern.
7
7
  class Search < IRB::HelperMethod::Base
8
- description "Search an object's methods by pattern."
8
+ MONIKER = :search
9
9
 
10
- def self.moniker = :search
10
+ description "Search an object's methods by pattern."
11
11
 
12
12
  def initialize regex = Regexp
13
13
  super()
@@ -18,10 +18,10 @@ 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 = helpers.each { |helper| registrar.register helper::MONIKER, helper }
22
22
 
23
23
  def register_selected(*monikers)
24
- helpers.select { |helper| monikers.include? helper.moniker }
24
+ helpers.select { |helper| monikers.include? helper::MONIKER }
25
25
  .then { |selected| monikers.zip selected }
26
26
  .each { |moniker, helper| registrar.register moniker, helper }
27
27
  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.0.0
4
+ version: 0.1.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-18 00:00:00.000000000 Z
38
+ date: 2024-05-23 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: irb
@@ -93,7 +93,7 @@ metadata:
93
93
  changelog_uri: https://alchemists.io/projects/irb-kit/versions
94
94
  documentation_uri: https://alchemists.io/projects/irb-kit
95
95
  funding_uri: https://github.com/sponsors/bkuhlmann
96
- label: Irb Kit
96
+ label: IRB Kit
97
97
  rubygems_mfa_required: 'true'
98
98
  source_code_uri: https://github.com/bkuhlmann/irb-kit
99
99
  post_install_message:
metadata.gz.sig CHANGED
Binary file