Class: Pfu

Inherits:
Object
  • Object
show all
Defined in:
lib/pfu.rb,
lib/pfu/version.rb

Defined Under Namespace

Classes: Generator, Parser

Constant Summary collapse

VERSION =
'0.0.5'

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Pfu

Returns a new instance of Pfu.



6
7
8
9
10
# File 'lib/pfu.rb', line 6

def initialize(options)
  @filenames = options[:filenames]
  @namespace = options[:namespace]
  @clean     = options[:clean]
end

Instance Method Details

#refactor!Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/pfu.rb', line 12

def refactor!
  @filenames.each do |path|
    next unless data = Pfu::Parser.parse(path)
    data[:namespace] = @namespace
    if Pfu::Generator.write(data)
      FileUtils.rm(path) if @clean
    end
  end

  $logger.info "Functions generated. Please inspect for suitability and then"
  $logger.info "update any Puppet code with the new function names."
  $logger.info "See https://puppet.com/docs/puppet/latest/custom_functions_ruby.html"
  $logger.info "for more information about Puppet's modern Ruby function API."
end