mirror of
https://github.com/awesome-print/awesome_print
synced 2023-03-27 23:22:34 -04:00
Rename Base formatter to Formatter
This commit is contained in:
parent
d2a07190c2
commit
de51f83260
35 changed files with 35 additions and 35 deletions
|
@ -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'
|
||||
|
|
|
@ -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?
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
module AwesomePrint
|
||||
module Formatters
|
||||
class ActiveRecordInstance < Base
|
||||
class ActiveRecordInstance < Formatter
|
||||
|
||||
# Format ActiveRecord instance object.
|
||||
#
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
module AwesomePrint
|
||||
module Formatters
|
||||
class ActiveSupportTime < Base
|
||||
class ActiveSupportTime < Formatter
|
||||
|
||||
def call
|
||||
formatter.colorize(object.inspect, :time)
|
||||
|
|
|
@ -3,7 +3,7 @@ require 'awesome_print/formatters/method_tuple'
|
|||
|
||||
module AwesomePrint
|
||||
module Formatters
|
||||
class Array < Base
|
||||
class Array < Formatter
|
||||
include Enumerable
|
||||
include MethodTuple
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
module AwesomePrint
|
||||
module Formatters
|
||||
class Bigdecimal < Base
|
||||
class Bigdecimal < Formatter
|
||||
|
||||
def call
|
||||
formatter.colorize(object.to_s('F'), :bigdecimal)
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
module AwesomePrint
|
||||
module Formatters
|
||||
class Dir < Base
|
||||
class Dir < Formatter
|
||||
|
||||
def call
|
||||
ls = `ls -alF #{object.path.shellescape}`
|
||||
|
|
|
@ -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}`
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
module AwesomePrint
|
||||
module Formatters
|
||||
class Base
|
||||
class Formatter
|
||||
|
||||
def initialize(formatter, object)
|
||||
@formatter = formatter
|
|
@ -2,7 +2,7 @@ require 'awesome_print/formatters/enumerable'
|
|||
|
||||
module AwesomePrint
|
||||
module Formatters
|
||||
class Hash < Base
|
||||
class Hash < Formatter
|
||||
include Enumerable
|
||||
|
||||
def call
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
module AwesomePrint
|
||||
module Formatters
|
||||
class HashWithIndifferentAccess < Base
|
||||
class HashWithIndifferentAccess < Formatter
|
||||
|
||||
def call
|
||||
AwesomePrint::Formatters::Hash.new(formatter, object).call
|
||||
|
|
|
@ -2,7 +2,7 @@ require 'awesome_print/formatters/method_tuple'
|
|||
|
||||
module AwesomePrint
|
||||
module Formatters
|
||||
class Method < Base
|
||||
class Method < Formatter
|
||||
include MethodTuple
|
||||
|
||||
def call
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
module AwesomePrint
|
||||
module Formatters
|
||||
class MongoMapperAssociation < Base
|
||||
class MongoMapperAssociation < Formatter
|
||||
|
||||
def call
|
||||
return object.inspect if !defined?(::ActiveSupport::OrderedHash)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
module AwesomePrint
|
||||
module Formatters
|
||||
class MongoMapperBsonId < Base
|
||||
class MongoMapperBsonId < Formatter
|
||||
|
||||
def call
|
||||
object.inspect
|
||||
|
|
|
@ -2,7 +2,7 @@ require 'awesome_print/formatters/mongo_mapper'
|
|||
|
||||
module AwesomePrint
|
||||
module Formatters
|
||||
class MongoMapperClass < Base
|
||||
class MongoMapperClass < Formatter
|
||||
include MongoMapper
|
||||
|
||||
def call
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
module AwesomePrint
|
||||
module Formatters
|
||||
class MongoidBsonId < Base
|
||||
class MongoidBsonId < Formatter
|
||||
|
||||
def call
|
||||
object.inspect
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
module AwesomePrint
|
||||
module Formatters
|
||||
class MongoidDocument < Base
|
||||
class MongoidDocument < Formatter
|
||||
|
||||
def call
|
||||
return object.inspect if !defined?(::ActiveSupport::OrderedHash)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
module AwesomePrint
|
||||
module Formatters
|
||||
class NobrainerDocument < Base
|
||||
class NobrainerDocument < Formatter
|
||||
|
||||
def call
|
||||
"#{object} #{AwesomePrint::Formatters::Hash.new(formatter, columns).call}"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
module AwesomePrint
|
||||
module Formatters
|
||||
class NokogiriXmlNode < Base
|
||||
class NokogiriXmlNode < Formatter
|
||||
|
||||
def call
|
||||
if empty?
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
module AwesomePrint
|
||||
module Formatters
|
||||
class Object < Base
|
||||
class Object < Formatter
|
||||
|
||||
def call
|
||||
build_vars
|
||||
|
|
|
@ -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}"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
module AwesomePrint
|
||||
module Formatters
|
||||
class Rational < Base
|
||||
class Rational < Formatter
|
||||
|
||||
def call
|
||||
formatter.colorize(object.to_s, :rational)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
module AwesomePrint
|
||||
module Formatters
|
||||
class RippleDocumentInstance < Base
|
||||
class RippleDocumentInstance < Formatter
|
||||
|
||||
# Format Ripple instance object.
|
||||
#
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
module AwesomePrint
|
||||
module Formatters
|
||||
class Self < Base
|
||||
class Self < Formatter
|
||||
|
||||
def call
|
||||
if options[:raw] && object.instance_variables.any?
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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|
|
||||
|
|
|
@ -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])}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
module AwesomePrint
|
||||
module Formatters
|
||||
class Unboundmethod < Base
|
||||
class Unboundmethod < Formatter
|
||||
|
||||
def call
|
||||
AwesomePrint::Formatters::Method.new(formatter, object).call
|
||||
|
|
Loading…
Reference in a new issue