Class: PolishGeeks::DevTools::ConfigManager

Inherits:
Object
  • Object
show all
Defined in:
lib/polish_geeks/dev_tools/config_manager.rb

Overview

Config manager which is able to check if config file exist either in local or application path

Examples:

config_manager = ConfigManager.new('rubocop.yml')
config_manager.present? = true
config_manager.path = /home/pg/project/.rubocop.yml

Instance Method Summary collapse

Constructor Details

#initialize(file_name) ⇒ ConfigManager

Returns a new instance of ConfigManager.



10
11
12
# File 'lib/polish_geeks/dev_tools/config_manager.rb', line 10

def initialize(file_name)
  @file_name = file_name
end

Instance Method Details

#pathString

If there is an application config file use that, if not check if local config file is available if not return nil

Examples:

/home/pg/project/.rubocop.yml

Returns:

  • (String)

    path to config file or nil



24
25
26
# File 'lib/polish_geeks/dev_tools/config_manager.rb', line 24

def path
  application? ? application_path : local_path
end

#present?Boolean

Returns true if there is a local or application config file present.

Returns:

  • (Boolean)

    true if there is a local or application config file present



15
16
17
# File 'lib/polish_geeks/dev_tools/config_manager.rb', line 15

def present?
  application? || local?
end