Sha256: dceaab76d14290f206816164e672d4d41036c57140f51572b049032d6af59def

Contents?: true

Size: 1.23 KB

Versions: 1

Compression:

Stored size: 1.23 KB

Contents

require 'yaml'

class TotrelloConfig
  @project_name
  @board_name
  @default_list
  @excludes
  @todo_types
  @file_types
  @comment_style

  def initialize(directory)
    read_config(directory)
    defaults(directory)
  end

  def build_hash
    {
        :project_name => @project_name,
        :board_name   => @board_name,
        :default_list => @default_list,
        :excludes     => @excludes,
        :todo_types   => @todo_types,
        :file_types   => @file_types,
        :comment_style   => @comment_style
    }
  end

  private
    def read_config(directory)

      totrello_config_file = File.join("#{directory}/", ".totrello.yml")
      trello_yml = Dir.glob(totrello_config_file)[0]

      unless trello_yml.nil?
          config = YAML.load_file(trello_yml )
          config['totrello'].each { |key, value| instance_variable_set("@#{key}", value) }
      end

    end

    def defaults(directory)
      @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

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
totrello-0.3.04 lib/totrello_config.rb