checkoff 0.165.0 → 0.166.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f99bede3359ea38fb1343dabad531fa83df0890f301bfab723f5c65ffc9eb2d7
4
- data.tar.gz: cf91f5f84ffdf059c37c1eddfad56e36af87562d63985c69760f0dbb7d54df3c
3
+ metadata.gz: c9cb05ee972b3a2f79c131e22fb0e690fb2d5df2497b6deb6086a1af3e66f968
4
+ data.tar.gz: 75db9682d91825259ce86276e820c2b45742943a0346728d0c4eb4a8316e93a7
5
5
  SHA512:
6
- metadata.gz: d5ff068f85a90f941f7b60cdb938968e0a6311082ea2b95d0753ee2f6bd1da258c06297a105afe97a6e4b9c48f9b91937a07b592cbc76488b99e1588178d9844
7
- data.tar.gz: 4d80c6ea635bfd686c09a6acf6fab8fb7a11d519223b1f80fd8b0e5e0cae58a4cbfe450b162c49044eca4e006cf96f8e6d8f12bc4aea56e972b463d72e27a875
6
+ metadata.gz: b47af68554c08cb0bfe4321a9ada6121b99ebf253cfdff749497def7f7afa9c0530bbb249b0b6b750b418def691ac3b3fae4521a777702fc674e291ffd916225
7
+ data.tar.gz: 37794f4d4a6ce253486fee8f1763436d1c301d5c65cfe5b60d2a01236992e093870d4c015e798866f7461d940894284d62ac00141cbd895d4c2c0cc496c0a248
data/Gemfile.lock CHANGED
@@ -12,7 +12,7 @@ GIT
12
12
  PATH
13
13
  remote: .
14
14
  specs:
15
- checkoff (0.165.0)
15
+ checkoff (0.166.0)
16
16
  activesupport
17
17
  asana (> 0.10.0)
18
18
  cache_method
@@ -10,12 +10,18 @@ module Checkoff
10
10
  # @param project [Asana::Resources::Project]
11
11
  # @param projects [Checkoff::Projects]
12
12
  # @param custom_fields [Checkoff::CustomFields]
13
+ # @param workspaces [Checkoff::Workspaces]
14
+ # @param portfolios [Checkoff::Portfolios]
13
15
  def initialize(project:,
14
16
  projects: Checkoff::Projects.new,
15
- custom_fields: Checkoff::CustomFields.new)
17
+ custom_fields: Checkoff::CustomFields.new,
18
+ workspaces: Checkoff::Workspaces.new,
19
+ portfolios: Checkoff::Portfolios.new)
16
20
  @item = project
17
21
  @projects = projects
18
22
  @custom_fields = custom_fields
23
+ @workspaces = workspaces
24
+ @portfolios = portfolios
19
25
  super()
20
26
  end
21
27
 
@@ -38,7 +44,10 @@ module Checkoff
38
44
 
39
45
  # @return [Hash]
40
46
  def initializer_kwargs
41
- { projects: projects, custom_fields: custom_fields }
47
+ {
48
+ projects: projects, custom_fields: custom_fields,
49
+ workspaces: workspaces, portfolios: portfolios
50
+ }
42
51
  end
43
52
 
44
53
  # @return [Asana::Resources::Project]
@@ -47,5 +56,9 @@ module Checkoff
47
56
  attr_reader :projects
48
57
  # @return [Checkoff::CustomFields]
49
58
  attr_reader :custom_fields
59
+ # @return [Checkoff::Workspaces]
60
+ attr_reader :workspaces
61
+ # @return [Checkoff::Portfolios]
62
+ attr_reader :portfolios
50
63
  end
51
64
  end
@@ -1,9 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'checkoff/internal/logging'
4
+
3
5
  module Checkoff
4
6
  module SelectorClasses
5
7
  # Base class to evaluate types of selector functions
6
8
  class FunctionEvaluator
9
+ include Logging
10
+
7
11
  # @sg-ignore
8
12
  # @param _index [Integer]
9
13
  def evaluate_arg?(_index)
@@ -9,11 +9,17 @@ module Checkoff
9
9
  class FunctionEvaluator < ::Checkoff::SelectorClasses::FunctionEvaluator
10
10
  # @param selector [Array<(Symbol, Array)>,String]
