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

Make parse from Ruby 1.9 to 2.3 available #233

Merged
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog/new_make_parse_from_ruby_19_to_23_available.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* [#233](https://github.com/rubocop-hq/rubocop-ast/pull/233): Make parse from Ruby 1.9 to 2.3 available. ([@koic][])
19 changes: 17 additions & 2 deletions lib/rubocop/ast/processed_source.rb
Original file line number Diff line number Diff line change
Expand Up @@ -226,9 +226,24 @@ def tokenize(parser)
[ast, comments, tokens]
end

# rubocop:disable Metrics/CyclomaticComplexity, Metrics/MethodLength
# rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength
def parser_class(ruby_version)
case ruby_version
when 1.9
require 'parser/ruby19'
Parser::Ruby19
when 2.0
require 'parser/ruby20'
Parser::Ruby20
when 2.1
require 'parser/ruby21'
Parser::Ruby21
when 2.2
require 'parser/ruby22'
Parser::Ruby22
when 2.3
require 'parser/ruby23'
Parser::Ruby23
when 2.4
require 'parser/ruby24'
Parser::Ruby24
Expand All @@ -255,7 +270,7 @@ def parser_class(ruby_version)
"RuboCop found unknown Ruby version: #{ruby_version.inspect}"
end
end
# rubocop:enable Metrics/CyclomaticComplexity, Metrics/MethodLength
# rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength

def create_parser(ruby_version)
builder = RuboCop::AST::Builder.new
Expand Down