Skip to content

Fix plugins parsing for 5.0.0 #197

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

Merged
merged 1 commit into from
Nov 10, 2022
Merged
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
4 changes: 4 additions & 0 deletions lib/syntax_tree.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ module SyntaxTree
# optional second argument to ::format.
DEFAULT_PRINT_WIDTH = 80

# This is the default ruby version that we're going to target for formatting.
# It shouldn't really be changed except in very niche circumstances.
DEFAULT_RUBY_VERSION = Formatter::SemanticVersion.new(RUBY_VERSION).freeze

# This is a hook provided so that plugins can register themselves as the
# handler for a particular file type.
def self.register_handler(extension, handler)
Expand Down
14 changes: 8 additions & 6 deletions lib/syntax_tree/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -377,14 +377,19 @@ class Options
:plugins,
:print_width,
:scripts,
:formatter_options
:target_ruby_version

def initialize
@ignore_files = []
@plugins = []
@print_width = DEFAULT_PRINT_WIDTH
@scripts = []
@formatter_options = Formatter::Options.new
@target_ruby_version = DEFAULT_RUBY_VERSION
end

def formatter_options
@formatter_options ||=
Formatter::Options.new(target_ruby_version: target_ruby_version)
end

def parse(arguments)
Expand Down Expand Up @@ -430,10 +435,7 @@ def parser
# If there is a target ruby version specified on the command line,
# parse that out and use it when formatting.
opts.on("--target-ruby-version=VERSION") do |version|
@formatter_options =
Formatter::Options.new(
target_ruby_version: Formatter::SemanticVersion.new(version)
)
@target_ruby_version = Formatter::SemanticVersion.new(version)
end
end
end
Expand Down