Class: TrelloConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/totrello/trello_config.rb

Overview

TrelloConfig

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(directory = Dir.pwd.to_s) ⇒ TrelloConfig

Returns a new instance of TrelloConfig.



8
9
10
11
# File 'lib/totrello/trello_config.rb', line 8

def initialize(directory = Dir.pwd.to_s)
  load_config("#{directory}/.totrello.yml")
  default_config(directory)
end

Instance Attribute Details

#board_nameObject

Returns the value of attribute board_name.



5
6
7
# File 'lib/totrello/trello_config.rb', line 5

def board_name
  @board_name
end

#comment_styleObject

Returns the value of attribute comment_style.



5
6
7
# File 'lib/totrello/trello_config.rb', line 5

def comment_style
  @comment_style
end

#default_listObject

Returns the value of attribute default_list.



5
6
7
# File 'lib/totrello/trello_config.rb', line 5

def default_list
  @default_list
end

#excludesObject

Returns the value of attribute excludes.



5
6
7
# File 'lib/totrello/trello_config.rb', line 5

def excludes
  @excludes
end

#file_typesObject

Returns the value of attribute file_types.



5
6
7
# File 'lib/totrello/trello_config.rb', line 5

def file_types
  @file_types
end

#project_nameObject

Returns the value of attribute project_name.



5
6
7
# File 'lib/totrello/trello_config.rb', line 5

def project_name
  @project_name
end

#todo_typesObject

Returns the value of attribute todo_types.



5
6
7
# File 'lib/totrello/trello_config.rb', line 5

def todo_types
  @todo_types
end

Instance Method Details

#default_config(directory = Dir.pwd.to_s) ⇒ Object



13
14
15
16
17
18
19
20
21
# File 'lib/totrello/trello_config.rb', line 13

def default_config(directory = Dir.pwd.to_s)
  @project_name  ||= directory.split('/').last
  @board_name    ||= directory.split('/').last
  @default_list  ||= 'To Do'
  @excludes      ||= Array(nil)
  @todo_types    ||= Array(['TODO', '#TODO', '#TODO:', 'TODO:'])
  @file_types    ||= Array(['.rb', '.erb'])
  @comment_style ||= Array(['#'])
end

#load_config(config_file) ⇒ Object



23
24
25
26
27
28
29
30
# File 'lib/totrello/trello_config.rb', line 23

def load_config(config_file)
  return if config_file == ''
  config_yaml = YAML.load_file(config_file)

  config_yaml['totrello'].each do |key, value|
    instance_variable_set("@#{key}", value)
  end
end