vendored/puppet/lib/puppet/util/fileparsing.rb in bolt-0.20.3 vs vendored/puppet/lib/puppet/util/fileparsing.rb in bolt-0.20.5
- old
+ new
@@ -22,19 +22,16 @@
#
# Each line in this case would be a hash, with each field set appropriately.
# You could then call 'parser.to_line(hash)' on any of those hashes to generate
# the text line again.
-require 'puppet/util/methodhelper'
-
module Puppet::Util::FileParsing
include Puppet::Util
attr_writer :line_separator, :trailing_separator
class FileRecord
include Puppet::Util
- include Puppet::Util::MethodHelper
attr_accessor :absent, :joiner, :rts, :separator, :rollup, :name, :match, :block_eval
attr_reader :fields, :optional, :type
INVALID_FIELDS = [:record_type, :target, :on_disk]
@@ -46,14 +43,39 @@
raise ArgumentError.new(_("Cannot have fields named %{name}") % { name: r }) if INVALID_FIELDS.include?(r)
r
end
end
- def initialize(type, options = {}, &block)
+ def initialize(type,
+ absent: nil,
+ block_eval: nil,
+ fields: nil,
+ joiner: nil,
+ match: nil,
+ optional: nil,
+ post_parse: nil,
+ pre_gen: nil,
+ rollup: nil,
+ rts: nil,
+ separator: nil,
+ to_line: nil,
+ &block)
@type = type.intern
raise ArgumentError, _("Invalid record type %{record_type}") % { record_type: @type } unless [:record, :text].include?(@type)
- set_options(options)
+ @absent = absent
+ @block_eval = block_eval
+ @joiner = joiner
+ @match = match
+ @rollup = rollup if rollup
+ @rts = rts
+ @separator = separator
+
+ self.fields = fields if fields
+ self.optional = optional if optional
+ self.post_parse = post_parse if post_parse
+ self.pre_gen = pre_gen if pre_gen
+ self.to_line = to_line if to_line
if self.type == :record
# Now set defaults.
self.absent ||= ""
self.separator ||= /\s+/