Sha256: fabcbd188421ecbf46441d90ffe43bd398e394947a8f32996c83e9e229a1fd92

Contents?: true

Size: 893 Bytes

Versions: 1

Compression:

Stored size: 893 Bytes

Contents

require 'yaml'

# TrelloConfig
class TrelloConfig
  attr_accessor :project_name, :board_name, :default_list,
                :excludes, :todo_types, :file_types, :comment_style

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

  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

  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
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
totrello-1.0.0 lib/totrello/trello_config.rb