[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, experimental, updated. debian/2.6.8-1-844-g7ec39d5
Luke Kanies
luke at puppetlabs.com
Tue May 10 08:04:37 UTC 2011
The following commit has been merged in the experimental branch:
commit 3ffb9abd3a500f1fb3246e04f737b79d232c082d
Author: Luke Kanies <luke at puppetlabs.com>
Date: Tue Feb 8 21:27:24 2011 -0800
Moving 'format' support to the application
This allows easier use of the Interfaces in ruby.
Signed-off-by: Luke Kanies <luke at puppetlabs.com>
diff --git a/lib/puppet/application/data_baseclass.rb b/lib/puppet/application/data_baseclass.rb
index 3f498f5..e67b1b3 100644
--- a/lib/puppet/application/data_baseclass.rb
+++ b/lib/puppet/application/data_baseclass.rb
@@ -18,7 +18,7 @@ class Puppet::Application::DataBaseclass < Puppet::Application
end
option("--format FORMAT") do |arg|
- @format = arg
+ @format = arg.to_sym
end
# XXX this doesn't work, I think
@@ -46,11 +46,11 @@ class Puppet::Application::DataBaseclass < Puppet::Application
def main
# Call the method associated with the provided action (e.g., 'find').
- interface.send(verb, name, *arguments)
+ result = interface.send(verb, name, *arguments)
+ puts result.render(format)
end
def setup
- @format ||= :yaml
Puppet::Util::Log.newdestination :console
@@ -60,7 +60,7 @@ class Puppet::Application::DataBaseclass < Puppet::Application
@type = self.class.name.to_s.sub(/.+:/, '').downcase.to_sym
@interface = Puppet::Interface.interface(@type).new
- @interface.format = format if format
+ @format ||= @interface.class.default_format || :pson
validate
diff --git a/lib/puppet/interface.rb b/lib/puppet/interface.rb
index 6e132f6..f35a8bf 100644
--- a/lib/puppet/interface.rb
+++ b/lib/puppet/interface.rb
@@ -1,6 +1,15 @@
require 'puppet'
class Puppet::Interface
+
+ class << self
+ attr_accessor :default_format
+
+ def set_default_format(format)
+ self.default_format = format.to_sym
+ end
+ end
+
# This is just so we can search for actions. We only use its
# list of directories to search.
def self.autoloader
@@ -67,7 +76,7 @@ class Puppet::Interface
@name || self.to_s.sub(/.+::/, '').downcase
end
- attr_accessor :from, :type, :verb, :name, :arguments, :indirection, :format
+ attr_accessor :from, :type, :verb, :name, :arguments, :indirection
def action?(name)
self.class.actions.include?(name.to_sym)
@@ -105,8 +114,6 @@ class Puppet::Interface
def initialize(options = {})
options.each { |opt, val| send(opt.to_s + "=", val) }
- @format ||= :yaml
-
Puppet::Util::Log.newdestination :console
self.class.load_actions
@@ -132,7 +139,7 @@ class Puppet::Interface
raise "Could not #{method} #{indirection.name} for #{name}"
end
- puts result.render(format.to_sym)
+ result
end
def indirections
diff --git a/lib/puppet/interface/facts.rb b/lib/puppet/interface/facts.rb
index 4114167..e40bb56 100644
--- a/lib/puppet/interface/facts.rb
+++ b/lib/puppet/interface/facts.rb
@@ -1,6 +1,8 @@
require 'puppet/interface'
class Puppet::Interface::Facts < Puppet::Interface
+ set_default_format :yaml
+
# Upload our facts to the server
action(:upload) do |*args|
Puppet::Node::Facts.indirection.terminus_class = :facter
--
Puppet packaging for Debian
More information about the Pkg-puppet-devel
mailing list