checkoff 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +3 -0
- data/Gemfile +2 -0
- data/Rakefile +1 -0
- data/bin/console +4 -3
- data/checkoff.gemspec +1 -0
- data/coverage/.last_run.json +1 -1
- data/exe/checkoff +1 -0
- data/lib/checkoff/cli.rb +38 -17
- data/lib/checkoff/config_loader.rb +2 -1
- data/lib/checkoff/projects.rb +13 -37
- data/lib/checkoff/sections.rb +8 -1
- data/lib/checkoff/tasks.rb +21 -1
- data/lib/checkoff/version.rb +2 -1
- data/lib/checkoff/workspaces.rb +28 -0
- data/lib/checkoff.rb +2 -0
- data/lib/tasks/ci.rake +1 -0
- data/lib/tasks/clear_metrics.rake +1 -0
- data/lib/tasks/default.rake +1 -0
- data/lib/tasks/feature.rake +1 -0
- data/lib/tasks/localtest.rake +2 -1
- data/lib/tasks/quality.rake +2 -0
- data/lib/tasks/spec.rake +1 -0
- data/lib/tasks/test.rake +1 -0
- data/metrics/bigfiles_high_water_mark +1 -1
- data/metrics/flake8_high_water_mark +1 -0
- data/metrics/mdl_high_water_mark +1 -0
- data/metrics/scalastyle_high_water_mark +1 -0
- metadata +6 -3
- data/bin/checkoff +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fb140b2c3cd6899f6244d46a8b8c979ff84156c4
|
4
|
+
data.tar.gz: 27fe46e1995216eb5e7a663e64baffc4528732a3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7296099b7f92d602263ffbff3f29365ece01b4915b5dcdbf8526dce9e2381c478e96b695443f57ef543a578f6c74550eb1470e855893abb2cc964171836fc704
|
7
|
+
data.tar.gz: ecabaf1af01734d7b5cfe4407fa35c80e2b0e1fddd15eecb31a87ab35a4c894e310166546cdadf06ec33505b0c356971b1c49a714c20aaca48f8750796d949a1
|
data/.rubocop.yml
CHANGED
data/Gemfile
CHANGED
data/Rakefile
CHANGED
data/bin/console
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
|
-
require
|
4
|
-
require
|
4
|
+
require 'bundler/setup'
|
5
|
+
require 'checkoff'
|
5
6
|
|
6
7
|
# You can add fixtures and/or initialization code here to make experimenting
|
7
8
|
# with your gem easier. You can also use a different console, if you like.
|
@@ -10,5 +11,5 @@ require "checkoff"
|
|
10
11
|
# require "pry"
|
11
12
|
# Pry.start
|
12
13
|
|
13
|
-
require
|
14
|
+
require 'irb'
|
14
15
|
IRB.start
|
data/checkoff.gemspec
CHANGED
data/coverage/.last_run.json
CHANGED
data/exe/checkoff
CHANGED
data/lib/checkoff/cli.rb
CHANGED
@@ -1,9 +1,11 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
# frozen_string_literal: true
|
4
|
+
|
4
5
|
require 'ostruct'
|
5
6
|
require 'dalli'
|
6
7
|
require 'cache_method'
|
8
|
+
require_relative 'workspaces'
|
7
9
|
require_relative 'projects'
|
8
10
|
require_relative 'tasks'
|
9
11
|
require_relative 'sections'
|
@@ -13,12 +15,16 @@ module Checkoff
|
|
13
15
|
class CLI
|
14
16
|
attr_reader :sections, :stderr
|
15
17
|
|
16
|
-
def initialize(
|
18
|
+
def initialize(workspaces: Checkoff::Workspaces.new,
|
19
|
+
projects: Checkoff::Projects.new,
|
17
20
|
sections: Checkoff::Sections.new(projects: projects),
|
21
|
+
tasks: Checkoff::Tasks.new,
|
18
22
|
stderr: STDERR,
|
19
23
|
kernel: Kernel)
|
24
|
+
@workspaces = workspaces
|
20
25
|
@projects = projects
|
21
26
|
@sections = sections
|
27
|
+
@tasks = tasks
|
22
28
|
@kernel = kernel
|
23
29
|
@stderr = stderr
|
24
30
|
end
|
@@ -54,26 +60,37 @@ module Checkoff
|
|
54
60
|
tasks_to_hash(tasks).to_json
|
55
61
|
end
|
56
62
|
|
57
|
-
def quickadd(task_name)
|
58
|
-
@
|
63
|
+
def quickadd(workspace_name, task_name)
|
64
|
+
workspace = @workspaces.workspace_by_name(workspace_name)
|
65
|
+
@tasks.add_task(task_name,
|
66
|
+
workspace_id: workspace.id)
|
59
67
|
end
|
60
68
|
|
61
69
|
def validate_args!(args)
|
62
|
-
return unless args.length < 2 || !%w
|
70
|
+
return unless args.length < 2 || !%w[view quickadd].include?(args[0])
|
63
71
|
|
64
72
|
output_help
|
65
73
|
exit(1)
|
66
74
|
end
|
67
75
|
|
76
|
+
def parse_view_args(subargs, args)
|
77
|
+
subargs.workspace = args[1]
|
78
|
+
subargs.project = args[2]
|
79
|
+
subargs.section = args[3]
|
80
|
+
end
|
81
|
+
|
82
|
+
def parse_quickadd_args(subargs, args)
|
83
|
+
subargs.workspace = args[1]
|
84
|
+
subargs.task_name = args[2]
|
85
|
+
end
|
86
|
+
|
68
87
|
def parse_args(args)
|
69
|
-
validate_args!(args)
|
70
88
|
mode = args[0]
|
71
89
|
subargs = OpenStruct.new
|
72
90
|
if mode == 'view'
|
73
|
-
subargs
|
74
|
-
subargs.project = args[2]
|
91
|
+
parse_view_args(subargs, args)
|
75
92
|
elsif mode == 'quickadd'
|
76
|
-
subargs
|
93
|
+
parse_quickadd_args(subargs, args)
|
77
94
|
else
|
78
95
|
raise
|
79
96
|
end
|
@@ -83,24 +100,28 @@ module Checkoff
|
|
83
100
|
def output_help
|
84
101
|
stderr.puts 'View tasks:'
|
85
102
|
stderr.puts " #{$PROGRAM_NAME} view workspace project [section]"
|
86
|
-
stderr.puts " #{$PROGRAM_NAME} quickadd task_name"
|
103
|
+
stderr.puts " #{$PROGRAM_NAME} quickadd workspace task_name"
|
87
104
|
stderr.puts
|
88
105
|
stderr.puts "'project' can be set to a project name, or :my_tasks, " \
|
89
106
|
':my_tasks_upcoming, :my_tasks_new, or :my_tasks_today'
|
90
107
|
end
|
91
108
|
|
109
|
+
def view(workspace_name, project_name, section_name)
|
110
|
+
project_name = project_name[1..-1].to_sym if project_name.start_with? ':'
|
111
|
+
if section_name.nil?
|
112
|
+
run_on_project(workspace_name, project_name)
|
113
|
+
else
|
114
|
+
run_on_section(workspace_name, project_name, section_name)
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
92
118
|
def run(args)
|
119
|
+
validate_args!(args)
|
93
120
|
command, subargs = parse_args(args)
|
94
121
|
if command == 'view'
|
95
|
-
project
|
96
|
-
project = project[1..-1].to_sym if project.start_with? ':'
|
97
|
-
if section.nil?
|
98
|
-
run_on_project(subargs.workspace, project)
|
99
|
-
else
|
100
|
-
run_on_section(subargs.workspace, project, subargs.section)
|
101
|
-
end
|
122
|
+
view(subargs.workspace, subargs.project, subargs.section)
|
102
123
|
elsif command == 'quickadd'
|
103
|
-
quickadd(subargs.task_name)
|
124
|
+
quickadd(subargs.workspace, subargs.task_name)
|
104
125
|
else
|
105
126
|
raise
|
106
127
|
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require 'yaml'
|
3
4
|
require 'active_support/core_ext/hash'
|
4
5
|
|
@@ -9,7 +10,7 @@ module Checkoff
|
|
9
10
|
def self.load(sym)
|
10
11
|
file = "#{sym}.yml"
|
11
12
|
YAML.load_file(File.expand_path("~/.#{file}"))
|
12
|
-
|
13
|
+
.with_indifferent_access
|
13
14
|
end
|
14
15
|
end
|
15
16
|
end
|
data/lib/checkoff/projects.rb
CHANGED
@@ -24,15 +24,15 @@ module Checkoff
|
|
24
24
|
# XXX: Move low-level functions private
|
25
25
|
|
26
26
|
def initialize(config: Checkoff::ConfigLoader.load(:asana),
|
27
|
-
asana_client: Asana::Client
|
27
|
+
asana_client: Asana::Client,
|
28
|
+
workspaces: Checkoff::Workspaces.new)
|
28
29
|
@config = config
|
29
30
|
@asana_client = asana_client
|
31
|
+
@workspaces = workspaces
|
30
32
|
end
|
31
33
|
|
32
34
|
def client
|
33
|
-
@client
|
34
|
-
c.authentication :access_token, @config[:personal_access_token]
|
35
|
-
end
|
35
|
+
@workspaces.client
|
36
36
|
end
|
37
37
|
|
38
38
|
def projects
|
@@ -40,37 +40,8 @@ module Checkoff
|
|
40
40
|
end
|
41
41
|
cache_method :projects, LONG_CACHE_TIME
|
42
42
|
|
43
|
-
def add_task(name,
|
44
|
-
workspace_id: default_workspace_id,
|
45
|
-
assignee_id: default_assignee_id)
|
46
|
-
Asana::Resources::Task.create(client,
|
47
|
-
assignee: assignee_id,
|
48
|
-
workspace: workspace_id, name: name)
|
49
|
-
end
|
50
|
-
|
51
|
-
def default_workspace_id
|
52
|
-
@config[:default_workspace_id]
|
53
|
-
end
|
54
|
-
|
55
|
-
def default_assignee_id
|
56
|
-
@config[:default_assignee_id]
|
57
|
-
end
|
58
|
-
|
59
|
-
def user_by_name(name, workspace_id: raise)
|
60
|
-
client.users.find_all(workspace: workspace_id).find do |user|
|
61
|
-
print(user)
|
62
|
-
user.name == name
|
63
|
-
end || raise("Could not find user #{email}")
|
64
|
-
end
|
65
|
-
|
66
|
-
def workspace_by_name(workspace_name)
|
67
|
-
client.workspaces.find_all.find do |workspace|
|
68
|
-
workspace.name == workspace_name
|
69
|
-
end || raise("Could not find workspace #{workspace_name}")
|
70
|
-
end
|
71
|
-
|
72
43
|
def projects_by_workspace_name(workspace_name)
|
73
|
-
workspace = workspace_by_name(workspace_name)
|
44
|
+
workspace = @workspaces.workspace_by_name(workspace_name)
|
74
45
|
raise "Could not find workspace named #{workspace_name}" unless workspace
|
75
46
|
projects.find_by_workspace(workspace: workspace.id)
|
76
47
|
end
|
@@ -102,14 +73,19 @@ module Checkoff
|
|
102
73
|
|
103
74
|
def task_options
|
104
75
|
{
|
76
|
+
per_page: 100,
|
105
77
|
options: {
|
106
|
-
fields: %w
|
78
|
+
fields: %w[name completed_at due_at due_on],
|
107
79
|
},
|
108
80
|
}
|
109
81
|
end
|
110
82
|
|
111
|
-
def tasks_from_project(project)
|
112
|
-
|
83
|
+
def tasks_from_project(project, only_uncompleted: true, extra_fields: [])
|
84
|
+
options = task_options
|
85
|
+
options[:completed_since] = '9999-12-01' if only_uncompleted
|
86
|
+
options[:project] = project.id
|
87
|
+
options[:options][:fields] += extra_fields
|
88
|
+
client.tasks.find_all(options).to_a
|
113
89
|
end
|
114
90
|
cache_method :tasks_from_project, LONG_CACHE_TIME
|
115
91
|
end
|
data/lib/checkoff/sections.rb
CHANGED
@@ -1,4 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'forwardable'
|
4
|
+
|
2
5
|
module Checkoff
|
3
6
|
# Query different sections of Asana projects
|
4
7
|
class Sections
|
@@ -6,6 +9,8 @@ module Checkoff
|
|
6
9
|
LONG_CACHE_TIME = MINUTE * 15
|
7
10
|
SHORT_CACHE_TIME = MINUTE * 5
|
8
11
|
|
12
|
+
extend Forwardable
|
13
|
+
|
9
14
|
attr_reader :projects, :time
|
10
15
|
|
11
16
|
def initialize(projects: Checkoff::Projects.new,
|
@@ -14,6 +19,8 @@ module Checkoff
|
|
14
19
|
@time = time
|
15
20
|
end
|
16
21
|
|
22
|
+
def_delegators :@projects, :client
|
23
|
+
|
17
24
|
def file_task_by_section(current_section, by_section, task)
|
18
25
|
if task.name =~ /:$/
|
19
26
|
current_section = task.name
|
@@ -47,7 +54,7 @@ module Checkoff
|
|
47
54
|
raw_tasks = projects.tasks_from_project(project)
|
48
55
|
by_assignee_status =
|
49
56
|
projects.active_tasks(raw_tasks)
|
50
|
-
|
57
|
+
.group_by(&:assignee_status)
|
51
58
|
active_tasks = by_assignee_status[assignee_status]
|
52
59
|
by_section(active_tasks)
|
53
60
|
end
|
data/lib/checkoff/tasks.rb
CHANGED
@@ -14,12 +14,32 @@ module Checkoff
|
|
14
14
|
LONG_CACHE_TIME = MINUTE * 15
|
15
15
|
SHORT_CACHE_TIME = MINUTE * 5
|
16
16
|
|
17
|
-
def initialize(
|
17
|
+
def initialize(config: Checkoff::ConfigLoader.load(:asana),
|
18
|
+
sections: Checkoff::Sections.new,
|
19
|
+
asana_task: Asana::Resources::Task)
|
20
|
+
@config = config
|
18
21
|
@sections = sections
|
22
|
+
@asana_task = asana_task
|
23
|
+
end
|
24
|
+
|
25
|
+
def client
|
26
|
+
@sections.client
|
19
27
|
end
|
20
28
|
|
21
29
|
def tasks_minus_sections(tasks)
|
22
30
|
@sections.by_section(tasks).values.flatten
|
23
31
|
end
|
32
|
+
|
33
|
+
def add_task(name,
|
34
|
+
workspace_id: default_workspace_id,
|
35
|
+
assignee_id: default_assignee_id)
|
36
|
+
@asana_task.create(client,
|
37
|
+
assignee: assignee_id,
|
38
|
+
workspace: workspace_id, name: name)
|
39
|
+
end
|
40
|
+
|
41
|
+
def default_assignee_id
|
42
|
+
@config[:default_assignee_id]
|
43
|
+
end
|
24
44
|
end
|
25
45
|
end
|
data/lib/checkoff/version.rb
CHANGED
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Checkoff
|
4
|
+
# Query different workspaces of Asana projects
|
5
|
+
class Workspaces
|
6
|
+
def initialize(config: Checkoff::ConfigLoader.load(:asana),
|
7
|
+
asana_client: Asana::Client)
|
8
|
+
@config = config
|
9
|
+
@asana_client = asana_client
|
10
|
+
end
|
11
|
+
|
12
|
+
def client
|
13
|
+
@client ||= @asana_client.new do |c|
|
14
|
+
c.authentication :access_token, @config[:personal_access_token]
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def default_workspace_id
|
19
|
+
@config[:default_workspace_id]
|
20
|
+
end
|
21
|
+
|
22
|
+
def workspace_by_name(workspace_name)
|
23
|
+
client.workspaces.find_all.find do |workspace|
|
24
|
+
workspace.name == workspace_name
|
25
|
+
end || raise("Could not find workspace #{workspace_name}")
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
data/lib/checkoff.rb
CHANGED
data/lib/tasks/ci.rake
CHANGED
data/lib/tasks/default.rake
CHANGED
data/lib/tasks/feature.rake
CHANGED
data/lib/tasks/localtest.rake
CHANGED
data/lib/tasks/quality.rake
CHANGED
data/lib/tasks/spec.rake
CHANGED
data/lib/tasks/test.rake
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
459
|
@@ -0,0 +1 @@
|
|
1
|
+
0
|
@@ -0,0 +1 @@
|
|
1
|
+
8
|
@@ -0,0 +1 @@
|
|
1
|
+
0
|
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.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vince Broz
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-07-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dalli
|
@@ -181,7 +181,6 @@ files:
|
|
181
181
|
- LICENSE.txt
|
182
182
|
- README.md
|
183
183
|
- Rakefile
|
184
|
-
- bin/checkoff
|
185
184
|
- bin/console
|
186
185
|
- bin/setup
|
187
186
|
- checkoff.gemspec
|
@@ -196,6 +195,7 @@ files:
|
|
196
195
|
- lib/checkoff/sections.rb
|
197
196
|
- lib/checkoff/tasks.rb
|
198
197
|
- lib/checkoff/version.rb
|
198
|
+
- lib/checkoff/workspaces.rb
|
199
199
|
- lib/tasks/ci.rake
|
200
200
|
- lib/tasks/clear_metrics.rake
|
201
201
|
- lib/tasks/default.rake
|
@@ -209,13 +209,16 @@ files:
|
|
209
209
|
- metrics/bundle-audit_high_water_mark
|
210
210
|
- metrics/cane_high_water_mark
|
211
211
|
- metrics/eslint_high_water_mark
|
212
|
+
- metrics/flake8_high_water_mark
|
212
213
|
- metrics/flay_high_water_mark
|
213
214
|
- metrics/flog_high_water_mark
|
214
215
|
- metrics/jscs_high_water_mark
|
216
|
+
- metrics/mdl_high_water_mark
|
215
217
|
- metrics/pep8_high_water_mark
|
216
218
|
- metrics/punchlist_high_water_mark
|
217
219
|
- metrics/rails_best_practices_high_water_mark
|
218
220
|
- metrics/rubocop_high_water_mark
|
221
|
+
- metrics/scalastyle_high_water_mark
|
219
222
|
homepage: http://github.com/apiology/checkoff
|
220
223
|
licenses:
|
221
224
|
- MIT
|
data/bin/checkoff
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|