Class: Docs::Rails::EntriesFilter

Inherits:
Docs::Rdoc::EntriesFilter show all
Defined in:
lib/docs/filters/rails/entries.rb

Constant Summary collapse

TYPE_BY_NAME_MATCHES =
{
/Assertions|::Test|Fixture/                          => 'Testing',
/\AActiveRecord.+mysql/i                             => 'ActiveRecord/MySQL',
/\AActiveRecord.+postgresql/i                        => 'ActiveRecord/PostgreSQL',
/\AActiveRecord.+sqlite/i                            => 'ActiveRecord/SQLite',
/\AActiveRecord.+Assoc/                              => 'ActiveRecord/Associations',
/\AActiveRecord.+Attribute/                          => 'ActiveRecord/Attributes',
/\AActiveRecord.+ConnectionAdapters/                 => 'ActiveRecord/Connection',
/\AActiveSupport.+(Subscriber|Notifications)/        => 'ActiveSupport/Instrumentation',
/\A(False|Nil|True)Class/                            => 'Boolean' }
TYPE_BY_NAME_STARTS_WITH =
{
'ActionDispatch::Integration' => 'Testing',
'ActionDispatch::Request'     => 'ActionDispatch/Request',
'ActionDispatch::Response'    => 'ActionDispatch/Response',
'ActionDispatch::Routing'     => 'ActionDispatch/Routing',
'ActionView::Helpers'         => 'ActionView/Helpers',
'ActiveModel::Errors'         => 'ActiveModel/Validation',
'ActiveModel::Valid'          => 'ActiveModel/Validation',
'ActiveRecord::Batches'       => 'ActiveModel/Query',
'ActiveRecord::Calculations'  => 'ActiveModel/Query',
'ActiveRecord::Connection'    => 'ActiveModel/Connection',
'ActiveRecord::FinderMethods' => 'ActiveModel/Query',
'ActiveRecord::Query'         => 'ActiveModel/Query',
'ActiveRecord::Relation'      => 'ActiveModel/Relation',
'ActiveRecord::Result'        => 'ActiveModel/Connection',
'ActiveRecord::Scoping'       => 'ActiveModel/Query',
'ActiveRecord::SpawnMethods'  => 'ActiveModel/Query',
'ActiveSupport::Cach'         => 'ActiveSupport/Caching',
'ActiveSupport::Inflector'    => 'ActiveSupport/Inflector',
'ActiveSupport::Time'         => 'ActiveSupport/TimeZones',
'Rails::Application'          => 'Rails/Application',
'Rails::Engine'               => 'Rails/Engine',
'Rails::Railtie'              => 'Rails/Railtie' }

Constants inherited from Filter

Filter::SCHEME_RGX

Instance Method Summary collapse

Methods inherited from Docs::Rdoc::EntriesFilter

#get_name

Methods inherited from EntriesFilter

#build_entries, #build_entry, #call, #default_entry, #entries, #get_name, #name, #path, #type

Methods inherited from Filter

#absolute_url_string?, #at_css, #at_xpath, #base_url, #css, #current_url, #fragment_url_string?, #initial_page?, #parse_html, #relative_url_string?, #root_page?, #root_path, #root_url, #slug, #subpath, #subpath_to, #xpath

Instance Method Details

#additional_entriesObject


61
62
63
# File 'lib/docs/filters/rails/entries.rb', line 61

def additional_entries
  skip? ? [] : super
end

#get_typeObject


39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/docs/filters/rails/entries.rb', line 39

def get_type
  parent = at_css('.meta-parent').try(:content).to_s

  if [name, parent].any? { |str| str.end_with?('Error') || str.end_with?('Exception') }
    return 'Errors'
  end

  TYPE_BY_NAME_MATCHES.each_pair do |key, value|
    return value if name =~ key
  end

  TYPE_BY_NAME_STARTS_WITH.each_pair do |key, value|
    return value if name.start_with?(key)
  end

  super
end

#include_default_entry?Boolean


57
58
59
# File 'lib/docs/filters/rails/entries.rb', line 57

def include_default_entry?
  super && !skip?
end

#skip?Boolean


65
66
67
# File 'lib/docs/filters/rails/entries.rb', line 65

def skip?
  @skip ||= !css('p').any? { |node| node.content.present? }
end