checkoff 0.37.0 → 0.39.0

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: 78eb26c757cafb9c92eb8e1127e454a3d05a0ed16548483cf0dceeca53c22114
4
- data.tar.gz: 39a81ddbcb197370af6e7328664ada5a26268cc434363f7291c518e3a7ce1621
3
+ metadata.gz: d4aa495392c511216d69ccb2d8ba6fa8efa6fb6a2466fad23dca9f8ee89ff9fa
4
+ data.tar.gz: 0a48cd6720b49c8b7988ad8469f5b6ca3b89a5a2abeff47855386560a495c007
5
5
  SHA512:
6
- metadata.gz: 1455835c137f7ed819cd6d5b774d360ee8d72b841a193955ad0b9df665a3f53568c515910b07d8221d6981a9e6f416a089add42025179c0f260cf8cc612740b5
7
- data.tar.gz: 31619893659ffe14a38183190f4d299c4354f5161ee41be0647eea5f4c45bc4f297d5051311d1e16fc1b300fdbf2ef6eefd88c21256e1ac0541e3b86312b446e
6
+ metadata.gz: 7c9535b045a9a35fd7a5df91d01f843d001c1f51761a638d50474c6437aa75781871d9afecb85664eb90a35e06a9b5be4511f8a943ca9928ab042c30fc7881e1
7
+ data.tar.gz: 03ced5118890e61a65defd98e65cc3cde499861959da931287e6430cb3dc024215157584d45307269dd2fd0428f39bff54958d503520c7b5f823ad2de25c5d38
@@ -49,7 +49,7 @@ module Overcommit
49
49
  message = error.sub("#{file_path}:#{lineno} - ",
50
50
  "#{file_path}:#{lineno}: ")
51
51
  # Emit the errors in the specified format
52
- Overcommit::Hook::Message.new(:error, file, lineno, message)
52
+ Overcommit::Hook::Message.new(:error, file, lineno.to_i, message)
53
53
  end
54
54
  end
55
55
  end
data/.overcommit.yml CHANGED
@@ -25,7 +25,6 @@ PreCommit:
25
25
  quiet: true
26
26
  RuboCop:
27
27
  enabled: true
28
- on_warn: fail # Treat all warnings as failures
29
28
  command: ['bundle', 'exec', 'rubocop']
30
29
  include:
31
30
  - '**/*.gemspec'
@@ -36,6 +35,7 @@ PreCommit:
36
35
  - '**/Rakefile'
37
36
  - 'bin/*'
38
37
  - 'exe/*'
38
+ problem_on_unmodified_line: warn
39
39
  exclude:
40
40
  - db/migrate/*.rb
41
41
  - db/schema.rb
@@ -60,7 +60,7 @@ PreCommit:
60
60
  enabled: true
61
61
  SolargraphTypecheck:
62
62
  enabled: true
63
- on_warn: fail
63
+ problem_on_unmodified_line: warn
64
64
  include:
65
65
  - '**/*.rb'
66
66
  Punchlist:
data/.rubocop.yml CHANGED
@@ -5,6 +5,10 @@ Layout/LineLength:
5
5
  Layout/MultilineMethodCallIndentation:
6
6
  EnforcedStyle: indented
7
7
 
8
+ Lint/EmptyClass:
9
+ # some workarounds for circular dependencies require empty classes
10
+ AllowComments: true
11
+
8
12
  Lint/UnusedMethodArgument:
9
13
  AllowUnusedKeywordArguments: true
10
14
 
@@ -79,6 +83,11 @@ Style/StringLiterals:
79
83
  - double_quotes
80
84
  ConsistentQuotesInMultiline: true
81
85
 
86
+ # Solargraph needs to see a class inherited from Struct to recognize
87
+ # what's going on
88
+ Style/StructInheritance:
89
+ Enabled: false
90
+
82
91
  # I like trailing commas in arrays and hashes. They let me insert new
83
92
  # elements and see them as one line in a diff, not two.
84
93
  Style/TrailingCommaInArrayLiteral:
data/Gemfile.lock CHANGED
@@ -12,7 +12,7 @@ GIT
12
12
  PATH
13
13
  remote: .
14
14
  specs:
15
- checkoff (0.37.0)
15
+ checkoff (0.39.0)
16
16
  activesupport
17
17
  asana (> 0.10.0)
