Class: TacoProfile
Overview
~/.taco_profile configures per-user interactions with taco a default .taco_profile exists at .taco/.taco_profile contrast with .taco/.tacorc
Instance Attribute Summary collapse
-
#columns ⇒ Object
readonly
Returns the value of attribute columns.
-
#filters ⇒ Object
readonly
Returns the value of attribute filters.
-
#sort_order ⇒ Object
readonly
Returns the value of attribute sort_order.
Instance Method Summary collapse
-
#initialize(text) ⇒ TacoProfile
constructor
A new instance of TacoProfile.
Constructor Details
#initialize(text) ⇒ TacoProfile
Returns a new instance of TacoProfile.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/taco/taco_profile.rb', line 8 def initialize(text) text ||= '' @sort_order, @columns, @filters = nil, nil, nil text.lines.each_with_index do |line, index| next if line =~ /^#/ || line =~ /^\s*$/ key, value = line.split(':', 2).map(&:strip) case key when 'sort' raise ArgumentError.new("sort defined more than once on line #{index+1}") if @sort_order @sort_order = value.split(',').map(&:to_sym) raise ArgumentError.new("Unknown Issue attribute in sort on line #{index+1}") unless @sort_order.all? { |attr| Issue.schema_attributes.include?(attr) } when 'filters' raise ArgumentError.new("filters defined more than once on line #{index+1}") if @filters @filters = value.split(/\s/) raise ArgumentError.new("Unknown Issue attribute in filters on line #{index+1}") unless @filters.all? { |token| attr, value = token.split(':'); Issue.schema_attributes.include?(attr.to_sym) } when 'columns' raise ArgumentError.new("columns defined more than once on line #{index+1}") if @columns @columns = value.split(',').map(&:to_sym) raise ArgumentError.new("Unknown Issue attribute in columns on line #{index+1}") unless @columns.all? do |attr| # FIXME: really? hard-code :short_id? there's got to be a better way. # attr == :short_id || Issue.schema_attributes.include?(attr) end else raise ArgumentError.new("Parse error on line #{index+1}") end end @sort_order ||= [ :created_at, :id ] @columns ||= [ :short_id, :priority, :summary ] @filters ||= [] end |
Instance Attribute Details
#columns ⇒ Object (readonly)
Returns the value of attribute columns.
6 7 8 |
# File 'lib/taco/taco_profile.rb', line 6 def columns @columns end |
#filters ⇒ Object (readonly)
Returns the value of attribute filters.
6 7 8 |
# File 'lib/taco/taco_profile.rb', line 6 def filters @filters end |
#sort_order ⇒ Object (readonly)
Returns the value of attribute sort_order.
6 7 8 |
# File 'lib/taco/taco_profile.rb', line 6 def sort_order @sort_order end |