Class: Sidenotes::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/sidenotes/configuration.rb

Constant Summary collapse

VALID_FORMATS =
%i[yaml json].freeze
VALID_SECTIONS =
%i[columns indexes associations foreign_keys check_constraints metadata].freeze
DEFAULT_SECTIONS =
%i[columns indexes associations foreign_keys metadata].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



12
13
14
15
16
17
18
19
# File 'lib/sidenotes/configuration.rb', line 12

def initialize
  @output_directory = '.annotations'
  @format = :yaml
  @sections = DEFAULT_SECTIONS.dup
  @model_paths = ['app/models']
  @exclude_patterns = []
  @auto_generate_after_migrate = false
end

Instance Attribute Details

#auto_generate_after_migrateObject

Returns the value of attribute auto_generate_after_migrate.



10
11
12
# File 'lib/sidenotes/configuration.rb', line 10

def auto_generate_after_migrate
  @auto_generate_after_migrate
end

#exclude_patternsObject

Returns the value of attribute exclude_patterns.



10
11
12
# File 'lib/sidenotes/configuration.rb', line 10

def exclude_patterns
  @exclude_patterns
end

#formatObject

Returns the value of attribute format.



9
10
11
# File 'lib/sidenotes/configuration.rb', line 9

def format
  @format
end

#model_pathsObject

Returns the value of attribute model_paths.



10
11
12
# File 'lib/sidenotes/configuration.rb', line 10

def model_paths
  @model_paths
end

#output_directoryObject

Returns the value of attribute output_directory.



9
10
11
# File 'lib/sidenotes/configuration.rb', line 9

def output_directory
  @output_directory
end

#sectionsObject

Returns the value of attribute sections.



9
10
11
# File 'lib/sidenotes/configuration.rb', line 9

def sections
  @sections
end

Instance Method Details

#auto_generate_after_migrate?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/sidenotes/configuration.rb', line 21

def auto_generate_after_migrate?
  auto_generate_after_migrate || ENV['SIDENOTES_AUTO_GENERATE'] == 'true'
end

#file_extensionObject



53
54
55
56
57
58
59
# File 'lib/sidenotes/configuration.rb', line 53

def file_extension
  case @format
  when :yaml then 'yml'
  when :json then 'json'
  else raise ArgumentError, "Unknown format: #{@format}"
  end
end