class Develry::Config

Abstract base class of tool configuration

Constants

DEFAULT_CONFIG

Represent no configuration

Attributes

project[R]

Return project

@return [Project]

@api private

Public Class Methods

new(project) click to toggle source

Initialize object

@return [Project]

@api private

# File lib/develry/config.rb, line 44
def initialize(project)
  @project = project
end

Private Class Methods

attribute(name, *default) click to toggle source

Declare an attribute

@param [Symbol] name

@yieldreturn [Object]

the default value to use

@api private

@return [self]

# File lib/develry/config.rb, line 23
def self.attribute(name, *default)
  define_method(name) do
    raw.fetch(name.to_s, *default)
  end
end

Public Instance Methods

config_file() click to toggle source

Return config path

@return [String]

@api private

# File lib/develry/config.rb, line 54
def config_file
  @config_file ||= project.config_dir.join(self.class::FILE).freeze
end
enabled?() click to toggle source

Test if the task is enabled

If there is no config file, and no sensible defaults, then the rake task should become disabled.

@return [Boolean]

@api private

# File lib/develry/config.rb, line 67
def enabled?
  ! raw.equal?(DEFAULT_CONFIG)
end

Private Instance Methods

raw() click to toggle source

Return raw data

@return [Hash]

@api private

# File lib/develry/config.rb, line 79
def raw
  @raw ||= yaml_config || DEFAULT_CONFIG
end
yaml_config() click to toggle source

Return the raw config data from a yaml file

@return [Hash]

returned if the yaml file is found

@return [nil]

returned if the yaml file is not found

@api private

# File lib/develry/config.rb, line 92
def yaml_config
  config_file = self.config_file
  YAML.load_file(config_file).freeze if config_file.file?
end