-
Notifications
You must be signed in to change notification settings - Fork 0
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
Support and require Rails 7.2 #2
Draft
joshuay03
wants to merge
2
commits into
master
Choose a base branch
from
support-rails-7-2
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,15 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rails/console/app' | ||
require_relative './rails_console_commands/console_delegation' | ||
require "irb" | ||
require_relative './rails_console_commands/test_command' | ||
require_relative './rails_console_commands/rake_command' | ||
require_relative './rails_console_commands/generate_command' | ||
require_relative './rails_console_commands/destroy_command' | ||
require_relative './rails_console_commands/update_command' | ||
require_relative './rails_console_commands/version' | ||
|
||
Rails::ConsoleMethods.send :include, RailsConsoleCommands::ConsoleDelegation | ||
IRB::Command.register(:test, RailsConsoleCommands::TestCommand) | ||
IRB::Command.register(:rake, RailsConsoleCommands::RakeCommand) | ||
IRB::Command.register(:generate, RailsConsoleCommands::GenerateCommand) | ||
IRB::Command.register(:destroy, RailsConsoleCommands::DestroyCommand) | ||
IRB::Command.register(:update, RailsConsoleCommands::UpdateCommand) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# frozen_string_literal: true | ||
|
||
module RailsConsoleCommands | ||
module ArgParser | ||
def parse_arg(arg) | ||
# IRB parses the arg differently for single and double quotes strings. E.g. | ||
# test 'foo' -> "'foo'" | ||
# test "foo" -> "\"foo\"" | ||
# test 'foo', 10 -> "'foo', 10" | ||
# test "foo", 10 -> "\"foo\", 10" | ||
arg = arg.strip | ||
arg = arg.delete("'") # handle single quote case | ||
begin | ||
JSON.parse(arg) # handle double quote case | ||
rescue JSON::ParserError | ||
arg | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative './arg_parser' | ||
require_relative './commander' | ||
|
||
module RailsConsoleCommands | ||
class DestroyCommand < IRB::Command::Base | ||
include ArgParser | ||
|
||
def execute(arg) | ||
Commander.commander.destroy(parse_arg(arg)) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative './arg_parser' | ||
require_relative './commander' | ||
|
||
module RailsConsoleCommands | ||
class GenerateCommand < IRB::Command::Base | ||
include ArgParser | ||
|
||
def execute(arg) | ||
Commander.commander.generate(parse_arg(arg)) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative './arg_parser' | ||
require_relative './commander' | ||
|
||
module RailsConsoleCommands | ||
class RakeCommand < IRB::Command::Base | ||
include ArgParser | ||
|
||
def execute(arg) | ||
Commander.commander.rake(parse_arg(arg)) | ||
end | ||
end | ||
end |
14 changes: 6 additions & 8 deletions
14
...ls_console_commands/console_delegation.rb → lib/rails_console_commands/test_command.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,20 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative './arg_parser' | ||
require_relative './commander' | ||
|
||
module RailsConsoleCommands | ||
module ConsoleDelegation | ||
def commander | ||
@commander ||= Commander.new | ||
end | ||
class TestCommand < IRB::Command::Base | ||
include ArgParser | ||
|
||
def test(*args) | ||
def execute(arg) | ||
if Rails.env.test? | ||
commander.test(*args) | ||
what, line = arg.split(',').map{ |a| parse_arg(a) } | ||
Commander.commander.test(what, line) | ||
else | ||
puts 'You can only run tests in a console started in the test environment. ' \ | ||
'Use `rails console test` to start such a console' | ||
end | ||
end | ||
|
||
delegate :rake, :generate, :destroy, :update, to: :commander | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative './arg_parser' | ||
require_relative './commander' | ||
|
||
module RailsConsoleCommands | ||
class UpdateCommand < IRB::Command::Base | ||
include ArgParser | ||
|
||
def execute(arg) | ||
Commander.commander.update(parse_arg(arg)) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to figure out a better way to do this so we can point to it,
7.2.0.alpha
is <7.2
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reverting for now so I can point to this to run tests locally.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a TODO, pointing payaus to this branch for now, once 7.2 is out need to merge this + point payaus to master.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
7-2-stable
is pretty stable now, I think we can lock this in.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
5feb5e4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can merge this if we want but need to be careful not to delete the branch cause payaus points to this. Might be safer to just leave as is though.