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
|
@ -1,7 +1,8 @@
|
|||
## master (unreleased)
|
||||
- ActiveRecord: #joins now show the columns #select'ed [@adrianomitre] - [#211]
|
||||
- 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
|
||||
- Refactoring by extracting formatters into their own classes [@waldyr] - [#237]
|
||||
|
@ -148,6 +149,7 @@
|
|||
[@clonezone]: https://github.com/clonezone
|
||||
[@cyberdelia]: https://github.com/cyberdelia
|
||||
[@gerrywastaken]: https://github.com/gerrywastaken
|
||||
[@ixti]: https://github.com/ixti
|
||||
[@jtnegrotto]: https://github.com/jtnegrotto
|
||||
[@kemmason]: https://github.com/kemmason
|
||||
[@maurogeorge]: https://github.com/maurogeorge
|
||||
|
|
|
@ -66,7 +66,11 @@ module AwesomePrint
|
|||
hash[c.name.to_sym] = c.type
|
||||
hash
|
||||
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
|
||||
|
|
|
@ -49,7 +49,10 @@ module AwesomePrint
|
|||
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
|
||||
|
||||
# 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
|
||||
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
|
||||
|
||||
# Format Mongoid Document object.
|
||||
|
|
|
@ -28,10 +28,15 @@ module AwesomePrint
|
|||
# Format 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|
|
||||
[field, (options[:type] || Object).to_s.underscore.to_sym]
|
||||
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
|
||||
|
||||
# Format NoBrainer Document object.
|
||||
|
|
|
@ -60,11 +60,10 @@ module AwesomePrint
|
|||
def awesome_ripple_document_class(object)
|
||||
return object.inspect if !defined?(::ActiveSupport::OrderedHash) || !object.respond_to?(:properties)
|
||||
|
||||
data = object.properties.inject(::ActiveSupport::OrderedHash.new) do |hash, (name, defn)|
|
||||
hash[name.to_sym] = defn.type.to_s.downcase.to_sym
|
||||
hash
|
||||
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
|
||||
|
|
|
@ -45,8 +45,11 @@ module AwesomePrint
|
|||
# Format Sequel Model class.
|
||||
#------------------------------------------------------------------------------
|
||||
def awesome_sequel_model_class(object)
|
||||
result = object.db_schema.inject({}) { |h, (name, data)| h.merge(name => data[:db_type]) }
|
||||
"class #{object} < #{object.superclass} " << awesome_hash(result)
|
||||
data = object.db_schema.inject({}) { |h, (prop, defn)| h.merge(prop => defn[:db_type]) }
|
||||
name = "class #{awesome_simple(object.to_s, :class)}"
|
||||
base = "< #{awesome_simple(object.superclass.to_s, :class)}"
|
||||
|
||||
[name, base, awesome_hash(data)].join(' ')
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ module AwesomePrint
|
|||
awesome_simple(o, type, @inspector)
|
||||
end
|
||||
|
||||
def awesome_simple(o, type, inspector)
|
||||
def awesome_simple(o, type, inspector = @inspector)
|
||||
AwesomePrint::Formatters::SimpleFormatter.new(o, type, inspector).format
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue