twmail 0.0.6 → 1.0.0
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 +5 -5
- data/.rubocop.yml +43 -0
- data/.ruby-version +1 -1
- data/.travis.yml +13 -0
- data/Gemfile +5 -3
- data/Guardfile +6 -4
- data/README.md +2 -0
- data/Rakefile +6 -3
- data/bin/task-uuid +13 -11
- data/bin/twmail +12 -11
- data/bin/twmail-hook +14 -12
- data/lib/extensions/string.rb +3 -1
- data/lib/twmail.rb +2 -0
- data/lib/twmail/version.rb +3 -1
- data/test/test_helper.rb +1 -2
- data/test/unit/test_mail.rb +2 -0
- data/test/unit/test_task_uuid.rb +12 -10
- data/test/unit/test_twmail.rb +5 -3
- data/twmail.gemspec +13 -9
- metadata +23 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 748e85ed390994cdeddf2c241a5b6335a7e60496d158be94b73964163747cd88
|
4
|
+
data.tar.gz: f07bbac0bd59b9c83f1236573f65532276945c58b8ceb17334fb8087c0cb9b21
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d44ef50ea1e6f57ff3d6fb46b78a110e1ef988b04b964cbaa574fec0a129e429b4948e6522163c9991674d0c5b4b9c25e01a85328371dd55072727e9ebb653e8
|
7
|
+
data.tar.gz: 12c9faef4553825b5b5b796041e9345ec437c91a9145e2736f069731b2c2865d4ae3fde6c681b13b6438fce05378051d45ae42f4479bb2a0ecbd9722d34380d3
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
AllCops:
|
2
|
+
TargetRubyVersion: 2.7
|
3
|
+
Include:
|
4
|
+
- '**/Gemfile'
|
5
|
+
- '**/Rakefile'
|
6
|
+
- '**/*.rake'
|
7
|
+
Exclude:
|
8
|
+
- vendor/**/*
|
9
|
+
- db/migrations/**/*
|
10
|
+
|
11
|
+
DisplayCopNames:
|
12
|
+
Enabled: true
|
13
|
+
|
14
|
+
DisplayStyleGuide:
|
15
|
+
Enabled: true
|
16
|
+
|
17
|
+
Metrics/BlockLength:
|
18
|
+
Exclude:
|
19
|
+
- spec/**/*
|
20
|
+
|
21
|
+
Layout/LineLength:
|
22
|
+
Max: 180
|
23
|
+
|
24
|
+
Layout/SpaceAroundMethodCallOperator:
|
25
|
+
Enabled: true
|
26
|
+
|
27
|
+
Lint/RaiseException:
|
28
|
+
Enabled: true
|
29
|
+
|
30
|
+
Lint/StructNewOverride:
|
31
|
+
Enabled: true
|
32
|
+
|
33
|
+
Style/ExponentialNotation:
|
34
|
+
Enabled: true
|
35
|
+
|
36
|
+
Style/HashEachMethods:
|
37
|
+
Enabled: true
|
38
|
+
|
39
|
+
Style/HashTransformKeys:
|
40
|
+
Enabled: true
|
41
|
+
|
42
|
+
Style/HashTransformValues:
|
43
|
+
Enabled: true
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.7.1
|
data/.travis.yml
ADDED
data/Gemfile
CHANGED
data/Guardfile
CHANGED
@@ -1,11 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
guard 'bundler' do
|
2
4
|
watch('Gemfile')
|
3
5
|
watch(/^.+\.gemspec/)
|
4
6
|
end
|
5
7
|
|
6
|
-
guard :test, :
|
7
|
-
watch(%r{^lib/(.+)\.rb$}){|m| "test/#{m[1]}_test.rb"}
|
8
|
+
guard :test, test_paths: ['test/unit'] do
|
9
|
+
watch(%r{^lib/(.+)\.rb$}) { |m| "test/#{m[1]}_test.rb" }
|
8
10
|
watch(%r{^test/unit/test_(.+)\.rb$})
|
9
|
-
watch('test/test_helper.rb'){
|
10
|
-
watch('test/helpers/**/*'){
|
11
|
+
watch('test/test_helper.rb') { 'test' }
|
12
|
+
watch('test/helpers/**/*') { 'test' }
|
11
13
|
end
|
data/README.md
CHANGED
data/Rakefile
CHANGED
@@ -1,10 +1,13 @@
|
|
1
|
-
|
2
|
-
require "bundler/gem_tasks"
|
1
|
+
# frozen_string_literal: true
|
3
2
|
|
3
|
+
require 'bundler/gem_tasks'
|
4
4
|
require 'rake/testtask'
|
5
|
+
require 'rubocop/rake_task'
|
6
|
+
RuboCop::RakeTask.new
|
7
|
+
|
5
8
|
Rake::TestTask.new(:test) do |test|
|
6
9
|
test.libs << 'lib' << 'test' << 'test/helpers'
|
7
10
|
test.test_files = FileList['test/**/test_*.rb']
|
8
11
|
end
|
9
12
|
|
10
|
-
task :
|
13
|
+
task default: %i[rubocop test]
|
data/bin/task-uuid
CHANGED
@@ -1,22 +1,24 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
2
4
|
require 'securerandom'
|
3
5
|
require 'optparse'
|
4
6
|
require 'twmail'
|
5
7
|
|
6
8
|
OptionParser.new do |opts|
|
7
|
-
banner =
|
8
|
-
#{opts.program_name} creates a new TaskWarrior task and prints its UUID to STDOUT using the following approach:
|
9
|
+
banner = <<~HERE
|
10
|
+
#{opts.program_name} creates a new TaskWarrior task and prints its UUID to STDOUT using the following approach:
|
9
11
|
|
10
|
-
|
12
|
+
1. Make up a temporary tag name that is very unlikely to exist yet.
|
11
13
|
|
12
|
-
|
14
|
+
2. Create the new task tagged with our temporary tag
|
13
15
|
|
14
|
-
|
16
|
+
3. Use the name of our temporary tag to find the actual UUID generated by TaskWarrior
|
15
17
|
|
16
|
-
|
18
|
+
4. Remove the temporary tag from the new task
|
17
19
|
|
18
|
-
|
19
|
-
HERE
|
20
|
+
5. Print the UUID to STDOUT
|
21
|
+
HERE
|
20
22
|
opts.banner = banner
|
21
23
|
opts.version = TaskWarriorMail::VERSION
|
22
24
|
end.parse!
|
@@ -26,13 +28,13 @@ end.parse!
|
|
26
28
|
tag = 'tag_' + SecureRandom.hex.tr('-', '')
|
27
29
|
|
28
30
|
# 2. Create the new task tagged with our temporary tag
|
29
|
-
|
31
|
+
`task rc.verbose=nothing add +#{tag} #{ARGV.join(' ')}`
|
30
32
|
|
31
33
|
# 3. Remember the UUID generated by TaskWarrior
|
32
|
-
task_uuid =
|
34
|
+
task_uuid = `task rc.verbose=nothing +#{tag} _uuid`.chomp
|
33
35
|
|
34
36
|
# 4. Remove the temporary tag from the new task
|
35
|
-
|
37
|
+
`task rc.verbose=nothing #{task_uuid} modify -#{tag}`
|
36
38
|
|
37
39
|
# 5. Print the UUID to STDOUT
|
38
40
|
puts task_uuid
|
data/bin/twmail
CHANGED
@@ -1,29 +1,30 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
4
|
require 'mail'
|
4
5
|
require 'optparse'
|
5
6
|
require 'twmail'
|
6
7
|
|
7
8
|
OptionParser.new do |opts|
|
8
|
-
banner =
|
9
|
-
#{opts.program_name} is a simple Mail Delivery Agent (MDA) that parses received mail and creates a new TaskWarrior task from the subject of the mail.
|
9
|
+
banner = <<~HERE
|
10
|
+
#{opts.program_name} is a simple Mail Delivery Agent (MDA) that parses received mail and creates a new TaskWarrior task from the subject of the mail.
|
10
11
|
|
11
|
-
USAGE
|
12
|
+
USAGE
|
12
13
|
|
13
|
-
Configure fetchmail to use #{opts.program_name} as MDA:
|
14
|
+
Configure fetchmail to use #{opts.program_name} as MDA:
|
14
15
|
|
15
|
-
|
16
|
-
|
17
|
-
HERE
|
18
|
-
opts.banner = banner
|
16
|
+
# ~/.fetchmailrc
|
17
|
+
mda #{opts.program_name}
|
18
|
+
HERE
|
19
|
+
opts.banner = banner # .wrap
|
19
20
|
opts.version = TaskWarriorMail::VERSION
|
20
21
|
end.parse!
|
21
22
|
|
22
23
|
mail = Mail.new(ARGF.read)
|
23
|
-
task_uuid =
|
24
|
+
task_uuid = `task-uuid \"#{mail.subject}\"`
|
24
25
|
body = mail.text? ? mail.body.decoded : mail.text_part.body.decoded
|
25
26
|
|
26
27
|
SEPARATOR = '-- '
|
27
|
-
body = body.split(SEPARATOR)[0] if
|
28
|
+
body = body.split(SEPARATOR)[0] if body.include?(SEPARATOR)
|
28
29
|
|
29
|
-
|
30
|
+
`task '#{task_uuid}' annotate \"#{body}\"`
|
data/bin/twmail-hook
CHANGED
@@ -1,37 +1,39 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
2
4
|
require 'mail'
|
3
5
|
require 'optparse'
|
4
6
|
require 'twmail'
|
5
7
|
|
6
8
|
OptionParser.new do |opts|
|
7
|
-
banner =
|
8
|
-
#{opts.program_name} is a simple Mail Delivery Agent (MDA) that that exports the parts of the received email as environment variables and calls a shell script that can make use of these variables to further process the mail.
|
9
|
+
banner = <<~HERE
|
10
|
+
#{opts.program_name} is a simple Mail Delivery Agent (MDA) that that exports the parts of the received email as environment variables and calls a shell script that can make use of these variables to further process the mail.
|
9
11
|
|
10
|
-
USAGE
|
12
|
+
USAGE
|
11
13
|
|
12
|
-
|
14
|
+
Configure fetchmail to use #{opts.program_name} as MDA:
|
13
15
|
|
14
|
-
|
15
|
-
|
16
|
+
# ~/.fetchmailrc
|
17
|
+
mda #{opts.program_name}
|
16
18
|
|
17
|
-
HERE
|
18
|
-
opts.banner = banner
|
19
|
+
HERE
|
20
|
+
opts.banner = banner # .wrap
|
19
21
|
opts.version = TaskWarriorMail::VERSION
|
20
22
|
end.parse!
|
21
23
|
|
22
24
|
mail = Mail.new(ARGF.read)
|
23
25
|
|
24
26
|
# Expose mail properties as environment variables
|
25
|
-
%w[date message_id from to subject body].each
|
27
|
+
%w[date message_id from to subject body].each do |field|
|
26
28
|
value = mail.send(field.to_sym)
|
27
29
|
value = value.join(',') if value.respond_to?(:join)
|
28
30
|
ENV["TWMAIL_#{field.upcase}"] = Shellwords.escape(value.to_s)
|
29
|
-
|
31
|
+
end
|
30
32
|
|
31
33
|
# The hook to be executed is read from the environment variable TWMAIL_HOOK
|
32
34
|
# If none is set, this script will assume that twmail_on_new_mail is in the
|
33
35
|
# $PATH and executable.
|
34
|
-
cmd = ENV.fetch(
|
36
|
+
cmd = ENV.fetch('TWMAIL_HOOK', 'twmail-hook')
|
35
37
|
|
36
38
|
# Call hook script
|
37
|
-
|
39
|
+
`#{cmd}`
|
data/lib/extensions/string.rb
CHANGED
data/lib/twmail.rb
CHANGED
data/lib/twmail/version.rb
CHANGED
data/test/test_helper.rb
CHANGED
data/test/unit/test_mail.rb
CHANGED
data/test/unit/test_task_uuid.rb
CHANGED
@@ -1,10 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'shellwords'
|
2
4
|
require 'open3'
|
3
5
|
require 'test/unit'
|
4
6
|
|
5
7
|
class Command
|
6
|
-
def exec(cmd
|
7
|
-
env.each{|k,v| ENV[k.to_s] = v.to_s}
|
8
|
+
def exec(cmd='', args={})
|
9
|
+
env.each { |k, v| ENV[k.to_s] = v.to_s }
|
8
10
|
line = build_line(cmd, args)
|
9
11
|
Open3.capture3(line)
|
10
12
|
end
|
@@ -23,18 +25,18 @@ class Command
|
|
23
25
|
|
24
26
|
private
|
25
27
|
|
26
|
-
def build_line(cmd
|
27
|
-
[].tap{|line|
|
28
|
+
def build_line(cmd='', args={})
|
29
|
+
[].tap { |line|
|
28
30
|
line << executable
|
29
|
-
line << default_args.merge(args).map{|k,v| "#{Shellwords.escape(k.strip)}=#{Shellwords.escape(v.strip)}"}.join(' ')
|
31
|
+
line << default_args.merge(args).map { |k, v| "#{Shellwords.escape(k.strip)}=#{Shellwords.escape(v.strip)}" }.join(' ')
|
30
32
|
line << cmd.strip
|
31
|
-
line.reject!
|
33
|
+
line.reject!(&:empty?)
|
32
34
|
}.join(' ')
|
33
35
|
end
|
34
36
|
|
35
37
|
def overrides(env)
|
36
38
|
intersection = env.keys.to_set & ENV.keys.to_set
|
37
|
-
ENV.select{|k,v| intersection.include?(k)}
|
39
|
+
ENV.select { |k, v| intersection.include?(k) }
|
38
40
|
end
|
39
41
|
end
|
40
42
|
|
@@ -51,11 +53,11 @@ class TaskWarriorCommand < Command
|
|
51
53
|
|
52
54
|
def env
|
53
55
|
raise "data_dir must not be empty for '#{executable}'" if @data_dir.nil? || data_dir.empty?
|
54
|
-
{TASKDATA: @data_dir}
|
56
|
+
{ TASKDATA: @data_dir }
|
55
57
|
end
|
56
58
|
|
57
59
|
def default_args
|
58
|
-
{'rc.verbose' => 'nothing', 'rc.json.array' => 'on'}
|
60
|
+
{ 'rc.verbose' => 'nothing', 'rc.json.array' => 'on' }
|
59
61
|
end
|
60
62
|
|
61
63
|
def executable
|
@@ -70,7 +72,7 @@ class TaskUUID < TaskWarriorCommand
|
|
70
72
|
|
71
73
|
def executable
|
72
74
|
# The gem version that uses the binstub fails if the script is not Ruby
|
73
|
-
#'task-uuid'
|
75
|
+
# 'task-uuid'
|
74
76
|
|
75
77
|
# The local version, called directly, works fine even if it's a Bash script
|
76
78
|
File.join(File.dirname(__FILE__), '..', '..', 'bin', 'task-uuid')
|
data/test/unit/test_twmail.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'test_helper'
|
2
4
|
|
3
|
-
class TestHelpers < TaskWarrior::Test::Integration::
|
5
|
+
class TestHelpers < TaskWarrior::Test::Integration::Test
|
4
6
|
def teardown
|
5
7
|
ENV['TASKRC'] = nil
|
6
8
|
super
|
@@ -67,8 +69,8 @@ class TestHelpers < TaskWarrior::Test::Integration::TestCase
|
|
67
69
|
def deliver_fixture(status, fixture)
|
68
70
|
twmail = File.join(File.dirname(__FILE__), '..', '..', 'bin', 'twmail')
|
69
71
|
ENV['TASKRC'] = @taskrc_file
|
70
|
-
output =
|
71
|
-
assert_equal(status,
|
72
|
+
output = `cat #{fixture} | #{twmail}`
|
73
|
+
assert_equal(status, $CHILD_STATUS.exitstatus)
|
72
74
|
output
|
73
75
|
end
|
74
76
|
|
data/twmail.gemspec
CHANGED
@@ -1,25 +1,29 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'English'
|
2
5
|
require File.expand_path('../lib/twmail/version', __FILE__)
|
3
6
|
|
4
7
|
Gem::Specification.new do |gem|
|
5
|
-
gem.authors = [
|
6
|
-
gem.email = [
|
7
|
-
gem.description =
|
8
|
-
gem.summary =
|
8
|
+
gem.authors = ['Nicholas E. Rabenau']
|
9
|
+
gem.email = ['nerab@gmx.net']
|
10
|
+
gem.description = 'Mail new tasks to your TaskWarrior inbox'
|
11
|
+
gem.summary = 'Use fetchmail and the scripts in this project to mail tasks to your local TaskWarrior installation'
|
9
12
|
gem.homepage = 'https://github.com/nerab/TaskWarriorMail'
|
10
13
|
|
11
|
-
gem.files = `git ls-files`.split(
|
12
|
-
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
14
|
+
gem.files = `git ls-files`.split($OUTPUT_RECORD_SEPARATOR)
|
15
|
+
gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) }
|
13
16
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
14
|
-
gem.name =
|
15
|
-
gem.require_paths = [
|
17
|
+
gem.name = 'twmail'
|
18
|
+
gem.require_paths = ['lib']
|
16
19
|
gem.version = TaskWarriorMail::VERSION
|
17
20
|
|
18
21
|
gem.add_dependency 'mail'
|
19
22
|
|
20
|
-
gem.add_development_dependency 'twtest', '
|
23
|
+
gem.add_development_dependency 'twtest', '~> 1.1.0'
|
21
24
|
gem.add_development_dependency 'guard-test'
|
22
25
|
gem.add_development_dependency 'guard-bundler'
|
23
26
|
gem.add_development_dependency 'pry'
|
24
27
|
gem.add_development_dependency 'rake'
|
28
|
+
gem.add_development_dependency 'rubocop'
|
25
29
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: twmail
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nicholas E. Rabenau
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-04-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mail
|
@@ -28,16 +28,16 @@ dependencies:
|
|
28
28
|
name: twtest
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 1.1.0
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: 1.1.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: guard-test
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -94,6 +94,20 @@ dependencies:
|
|
94
94
|
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rubocop
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
97
111
|
description: Mail new tasks to your TaskWarrior inbox
|
98
112
|
email:
|
99
113
|
- nerab@gmx.net
|
@@ -105,7 +119,9 @@ extensions: []
|
|
105
119
|
extra_rdoc_files: []
|
106
120
|
files:
|
107
121
|
- ".gitignore"
|
122
|
+
- ".rubocop.yml"
|
108
123
|
- ".ruby-version"
|
124
|
+
- ".travis.yml"
|
109
125
|
- CONTRIBUTING.markdown
|
110
126
|
- Gemfile
|
111
127
|
- Guardfile
|
@@ -153,8 +169,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
153
169
|
- !ruby/object:Gem::Version
|
154
170
|
version: '0'
|
155
171
|
requirements: []
|
156
|
-
|
157
|
-
rubygems_version: 2.6.11
|
172
|
+
rubygems_version: 3.1.2
|
158
173
|
signing_key:
|
159
174
|
specification_version: 4
|
160
175
|
summary: Use fetchmail and the scripts in this project to mail tasks to your local
|