emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/inf-ruby 9157d9c561 115/265: inf-ruby-console-gem: when ge


From: ELPA Syncer
Subject: [nongnu] elpa/inf-ruby 9157d9c561 115/265: inf-ruby-console-gem: when gemspec doesn't modify LOAD_PATH, -I lib
Date: Sat, 9 Jul 2022 21:59:18 -0400 (EDT)

branch: elpa/inf-ruby
commit 9157d9c56123e8e442ff656946655030d1f47888
Author: Dmitry Gutov <dgutov@yandex.ru>
Commit: Dmitry Gutov <dgutov@yandex.ru>

    inf-ruby-console-gem: when gemspec doesn't modify LOAD_PATH, -I lib
---
 inf-ruby.el | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/inf-ruby.el b/inf-ruby.el
index fbbffba4dc..1303c5c9f4 100755
--- a/inf-ruby.el
+++ b/inf-ruby.el
@@ -644,9 +644,13 @@ The main module should be loaded automatically.  If DIR 
contains a
 Gemfile, it should use the `gemspec' instruction."
   (interactive "D")
   (let* ((default-directory (file-name-as-directory dir))
-         (base-command (if (file-exists-p "Gemfile")
-                           "bundle exec irb"
-                         "irb -I lib"))
+         (gemspec (car (file-expand-wildcards "*.gemspec")))
+         (base-command
+          (if (file-exists-p "Gemfile")
+              (if (inf-ruby-file-contents-match gemspec "\\$LOAD_PATH")
+                  "bundle exec irb"
+                "bundle exec irb -I lib")
+            "irb -I lib"))
          files)
     (unless (file-exists-p "lib")
       (error "The directory must contain a 'lib' subdirectory"))
@@ -671,15 +675,19 @@ Gemfile, it should use the `gemspec' instruction."
     (unless (file-exists-p "Gemfile")
       (error "The directory must contain a Gemfile"))
     (cond
-     ((with-temp-buffer
-        (insert-file-contents "Gemfile")
-        (re-search-forward "[\"']racksh[\"']" nil t))
+     ((inf-ruby-file-contents-match "Gemfile" "[\"']racksh[\"']")
       (run-ruby "bundle exec racksh" "racksh"))
      ((file-exists-p "console.rb")
       (run-ruby "ruby console.rb" "console.rb"))
      (t
       (run-ruby "bundle console")))))
 
+;;;###autoload
+(defun inf-ruby-file-contents-match (file regexp)
+  (with-temp-buffer
+    (insert-file-contents file)
+    (re-search-forward regexp nil t)))
+
 ;;;###autoload (dolist (mode ruby-source-modes) (add-hook (intern (format 
"%s-hook" mode)) 'inf-ruby-minor-mode))
 
 (provide 'inf-ruby)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]