huginn_asana_agent 0.1.5

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 4e93d9d3fcede39e5f0f6dc803f7f7911efbe404
4
+ data.tar.gz: 2fc26b41da8ebc9809891583f13f4323967568d9
5
+ SHA512:
6
+ metadata.gz: 9a528a3ac77e75783a332e809158d8f0376db82e9463fa755b09d37f8a6feed6d3c2ab8eaac376d3e2058c23b3a02cf7106ee3c35961e8355b927421a7144a87
7
+ data.tar.gz: ba5c6bf9bb749786147d9b16a955332172ef53c271d7aca4b6b1ad29dd0b4c42200edf6f6bb3dbe2c19e3e04ce82657d1e94460a2ad9518274686de32f950303
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ /coverage/
2
+ spec/huginn
3
+ .env
4
+ Gemfile.lock
data/.travis.yml ADDED
@@ -0,0 +1,12 @@
1
+ sudo: false
2
+ language: ruby
3
+ env:
4
+ global:
5
+ - APP_SECRET_TOKEN=b2724973fd81c2f4ac0f92ac48eb3f0152c4a11824c122bcf783419a4c51d8b9bba81c8ba6a66c7de599677c7f486242cf819775c433908e77c739c5c8ae118d
6
+ matrix:
7
+ - DATABASE_ADAPTER=mysql2
8
+ - DATABASE_ADAPTER=postgresql DATABASE_USERNAME=postgres
9
+ rvm:
10
+ - 2.3.0
11
+ cache: bundler
12
+ script: bundle exec rake
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in huginn_asana_agent.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2019 Akshaya Srivatsa
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,32 @@
1
+ # HuginnAsanaAgent
2
+
3
+ [![Build Status](https://travis-ci.com/akshayas/huginn_asana_agent.svg?token=CHtFMrvvbzYwu91xZnbc&branch=master)](https://travis-ci.com/akshayas/huginn_asana_agent)
4
+
5
+ This is Huginn Asana Agent. This repository is a collection of agents to do operations on Asans using Huginn.
6
+
7
+ ## Installation
8
+
9
+ Add this string to your Huginn's .env ADDITIONAL_GEMS configuration:
10
+
11
+ huginn_asana_agent
12
+ And then execute:
13
+
14
+ bundle
15
+
16
+ ## Development
17
+
18
+ Run `bundle` to install all dependencies
19
+
20
+ ### .env configuration
21
+ Create a .env file at the root of the repository using the [example](https://github.com/huginn/huginn/blob/master/.env.example) config from huginn. Make sure to add any missing dependencies in ADDITIONAL_GEMS.
22
+
23
+ ### Testing
24
+ Then, run `rake spec` to run the tests. This will download a copy of huginn into `spec/` directory and run your test against Huginn dependencies. If download and setup of Huginn fails, you will have to reconfigure your `.env` file, delete `spec/huginn` before running `rake spec`
25
+
26
+ ## Contributing
27
+
28
+ Bug reports and pull requests are welcome on GitHub at https://github.com/akshayas/huginn_asana_agent. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
29
+
30
+ ## License
31
+
32
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env rake
2
+
3
+ require "huginn_agent"
4
+
5
+ HuginnAgent.load_tasks(branch: "master", remote: "https://github.com/cantino/huginn.git")
@@ -0,0 +1,39 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "huginn_asana_agent"
7
+ spec.version = "0.1.5"
8
+ spec.authors = ["Akshaya Srivatsa"]
9
+ spec.email = ["akshay.s86@gmail.com"]
10
+
11
+ spec.summary = %q{Collection of agents to perform actions on Asana}
12
+ spec.description = %q{Collection of agents to perform actions on Asana}
13
+ spec.homepage = "https://github.com/akshayas/huginn_asana_agent"
14
+ spec.license = "MIT"
15
+
16
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
17
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
18
+ if spec.respond_to?(:metadata)
19
+ spec.metadata["allowed_push_host"] = "https://rubygems.org"
20
+ else
21
+ raise "RubyGems 2.0 or newer is required to protect against " \
22
+ "public gem pushes."
23
+ end
24
+
25
+ # Specify which files should be added to the gem when it is released.
26
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
27
+ spec.files = Dir.chdir(File.expand_path("..", __FILE__)) do
28
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
29
+ end
30
+ spec.bindir = "exe"
31
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
32
+ spec.require_paths = ["lib"]
33
+
34
+ spec.add_development_dependency "bundler", "~> 1.16"
35
+ spec.add_development_dependency "rake", "~> 10.0"
36
+
37
+ spec.add_runtime_dependency "huginn_agent", "~> 0.4.0"
38
+ spec.add_runtime_dependency "asana", "~> 0.8.1"
39
+ end
@@ -0,0 +1,92 @@
1
+ require "json"
2
+ require_relative "huginn_asana"
3
+
4
+ module Agents
5
+ class AsanaTaskQueryAgent < Agent
6
+ include FormConfigurable
7
+ using HuginnAsana
8
+
9
+ SUPPORTED_FIELDS=[:id, :name, :assignee, :assignee_status, :created_at, :completed, :custom_fields, :due_at, :due_on, :resource_type, :resource_subtype]
10
+
11
+ cannot_receive_events!
12
+
13
+ gem_dependency_check { defined?(Asana::Client) }
14
+
15
+ description do
16
+ <<-MD
17
+ The Asana Task Query Agent allows to query all tasks in a given project or section or tag.
18
+
19
+ To authenticate you need to set `access_token`. You can find it within Asana
20
+ webapp from "My Profile Settings" > Apps > Manage developer apps > Personal access token.
21
+ Note that personal access tokens will only be shown once after which you wont be able to see it again.
22
+ Make sure you are ready to save the access token in Huginn or in your password vault (1Password)
23
+
24
+ List of supported fields
25
+
26
+ #{SUPPORTED_FIELDS.map { |f| f.to_s }}
27
+ MD
28
+ end
29
+
30
+ default_schedule "every_1h"
31
+
32
+ def default_options
33
+ {
34
+ "access_token" => "",
35
+ "id" => "",
36
+ "field" => "",
37
+ "type" => "project"
38
+ }
39
+ end
40
+
41
+ form_configurable :access_token
42
+ form_configurable :id
43
+ form_configurable :fields
44
+ form_configurable :type, type: :array, values: ["project", "section", "tag"]
45
+
46
+ def working?
47
+ !recent_error_logs?
48
+ end
49
+
50
+ def validate_options
51
+ errors.add(:base, "you need to specify your Asana access token") unless options["access_token"].present?
52
+ errors.add(:base, "you need to specify a valid id") unless options["id"].present?
53
+ errors.add(:base, "you need to all the fields you want to receive. id and gid are included by default") unless options["fields"].present?
54
+ if options["fields"].present?
55
+ fields = options["fields"].split(",").map(&:strip)
56
+ errors.add(:base, "one or more of your fields is invalid. Check your input") unless verify_fields(fields)
57
+ end
58
+ end
59
+
60
+ def verify_fields(fields)
61
+ fields.reduce(true) do |result, field|
62
+ result && SUPPORTED_FIELDS.include?(field.to_sym)
63
+ end
64
+ end
65
+
66
+ def generate_events(result, fields)
67
+ result.each do |item|
68
+ create_event(payload: item.to_json(fields))
69
+ end
70
+ end
71
+
72
+ def check
73
+ asanaClient = Asana::Client.new do |c|
74
+ c.authentication :oauth2, bearer_token: interpolated["access_token"]
75
+ end
76
+
77
+ fields = interpolated["fields"].split(",").map(&:strip)
78
+
79
+ case options["type"]
80
+ when "project"
81
+ result = asanaClient.tasks.find_by_project(projectId: interpolated["id"], options: { fields: fields })
82
+ generate_events(result, fields)
83
+ when "section"
84
+ result = asanaClient.tasks.find_by_section(section: interpolated["id"], options: { fields: fields })
85
+ generate_events(result, fields)
86
+ when "tag"
87
+ result = asanaClient.tasks.find_by_tag(tag: interpolated["id"], options: { fields: fields })
88
+ generate_events(result, fields)
89
+ end
90
+ end
91
+ end
92
+ end
@@ -0,0 +1,18 @@
1
+ require "asana"
2
+
3
+ module HuginnAsana
4
+ refine Asana::Resources::Task do
5
+ def to_json(fields)
6
+ payload = {
7
+ "id" => self.id,
8
+ "gid" => self.gid
9
+ }
10
+
11
+ fields.each do |field|
12
+ payload[field] = self.send(field)
13
+ end
14
+
15
+ payload.to_json
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,5 @@
1
+ require "asana"
2
+
3
+ module HuginnAsanaAgent
4
+ HuginnAgent.register "huginn_asana_agent/asana_task_query_agent"
5
+ end
metadata ADDED
@@ -0,0 +1,111 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: huginn_asana_agent
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.5
5
+ platform: ruby
6
+ authors:
7
+ - Akshaya Srivatsa
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2019-08-14 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.16'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.16'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: huginn_agent
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 0.4.0
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 0.4.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: asana
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 0.8.1
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 0.8.1
69
+ description: Collection of agents to perform actions on Asana
70
+ email:
71
+ - akshay.s86@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - ".travis.yml"
78
+ - Gemfile
79
+ - LICENSE
80
+ - README.md
81
+ - Rakefile
82
+ - huginn_asana_agent.gemspec
83
+ - lib/huginn_asana_agent.rb
84
+ - lib/huginn_asana_agent/asana_task_query_agent.rb
85
+ - lib/huginn_asana_agent/huginn_asana.rb
86
+ homepage: https://github.com/akshayas/huginn_asana_agent
87
+ licenses:
88
+ - MIT
89
+ metadata:
90
+ allowed_push_host: https://rubygems.org
91
+ post_install_message:
92
+ rdoc_options: []
93
+ require_paths:
94
+ - lib
95
+ required_ruby_version: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - ">="
98
+ - !ruby/object:Gem::Version
99
+ version: '0'
100
+ required_rubygems_version: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ requirements: []
106
+ rubyforge_project:
107
+ rubygems_version: 2.5.2.3
108
+ signing_key:
109
+ specification_version: 4
110
+ summary: Collection of agents to perform actions on Asana
111
+ test_files: []