checkoff 0.39.0 → 0.39.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d4aa495392c511216d69ccb2d8ba6fa8efa6fb6a2466fad23dca9f8ee89ff9fa
4
- data.tar.gz: 0a48cd6720b49c8b7988ad8469f5b6ca3b89a5a2abeff47855386560a495c007
3
+ metadata.gz: e76d0cf72eb0426c6c69b27837d486f9cbe6de2f0782b10acc157f1b305941b1
4
+ data.tar.gz: effbabaaccae53bf8e3e843f509bba7477a24a34be44542906bf33e39a6a1f91
5
5
  SHA512:
6
- metadata.gz: 7c9535b045a9a35fd7a5df91d01f843d001c1f51761a638d50474c6437aa75781871d9afecb85664eb90a35e06a9b5be4511f8a943ca9928ab042c30fc7881e1
7
- data.tar.gz: 03ced5118890e61a65defd98e65cc3cde499861959da931287e6430cb3dc024215157584d45307269dd2fd0428f39bff54958d503520c7b5f823ad2de25c5d38
6
+ metadata.gz: a0d0e684e7811ab1ba2637117969e114b1c2c01e8e495f5dd2aa42255ff9d8ee1b67cf6368dcb2908ce1e70000b51c537492a5e812632b2c134ff0b632602510
7
+ data.tar.gz: b24402a8cbf03684397dddea78ba3d778cd96fbb9408a828853e737c65b787b7bb1170f14ff5f28d1efb7b599766e944df8f1e2ce27eff93f03e5b02736ccd86
data/Gemfile.lock CHANGED
@@ -12,7 +12,7 @@ GIT
12
12
  PATH
13
13
  remote: .
14
14
  specs:
15
- checkoff (0.39.0)
15
+ checkoff (0.39.2)
16
16
  activesupport
17
17
  asana (> 0.10.0)
18
18
  cache_method
@@ -74,7 +74,7 @@ GEM
74
74
  multi_json
75
75
  gli (2.21.0)
76
76
  hashdiff (1.0.1)
77
- i18n (1.13.0)
77
+ i18n (1.14.1)
78
78
  concurrent-ruby (~> 1.0)
79
79
  imagen (0.1.8)
80
80
  parser (>= 2.5, != 2.5.1.1)
@@ -14,6 +14,8 @@
14
14
  # def tasks; end
15
15
  # # @return [Asana::ProxiedResourceClasses::Workspace]
16
16
  # def workspaces; end
17
+ # # @return [Asana::ProxiedResourceClasses::Section]
18
+ # def sections; end
17
19
  # end
18
20
  # module Resources
19
21
  # class Task
@@ -43,10 +45,26 @@
43
45
  # # @param options [Hash] the request I/O options.
44
46
  # # @return [Asana::Resources::Task]
45
47
  # def find_by_id(id, options: {}); end
48
+ # # @param section [Asana::Resources::section]
49
+ # # @param options [Hash] the request I/O options.
50
+ # # @return [Array<Asana::Resources::Task>]
51
+ # def get_tasks(assignee: nil,
52
+ # project: nil,
53
+ # section: nil,
54
+ # workspace: nil,
55
+ # completed_since: nil,
56
+ # per_page: 20,
57
+ # modified_since: nil,
58
+ # options: {}); end
46
59
  # end
47
60
  # class Workspace
48
61
  # # @return [Array<Asana::Resources::Workspace>]
49
62
  # def find_all; end
50
63
  # end
64
+ # class Section
65
+ # # @param project_gid [String]
66
+ # # @return [Array<Asana::Resources::Section>]
67
+ # def get_sections_for_project(client, project_gid:, options: {}); end
68
+ # end
51
69
  # end
52
70
  # end
@@ -9,14 +9,23 @@ require_relative 'my_tasks'
9
9
  module Checkoff
10
10
  # Query different sections of Asana projects
11
11
  class Sections
12
+ # @!parse
13
+ # extend CacheMethod::ClassMethods
14
+
12
15
  MINUTE = 60
16
+ # @sg-ignore
13
17
  LONG_CACHE_TIME = MINUTE * 15
18
+ # @sg-ignore
14
19
  SHORT_CACHE_TIME = MINUTE * 5
15
20
 
16
21
  extend Forwardable
17
22
 
18
23
  attr_reader :projects, :workspaces, :time, :my_tasks
19
24
 