18
18
  cache_method
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+ #
3
+ # @!parse
4
+ # class Time
5
+ # class << self
6
+ # # @param date [String]
7
+ # # @return [Time]
8
+ # def parse(date); end
9
+ # end
10
+ # end
11
+ # module Asana
12
+ # class Client
13
+ # # @return [Asana::ProxiedResourceClasses::Task]
14
+ # def tasks; end
15
+ # # @return [Asana::ProxiedResourceClasses::Workspace]
16
+ # def workspaces; end
17
+ # end
18
+ # module Resources
19
+ # class Task
20
+ # # @return [String, nil]
21
+ # def html_notes; end
22
+ # class << self
23
+ # # @return [Asana::Resources::Task]
24
+ # def create(client, assignee:, workspace:, name:); end
25
+ # end
26
+ # end
27
+ # end
28
+ # module Resources
29
+ # class Workspace
30
+ # # @return [String, nil]
31
+ # def html_notes; end
32
+ # class << self
33
+ # # @return [Asana::Resources::Workspace]
34
+ # def find_by_id(client, id, options: {}); end
35
+ # end
36
+ # end
37
+ # end
38
+ # module ProxiedResourceClasses
39
+ # class Task
40
+ # # Returns the complete task record for a single task.
41
+ # #
42
+ # # @param id [String] The task to get.
43
+ # # @param options [Hash] the request I/O options.
44
+ # # @return [Asana::Resources::Task]
45
+ # def find_by_id(id, options: {}); end
46
+ # end
47
+ # class Workspace
48
+ # # @return [Array<Asana::Resources::Workspace>]
49
+ # def find_all; end
50
+ # end
51
+ # end
52
+ # end
@@ -99,9 +99,14 @@ module Checkoff
99
99
  # handle 'subtask' search url param
100
100
  class Subtask < SimpleParam
101
101
  def convert
102
- return ['is_subtask', false] if single_value == 'is_not_subtask'
103
-
104
- raise "Teach me how to handle #{key} = #{values}"
102
+ case single_value
103
+ when 'is_not_subtask'
104
+ ['is_subtask', false]
105
+ when 'is_subtask'
106
+ ['is_subtask', true]
107
+ else
108
+ raise "Teach me how to handle #{key} = #{values}"
109
+ end
105
110
  end
106
111
  end
107
112
 
@@ -3,21 +3,30 @@
3
3
  # frozen_string_literal: true
4
4
 
5
5
  require_relative 'sections'
6
+ require_relative 'workspaces'
6
7
  require 'asana'
7
8
 
8
9
  module Checkoff
9
10
  # Pull tasks from Asana
10
11
  class Tasks
11
12
  MINUTE = 60
13
+ # @sg-ignore
12
14
  HOUR = MINUTE * 60
13
15
  DAY = 24 * HOUR
14
16
  REALLY_LONG_CACHE_TIME = HOUR
17
+ # @sg-ignore
15
18
  LONG_CACHE_TIME = MINUTE * 15
19
+ # @sg-ignore
16
20
  SHORT_CACHE_TIME = MINUTE * 5
17
21
 
22
+ # @param client [Asana::Client]
23
+ # @param workspaces [Checkoff::Workspaces]
24
+ # @param time_class [Class<Time>]
18
25
  # @param sections [Checkoff::Sections]
