Class: Bullematic::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/bullematic/configuration.rb,
sig/generated/bullematic/configuration.rbs

Constant Summary collapse

VALID_FIX_STRATEGIES =

Signature:

  • Array[Symbol]

Returns:

  • (Array[Symbol])
%i[includes preload eager_load].freeze
DEFAULTS =

Returns:

  • (Object)
{ #: Hash[Symbol, untyped]
  enabled: true,
  auto_fix: false,
  target_paths: %w[app/controllers app/models app/services],
  skip_paths: [],
  dry_run: true,
  backup: true,
  fix_strategy: :includes,
  logger: nil,
  debug: false
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

: () -> void



49
50
51
# File 'lib/bullematic/configuration.rb', line 49

def initialize
  DEFAULTS.each { |key, value| public_send(:"#{key}=", value.dup) }
end

Instance Attribute Details

#auto_fixObject

RBS:

  • attr_accessor enabled: bool
    attr_accessor auto_fix: bool
    attr_accessor target_paths: Array[String]
    attr_accessor skip_paths: Array[String]
    attr_accessor dry_run: bool
    attr_accessor backup: bool
    attr_accessor fix_strategy: Symbol
    attr_accessor debug: bool
    attr_writer logger: Logger?

Returns:

  • (Object)


43
44
45
# File 'lib/bullematic/configuration.rb', line 43

def auto_fix
  @auto_fix
end

#backupObject

RBS:

  • attr_accessor enabled: bool
    attr_accessor auto_fix: bool
    attr_accessor target_paths: Array[String]
    attr_accessor skip_paths: Array[String]
    attr_accessor dry_run: bool
    attr_accessor backup: bool
    attr_accessor fix_strategy: Symbol
    attr_accessor debug: bool
    attr_writer logger: Logger?

Returns:

  • (Object)


43
44
45
# File 'lib/bullematic/configuration.rb', line 43

def backup
  @backup
end

#debugObject

RBS:

  • attr_accessor enabled: bool
    attr_accessor auto_fix: bool
    attr_accessor target_paths: Array[String]
    attr_accessor skip_paths: Array[String]
    attr_accessor dry_run: bool
    attr_accessor backup: bool
    attr_accessor fix_strategy: Symbol
    attr_accessor debug: bool
    attr_writer logger: Logger?

Returns:

  • (Object)


43
44
45
# File 'lib/bullematic/configuration.rb', line 43

def debug
  @debug
end

#dry_runObject

RBS:

  • attr_accessor enabled: bool
    attr_accessor auto_fix: bool
    attr_accessor target_paths: Array[String]
    attr_accessor skip_paths: Array[String]
    attr_accessor dry_run: bool
    attr_accessor backup: bool
    attr_accessor fix_strategy: Symbol
    attr_accessor debug: bool
    attr_writer logger: Logger?

Returns:

  • (Object)


43
44
45
# File 'lib/bullematic/configuration.rb', line 43

def dry_run
  @dry_run
end

#enabledObject

RBS:

  • attr_accessor enabled: bool
    attr_accessor auto_fix: bool
    attr_accessor target_paths: Array[String]
    attr_accessor skip_paths: Array[String]
    attr_accessor dry_run: bool
    attr_accessor backup: bool
    attr_accessor fix_strategy: Symbol
    attr_accessor debug: bool
    attr_writer logger: Logger?

Returns:

  • (Object)


43
44
45
# File 'lib/bullematic/configuration.rb', line 43

def enabled
  @enabled
end

#fix_strategyObject

Returns the value of attribute fix_strategy.

Returns:

  • (Object)


45
46
47
# File 'lib/bullematic/configuration.rb', line 45

def fix_strategy
  @fix_strategy
end

#loggerLogger

: () -> Logger

Returns:



54
55
56
# File 'lib/bullematic/configuration.rb', line 54

def logger
  @logger ||= default_logger
end

#skip_pathsObject

RBS:

  • attr_accessor enabled: bool
    attr_accessor auto_fix: bool
    attr_accessor target_paths: Array[String]
    attr_accessor skip_paths: Array[String]
    attr_accessor dry_run: bool
    attr_accessor backup: bool
    attr_accessor fix_strategy: Symbol
    attr_accessor debug: bool
    attr_writer logger: Logger?

Returns:

  • (Object)


43
44
45
# File 'lib/bullematic/configuration.rb', line 43

def skip_paths
  @skip_paths
end

#target_pathsObject

RBS:

  • attr_accessor enabled: bool
    attr_accessor auto_fix: bool
    attr_accessor target_paths: Array[String]
    attr_accessor skip_paths: Array[String]
    attr_accessor dry_run: bool
    attr_accessor backup: bool
    attr_accessor fix_strategy: Symbol
    attr_accessor debug: bool
    attr_writer logger: Logger?

Returns:

  • (Object)


43
44
45
# File 'lib/bullematic/configuration.rb', line 43

def target_paths
  @target_paths
end

Instance Method Details

#default_loggerLogger

: () -> Logger

Returns:



69
70
71
72
73
74
75
# File 'lib/bullematic/configuration.rb', line 69

def default_logger
  if defined?(Rails) && Rails.respond_to?(:root) && Rails.root
    ::Logger.new(Rails.root.join("log", "bullematic.log"))
  else
    ::Logger.new($stdout)
  end
end