Class: DroppableTable::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/droppable_table/config.rb

Constant Summary collapse

DEFAULT_CONFIG_FILE =
"droppable_table.yml"
RAILS_INTERNAL_TABLES_FILE =
File.expand_path("../../config/rails_internal_tables.yml", __dir__)
KNOWN_GEMS_FILE =
File.expand_path("../../config/known_gems.yml", __dir__)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config_file_path = nil) ⇒ Config

Returns a new instance of Config.



14
15
16
17
18
19
20
21
22
# File 'lib/droppable_table/config.rb', line 14

def initialize(config_file_path = nil)
  @config_file_path = config_file_path || DEFAULT_CONFIG_FILE
  @excluded_tables = Set.new
  @excluded_gems = Set.new
  @strict_mode = {}

  load_default_config
  load_user_config if File.exist?(@config_file_path)
end

Instance Attribute Details

#config_file_pathObject (readonly)

Returns the value of attribute config_file_path.



12
13
14
# File 'lib/droppable_table/config.rb', line 12

def config_file_path
  @config_file_path
end

#excluded_gemsObject (readonly)

Returns the value of attribute excluded_gems.



12
13
14
# File 'lib/droppable_table/config.rb', line 12

def excluded_gems
  @excluded_gems
end

#excluded_tablesObject (readonly)

Returns the value of attribute excluded_tables.



12
13
14
# File 'lib/droppable_table/config.rb', line 12

def excluded_tables
  @excluded_tables
end

#strict_modeObject (readonly)

Returns the value of attribute strict_mode.



12
13
14
# File 'lib/droppable_table/config.rb', line 12

def strict_mode
  @strict_mode
end

Instance Method Details

#all_excluded_tablesObject



32
33
34
# File 'lib/droppable_table/config.rb', line 32

def all_excluded_tables
  Set.new(excluded_tables) + Set.new(rails_internal_tables) + gem_excluded_tables
end

#baseline_fileObject



40
41
42
# File 'lib/droppable_table/config.rb', line 40

def baseline_file
  strict_mode["baseline_file"] || ".droppable_table_baseline.json"
end

#known_gem_tablesObject



28
29
30
# File 'lib/droppable_table/config.rb', line 28

def known_gem_tables
  @known_gem_tables ||= load_yaml_file(KNOWN_GEMS_FILE)
end

#rails_internal_tablesObject



24
25
26
# File 'lib/droppable_table/config.rb', line 24

def rails_internal_tables
  @rails_internal_tables ||= load_yaml_file(RAILS_INTERNAL_TABLES_FILE)
end

#strict_mode_enabled?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/droppable_table/config.rb', line 36

def strict_mode_enabled?
  strict_mode["enabled"] == true
end