Class: TrelloTool::Configuration
- Inherits:
-
Struct
- Object
- Struct
- TrelloTool::Configuration
show all
- Includes:
- DefaultConfiguration
- Defined in:
- lib/trello_tool/configuration.rb
Constant Summary
DefaultConfiguration::DEFAULTS, DefaultConfiguration::FILE_NAME
Instance Method Summary
collapse
Constructor Details
#initialize(root_dir = Dir.pwd) ⇒ Configuration
Returns a new instance of Configuration.
27
28
29
30
31
|
# File 'lib/trello_tool/configuration.rb', line 27
def initialize(root_dir = Dir.pwd)
@root_dir = root_dir
super(DefaultConfiguration::DEFAULTS)
load_from_config_file if config_file_exists?
end
|
Instance Method Details
#config_file_exists? ⇒ Boolean
40
41
42
|
# File 'lib/trello_tool/configuration.rb', line 40
def config_file_exists?
File.exist?(config_file)
end
|
#divider_list_matcher ⇒ Object
58
59
60
61
62
63
64
|
# File 'lib/trello_tool/configuration.rb', line 58
def divider_list_matcher
@divider_list_matcher ||= begin
pieces = divider_template.split(/(%s)/)
pieces = pieces.map { |piece| piece == "%s" ? ".+" : Regexp.escape(piece) }
Regexp.new("\\A#{pieces.join}\\Z")
end
end
|
#divider_list_name?(list_name) ⇒ Boolean
54
55
56
|
# File 'lib/trello_tool/configuration.rb', line 54
def divider_list_name?(list_name)
divider_list_matcher.match?(list_name)
end
|
#expected_list_names ⇒ Object
an ordered array of expected list names before the version and month names
49
50
51
52
|
# File 'lib/trello_tool/configuration.rb', line 49
def expected_list_names
@expected_list_names ||= initial_list_names + [todo_list_name,
doing_list_name] + done_list_names + [next_version_list_name]
end
|
#generate ⇒ Object
generates a file based on current settings
34
35
36
37
38
|
# File 'lib/trello_tool/configuration.rb', line 34
def generate
File.open(config_file, "w") do |f|
Psych.dump(to_h { |k, v| [k.to_s, v] }, f) end
end
|
#month_template=(template) ⇒ Object
74
75
76
77
|
# File 'lib/trello_tool/configuration.rb', line 74
def month_template=(template)
self.divider_template = template
puts "DEPRECATED: use divider_template instead of month_template"
end
|
#version_list_matcher ⇒ Object
70
71
72
|
# File 'lib/trello_tool/configuration.rb', line 70
def version_list_matcher
@version_list_matcher ||= Regexp.new("\\A#{format(version_template, '\d+[.]\d+[.]\d+')}")
end
|
#version_list_name?(list_name) ⇒ Boolean
66
67
68
|
# File 'lib/trello_tool/configuration.rb', line 66
def version_list_name?(list_name)
version_list_matcher.match?(list_name)
end
|