Module: AwesomePrint::Puppet
- Defined in:
- lib/awesome_print/ext/awesome_puppet.rb
Class Method Summary collapse
Instance Method Summary collapse
- #awesome_puppet_resource(object) ⇒ Object
- #awesome_puppet_type(object) ⇒ Object
-
#cast_with_puppet_resource(object, type) ⇒ Object
this tells ap how to cast our object so we can be specific about printing different puppet objects.
Class Method Details
.included(base) ⇒ Object
3 4 5 6 |
# File 'lib/awesome_print/ext/awesome_puppet.rb', line 3 def self.included(base) base.send :alias_method, :cast_without_puppet_resource, :cast base.send :alias_method, :cast, :cast_with_puppet_resource end |
Instance Method Details
#awesome_puppet_resource(object) ⇒ Object
25 26 27 28 |
# File 'lib/awesome_print/ext/awesome_puppet.rb', line 25 def awesome_puppet_resource(object) return '' if object.nil? awesome_puppet_type(object.to_ral) end |
#awesome_puppet_type(object) ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/awesome_print/ext/awesome_puppet.rb', line 30 def awesome_puppet_type(object) return '' if object.nil? return object.to_s unless object.respond_to?(:name) && object.respond_to?(:title) h = object.to_hash.merge(:name => object.name, :title => object.title) res_str = awesome_hash(h) "#{object.class} #{res_str.gsub(':', '')}" end |
#cast_with_puppet_resource(object, type) ⇒ Object
this tells ap how to cast our object so we can be specific about printing different puppet objects
10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/awesome_print/ext/awesome_puppet.rb', line 10 def cast_with_puppet_resource(object, type) cast = cast_without_puppet_resource(object, type) # check the object to see if it has an acestor (< ) of the specified type if (defined?(::Puppet::Type)) && (object.class < ::Puppet::Type) cast = :puppet_type elsif (defined?(::Puppet::Pops::Types)) && (object.class < ::Puppet::Pops::Types) cast = :puppet_type elsif (defined?(::Puppet::Parser::Resource)) && (object.class < ::Puppet::Parser::Resource) cast = :puppet_resource elsif /Puppet::Pops::Types/.match(object.class.to_s) cast = :puppet_type end cast end |