Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

don't require rails and check for rails defined #319

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ git_source(:github) { |repo| "https://github.com/#{repo}.git" }

gemspec

gem "rails", github: "rails/rails"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This gem needs to continue being tested with Rails, so this can't be removed.

gem "json"
gem "rack", github: "rack/rack"
gem "rack-session", github: "rack/rack-session"

Expand Down
2 changes: 1 addition & 1 deletion lib/web_console.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ def self.logger
end
end

require "web_console/railtie"
require "web_console/railtie" if defined?(::Rails::Railtie)
2 changes: 1 addition & 1 deletion lib/web_console/exception_mapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this change should be made like this. We should be configuring the application path, and using the Railtie we can set it to Rails.root

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rails.root is not a method in my case. Would you prefer just checking for the method

Suggested change
end if defined?(Rails.root) && Rails.root
end if defined?(Rails.root)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. I'd prefer if this class didn't call Rails.root at all, and instead had a application_root configuration that could be set by this gem Railtie to ExceptionMapper.application_root = Rails.root

end
end
end
1 change: 1 addition & 0 deletions lib/web_console/middleware.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# frozen_string_literal: true

require "active_support/core_ext/string/strip"
require "json"

module WebConsole
class Middleware
Expand Down
1 change: 1 addition & 0 deletions test/templates/config.ru
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
require "json"
require "web_console/testing/fake_middleware"

TEST_ROOT = Pathname(__FILE__).dirname
Expand Down