huginn_todoist_agent 0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c85d85dc83cb07347d239dae248831c88103869a
4
+ data.tar.gz: 14676173cd5ef4e61cc8610a2bcef96d2cf8a5a6
5
+ SHA512:
6
+ metadata.gz: 9336eff0a18785196e2aea96745e2f3a0c9f8f5eae16b64013fb529d0f1a99af6f0be6858b651aa4e8205e5ffb00909c634e4722055a14854788109a9e8a00cb
7
+ data.tar.gz: fb98a6d61a4ef57416ac4c0f99b09a1100bf9e97dd4e544c6037f9b521ecd1b75f3897557b13432b313917a51f73ce4d0b697aa16813032cd94b79bc07235e9a
data/LICENSE.txt ADDED
@@ -0,0 +1,7 @@
1
+ Copyright (c) 2017 Stefan Siegl
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,4 @@
1
+ require 'huginn_agent'
2
+
3
+ #HuginnAgent.load 'huginn_todoist_agent/concerns/my_agent_concern'
4
+ HuginnAgent.register 'huginn_todoist_agent/todoist_agent'
@@ -0,0 +1,77 @@
1
+ module Agents
2
+ class TodoistAgent < Agent
3
+ include FormConfigurable
4
+
5
+ cannot_be_scheduled!
6
+ cannot_create_events!
7
+
8
+ gem_dependency_check { defined?(Todoist::Client) }
9
+
10
+ description do
11
+ <<-MD
12
+ The Todoist Agent will create one item on your Todoist for every event it receives.
13
+
14
+ Specify your Todoist API token (from Todoist Settings > Account) as `token` and
15
+ provide some `content`.
16
+
17
+ In order to set a due date provide a `date_string` (which may contain all date string
18
+ features supported by Todoist).
19
+
20
+ `project_id` is the *ID* of the project to add the item to. Leave blank for INBOX.
21
+
22
+ `labels` is a comma-seperated list of label IDs (or blank for no labels).
23
+
24
+ `prority` is an integer from 1 to 4. Where 1 means lowest (natural) priority and
25
+ 4 highest. Defaults to natural priority (aka 1).
26
+ MD
27
+ end
28
+
29
+ def default_options
30
+ {
31
+ 'token' => '',
32
+ 'content' => '{{ content }}',
33
+ 'date_string' => 'today',
34
+ 'project_id' => '',
35
+ 'labels' => '',
36
+ 'priority' => '',
37
+ }
38
+ end
39
+
40
+ form_configurable :token
41
+ form_configurable :content, type: :text
42
+ form_configurable :date_string
43
+ form_configurable :project_id
44
+ form_configurable :labels
45
+ form_configurable :priority
46
+
47
+ def working?
48
+ !recent_error_logs?
49
+ end
50
+
51
+ def validate_options
52
+ errors.add(:base, 'you need to specify your Todoist token') unless options['token'].present?
53
+ end
54
+
55
+ def receive(incoming_events)
56
+ incoming_events.each do |event|
57
+ interpolate_with(event) do
58
+ item = { 'content' => interpolated['content'] }
59
+ item['date_string'] = interpolated['date_string'] if interpolated['date_string'].present?
60
+ item['project_id'] = interpolated['project_id'].to_i if interpolated['project_id'].present?
61
+ item['priority'] = interpolated['priority'].to_i if interpolated['priority'].present?
62
+
63
+ if interpolated['labels'].present?
64
+ item['labels'] = interpolated['labels'].split(%r{,\s*}).map(&:to_i)
65
+ end
66
+
67
+ log "creating item: #{item}"
68
+ todoist = Todoist::Client.new(interpolated['token'])
69
+ todoist.items.create(item)
70
+ todoist.process!
71
+ end
72
+ end
73
+ end
74
+
75
+ end
76
+ end
77
+
@@ -0,0 +1,13 @@
1
+ require 'rails_helper'
2
+ require 'huginn_agent/spec_helper'
3
+
4
+ describe Agents::TodoistAgent do
5
+ before(:each) do
6
+ @valid_options = Agents::TodoistAgent.new.default_options
7
+ @checker = Agents::TodoistAgent.new(:name => "TodoistAgent", :options => @valid_options)
8
+ @checker.user = users(:bob)
9
+ @checker.save!
10
+ end
11
+
12
+ pending "add specs here"
13
+ end
metadata ADDED
@@ -0,0 +1,106 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: huginn_todoist_agent
3
+ version: !ruby/object:Gem::Version
4
+ version: '0.1'
5
+ platform: ruby
6
+ authors:
7
+ - Stefan Siegl
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-01-31 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.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
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'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: ruby-todoist-api
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0.3'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0.3'
69
+ description: The Todoist Agent will create one item on your Todoist for every Huginn
70
+ event it receives.
71
+ email:
72
+ - stesie@brokenpipe.de
73
+ executables: []
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - LICENSE.txt
78
+ - lib/huginn_todoist_agent.rb
79
+ - lib/huginn_todoist_agent/todoist_agent.rb
80
+ - spec/todoist_agent_spec.rb
81
+ homepage: https://github.com/stesie/huginn_todoist_agent
82
+ licenses:
83
+ - MIT
84
+ metadata: {}
85
+ post_install_message:
86
+ rdoc_options: []
87
+ require_paths:
88
+ - lib
89
+ required_ruby_version: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - ">="
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ required_rubygems_version: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - ">="
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
99
+ requirements: []
100
+ rubyforge_project:
101
+ rubygems_version: 2.5.1
102
+ signing_key:
103
+ specification_version: 4
104
+ summary: Huginn agent to add items to your Todoist.
105
+ test_files:
106
+ - spec/todoist_agent_spec.rb