summaryrefslogtreecommitdiffstats
path: root/lib/puppet/util
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-11-11 07:40:16 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-11-11 07:40:16 +0000
commit0643113a7a8127ce559aa0cce0b81df5e99d386c (patch)
tree15e693db02840a656ed8b43027fcb55d257d7c8c /lib/puppet/util
parent7c8614b0589f7c843d17b9d16720419817394cee (diff)
downloadpuppet-0643113a7a8127ce559aa0cce0b81df5e99d386c.tar.gz
puppet-0643113a7a8127ce559aa0cce0b81df5e99d386c.tar.xz
puppet-0643113a7a8127ce559aa0cce0b81df5e99d386c.zip
An intermediate commit. All of the classes that use parsedfile are assuredly broken, since I have basically completely rewritten it. These classes have been a thorn in my side almost since I created them, yet they have been significantly less functional that I wanted. So, I decided to do the rewrite I have been putting off, just to spend all of the maintenance time now so I do not spend 3 days on them every release.
Tomorrow I will be porting all of the existing types (including cron, hopefully) over to this new base. This will also make it possible to add other types of providers to these classes; we should be able to reuse the netinfo provider for os x types, and we should be able to create a cron provider that writes to /etc/crontab instead of user crontabs. git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1856 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib/puppet/util')
-rw-r--r--lib/puppet/util/classgen.rb17
-rw-r--r--lib/puppet/util/fileparsing.rb5
2 files changed, 15 insertions, 7 deletions
diff --git a/lib/puppet/util/classgen.rb b/lib/puppet/util/classgen.rb
index 8fa2a34cf..0c774eecd 100644
--- a/lib/puppet/util/classgen.rb
+++ b/lib/puppet/util/classgen.rb
@@ -50,7 +50,7 @@ module Puppet::Util::ClassGen
# Remove an existing class
def rmclass(name, options)
options = symbolize_options(options)
- const = name2const(name)
+ const = genconst_string(name, options)
retval = false
if const_defined? const
remove_const(const)
@@ -68,6 +68,16 @@ module Puppet::Util::ClassGen
private
+ # Generate the constant to create or remove.
+ def genconst_string(name, options)
+ unless const = options[:constant]
+ prefix = options[:prefix] || ""
+ const = prefix + name2const(name)
+ end
+
+ return const
+ end
+
# This does the actual work of creating our class or module. It's just a
# slightly abstract version of genclass.
def genthing(name, type, options, block)
@@ -120,10 +130,7 @@ module Puppet::Util::ClassGen
# Handle the setting and/or removing of the associated constant.
def handleclassconst(klass, name, options)
- unless const = options[:constant]
- prefix = options[:prefix] || ""
- const = prefix + name2const(name)
- end
+ const = genconst_string(name, options)
if const_defined? const
if options[:overwrite]
diff --git a/lib/puppet/util/fileparsing.rb b/lib/puppet/util/fileparsing.rb
index e4998cf7e..705192b11 100644
--- a/lib/puppet/util/fileparsing.rb
+++ b/lib/puppet/util/fileparsing.rb
@@ -108,10 +108,11 @@ module Puppet::Util::FileParsing
raise ArgumentError, "Must include a list of fields"
end
+ invalidfields = [:record_type, :target, :on_disk]
options[:fields] = options[:fields].collect do |field|
r = symbolize(field)
- if r == :record_type
- raise ArgumentError.new("Cannot have fields named record_type")
+ if invalidfields.include?(r)
+ raise ArgumentError.new("Cannot have fields named %s" % r)
end
r
end