Class: GemfileRewrite

Inherits:
Parser::TreeRewriter
  • Object
show all
Defined in:
lib/puppet-lint/tasks/gemfile_rewrite.rb

Overview

Simple rewriter using whitequark/parser that rewrites the “gem ‘puppet-lint’” entry in the module’s Gemfile (if present) to instead use the local puppet-lint working directory.

Instance Method Summary collapse

Instance Method Details

#on_send(node) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/puppet-lint/tasks/gemfile_rewrite.rb', line 7

def on_send(node)
  _, method_name, *args = *node

  if method_name == :gem
    gem_name = args.first
    if gem_name.type == :str && gem_name.children.first == 'puppet-lint'
      puppet_lint_root = File.expand_path(File.join(__FILE__, '..', '..', '..', '..'))
      replace(node.location.expression, "gem 'puppet-lint', :path => '#{puppet_lint_root}'")
    end
  end

  super
end