File tree Expand file tree Collapse file tree 2 files changed +12
-6
lines changed Expand file tree Collapse file tree 2 files changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -40,6 +40,10 @@ module SyntaxTree
4040 # optional second argument to ::format.
4141 DEFAULT_PRINT_WIDTH = 80
4242
43+ # This is the default ruby version that we're going to target for formatting.
44+ # It shouldn't really be changed except in very niche circumstances.
45+ DEFAULT_RUBY_VERSION = Formatter ::SemanticVersion . new ( RUBY_VERSION ) . freeze
46+
4347 # This is a hook provided so that plugins can register themselves as the
4448 # handler for a particular file type.
4549 def self . register_handler ( extension , handler )
Original file line number Diff line number Diff line change @@ -377,14 +377,19 @@ class Options
377377 :plugins ,
378378 :print_width ,
379379 :scripts ,
380- :formatter_options
380+ :target_ruby_version
381381
382382 def initialize
383383 @ignore_files = [ ]
384384 @plugins = [ ]
385385 @print_width = DEFAULT_PRINT_WIDTH
386386 @scripts = [ ]
387- @formatter_options = Formatter ::Options . new
387+ @target_ruby_version = DEFAULT_RUBY_VERSION
388+ end
389+
390+ def formatter_options
391+ @formatter_options ||=
392+ Formatter ::Options . new ( target_ruby_version : target_ruby_version )
388393 end
389394
390395 def parse ( arguments )
@@ -430,10 +435,7 @@ def parser
430435 # If there is a target ruby version specified on the command line,
431436 # parse that out and use it when formatting.
432437 opts . on ( "--target-ruby-version=VERSION" ) do |version |
433- @formatter_options =
434- Formatter ::Options . new (
435- target_ruby_version : Formatter ::SemanticVersion . new ( version )
436- )
438+ @target_ruby_version = Formatter ::SemanticVersion . new ( version )
437439 end
438440 end
439441 end
You can’t perform that action at this time.
0 commit comments