19
26
  def initialize(config: Checkoff::Internal::ConfigLoader.load(:asana),
20
27
  client: Checkoff::Clients.new(config: config).client,
28
+ workspaces: Checkoff::Workspaces.new(config: config,
29
+ client: client),
21
30
  sections: Checkoff::Sections.new(config: config,
22
31
  client: client),
23
32
  time_class: Time,
@@ -27,6 +36,7 @@ module Checkoff
27
36
  @time_class = time_class
28
37
  @asana_task = asana_task
29
38
  @client = client
39
+ @workspaces = workspaces
30
40
  end
31
41
 
32
42
  def task_ready?(task)
@@ -53,9 +63,22 @@ module Checkoff
53
63
  tasks.find { |task| task.name == task_name }
54
64
  end
55
65
 
66
+ # Pull a specific task by name
67
+ # @return [Asana::Resources::Task, nil]
68
+ def task_by_gid(task_gid,
69
+ only_uncompleted: true,
70
+ extra_fields: [])
71
+ options = projects.task_options
72
+ options[:options][:fields] += extra_fields
73
+ options[:completed_since] = '9999-12-01' if only_uncompleted
74
+ client.tasks.find_by_id(task_gid, options: options)
75
+ end
76
+
77
+ # @param workspace_gid [String]
78
+ # @param assignee_gid [String]
56
79
  # @return [Asana::Resources::Task]
57
80
  def add_task(name,
58
- workspace_gid: default_workspace_gid,
81
+ workspace_gid: @workspaces.default_workspace_gid,
59
82
  assignee_gid: default_assignee_gid)
60
83
  @asana_task.create(client,
61
84
  assignee: assignee_gid,
@@ -93,11 +116,14 @@ module Checkoff
93
116
  @projects ||= @sections.projects
94
117
  end
95
118
 
119
+ # @sg-ignore
96
120
  # @return [String]
97
121
  def default_assignee_gid
98
122
  @config.fetch(:default_assignee_gid)
99
123
  end
100
124
 
125
+ # @param task [Asana::Resources::Task]
126
+ # @return [Time, nil]
101
127
  def due_time(task)
102
128
  return @time_class.parse(task.due_at) if task.due_at
103
129
  return @time_class.parse(task.due_on) if task.due_on
@@ -117,6 +143,7 @@ module Checkoff
117
143
  # @sg-ignore
118
144
  # @type [Array<Asana::Resources::Task>, nil]
119
145
  already_fetched_dependencies = task.instance_variable_get(:@dependencies)
146
+ # @sg-ignore
120
147
  return false unless already_fetched_dependencies.nil? || already_fetched_dependencies.size.positive?
121
148
 
122
149
  task.dependencies.any? do |parent_task_info|
@@ -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.37.0'
6
+ VERSION = '0.39.0'
7
7
  end
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'asana'
3
4
  require 'forwardable'
4
5
  require 'cache_method'
5
6
  require_relative 'internal/config_loader'
@@ -11,12 +12,16 @@ module Checkoff
11
12
  # Query different workspaces of Asana projects
12
13
  class Workspaces
13
14
  MINUTE = 60
15
+ # @sg-ignore
14
16
  HOUR = MINUTE * 60
15
17
  DAY = 24 * HOUR
18
+ # @sg-ignore
16
19
  REALLY_LONG_CACHE_TIME = HOUR * 1
20
+ # @sg-ignore
17
21
  LONG_CACHE_TIME = MINUTE * 15
18
22
  SHORT_CACHE_TIME = MINUTE
19
23
 
24
+ # @param client [Asana::Client]
20
25
  def initialize(config: Checkoff::Internal::ConfigLoader.load(:asana),
21
26
  client: Checkoff::Clients.new(config: config).client,
22
27
  asana_workspace: Asana::Resources::Workspace)
@@ -26,12 +31,15 @@ module Checkoff
26
31
  end
27
32
 
28
33
  # Pulls an Asana workspace object
34
+ # @param [String] workspace_name
35
+ # @return [Asana::Resources::Workspace, nil]
29
36
  def workspace(workspace_name)
30
37
  client.workspaces.find_all.find do |workspace|
31
38
  workspace.name == workspace_name
32
39
  end
33
40
  end
34
41
 
42
+ # @return [Asana::Resources::Workspace]
35
43
  def default_workspace
36
44
  @asana_workspace.find_by_id(client, default_workspace_gid)
37
45
  end
@@ -39,18 +47,20 @@ module Checkoff
39
47
  # @param [String] workspace_name
40
48
  # @return [Asana::Resources::Workspace]
41
49
  def workspace_or_raise(workspace_name)
42
- workspace = workspace(workspace_name)
43
- raise "Could not find workspace #{workspace_name}" if workspace.nil?
50
+ w = workspace(workspace_name)
51
+ raise "Could not find workspace #{workspace_name}" if w.nil?
44
52
 
45
- workspace
53
+ w
46
54
  end
47
55
 
48
- private
49
-
50
- attr_reader :client
51
-
56
+ # @sg-ignore
57
+ # @return [String]
52
58
  def default_workspace_gid
53
59
  @config.fetch(:default_workspace_gid)
54
60
  end
61
+
62
+ private
63
+
64
+ attr_reader :client
55
65
  end
56
66
  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.37.0
4
+ version: 0.39.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-05-28 00:00:00.000000000 Z
11
+ date: 2023-05-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -411,6 +411,7 @@ files:
411
411
  - bin/solargraph
412
412
  - bin/yard
413
413
  - checkoff.gemspec
414
+ - config/definitions.rb
414
415
  - docs/cookiecutter_input.json
415
416
  - docs/example_project.png
416
417
  - exe/checkoff