mirror of
https://github.com/awesome-print/awesome_print
synced 2023-03-27 23:22:34 -04:00
Colorize ORM class names
This commit is contained in:
parent
551bb9cd30
commit
43f856ea2e
8 changed files with 33 additions and 13 deletions
|
@ -2,6 +2,7 @@
|
||||||
- ActiveRecord: #joins now show the columns #select'ed [@adrianomitre] - [#211]
|
- ActiveRecord: #joins now show the columns #select'ed [@adrianomitre] - [#211]
|
||||||
- Handles NoMethodError for IRB implicit `ai` [@jtnegrotto] - [#212]
|
- Handles NoMethodError for IRB implicit `ai` [@jtnegrotto] - [#212]
|
||||||
- Replaced Fixnum reference with Integer
|
- Replaced Fixnum reference with Integer
|
||||||
|
- Colorize ORM class names [@ixti]
|
||||||
|
|
||||||
## 1.7.0
|
## 1.7.0
|
||||||
- Refactoring by extracting formatters into their own classes [@waldyr] - [#237]
|
- Refactoring by extracting formatters into their own classes [@waldyr] - [#237]
|
||||||
|
@ -148,6 +149,7 @@
|
||||||
[@clonezone]: https://github.com/clonezone
|
[@clonezone]: https://github.com/clonezone
|
||||||
[@cyberdelia]: https://github.com/cyberdelia
|
[@cyberdelia]: https://github.com/cyberdelia
|
||||||
[@gerrywastaken]: https://github.com/gerrywastaken
|
[@gerrywastaken]: https://github.com/gerrywastaken
|
||||||
|
[@ixti]: https://github.com/ixti
|
||||||
[@jtnegrotto]: https://github.com/jtnegrotto
|
[@jtnegrotto]: https://github.com/jtnegrotto
|
||||||
[@kemmason]: https://github.com/kemmason
|
[@kemmason]: https://github.com/kemmason
|
||||||
[@maurogeorge]: https://github.com/maurogeorge
|
[@maurogeorge]: https://github.com/maurogeorge
|
||||||
|
|
|
@ -66,7 +66,11 @@ module AwesomePrint
|
||||||
hash[c.name.to_sym] = c.type
|
hash[c.name.to_sym] = c.type
|
||||||
hash
|
hash
|
||||||
end
|
end
|
||||||
"class #{object} < #{object.superclass} " << awesome_hash(data)
|
|
||||||
|
name = "class #{awesome_simple(object.to_s, :class)}"
|
||||||
|
base = "< #{awesome_simple(object.superclass.to_s, :class)}"
|
||||||
|
|
||||||
|
[name, base, awesome_hash(data)].join(' ')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -49,7 +49,10 @@ module AwesomePrint
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
"class #{object} < #{object.superclass} " << awesome_hash(data)
|
name = "class #{awesome_simple(object.to_s, :class)}"
|
||||||
|
base = "< #{awesome_simple(object.superclass.to_s, :class)}"
|
||||||
|
|
||||||
|
[name, base, awesome_hash(data)].join(' ')
|
||||||
end
|
end
|
||||||
|
|
||||||
# Format MongoMapper instance object.
|
# Format MongoMapper instance object.
|
||||||
|
|
|
@ -36,7 +36,11 @@ module AwesomePrint
|
||||||
hash[c[1].name.to_sym] = (c[1].type || 'undefined').to_s.underscore.intern
|
hash[c[1].name.to_sym] = (c[1].type || 'undefined').to_s.underscore.intern
|
||||||
hash
|
hash
|
||||||
end
|
end
|
||||||
"class #{object} < #{object.superclass} " << awesome_hash(data)
|
|
||||||
|
name = "class #{awesome_simple(object.to_s, :class)}"
|
||||||
|
base = "< #{awesome_simple(object.superclass.to_s, :class)}"
|
||||||
|
|
||||||
|
[name, base, awesome_hash(data)].join(' ')
|
||||||
end
|
end
|
||||||
|
|
||||||
# Format Mongoid Document object.
|
# Format Mongoid Document object.
|
||||||
|
|
|
@ -28,10 +28,15 @@ module AwesomePrint
|
||||||
# Format NoBrainer class object.
|
# Format NoBrainer class object.
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
def awesome_nobrainer_class(object)
|
def awesome_nobrainer_class(object)
|
||||||
|
name = "#{awesome_simple(object, :class)} < #{awesome_simple(object.superclass, :class)}"
|
||||||
data = Hash[object.fields.map do |field, options|
|
data = Hash[object.fields.map do |field, options|
|
||||||
[field, (options[:type] || Object).to_s.underscore.to_sym]
|
[field, (options[:type] || Object).to_s.underscore.to_sym]
|
||||||
end]
|
end]
|
||||||
"class #{object} < #{object.superclass} " << awesome_hash(data)
|
|
||||||
|
name = "class #{awesome_simple(object.to_s, :class)}"
|
||||||
|
base = "< #{awesome_simple(object.superclass.to_s, :class)}"
|
||||||
|
|
||||||
|
[name, base, awesome_hash(data)].join(' ')
|
||||||
end
|
end
|
||||||
|
|
||||||
# Format NoBrainer Document object.
|
# Format NoBrainer Document object.
|
||||||
|
|
|
@ -60,11 +60,10 @@ module AwesomePrint
|
||||||
def awesome_ripple_document_class(object)
|
def awesome_ripple_document_class(object)
|
||||||
return object.inspect if !defined?(::ActiveSupport::OrderedHash) || !object.respond_to?(:properties)
|
return object.inspect if !defined?(::ActiveSupport::OrderedHash) || !object.respond_to?(:properties)
|
||||||
|
|
||||||
data = object.properties.inject(::ActiveSupport::OrderedHash.new) do |hash, (name, defn)|
|
name = "class #{awesome_simple(object.to_s, :class)}"
|
||||||
hash[name.to_sym] = defn.type.to_s.downcase.to_sym
|
base = "< #{awesome_simple(object.superclass.to_s, :class)}"
|
||||||
hash
|
|
||||||
end
|
[name, base, awesome_hash(data)].join(' ')
|
||||||
"class #{object} < #{object.superclass} " << awesome_hash(data)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -45,8 +45,11 @@ module AwesomePrint
|
||||||
# Format Sequel Model class.
|
# Format Sequel Model class.
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
def awesome_sequel_model_class(object)
|
def awesome_sequel_model_class(object)
|
||||||
result = object.db_schema.inject({}) { |h, (name, data)| h.merge(name => data[:db_type]) }
|
data = object.db_schema.inject({}) { |h, (prop, defn)| h.merge(prop => defn[:db_type]) }
|
||||||
"class #{object} < #{object.superclass} " << awesome_hash(result)
|
name = "class #{awesome_simple(object.to_s, :class)}"
|
||||||
|
base = "< #{awesome_simple(object.superclass.to_s, :class)}"
|
||||||
|
|
||||||
|
[name, base, awesome_hash(data)].join(' ')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -63,7 +63,7 @@ module AwesomePrint
|
||||||
awesome_simple(o, type, @inspector)
|
awesome_simple(o, type, @inspector)
|
||||||
end
|
end
|
||||||
|
|
||||||
def awesome_simple(o, type, inspector)
|
def awesome_simple(o, type, inspector = @inspector)
|
||||||
AwesomePrint::Formatters::SimpleFormatter.new(o, type, inspector).format
|
AwesomePrint::Formatters::SimpleFormatter.new(o, type, inspector).format
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue