From 46191c3ffd1f73da5d6f296b076b18046f3e83be Mon Sep 17 00:00:00 2001 From: TSMMark Date: Mon, 1 Aug 2022 14:34:27 -0400 Subject: [PATCH 1/2] don't require rails and check for rails defined --- Gemfile | 1 - lib/web_console.rb | 2 +- lib/web_console/exception_mapper.rb | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/Gemfile b/Gemfile index 642fc335..f12a2d9a 100644 --- a/Gemfile +++ b/Gemfile @@ -6,7 +6,6 @@ git_source(:github) { |repo| "https://github.com/#{repo}.git" } gemspec -gem "rails", github: "rails/rails" gem "rack", github: "rack/rack" gem "rack-session", github: "rack/rack-session" diff --git a/lib/web_console.rb b/lib/web_console.rb index 38526094..51fb34da 100644 --- a/lib/web_console.rb +++ b/lib/web_console.rb @@ -30,4 +30,4 @@ def self.logger end end -require "web_console/railtie" +require "web_console/railtie" if defined?(::Rails::Railtie) diff --git a/lib/web_console/exception_mapper.rb b/lib/web_console/exception_mapper.rb index e750fc3a..c4317904 100644 --- a/lib/web_console/exception_mapper.rb +++ b/lib/web_console/exception_mapper.rb @@ -50,7 +50,7 @@ def guess_the_first_application_binding @bindings.find do |binding| source_location = SourceLocation.new(binding) source_location.path.to_s.start_with?(Rails.root.to_s) - end + end if defined?(Rails.root) && Rails.root end end end From 1c8f3ae276c2278c02a301772369de251d3f8c6a Mon Sep 17 00:00:00 2001 From: TSMMark Date: Mon, 1 Aug 2022 15:21:15 -0400 Subject: [PATCH 2/2] fix rake templates:test by require "json" --- Gemfile | 1 + lib/web_console/middleware.rb | 1 + test/templates/config.ru | 1 + 3 files changed, 3 insertions(+) diff --git a/Gemfile b/Gemfile index f12a2d9a..49e01577 100644 --- a/Gemfile +++ b/Gemfile @@ -6,6 +6,7 @@ git_source(:github) { |repo| "https://github.com/#{repo}.git" } gemspec +gem "json" gem "rack", github: "rack/rack" gem "rack-session", github: "rack/rack-session" diff --git a/lib/web_console/middleware.rb b/lib/web_console/middleware.rb index 256e1514..7e9c6739 100644 --- a/lib/web_console/middleware.rb +++ b/lib/web_console/middleware.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true require "active_support/core_ext/string/strip" +require "json" module WebConsole class Middleware diff --git a/test/templates/config.ru b/test/templates/config.ru index b89f8376..87a7a0de 100644 --- a/test/templates/config.ru +++ b/test/templates/config.ru @@ -1,3 +1,4 @@ +require "json" require "web_console/testing/fake_middleware" TEST_ROOT = Pathname(__FILE__).dirname