Module: Card::Set::Right::Debug::HtmlFormat
- Extended by:
- AbstractFormat
- Defined in:
- tmpsets/set/mod018-developer/right/debug.rb
Instance Method Summary collapse
- #cache_comparison_table(subject) ⇒ Object
- #class_locations(klass) ⇒ Object
- #defined_methods(klass) ⇒ Object
- #section(title, content) ⇒ Object
-
#set_modules_accordion(subject) ⇒ Object
rubocop:disable AccessorMethodName.
- #set_patterns_breadcrumb(subject) ⇒ Object
-
#singleton_modules_list(subject) ⇒ Object
rubocop:enable AccessorMethodName.
Instance Method Details
#cache_comparison_table(subject) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'tmpsets/set/mod018-developer/right/debug.rb', line 54 def cache_comparison_table subject cache_card = Card.fetch(subject.key) db_card = Card.find_by_key(subject.key) return unless cache_card && db_card table( %i[name updated_at updater_id content inspect].map do |field| [field.to_s, h(cache_card.send(field)), h(db_card.send(field))] end, header: ["Field", "Cache Val", "Database Val"] ) end |
#class_locations(klass) ⇒ Object
75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'tmpsets/set/mod018-developer/right/debug.rb', line 75 def class_locations klass methods = defined_methods(klass) file_groups = methods.group_by { |sl| sl[0] } file_counts = file_groups.map do |file, sls| lines = sls.map { |sl| sl[1] } count = lines.size line = lines.min { file: file, count: count, line: line } end file_counts.sort_by! { |fc| fc[:count] } file_counts.map { |fc| [fc[:file], fc[:line]] } end |
#defined_methods(klass) ⇒ Object
88 89 90 91 92 93 94 95 |
# File 'tmpsets/set/mod018-developer/right/debug.rb', line 88 def defined_methods klass methods = klass.methods(false).map { |m| klass.method(m) } + klass.instance_methods(false).map { |m| klass.instance_method(m) } methods.map!(&:source_location) methods.compact! methods end |
#section(title, content) ⇒ Object
68 69 70 71 72 73 |
# File 'tmpsets/set/mod018-developer/right/debug.rb', line 68 def section title, content %( <h2>#{title}</h2> #{content} ) end |
#set_modules_accordion(subject) ⇒ Object
rubocop:disable AccessorMethodName
33 34 35 36 37 38 39 40 |
# File 'tmpsets/set/mod018-developer/right/debug.rb', line 33 def set_modules_accordion subject sets = subject.set_modules.each_with_object({}) do |sm, hash| ans = sm.ancestors ans.shift hash[sm.to_s] = ans end accordion_group sets end |
#set_patterns_breadcrumb(subject) ⇒ Object
42 43 44 45 |
# File 'tmpsets/set/mod018-developer/right/debug.rb', line 42 def subject links = subject.patterns.reverse.map { |pattern| link_to_card pattern.to_s } links end |
#singleton_modules_list(subject) ⇒ Object
rubocop:enable AccessorMethodName
48 49 50 51 52 |
# File 'tmpsets/set/mod018-developer/right/debug.rb', line 48 def singleton_modules_list subject all_mods = subject.singleton_class.ancestors.map(&:to_s) all_mods.shift list_group all_mods end |