Module: Rails::Annotate::Solargraph

Extended by:
TerminalColors
Defined in:
lib/rails/annotate/solargraph.rb,
lib/rails/annotate/solargraph/model.rb,
lib/rails/annotate/solargraph/scope.rb,
lib/rails/annotate/solargraph/version.rb,
lib/rails/annotate/solargraph/configuration.rb,
lib/rails/annotate/solargraph/terminal_colors.rb

Defined Under Namespace

Modules: TerminalColors Classes: Configuration, Error, Model, Scope

Constant Summary collapse

MODEL_DIR =

Returns:

  • (String)
'app/models'
RAKEFILE_NAME =

Returns:

  • (String)
'rails_annotate_solargraph.rake'
CONFIG =

Returns:

Configuration.new
VALID_MODIFICATION_METHODS =

Returns:

  • (Set<Symbol>)
::Set[:annotate, :remove_annotation].freeze
SCHEMA_CLASS_NAME =

Returns:

  • (String)
'AnnotateSolargraphSchema'
SOLARGRAPH_FILE_NAME =

Returns:

  • (String)
'.solargraph.yml'
SOLARGRAPH_FILE_PATH =

Returns:

  • (String)
SOLARGRAPH_FILE_NAME
SCHEMA_FILE_NAME =

Returns:

  • (String)
'.annotate_solargraph_schema'
SCHEMA_RAILS_PATH =

Returns:

  • (String)
SCHEMA_FILE_NAME
VERSION =
'0.5.5'

Constants included from TerminalColors

TerminalColors::MAP

Class Method Summary collapse

Methods included from TerminalColors

error, error_string, title, title_string, with_style, with_styles

Class Method Details

.configure {|| ... } ⇒ Object

Yield Parameters:



56
57
58
# File 'lib/rails/annotate/solargraph.rb', line 56

def configure
  yield(CONFIG)
end

.generateArray<String> Also known as: call

Returns Array of changed files.

Returns:

  • (Array<String>)

    Array of changed files.



43
44
45
46
47
# File 'lib/rails/annotate/solargraph.rb', line 43

def generate
  title 'Generating model schema annotations'
  create_schema_file
  modify_models :annotate
end

.model_classesArray<ActiveRecord::Base>

Returns:



63
64
65
66
67
68
69
70
71
72
73
# File 'lib/rails/annotate/solargraph.rb', line 63

def model_classes
  @model_classes ||= begin
    base_abstract_class = begin
      ::ApplicationRecord
    rescue
      ::ActiveRecord::Base
    end

    extract_subclasses(base_abstract_class).sort_by(&:name)
  end
end

.removeArray<String>

Returns Array of changed files.

Returns:

  • (Array<String>)

    Array of changed files.



50
51
52
53
# File 'lib/rails/annotate/solargraph.rb', line 50

def remove
  title 'Removing model schema annotations'
  modify_models :remove_annotation
end