Class: Repository::ConfigStore

Inherits:
Object
  • Object
show all
Defined in:
lib/devlogs/repository/config_store.rb

Constant Summary collapse

CONFIG_FILE =
".devlogs.config.yml"
DATA_FILE =
".devlogs.data.yml"
ISSUE_TEMPLATE_FILE =
".issue_template.erb.md"
LOG_TEMPLATE_FILE =
".log_template.erb.md"
ISSUE_DIR =
"issues"
DEFAULT_DIRECTORY_PATH =
"."
DEFAULT_DIRECTORY_NAME =
".devlogs"

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(dir: File.join(DEFAULT_DIRECTORY_PATH, DEFAULT_DIRECTORY_NAME)) ⇒ ConfigStore

Returns a new instance of ConfigStore.



22
23
24
# File 'lib/devlogs/repository/config_store.rb', line 22

def initialize(dir: File.join(DEFAULT_DIRECTORY_PATH, DEFAULT_DIRECTORY_NAME))
  @dir = dir
end

Instance Attribute Details

#dirObject (readonly)

Returns the value of attribute dir.



11
12
13
# File 'lib/devlogs/repository/config_store.rb', line 11

def dir
  @dir
end

Class Method Details

.load_from(path = File.join(DEFAULT_DIRECTORY_PATH, DEFAULT_DIRECTORY_NAME)) ⇒ Object

Initialization utility method



79
80
81
82
83
84
85
# File 'lib/devlogs/repository/config_store.rb', line 79

def load_from(path = File.join(DEFAULT_DIRECTORY_PATH, DEFAULT_DIRECTORY_NAME))
  exists = File.exist?(path)

  raise "no repository found #{path}" unless exists

  new(dir: path)
end

Instance Method Details

#data_file_pathObject

Retrieves the data file



35
36
37
# File 'lib/devlogs/repository/config_store.rb', line 35

def data_file_path
  File.join(@dir, DATA_FILE)
end

#file_pathObject

Retrieves .devlogs.config.yml file path



44
45
46
# File 'lib/devlogs/repository/config_store.rb', line 44

def file_path
  File.join(@dir, CONFIG_FILE)
end

#issue_dir_pathObject

Issue directory path



71
72
73
# File 'lib/devlogs/repository/config_store.rb', line 71

def issue_dir_path
  File.join(@dir, ISSUE_DIR)
end

#issue_template_file_pathObject

The issue template file path:



62
63
64
# File 'lib/devlogs/repository/config_store.rb', line 62

def issue_template_file_path
  File.join(@dir, ISSUE_TEMPLATE_FILE)
end

#template_file_pathObject

The template File

FIXME: rename to log_template_file_path



53
54
55
# File 'lib/devlogs/repository/config_store.rb', line 53

def template_file_path
  File.join(@dir, LOG_TEMPLATE_FILE)
end

#valuesObject



26
27
28
# File 'lib/devlogs/repository/config_store.rb', line 26

def values
  @values ||= load_values_from_config_file
end