diff --git a/lib/awesome_print/formatters.rb b/lib/awesome_print/formatters.rb index bcead41..5e0b85e 100644 --- a/lib/awesome_print/formatters.rb +++ b/lib/awesome_print/formatters.rb @@ -1,6 +1,6 @@ module AwesomePrint module Formatters - require 'awesome_print/formatters/base' + require 'awesome_print/formatters/formatter' require 'awesome_print/formatters/self' require 'awesome_print/formatters/array' require 'awesome_print/formatters/hash' diff --git a/lib/awesome_print/formatters/active_record_class.rb b/lib/awesome_print/formatters/active_record_class.rb index de5af6e..4ad5319 100644 --- a/lib/awesome_print/formatters/active_record_class.rb +++ b/lib/awesome_print/formatters/active_record_class.rb @@ -1,6 +1,6 @@ module AwesomePrint module Formatters - class ActiveRecordClass < Base + class ActiveRecordClass < Formatter def call return object.inspect if not_a_active_record_class? diff --git a/lib/awesome_print/formatters/active_record_instance.rb b/lib/awesome_print/formatters/active_record_instance.rb index df0afd7..45e52b7 100644 --- a/lib/awesome_print/formatters/active_record_instance.rb +++ b/lib/awesome_print/formatters/active_record_instance.rb @@ -1,6 +1,6 @@ module AwesomePrint module Formatters - class ActiveRecordInstance < Base + class ActiveRecordInstance < Formatter # Format ActiveRecord instance object. # diff --git a/lib/awesome_print/formatters/active_support_time.rb b/lib/awesome_print/formatters/active_support_time.rb index b3ccce9..f30e5bc 100644 --- a/lib/awesome_print/formatters/active_support_time.rb +++ b/lib/awesome_print/formatters/active_support_time.rb @@ -1,6 +1,6 @@ module AwesomePrint module Formatters - class ActiveSupportTime < Base + class ActiveSupportTime < Formatter def call formatter.colorize(object.inspect, :time) diff --git a/lib/awesome_print/formatters/array.rb b/lib/awesome_print/formatters/array.rb index f62a694..75062eb 100644 --- a/lib/awesome_print/formatters/array.rb +++ b/lib/awesome_print/formatters/array.rb @@ -3,7 +3,7 @@ require 'awesome_print/formatters/method_tuple' module AwesomePrint module Formatters - class Array < Base + class Array < Formatter include Enumerable include MethodTuple diff --git a/lib/awesome_print/formatters/bigdecimal.rb b/lib/awesome_print/formatters/bigdecimal.rb index 73625cc..feea430 100644 --- a/lib/awesome_print/formatters/bigdecimal.rb +++ b/lib/awesome_print/formatters/bigdecimal.rb @@ -1,6 +1,6 @@ module AwesomePrint module Formatters - class Bigdecimal < Base + class Bigdecimal < Formatter def call formatter.colorize(object.to_s('F'), :bigdecimal) diff --git a/lib/awesome_print/formatters/class.rb b/lib/awesome_print/formatters/class.rb index 6c53333..ddc2e2e 100644 --- a/lib/awesome_print/formatters/class.rb +++ b/lib/awesome_print/formatters/class.rb @@ -1,6 +1,6 @@ module AwesomePrint module Formatters - class Class < Base + class Class < Formatter def call if superclass = object.superclass # <-- Assign and test if nil. diff --git a/lib/awesome_print/formatters/dir.rb b/lib/awesome_print/formatters/dir.rb index 383bf4f..b9b3cd9 100644 --- a/lib/awesome_print/formatters/dir.rb +++ b/lib/awesome_print/formatters/dir.rb @@ -1,6 +1,6 @@ module AwesomePrint module Formatters - class Dir < Base + class Dir < Formatter def call ls = `ls -alF #{object.path.shellescape}` diff --git a/lib/awesome_print/formatters/file.rb b/lib/awesome_print/formatters/file.rb index 222021a..f11ce73 100644 --- a/lib/awesome_print/formatters/file.rb +++ b/lib/awesome_print/formatters/file.rb @@ -1,6 +1,6 @@ module AwesomePrint module Formatters - class File < Base + class File < Formatter def call ls = ::File.directory?(object) ? `ls -adlF #{object.path.shellescape}` : `ls -alF #{object.path.shellescape}` diff --git a/lib/awesome_print/formatters/base.rb b/lib/awesome_print/formatters/formatter.rb similarity index 95% rename from lib/awesome_print/formatters/base.rb rename to lib/awesome_print/formatters/formatter.rb index 57d5583..cc963ce 100644 --- a/lib/awesome_print/formatters/base.rb +++ b/lib/awesome_print/formatters/formatter.rb @@ -1,6 +1,6 @@ module AwesomePrint module Formatters - class Base + class Formatter def initialize(formatter, object) @formatter = formatter diff --git a/lib/awesome_print/formatters/hash.rb b/lib/awesome_print/formatters/hash.rb index 0d069c7..217d0dc 100644 --- a/lib/awesome_print/formatters/hash.rb +++ b/lib/awesome_print/formatters/hash.rb @@ -2,7 +2,7 @@ require 'awesome_print/formatters/enumerable' module AwesomePrint module Formatters - class Hash < Base + class Hash < Formatter include Enumerable def call diff --git a/lib/awesome_print/formatters/hash_with_indifferent_access.rb b/lib/awesome_print/formatters/hash_with_indifferent_access.rb index e988c09..37ff555 100644 --- a/lib/awesome_print/formatters/hash_with_indifferent_access.rb +++ b/lib/awesome_print/formatters/hash_with_indifferent_access.rb @@ -1,6 +1,6 @@ module AwesomePrint module Formatters - class HashWithIndifferentAccess < Base + class HashWithIndifferentAccess < Formatter def call AwesomePrint::Formatters::Hash.new(formatter, object).call diff --git a/lib/awesome_print/formatters/method.rb b/lib/awesome_print/formatters/method.rb index b4b6df3..97c3261 100644 --- a/lib/awesome_print/formatters/method.rb +++ b/lib/awesome_print/formatters/method.rb @@ -2,7 +2,7 @@ require 'awesome_print/formatters/method_tuple' module AwesomePrint module Formatters - class Method < Base + class Method < Formatter include MethodTuple def call diff --git a/lib/awesome_print/formatters/mongo_mapper_association.rb b/lib/awesome_print/formatters/mongo_mapper_association.rb index a37f7b5..2a2b505 100644 --- a/lib/awesome_print/formatters/mongo_mapper_association.rb +++ b/lib/awesome_print/formatters/mongo_mapper_association.rb @@ -1,6 +1,6 @@ module AwesomePrint module Formatters - class MongoMapperAssociation < Base + class MongoMapperAssociation < Formatter def call return object.inspect if !defined?(::ActiveSupport::OrderedHash) diff --git a/lib/awesome_print/formatters/mongo_mapper_bson_id.rb b/lib/awesome_print/formatters/mongo_mapper_bson_id.rb index 360ff28..f45788c 100644 --- a/lib/awesome_print/formatters/mongo_mapper_bson_id.rb +++ b/lib/awesome_print/formatters/mongo_mapper_bson_id.rb @@ -1,6 +1,6 @@ module AwesomePrint module Formatters - class MongoMapperBsonId < Base + class MongoMapperBsonId < Formatter def call object.inspect diff --git a/lib/awesome_print/formatters/mongo_mapper_class.rb b/lib/awesome_print/formatters/mongo_mapper_class.rb index d890a0a..3530c4d 100644 --- a/lib/awesome_print/formatters/mongo_mapper_class.rb +++ b/lib/awesome_print/formatters/mongo_mapper_class.rb @@ -2,7 +2,7 @@ require 'awesome_print/formatters/mongo_mapper' module AwesomePrint module Formatters - class MongoMapperClass < Base + class MongoMapperClass < Formatter include MongoMapper def call diff --git a/lib/awesome_print/formatters/mongo_mapper_instance.rb b/lib/awesome_print/formatters/mongo_mapper_instance.rb index 60aee52..fbbb841 100644 --- a/lib/awesome_print/formatters/mongo_mapper_instance.rb +++ b/lib/awesome_print/formatters/mongo_mapper_instance.rb @@ -2,7 +2,7 @@ require 'awesome_print/formatters/mongo_mapper' module AwesomePrint module Formatters - class MongoMapperInstance < Base + class MongoMapperInstance < Formatter include MongoMapper # Format MongoMapper instance object. diff --git a/lib/awesome_print/formatters/mongoid_bson_id.rb b/lib/awesome_print/formatters/mongoid_bson_id.rb index 7ec4862..3d0be01 100644 --- a/lib/awesome_print/formatters/mongoid_bson_id.rb +++ b/lib/awesome_print/formatters/mongoid_bson_id.rb @@ -1,6 +1,6 @@ module AwesomePrint module Formatters - class MongoidBsonId < Base + class MongoidBsonId < Formatter def call object.inspect diff --git a/lib/awesome_print/formatters/mongoid_class.rb b/lib/awesome_print/formatters/mongoid_class.rb index 0607e78..bd69f6f 100644 --- a/lib/awesome_print/formatters/mongoid_class.rb +++ b/lib/awesome_print/formatters/mongoid_class.rb @@ -1,6 +1,6 @@ module AwesomePrint module Formatters - class MongoidClass < Base + class MongoidClass < Formatter def call return object.inspect if !defined?(::ActiveSupport::OrderedHash) || !object.respond_to?(:fields) diff --git a/lib/awesome_print/formatters/mongoid_document.rb b/lib/awesome_print/formatters/mongoid_document.rb index 9566276..5b9b9b3 100644 --- a/lib/awesome_print/formatters/mongoid_document.rb +++ b/lib/awesome_print/formatters/mongoid_document.rb @@ -1,6 +1,6 @@ module AwesomePrint module Formatters - class MongoidDocument < Base + class MongoidDocument < Formatter def call return object.inspect if !defined?(::ActiveSupport::OrderedHash) diff --git a/lib/awesome_print/formatters/nobrainer_class.rb b/lib/awesome_print/formatters/nobrainer_class.rb index 532d345..a5ae969 100644 --- a/lib/awesome_print/formatters/nobrainer_class.rb +++ b/lib/awesome_print/formatters/nobrainer_class.rb @@ -1,6 +1,6 @@ module AwesomePrint module Formatters - class NobrainerClass < Base + class NobrainerClass < Formatter def call "class #{object} < #{object.superclass} " << AwesomePrint::Formatters::Hash.new(formatter, columns).call diff --git a/lib/awesome_print/formatters/nobrainer_document.rb b/lib/awesome_print/formatters/nobrainer_document.rb index 64c765b..879336d 100644 --- a/lib/awesome_print/formatters/nobrainer_document.rb +++ b/lib/awesome_print/formatters/nobrainer_document.rb @@ -1,6 +1,6 @@ module AwesomePrint module Formatters - class NobrainerDocument < Base + class NobrainerDocument < Formatter def call "#{object} #{AwesomePrint::Formatters::Hash.new(formatter, columns).call}" diff --git a/lib/awesome_print/formatters/nokogiri_xml_node.rb b/lib/awesome_print/formatters/nokogiri_xml_node.rb index aa58555..4300d66 100644 --- a/lib/awesome_print/formatters/nokogiri_xml_node.rb +++ b/lib/awesome_print/formatters/nokogiri_xml_node.rb @@ -1,6 +1,6 @@ module AwesomePrint module Formatters - class NokogiriXmlNode < Base + class NokogiriXmlNode < Formatter def call if empty? diff --git a/lib/awesome_print/formatters/object.rb b/lib/awesome_print/formatters/object.rb index f609fb5..b0b2917 100644 --- a/lib/awesome_print/formatters/object.rb +++ b/lib/awesome_print/formatters/object.rb @@ -1,6 +1,6 @@ module AwesomePrint module Formatters - class Object < Base + class Object < Formatter def call build_vars diff --git a/lib/awesome_print/formatters/open_struct_instance.rb b/lib/awesome_print/formatters/open_struct_instance.rb index c1b8746..cca0345 100644 --- a/lib/awesome_print/formatters/open_struct_instance.rb +++ b/lib/awesome_print/formatters/open_struct_instance.rb @@ -1,6 +1,6 @@ module AwesomePrint module Formatters - class OpenStructInstance < Base + class OpenStructInstance < Formatter def call "#{object.class} #{AwesomePrint::Formatters::Hash.new(formatter, object.marshal_dump).call}" diff --git a/lib/awesome_print/formatters/rational.rb b/lib/awesome_print/formatters/rational.rb index dea9cbf..1a9da12 100644 --- a/lib/awesome_print/formatters/rational.rb +++ b/lib/awesome_print/formatters/rational.rb @@ -1,6 +1,6 @@ module AwesomePrint module Formatters - class Rational < Base + class Rational < Formatter def call formatter.colorize(object.to_s, :rational) diff --git a/lib/awesome_print/formatters/ripple_document_class.rb b/lib/awesome_print/formatters/ripple_document_class.rb index 66bd7b6..fd55c30 100644 --- a/lib/awesome_print/formatters/ripple_document_class.rb +++ b/lib/awesome_print/formatters/ripple_document_class.rb @@ -1,6 +1,6 @@ module AwesomePrint module Formatters - class RippleDocumentClass < Base + class RippleDocumentClass < Formatter def call return object.inspect if !defined?(::ActiveSupport::OrderedHash) || !object.respond_to?(:properties) diff --git a/lib/awesome_print/formatters/ripple_document_instance.rb b/lib/awesome_print/formatters/ripple_document_instance.rb index 9f491fa..8fe0d83 100644 --- a/lib/awesome_print/formatters/ripple_document_instance.rb +++ b/lib/awesome_print/formatters/ripple_document_instance.rb @@ -1,6 +1,6 @@ module AwesomePrint module Formatters - class RippleDocumentInstance < Base + class RippleDocumentInstance < Formatter # Format Ripple instance object. # diff --git a/lib/awesome_print/formatters/self.rb b/lib/awesome_print/formatters/self.rb index 5dce77e..d5b497f 100644 --- a/lib/awesome_print/formatters/self.rb +++ b/lib/awesome_print/formatters/self.rb @@ -1,6 +1,6 @@ module AwesomePrint module Formatters - class Self < Base + class Self < Formatter def call if options[:raw] && object.instance_variables.any? diff --git a/lib/awesome_print/formatters/sequel_dataset.rb b/lib/awesome_print/formatters/sequel_dataset.rb index e7cb34d..5bfae74 100644 --- a/lib/awesome_print/formatters/sequel_dataset.rb +++ b/lib/awesome_print/formatters/sequel_dataset.rb @@ -1,6 +1,6 @@ module AwesomePrint module Formatters - class SequelDataset < Base + class SequelDataset < Formatter def call [AwesomePrint::Formatters::Array.new(formatter, object.to_a).call, diff --git a/lib/awesome_print/formatters/sequel_document.rb b/lib/awesome_print/formatters/sequel_document.rb index ef959b7..186187f 100644 --- a/lib/awesome_print/formatters/sequel_document.rb +++ b/lib/awesome_print/formatters/sequel_document.rb @@ -1,6 +1,6 @@ module AwesomePrint module Formatters - class SequelDocument < Base + class SequelDocument < Formatter def call data = object.values.sort_by { |key| key.to_s }.inject({}) do |hash, c| diff --git a/lib/awesome_print/formatters/sequel_model_class.rb b/lib/awesome_print/formatters/sequel_model_class.rb index c6cc848..9510880 100644 --- a/lib/awesome_print/formatters/sequel_model_class.rb +++ b/lib/awesome_print/formatters/sequel_model_class.rb @@ -1,6 +1,6 @@ module AwesomePrint module Formatters - class SequelModelClass < Base + class SequelModelClass < Formatter def call data = object.db_schema.inject({}) {|h, (name,data)| h.merge(name => data[:db_type])} diff --git a/lib/awesome_print/formatters/set.rb b/lib/awesome_print/formatters/set.rb index ea5d625..01d3bf2 100644 --- a/lib/awesome_print/formatters/set.rb +++ b/lib/awesome_print/formatters/set.rb @@ -1,6 +1,6 @@ module AwesomePrint module Formatters - class Set < Base + class Set < Formatter def call AwesomePrint::Formatters::Array.new(formatter, object.to_a).call diff --git a/lib/awesome_print/formatters/struct.rb b/lib/awesome_print/formatters/struct.rb index 39f05b1..d4512e1 100644 --- a/lib/awesome_print/formatters/struct.rb +++ b/lib/awesome_print/formatters/struct.rb @@ -1,6 +1,6 @@ module AwesomePrint module Formatters - class Struct < Base + class Struct < Formatter # # The code is slightly uglier because of Ruby 1.8.6 quirks: # awesome_hash(Hash[s.members.zip(s.values)]) <-- ArgumentError: odd number of arguments for Hash) diff --git a/lib/awesome_print/formatters/unboundmethod.rb b/lib/awesome_print/formatters/unboundmethod.rb index 70594ee..5fa5cdf 100644 --- a/lib/awesome_print/formatters/unboundmethod.rb +++ b/lib/awesome_print/formatters/unboundmethod.rb @@ -1,6 +1,6 @@ module AwesomePrint module Formatters - class Unboundmethod < Base + class Unboundmethod < Formatter def call AwesomePrint::Formatters::Method.new(formatter, object).call