checkoff 0.184.0 → 0.185.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: e8eb599f0019414a7aaa86484ebacab58fdc9abd5f0e011c789cbff5672be954
4
- data.tar.gz: 496e59dacc6ca7319b5549ae56fcfe9054fcc567b93e2df51dc45bebb6d43854
3
+ metadata.gz: 2c144884f931d0a839d66654dbb1ce02487d6024bbd32ca3a56ed749dfb650fa
4
+ data.tar.gz: fbce0b5063ca8dbec172cc2f3d062a266daae30af1d70d090586cb8eee485b03
5
5
  SHA512:
6
- metadata.gz: a8feba7f88c8a1fade31615176feacb95ec1b42cdde47cf41a44779fc04c87822d131f5d68c9bbafe5b714f2e7fa58dcf06db8ce38fb19145d6eb0db5091f413
7
- data.tar.gz: b52827bd2a85db528b50d899b1c78f057364590a46ec603d2a4ae8d1dfc975c896672eb8b9a4dcad28809f8e67afab21b56d4ca35b0aa1910bd1eee8e35ee214
6
+ metadata.gz: c77b6170bf7eaa08e532eb38013ff25ae581d7363543128516a98d1cf354bc5137e6caa24e8f99d5d2ec52747ed300fc3e9ab279a3a209e89eee5a64b5900b10
7
+ data.tar.gz: 928dba035f252897d2a400b1b55ba05bf98dc91f676818395a6d070f14ed0f179a8e09421f4580f9c7c3bff15d1570eee7b7561d0a4d01b0d3dfcd68d0f6ab83
data/Gemfile.lock CHANGED
@@ -12,7 +12,7 @@ GIT
12
12
  PATH
13
13
  remote: .
14
14
  specs:
15
- checkoff (0.184.0)
15
+ checkoff (0.185.0)
16
16
  activesupport
17
17
  asana (> 0.10.0)
18
18
  cache_method
@@ -5,6 +5,7 @@
5
5
  require 'forwardable'
6
6
  require 'cache_method'
7
7
  require_relative 'internal/config_loader'
8
+ require_relative 'internal/logging'
8
9
  require_relative 'internal/asana_event_filter'
9
10
  require_relative 'workspaces'
10
11
  require_relative 'clients'
@@ -32,15 +33,18 @@ module Checkoff
32
33
 
33
34
  # @param config [Hash]
34
35
  # @param workspaces [Checkoff::Workspaces]
36
+ # @param tasks [Checkoff::Tasks]
35
37
  # @param clients [Checkoff::Clients]
36
38
  # @param client [Asana::Client]
37
39
  # @param asana_event_filter_class [Class<Checkoff::Internal::AsanaEventFilter>]
38
40
  def initialize(config: Checkoff::Internal::ConfigLoader.load(:asana),
39
41
  workspaces: Checkoff::Workspaces.new(config: config),
42
+ tasks: Checkoff::Tasks.new(config: config),
40
43
  clients: Checkoff::Clients.new(config: config),
41
44
  client: clients.client,
42
45
  asana_event_filter_class: Checkoff::Internal::AsanaEventFilter)
43
46
  @workspaces = workspaces
47
+ @tasks = tasks
44
48
  @client = client
45
49
  @asana_event_filter_class = asana_event_filter_class
46
50
  end
@@ -54,8 +58,44 @@ module Checkoff
54
58
  asana_events.select { |event| asana_event_filter.matches?(event) }
55
59
  end
56
60
 
61
+ # Add useful info (like resource task names) into an event for
62
+ # human consumption
63
+ #
64
+ # @param asana_event [Hash]
65
+ #
66
+ # @return [Hash]
67
+ def enrich_event(asana_event)
68
+ finer { "Enriching event: #{asana_event}" }
69
+ asana_event = asana_event.dup
70
+ enrich_event_resource!(asana_event)
71
+ asana_event
72
+ end
73
+
57
74
  private
58
75
 
76
+ # @param asana_event [Hash{'resource' => Hash}]
77
+ #
78
+ # @return [void]
79
+ def enrich_event_resource!(asana_event)
80
+ # @type [Hash{String => String }]
81
+ resource = asana_event['resource']
82
+ # @type [String]
83
+ resource_type = resource.fetch('resource_type')
84
+ # @type [String]
85
+ gid = resource.fetch('gid')
86
+
87
+ if resource_type == 'task'
88
+ task = tasks.task_by_gid(gid, only_uncompleted: false)
89
+ resource['checkoff:name'] = task.name if task
90
+ end
91
+ nil
92
+ end
93
+
94
+ include Logging
95
+
96
+ # @return [Checkoff::Tasks]
97
+ attr_reader :tasks
98
+
59
99
  # @return [Checkoff::Workspaces]
60
100
  attr_reader :workspaces
61
101
 
@@ -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.184.0'
6
+ VERSION = '0.185.0'
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.184.0
4
+ version: 0.185.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: 2024-01-23 00:00:00.000000000 Z
11
+ date: 2024-01-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport