checkoff 0.7.0 → 0.8.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: 4602a0a2276fa337153e3394f009fa99a8a22603003baf9e99fb9da65c9b9107
4
- data.tar.gz: e1a006d0debc96dbf11fd5e63d4930446bf35a3ae7f261bbbfca79a9d9bbad02
3
+ metadata.gz: 834d9600b69c5f79ba30cbf22a79c66d0a277d517cafe6c2aee32de1c63bb533
4
+ data.tar.gz: 5cb97edadfd9aca288f6f1e5d95400c0e291306ffd2f3a76ad003560539b88cb
5
5
  SHA512:
6
- metadata.gz: 9c998ad14b388dd17a118536b1abacd2e2dc0195fd42f847090c142cb17636f9bd8fe17e2ee4202d2784d7d907ea6aad59381639a5fa71af32babd70bd229229
7
- data.tar.gz: b47bb6ce0899ad62c683fefb67596cc5ca371dc0b67d1cacec881060c19d2cb796175b781530231d2cb320b7662dd4929b5a6eac21b8ae9accfd1c138d344d10
6
+ metadata.gz: 83050b84c4cc44b0c5992174cfe8f837f985dd361627ed60e81466f9cb14713b87d14508c9d46d997e9887c8944557252a64bd79f3354c04285c852758fd5021
7
+ data.tar.gz: '083875c0f26f4309170d036ccec8dc3bb970ddf276916f1744ac0bd1285055de662ac7b29054bceba10fe82baba0ef319731ab32de522fb773a3af824ba687c1'
data/.envrc ADDED
@@ -0,0 +1,2 @@
1
+ PATH_add bin
2
+ eval $(with-op op-env sh)
data/.overcommit.yml CHANGED
@@ -31,3 +31,10 @@ PreCommit:
31
31
  #
32
32
  # IndexTags:
33
33
  # enabled: true # Generate a tags file with `ctags` each time HEAD changes
34
+
35
+ PrePush:
36
+ Minitest:
37
+ command: ['ruby', '-Ilib:test/unit:lib/checkoff', '-rbundler/setup', '-rminitest', "-e 'exit! Minitest.run'"]
38
+ include:
39
+ - 'test/unit/**/test*.rb'
40
+ enabled: true
data/.rubocop.yml CHANGED
@@ -195,6 +195,8 @@ RSpec/StubbedMock: # (new in 1.44)
195
195
 
196
196
  AllCops:
197
197
  TargetRubyVersion: 2.5
198
+ Exclude:
199
+ - 'bin/*'
198
200
 
199
201
  require:
200
202
  - rubocop-rspec
data/bin/checkoff ADDED
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'checkoff' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require "pathname"
12
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13
+ Pathname.new(__FILE__).realpath)
14
+
15
+ bundle_binstub = File.expand_path("../bundle", __FILE__)
16
+
17
+ if File.file?(bundle_binstub)
18
+ if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19
+ load(bundle_binstub)
20
+ else
21
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23
+ end
24
+ end
25
+
26
+ require "rubygems"
27
+ require "bundler/setup"
28
+
29
+ load Gem.bin_path("checkoff", "checkoff")
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "result": {
3
- "covered_percent": 85.38
3
+ "covered_percent": 89.61
4
4
  }
5
5
  }
data/lib/checkoff/cli.rb CHANGED
@@ -110,6 +110,10 @@ module Checkoff
110
110
  end
111
111
 
112
112
  def view(workspace_name, project_name, section_name)
113
+ if project_name.nil?
114
+ stderr.puts 'Please specify a project name'
115
+ exit(1)
116
+ end
113
117
  project_name = project_name[1..-1].to_sym if project_name.start_with? ':'
114
118
  if section_name.nil?
115
119
  run_on_project(workspace_name, project_name)
@@ -11,12 +11,14 @@ module Checkoff
11
11
 
12
12
  extend Forwardable
13
13
 
14
- attr_reader :projects, :time
14
+ attr_reader :projects, :workspaces, :time
15
15
 
16
16
  def initialize(config: Checkoff::ConfigLoader.load(:asana),
17
17
  projects: Checkoff::Projects.new(config: config),
18
+ workspaces: Checkoff::Workspaces.new(config: config),
18
19
  time: Time)
19
20
  @projects = projects
21
+ @workspaces = workspaces
20
22
  @time = time
21
23
  end
22
24
 
@@ -41,6 +43,12 @@ module Checkoff
41
43
  end
42
44
  cache_method :by_section, LONG_CACHE_TIME
43
45
 
46
+ def legacy_tasks_by_section_for_project(project)
47
+ raw_tasks = projects.tasks_from_project(project)
48
+ active_tasks = projects.active_tasks(raw_tasks)
49
+ legacy_by_section(active_tasks)
50
+ end
51
+
44
52
  def tasks_by_section_for_project(project)
45
53
  raw_tasks = projects.tasks_from_project(project)
46
54
  active_tasks = projects.active_tasks(raw_tasks)
@@ -68,8 +76,8 @@ module Checkoff
68
76
  by_section
69
77
  end
70
78
 
71
- def tasks_by_section_for_project_and_assignee_status(project,
72
- assignee_status)
79
+ def legacy_tasks_by_section_for_project_and_assignee_status(project,
80
+ assignee_status)
73
81
  raw_tasks = projects.tasks_from_project(project)
74
82
  by_assignee_status =
75
83
  projects.active_tasks(raw_tasks)
@@ -87,15 +95,40 @@ module Checkoff
87
95
  project
88
96
  end
89
97
 
98
+ def verify_legacy_user_task_list!(workspace_name)
99
+ return unless user_task_list_migrated_to_real_sections?(workspace_name)
100
+
101
+ raise NotImplementedError, 'Section-based user task lists not yet supported'
102
+ end
103
+
104
+ ASSIGNEE_STATUS_BY_PROJECT_NAME = {
105
+ my_tasks_new: 'inbox',
106
+ my_tasks_today: 'today',
107
+ my_tasks_upcoming: 'upcoming',
108
+ }.freeze
109
+
110
+ def user_task_list_by_section(workspace_name, project_name)
111
+ verify_legacy_user_task_list!(workspace_name)
112
+
113
+ if project_name == :my_tasks
114
+ legacy_tasks_by_section_for_project(project_name)
115
+ else
116
+ legacy_tasks_by_section_for_project_and_assignee_status(project_name,
117
+ ASSIGNEE_STATUS_BY_PROJECT_NAME.fetch(project_name))
118
+ end
119
+ end
120
+
90
121
  def tasks_by_section(workspace_name, project_name)
91
122
  project = project_or_raise(workspace_name, project_name)
92
123
  case project_name
124
+ when :my_tasks
125
+ user_task_list_by_section(workspace_name, project_name)
93
126
  when :my_tasks_new
94
- tasks_by_section_for_project_and_assignee_status(project, 'inbox')
127
+ user_task_list_by_section(workspace_name, project_name)
95
128
  when :my_tasks_today
96
- tasks_by_section_for_project_and_assignee_status(project, 'today')
129
+ user_task_list_by_section(workspace_name, project_name)
97
130
  when :my_tasks_upcoming
98
- tasks_by_section_for_project_and_assignee_status(project, 'upcoming')
131
+ user_task_list_by_section(workspace_name, project_name)
99
132
  else
100
133
  tasks_by_section_for_project(project)
101
134
  end
@@ -120,6 +153,13 @@ module Checkoff
120
153
  end
121
154
  cache_method :section_task_names, SHORT_CACHE_TIME
122
155
 
156
+ def user_task_list_migrated_to_real_sections?(workspace_name)
157
+ workspace = workspaces.workspace_by_name(workspace_name)
158
+ result = client.user_task_lists.get_user_task_list_for_user(user_gid: 'me',
159
+ workspace: workspace.gid)
160
+ result.migration_status != 'not_migrated'
161
+ end
162
+
123
163
  def task_due?(task)
124
164
  if task.due_at
125
165
  Time.parse(task.due_at) <= time.now
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Checkoff
4
- VERSION = '0.7.0'
4
+ VERSION = '0.8.0'
5
5
  end
@@ -13,6 +13,7 @@ module Checkoff
13
13
  @client ||= @asana_client.new do |c|
14
14
  c.authentication :access_token, @config.fetch(:personal_access_token)
15
15
  c.default_headers 'asana-enable' => 'string_ids,new_sections'
16
+ c.default_headers 'asana-disable' => 'new_user_task_lists'
16
17
  end
17
18
  end
18
19
 
@@ -23,7 +24,7 @@ module Checkoff
23
24
  def workspace_by_name(workspace_name)
24
25
  client.workspaces.find_all.find do |workspace|
25
26
  workspace.name == workspace_name
26
- end || raise("Could not find workspace #{workspace_name}")
27
+ end || raise("Could not find workspace named [#{workspace_name}]")
27
28
  end
28
29
  end
29
30
  end
@@ -1 +1 @@
1
- 416
1
+ 488
@@ -1 +1 @@
1
- 4
1
+ 6
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.7.0
4
+ version: 0.8.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: 2021-02-04 00:00:00.000000000 Z
11
+ date: 2021-03-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -187,6 +187,7 @@ extensions: []
187
187
  extra_rdoc_files: []
188
188
  files:
189
189
  - ".circleci/config.yml"
190
+ - ".envrc"
190
191
  - ".gitignore"
191
192
  - ".overcommit.yml"
192
193
  - ".rubocop.yml"
@@ -198,6 +199,7 @@ files:
198
199
  - Makefile
199
200
  - README.md
200
201
  - Rakefile
202
+ - bin/checkoff
201
203
  - bin/console
202
204
  - bin/setup
203
205
  - checkoff.gemspec