diff options
| author | Luke Kanies <luke@madstop.com> | 2008-07-28 18:50:24 -0500 |
|---|---|---|
| committer | Luke Kanies <luke@madstop.com> | 2008-07-29 00:51:22 -0500 |
| commit | 352e2d0fb74fd7226ecac06b6108e672c221baa1 (patch) | |
| tree | 859bc5a7b73af3ac3e22a16dac68877636bd72df /lib/puppet/network/format.rb | |
| parent | 55e29444c15fe2f810b3d5332605f27ac5942fda (diff) | |
| download | puppet-352e2d0fb74fd7226ecac06b6108e672c221baa1.tar.gz puppet-352e2d0fb74fd7226ecac06b6108e672c221baa1.tar.xz puppet-352e2d0fb74fd7226ecac06b6108e672c221baa1.zip | |
Adding rudimentary support for directly managing formats.
We have a simple Format class, and the FormatHandler
module is responsible for managing its instances,
including providing access by mime type or name.
It will soon replace some of the testing functionality
in the FormatHandler module, but for now, it's just
there as a name => mimetype converter, which makes it
seem a lot like overkill.
Signed-off-by: Luke Kanies <luke@madstop.com>
Diffstat (limited to 'lib/puppet/network/format.rb')
| -rw-r--r-- | lib/puppet/network/format.rb | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/lib/puppet/network/format.rb b/lib/puppet/network/format.rb new file mode 100644 index 000000000..7c678568d --- /dev/null +++ b/lib/puppet/network/format.rb @@ -0,0 +1,27 @@ +require 'puppet/provider/confiner' + +# A simple class for modeling encoding formats for moving +# instances around the network. +class Puppet::Network::Format + include Puppet::Provider::Confiner + + attr_reader :name + attr_accessor :mime + + def initialize(name, options = {}, &block) + @name = name + + if mime = options[:mime] + @mime = mime + options.delete(:mime) + else + @mime = "text/%s" % name + end + + unless options.empty? + raise ArgumentError, "Unsupported option(s) %s" % options.keys + end + + instance_eval(&block) if block_given? + end +end |