25
+ # @param client [Asana::Client]
26
+ # @param projects [Checkoff::Projects]
27
+ # @param workspaces [Checkoff::Workspaces]
28
+ # @param time [Class<Time>]
20
29
  def initialize(config: Checkoff::Internal::ConfigLoader.load(:asana),
21
30
  client: Checkoff::Clients.new(config: config).client,
22
31
  projects: Checkoff::Projects.new(config: config,
@@ -32,13 +41,22 @@ module Checkoff
32
41
  end
33
42
 
34
43
  # Returns a list of Asana API section objects for a given project
44
+ # @param workspace_name [String]
45
+ # @param project_name [String, Symbol]
46
+ #
47
+ # @return [Array<Asana::Resources::Section>]
35
48
  def sections_or_raise(workspace_name, project_name)
36
49
  project = project_or_raise(workspace_name, project_name)
50
+ # @sg-ignore
37
51
  client.sections.get_sections_for_project(project_gid: project.gid)
38
52
  end
39
53
 
40
54
  # Given a workspace name and project name, then provide a Hash of
41
55
  # tasks with section name -> task list of the uncompleted tasks
56
+ # @param workspace_name [String]
57
+ # @param project_name [String, Symbol]
58
+ # @param extra_fields [Array<String>]
59
+ # @return [Hash{[String, nil] => Array<Asana::Resources::Task>}]
42
60
  def tasks_by_section(workspace_name, project_name, extra_fields: [])
43
61
  project = project_or_raise(workspace_name, project_name)
44
62
  if project_name == :my_tasks
@@ -51,6 +69,14 @@ module Checkoff
51
69
  # XXX: Rename to section_tasks
52
70
  #
53
71
  # Pulls task objects from a specified section
72
+ #
73
+ # @param workspace_name [String]
74
+ # @param project_name [String, Symbol]
75
+ # @param section_name [String, nil]
76
+ # @param only_uncompleted [Boolean]
77
+ # @param extra_fields [Array<String>]
78
+ #
79
+ # @return [Array<Asana::Resources::Task>]
54
80
  def tasks(workspace_name, project_name, section_name,
55
81
  only_uncompleted: true,
56
82
  extra_fields: [])
@@ -64,30 +90,44 @@ module Checkoff
64
90
  cache_method :tasks, SHORT_CACHE_TIME
65
91
 
66
92
  # Pulls just names of tasks from a given section.
93
+ # @param workspace_name [String]
94
+ # @param project_name [String, Symbol]
95
+ # @param section_name [String, nil]
96
+ #
97
+ # @return [Array<String>]
67
98
  def section_task_names(workspace_name, project_name, section_name)
68
- tasks = tasks(workspace_name, project_name, section_name)
69
- tasks.map(&:name)
99
+ task_array = tasks(workspace_name, project_name, section_name)
100
+ task_array.map(&:name)
70
101
  end
71
102
  cache_method :section_task_names, SHORT_CACHE_TIME
72
103
 
104
+ # @param workspace_name [String]
105
+ # @param project_name [String, Symbol]
106
+ # @param section_name [String, nil]
107
+ #
108
+ # @return [Asana::Resources::Section]
73
109
  def section_or_raise(workspace_name, project_name, section_name)
74
- section = section(workspace_name, project_name, section_name)
75
- if section.nil?
110
+ s = section(workspace_name, project_name, section_name)
111
+ if s.nil?
76
112
  valid_sections = sections_or_raise(workspace_name, project_name).map(&:name)
77
113
 
78
114
  raise "Could not find section #{section_name} under project #{project_name} " \
79
115
  "under workspace #{workspace_name}. Valid sections: #{valid_sections}"
80
116
  end
81
- section
117
+ s
82
118
  end
83
119
  cache_method :section_or_raise, LONG_CACHE_TIME
84
120
 
85
121
  private
86
122
 
123
+ # @!attribute [r] client
124
+ # @return [Asana::Client]
87
125
  attr_reader :client
88
126
 
89
127
  # Given a project object, pull all tasks, then provide a Hash of
90
128
  # tasks with section name -> task list of the uncompleted tasks
129
+ # @param project [Asana::Resources::Project]
130
+ # @return [Hash<[String,nil], Array<Asana::Resources::Task>>]
91
131
  def tasks_by_section_for_project(project, extra_fields: [])
92
132
  raw_tasks = projects.tasks_from_project(project, extra_fields: extra_fields)
93
133
  active_tasks = projects.active_tasks(raw_tasks)
@@ -102,8 +142,12 @@ module Checkoff
102
142
  end
103
143
 
104
144
  # Given a list of tasks, pull a Hash of tasks with section name -> task list
145
+ # @param tasks [Array<Asana::Resources::Task>]
146
+ # @param project_gid [String]
147
+ # @return [Hash<[String,nil], Array<Asana::Resources::Task>>]
105
148
  def by_section(tasks, project_gid)
106
149
  by_section = {}
150
+ # @sg-ignore
107
151
  sections = client.sections.get_sections_for_project(project_gid: project_gid)
108
152
  sections.each { |section| by_section[section_key(section.name)] = [] }
109
153
  tasks.each { |task| file_task_by_section(by_section, task, project_gid) }
@@ -111,15 +155,25 @@ module Checkoff
111
155
  end
112
156
  cache_method :by_section, LONG_CACHE_TIME
113
157
 
158
+ # @param by_section [Hash{[String, nil] => Array<Asana::Resources::Task>}]
159
+ # @param task [Asana::Resources::Task]
160
+ # @param project_gid [String]
161
+ # @return [void]
114
162
  def file_task_by_section(by_section, task, project_gid)
163
+ # @type [Array<Hash>]
115
164
  membership = task.memberships.find { |m| m['project']['gid'] == project_gid }
116
165
  raise "Could not find task in project_gid #{project_gid}: #{task}" if membership.nil?
117
166
 
167
+ # @type [String, nil]
118
168
  current_section = section_key(membership['section']['name'])
119
169
 
170
+ # @sg-ignore
120
171
  by_section.fetch(current_section) << task
121
172
  end
122
173
 
174
+ # @param workspace_name [String]
175
+ # @param project_name [String, Symbol]
176
+ # @return [Asana::Resources::Project]
123
177
  def project_or_raise(workspace_name, project_name)
124
178
  project = projects.project(workspace_name, project_name)
125
179
  if project.nil?
@@ -27,6 +27,8 @@ module Checkoff
27
27
  end
28
28
 
29
29
  # pulls a Hash of subtasks broken out by section
30
+ # @param tasks [Array<Asana::Resources::Task>]
31
+ # @return [Hash<[nil,String], Array<Asana::Resources::Task>>]
30
32
  def by_section(tasks)
31
33
  current_section = nil
32
34
  by_section = { nil => [] }
@@ -14,7 +14,6 @@ require_relative 'tasks'
14
14
  module Checkoff
15
15
  # Filter lists of tasks using declarative selectors.
16
16
  class TaskSelectors
17
- # @type [Integer]
18
17
  MINUTE = 60
19
18
  HOUR = MINUTE * 60
20
19
  DAY = 24 * HOUR
@@ -30,8 +29,10 @@ module Checkoff
30
29
  @tasks = tasks
31
30
  end
32
31
 
32
+ # @param [Asana::Resources::Task] task
33
33
  # @param [Hash<Symbol, Object>] task_selector Filter based on
34
34
  # description. Examples: {tag: 'foo'} {:not {tag: 'foo'} (:tag 'foo')
35
+ # @return [Boolean]
35
36
  def filter_via_task_selector(task, task_selector)
36
37
  evaluator = TaskSelectorEvaluator.new(task: task, tasks: tasks)
37
38
  evaluator.evaluate(task_selector)
@@ -64,13 +64,13 @@ module Checkoff
64
64
  end
65
65
 
66
66
  # Pull a specific task by name
67
+ # @param task_gid [String]
68
+ # @param extra_fields [Array<String>]
67
69
  # @return [Asana::Resources::Task, nil]
68
70
  def task_by_gid(task_gid,
69
- only_uncompleted: true,
70
71
  extra_fields: [])
71
- options = projects.task_options
72
- options[:options][:fields] += extra_fields
73
- options[:completed_since] = '9999-12-01' if only_uncompleted
72
+ options = projects.task_options.fetch(:options, {})
73
+ options[:fields] += extra_fields
74
74
  client.tasks.find_by_id(task_gid, options: options)
75
75
  end
76
76
 
@@ -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.39.0'
6
+ VERSION = '0.39.2'
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.39.0
4
+ version: 0.39.2
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-05-29 00:00:00.000000000 Z
11
+ date: 2023-06-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport