checkoff 0.1.2 → 0.1.3

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
  SHA1:
3
- metadata.gz: aa5db0770176136646b1abe9daed13a86c5d1b92
4
- data.tar.gz: a2d23b7210830073ca5896bb348d3da8e5025d92
3
+ metadata.gz: 2072628c4164da14449f985dc2e455b04a2a9973
4
+ data.tar.gz: 3a8cdae4f8678cfc2295f79a9477a11bc996715b
5
5
  SHA512:
6
- metadata.gz: 464246ff90bd41b097c04887c3a91b38c45f04513877bf061e90d6edd3c9268840c759b0012afda92c3e5381b94cd9ef51970abb98aab11cdb640c0d2e8b7c67
7
- data.tar.gz: 5809256f6164b78db7a53276d0abac32b900e1213a662c92a7681018bea1e150d613fe9c2026dd5fef109231f08ca7b94b81b47db06ed2162933cd8db059815b
6
+ metadata.gz: 9d30eed934598931ef970ebe69a19196ac8fb027186da42e447f8f1a03a73366621164148e46d143a5317bc5a66e3ca392f25bf98398a7aba69a66bcacd2bec1
7
+ data.tar.gz: de6b37ce6683cc2f1ee58276d2594b6ff16ddf1b3694d33c3bc328922958eba3a82072fe6291dcda3cfbc5d3feb8388a764acf9766d2b5adce27f48bcd0c2990
@@ -1 +1 @@
1
- ruby-2.1.0
1
+ ruby-2.3.1
@@ -2,8 +2,7 @@ before_install:
2
2
  - gem install bundler
3
3
  language: ruby
4
4
  rvm:
5
- - ruby-2.1
6
- - ruby-2.2
5
+ - ruby-2.2.2
7
6
  - ruby-2.3.1
8
7
  # - jruby-head # see https://github.com/apiology/quality/issues/59
9
8
  # - jruby-9.0 # see https://github.com/apiology/quality/issues/59
data/Rakefile CHANGED
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'bundler/gem_tasks'
2
3
 
3
4
  Dir['lib/tasks/**/*.rake'].each { |t| load t }
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  # coding: ascii
2
3
  lib = File.expand_path('../lib', __FILE__)
3
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "result": {
3
- "covered_percent": 98.65
3
+ "covered_percent": 98.66
4
4
  }
5
5
  }
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'checkoff/version'
2
3
  require 'checkoff/projects'
3
4
  require 'checkoff/sections'
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
+ # frozen_string_literal: true
3
4
  require 'ostruct'
4
5
  require 'dalli'
5
6
  require 'cache_method'
@@ -12,9 +13,11 @@ module Checkoff
12
13
  class CLI
13
14
  attr_reader :sections, :stderr
14
15
 
15
- def initialize(sections: Checkoff::Sections.new,
16
+ def initialize(projects: Checkoff::Projects.new,
17
+ sections: Checkoff::Sections.new(projects: projects),
16
18
  stderr: STDERR,
17
19
  kernel: Kernel)
20
+ @projects = projects
18
21
  @sections = sections
19
22
  @kernel = kernel
20
23
  @stderr = stderr
@@ -51,9 +54,12 @@ module Checkoff
51
54
  tasks_to_hash(tasks).to_json
52
55
  end
53
56
 
57
+ def quickadd(task_name)
58
+ @projects.add_task(task_name)
59
+ end
60
+
54
61
  def validate_args!(args)
55
- mode, _workspace, project, _section = args
56
- return unless project.nil? || mode != 'view'
62
+ return unless args.length < 2 || !%w(view quickadd).include?(args[0])
57
63
 
58
64
  output_help
59
65
  exit(1)
@@ -61,24 +67,42 @@ module Checkoff
61
67
 
62
68
  def parse_args(args)
63
69
  validate_args!(args)
64
- args[1..-1]
70
+ mode = args[0]
71
+ subargs = OpenStruct.new
72
+ if mode == 'view'
73
+ subargs.workspace = args[1]
74
+ subargs.project = args[2]
75
+ elsif mode == 'quickadd'
76
+ subargs.task_name = args[1]
77
+ else
78
+ raise
79
+ end
80
+ [mode, subargs]
65
81
  end
66
82
 
67
83
  def output_help
68
84
  stderr.puts 'View tasks:'
69
85
  stderr.puts " #{$PROGRAM_NAME} view workspace project [section]"
86
+ stderr.puts " #{$PROGRAM_NAME} quickadd task_name"
70
87
  stderr.puts
71
88
  stderr.puts "'project' can be set to a project name, or :my_tasks, " \
72
89
  ':my_tasks_upcoming, :my_tasks_new, or :my_tasks_today'
73
90
  end
74
91
 
75
92
  def run(args)
76
- workspace, project, section = parse_args(args)
77
- project = project[1..-1].to_sym if project.start_with? ':'
78
- if section.nil?
79
- run_on_project(workspace, project)
93
+ command, subargs = parse_args(args)
94
+ if command == 'view'
95
+ project = subargs.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
102
+ elsif command == 'quickadd'
103
+ quickadd(subargs.task_name)
80
104
  else
81
- run_on_section(workspace, project, section)
105
+ raise
82
106
  end
83
107
  end
84
108
  end
@@ -1,6 +1,8 @@
1
+ # frozen_string_literal: true
1
2
  require 'yaml'
2
3
  require 'active_support/core_ext/hash'
3
4
 
5
+ # frozen_string_literal: true
4
6
  module Checkoff
5
7
  # Load configuration file
6
8
  class ConfigLoader
@@ -1,5 +1,6 @@
1
1
  require_relative 'config_loader'
2
2
 
3
+ # frozen_string_literal: true
3
4
  require 'cache_method'
4
5
  require 'asana'
5
6
 
@@ -39,6 +40,29 @@ module Checkoff
39
40
  end
40
41
  cache_method :projects, LONG_CACHE_TIME
41
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
+
42
66
  def workspace_by_name(workspace_name)
43
67
  client.workspaces.find_all.find do |workspace|
44
68
  workspace.name == workspace_name
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Checkoff
2
3
  # Query different sections of Asana projects
3
4
  class Sections
@@ -1,5 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
+ # frozen_string_literal: true
4
+
3
5
  require_relative 'sections'
4
6
 
5
7
  module Checkoff
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Checkoff
2
- VERSION = '0.1.2'.freeze
3
+ VERSION = '0.1.3'
3
4
  end
@@ -1 +1,2 @@
1
+ # frozen_string_literal: true
1
2
  task ci: :localtest
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  task :clear_metrics do |_t|
2
3
  ret =
3
4
  system('git checkout coverage/.last_run.json metrics/*_high_water_mark')
@@ -1 +1,2 @@
1
+ # frozen_string_literal: true
1
2
  task default: :localtest
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'rspec/core/rake_task'
2
3
 
3
4
  desc 'Run features'
@@ -1 +1,2 @@
1
+ # frozen_string_literal: true
1
2
  task localtest: [:clear_metrics, :test, :quality]
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'quality/rake/task'
2
3
 
3
4
  Quality::Rake::Task.new do |task|
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'rspec/core/rake_task'
2
3
 
3
4
  desc 'Run specs'
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'rake/testtask'
2
3
 
3
4
  Rake::TestTask.new do |t|
@@ -1 +1 @@
1
- 484
1
+ 487
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.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vince Broz
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-07-05 00:00:00.000000000 Z
11
+ date: 2017-06-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dalli
@@ -192,6 +192,7 @@ files:
192
192
  - lib/tasks/test.rake
193
193
  - metrics/bigfiles_high_water_mark
194
194
  - metrics/brakeman_high_water_mark
195
+ - metrics/bundle-audit_high_water_mark
195
196
  - metrics/cane_high_water_mark
196
197
  - metrics/eslint_high_water_mark
197
198
  - metrics/flay_high_water_mark
@@ -221,7 +222,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
221
222
  version: '0'
222
223
  requirements: []
223
224
  rubyforge_project:
224
- rubygems_version: 2.4.6
225
+ rubygems_version: 2.5.1
225
226
  signing_key:
226
227
  specification_version: 4
227
228
  summary: Command-line and gem client for Asana (unofficial)