Class: Checkoff::SectionSelectors

Inherits:
Object
  • Object
show all
Defined in:
lib/checkoff/section_selectors.rb

Overview

Filter lists of sections using declarative selectors.

Constant Summary collapse

MINUTE =
60
HOUR =
MINUTE * 60
DAY =
24 * HOUR
REALLY_LONG_CACHE_TIME =
HOUR * 1
LONG_CACHE_TIME =
MINUTE * 15
SHORT_CACHE_TIME =
MINUTE

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config: Checkoff::Internal::ConfigLoader.load(:asana), workspaces: Checkoff::Workspaces.new(config: config), sections: Checkoff::Sections.new(config: config), custom_fields: Checkoff::CustomFields.new(config: config), clients: Checkoff::Clients.new(config: config), client: clients.client) ⇒ SectionSelectors

Returns a new instance of SectionSelectors.

Parameters:

  • config (Hash<Symbol, Object>) (defaults to: Checkoff::Internal::ConfigLoader.load(:asana))
  • workspaces (Checkoff::Workspaces) (defaults to: Checkoff::Workspaces.new(config: config))
  • sections (Checkoff::Sections) (defaults to: Checkoff::Sections.new(config: config))
  • custom_fields (Checkoff::CustomFields) (defaults to: Checkoff::CustomFields.new(config: config))
  • clients (Checkoff::Clients) (defaults to: Checkoff::Clients.new(config: config))
  • client (Asana::Client) (defaults to: clients.client)


28
29
30
31
32
33
34
35
36
37
38
# File 'lib/checkoff/section_selectors.rb', line 28

def initialize(config: Checkoff::Internal::ConfigLoader.load(:asana),
               workspaces: Checkoff::Workspaces.new(config: config),
               sections: Checkoff::Sections.new(config: config),
               custom_fields: Checkoff::CustomFields.new(config: config),
               clients: Checkoff::Clients.new(config: config),
               client: clients.client)
  @workspaces = workspaces
  @sections = sections
  @custom_fields = custom_fields
  @client = client
end

Class Method Details

.runvoid

This method returns an undefined value.



69
70
71
72
73
74
75
# File 'lib/checkoff/section_selectors.rb', line 69

def run
  # workspace_name = ARGV[0] || raise('Please pass workspace name as first argument')
  # section_selector_name = ARGV[1] || raise('Please pass section_selector name as second argument')
  # section_selectors = Checkoff::SectionSelectors.new
  # section_selector = section_selectors.section_selector_or_raise(workspace_name, section_selector_name)
  # puts "Results: #{section_selector}"
end

Instance Method Details

#filter_via_section_selector(section, section_selector) ⇒ Boolean

Parameters:

  • section (Asana::Resources::Section)
  • section_selector (Array<(Symbol, Array)>)

    Filter based on section details. Examples: [:tag, ‘foo’] [:not, [:tag, ‘foo’]] [:tag, ‘foo’]

Returns:

  • (Boolean)


44
45
46
47
48
49
# File 'lib/checkoff/section_selectors.rb', line 44

def filter_via_section_selector(section, section_selector)
  # @sg-ignore
  evaluator = SectionSelectorEvaluator.new(section: section, sections: sections, custom_fields: custom_fields,
                                           client: client)
  evaluator.evaluate(section_selector)
end