Sha256: 22fe254f3dfe859fd1b72e8e77a5e2c101eeff98da2a396a268f023796e52ef5

Contents?: true

Size: 1.24 KB

Versions: 18

Compression:

Stored size: 1.24 KB

Contents

module Doing
  # State queries for a Doing entry
  module ItemState
    ##
    ## Test if item has a @done tag
    ##
    ## @return     [Boolean] true item has @done tag
    ##
    def finished?
      tags?('done')
    end

    ##
    ## Test if item does not contain @done tag
    ##
    ## @return     [Boolean] true if item is missing @done tag
    ##
    def unfinished?
      tags?('done', negate: true)
    end

    ##
    ## Test if item is included in never_finish config and
    ## thus should not receive a @done tag
    ##
    ## @return     [Boolean] item should receive @done tag
    ##
    def should_finish?
      should?('never_finish')
    end

    ##
    ## Test if item is included in never_time config and
    ## thus should not receive a date on the @done tag
    ##
    ## @return     [Boolean] item should receive @done date
    ##
    def should_time?
      should?('never_time')
    end

    private

    def should?(key)
      config = Doing.settings
      return true unless config[key].is_a?(Array)

      config[key].each do |tag|
        if tag =~ /^@/
          return false if tags?(tag.sub(/^@/, '').downcase)
        elsif section.downcase == tag.downcase
          return false
        end
      end

      true
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
doing-2.1.62 lib/doing/item/state.rb
doing-2.1.61 lib/doing/item/state.rb
doing-2.1.60 lib/doing/item/state.rb
doing-2.1.58 lib/doing/item/state.rb
doing-2.1.57 lib/doing/item/state.rb
doing-2.1.56 lib/doing/item/state.rb
doing-2.1.55 lib/doing/item/state.rb
doing-2.1.54 lib/doing/item/state.rb
doing-2.1.52 lib/doing/item/state.rb
doing-2.1.49 lib/doing/item/state.rb
doing-2.1.48 lib/doing/item/state.rb
doing-2.1.47 lib/doing/item/state.rb
doing-2.1.46 lib/doing/item/state.rb
doing-2.1.45 lib/doing/item/state.rb
doing-2.1.44 lib/doing/item/state.rb
doing-2.1.43 lib/doing/item/state.rb
doing-2.1.42 lib/doing/item/state.rb
doing-2.1.41 lib/doing/item/state.rb