11
11
  # @param projects [Checkoff::Projects]
12
+ # @param portfolios [Checkoff::Portfolios]
13
+ # @param workspaces [Checkoff::Workspaces]
12
14
  def initialize(selector:,
13
15
  projects:,
16
+ portfolios:,
17
+ workspaces:,
14
18
  **_kwargs)
15
19
  @selector = selector
16
20
  @projects = projects
21
+ @portfolios = portfolios
22
+ @workspaces = workspaces
17
23
  super()
18
24
  end
19
25
 
@@ -36,6 +36,29 @@ module Checkoff
36
36
  @projects.project_ready?(project, period: period)
37
37
  end
38
38
  end
39
+
40
+ # :in_portfolio_named? function
41
+ class InPortfolioNamedPFunctionEvaluator < FunctionEvaluator
42
+ FUNCTION_NAME = :in_portfolio_named?
43
+
44
+ def matches?
45
+ fn?(selector, FUNCTION_NAME)
46
+ end
47
+
48
+ # @param project [Asana::Resources::Project]
49
+ # @param portfolio_name [String]
50
+ # @param workspace_name [String, nil]
51
+ # @param extra_project_fields [Array<String>]
52
+ #
53
+ # @return [Boolean]
54
+ def evaluate(project, portfolio_name, workspace_name: nil, extra_project_fields: [])
55
+ workspace_name ||= project.workspace&.name
56
+ workspace_name ||= @workspaces.default_workspace.name
57
+ projects = @portfolios.projects_in_portfolio(workspace_name, portfolio_name,
58
+ extra_project_fields: extra_project_fields)
59
+ projects.any? { |p| p.name == project.name }
60
+ end
61
+ end
39
62
  end
40
63
  end
41
64
  end
@@ -23,17 +23,20 @@ module Checkoff
23
23
  # @param workspaces [Checkoff::Workspaces]
24
24
  # @param projects [Checkoff::Projects]
25
25
  # @param custom_fields [Checkoff::CustomFields]
26
+ # @param portfolios [Checkoff::Portfolios]
26
27
  # @param clients [Checkoff::Clients]
27
28
  # @param client [Asana::Client]
28
29
  def initialize(config: Checkoff::Internal::ConfigLoader.load(:asana),
29
30
  workspaces: Checkoff::Workspaces.new(config: config),
30
31
  projects: Checkoff::Projects.new(config: config),
31
32
  custom_fields: Checkoff::CustomFields.new(config: config),
33
+ portfolios: Checkoff::Portfolios.new(config: config),
32
34
  clients: Checkoff::Clients.new(config: config),
33
35
  client: clients.client)
34
36
  @workspaces = workspaces
35
37
  @projects = projects
36
38
  @custom_fields = custom_fields
39
+ @portfolios = portfolios
37
40
  @client = client
38
41
  end
39
42
 
@@ -42,7 +45,8 @@ module Checkoff
42
45
  # project details. Examples: [:tag, 'foo'] [:not, [:tag, 'foo']] [:tag, 'foo']
43
46
  # @return [Boolean]
44
47
  def filter_via_project_selector(project, project_selector)
45
- evaluator = ProjectSelectorEvaluator.new(project: project, projects: projects, custom_fields: custom_fields)
48
+ evaluator = ProjectSelectorEvaluator.new(project: project, projects: projects, custom_fields: custom_fields,
49
+ workspaces: workspaces, portfolios: portfolios)
46
50
  evaluator.evaluate(project_selector)
47
51
  end
48
52
 
@@ -57,6 +61,9 @@ module Checkoff
57
61
  # @return [Checkoff::CustomFields]
58
62
  attr_reader :custom_fields
59
63
 
64
+ # @return [Checkoff::Portfolios]
65
+ attr_reader :portfolios
66
+
60
67
  # @return [Asana::Client]
61
68
  attr_reader :client
62
69
 
@@ -3,5 +3,5 @@
3
3
  # Command-line and gem client for Asana (unofficial)
4
4
  module Checkoff
5
5
  # Version of library
6
- VERSION = '0.165.0'
6
+ VERSION = '0.166.0'
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: checkoff
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.165.0
4
+ version: 0.166.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vince Broz
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-12-29 00:00:00.000000000 Z
11
+ date: 2023-12-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport