Skip to content

Instantly share code, notes, and snippets.

@pocke
Created December 12, 2017 14:19
Show Gist options
  • Select an option

  • Save pocke/70d54e34b6ebb728bf074916e98877a8 to your computer and use it in GitHub Desktop.

Select an option

Save pocke/70d54e34b6ebb728bf074916e98877a8 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'pathname'
require 'optparse'
$LOAD_PATH.unshift(Pathname(__dir__).join('../lib/').realpath)
require 'rubocop'
pattern, ruby, version = ARGV.options do |opt|
version = RUBY_VERSION
opt.on('-v VERSION') { |v| version = v }
[*opt.parse!, version]
end
source = RuboCop::ProcessedSource.new(ruby, version.to_f)
mod = Module.new do
extend RuboCop::NodePattern::Macros
extend self
def_node_matcher :match, pattern
end
p mod.match(source.ast)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment