mail2matrix 0.1.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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 320a5cabc89afea79bebb4e2f7949b99d10178112087288eaafc0e97e7357848
4
+ data.tar.gz: 45691d230124e3b707a9e9ccc6ed033d5cd34e79629d6ed362f373dd24bcadb3
5
+ SHA512:
6
+ metadata.gz: e8381df76911d5342bafcb6531ddf8fa8c705a45808593d2491ec107642e89a873046bb1483ec707ab5da8d2704c40aa1b0a5c1555af3a04b2e697c128ab2123
7
+ data.tar.gz: d2d707e809e3dac009dbc8a8eb505107c2850d53976bbf7e90f3e3f3d2c9338a6e7e0a2a2eb6c7943800deefffe54a00673a5186da8db6b7a1298ac22be6a18d
@@ -0,0 +1,20 @@
1
+ Copyright 2019 []().
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,81 @@
1
+ <p align="center">
2
+ <img src="mail2matrix.png" alt="Mail2matrix Icon"/>
3
+ </p>
4
+
5
+ # Mail2matrix
6
+
7
+ [![Gem Version](https://badge.fury.io/rb/mail2matrix.svg)](http://badge.fury.io/rb/mail2matrix)
8
+
9
+ <!-- Tocer[start]: Auto-generated, don't remove. -->
10
+
11
+ ## Table of Contents
12
+
13
+ - [Features](#features)
14
+ - [Screencasts](#screencasts)
15
+ - [Requirements](#requirements)
16
+ - [Setup](#setup)
17
+ - [Usage](#usage)
18
+ - [Tests](#tests)
19
+ - [Versioning](#versioning)
20
+ - [Code of Conduct](#code-of-conduct)
21
+ - [Contributions](#contributions)
22
+ - [License](#license)
23
+ - [History](#history)
24
+ - [Credits](#credits)
25
+
26
+ <!-- Tocer[finish]: Auto-generated, don't remove. -->
27
+
28
+ ## Features
29
+
30
+ ## Screencasts
31
+
32
+ ## Requirements
33
+
34
+ 1. [Ruby 2.6.4](https://www.ruby-lang.org)
35
+
36
+ ## Setup
37
+
38
+ To install, run:
39
+
40
+ gem install mail2matrix
41
+
42
+
43
+ ## Usage
44
+
45
+ ## Tests
46
+
47
+ To test, run:
48
+
49
+ bundle exec rake
50
+
51
+ ## Versioning
52
+
53
+ Read [Semantic Versioning](https://semver.org) for details. Briefly, it means:
54
+
55
+ - Major (X.y.z) - Incremented for any backwards incompatible public API changes.
56
+ - Minor (x.Y.z) - Incremented for new, backwards compatible, public API enhancements/fixes.
57
+ - Patch (x.y.Z) - Incremented for small, backwards compatible, bug fixes.
58
+
59
+ ## Code of Conduct
60
+
61
+ Please note that this project is released with a [CODE OF CONDUCT](CODE_OF_CONDUCT.md). By
62
+ participating in this project you agree to abide by its terms.
63
+
64
+ ## Contributions
65
+
66
+ Read [CONTRIBUTING](CONTRIBUTING.md) for details.
67
+
68
+ ## License
69
+
70
+ Copyright 2019 []().
71
+ Read [LICENSE](LICENSE.md) for details.
72
+
73
+ ## History
74
+
75
+ Read [CHANGES](CHANGES.md) for details.
76
+ Built with [Gemsmith](https://github.com/bkuhlmann/gemsmith).
77
+
78
+ ## Credits
79
+
80
+ Developed by [Paul Sadauskas]() at
81
+ []().
@@ -0,0 +1,9 @@
1
+ #! /usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require_relative "../lib/mail2matrix"
5
+ require_relative "../lib/mail2matrix/cli"
6
+ require_relative "../lib/mail2matrix/configuration"
7
+
8
+ Process.setproctitle Mail2Matrix::Identity.version_label
9
+ Mail2Matrix::CLI.start
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "mail2matrix/identity"
4
+ require_relative "mail2matrix/cli"
5
+
6
+ module Mail2Matrix
7
+ end
@@ -0,0 +1,101 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "forwardable"
4
+ require "optparse"
5
+ require "singleton"
6
+
7
+ require "matrix_sdk"
8
+ require "redcarpet"
9
+ require "xdg"
10
+
11
+ module Mail2Matrix
12
+ # The Command Line Interface (CLI) for the gem.
13
+ class CLI
14
+ include Singleton
15
+ extend Forwardable
16
+
17
+ def self.start
18
+ instance.start
19
+ end
20
+
21
+ def start
22
+ load_configuration
23
+ parse_arguments
24
+ read_stdin
25
+ configuration.finalize!
26
+ run
27
+ end
28
+
29
+ private
30
+
31
+ def load_configuration
32
+ XDG::Config.new
33
+ .all
34
+ .reverse
35
+ .map { |dir| dir.join "mail2matrix.conf" }
36
+ .select(&:exist?)
37
+ .each { |file| configuration.load_from file }
38
+ end
39
+
40
+ def parse_arguments
41
+ parser.parse!
42
+ config.message.room = ARGV.join(" ") unless ARGV.empty?
43
+ end
44
+
45
+ def read_stdin
46
+ config.message.body = STDIN.read
47
+ end
48
+
49
+ def run
50
+ matrix = MatrixSdk::Client.new config.auth.server
51
+ matrix.api.access_token = config.auth.token
52
+
53
+ room = matrix.join_room config.message.room
54
+
55
+ text = <<~BODY
56
+ **#{config.message.subject}**
57
+
58
+ ```
59
+ #{config.message.body}
60
+ ```
61
+ BODY
62
+
63
+ markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML, autolink: true, tables: true, fenced_code_blocks: true)
64
+ html = markdown.render(text)
65
+ puts text
66
+ puts html
67
+
68
+ p room.send_html(html, text)
69
+ end
70
+
71
+ def configuration
72
+ Mail2Matrix::Configuration
73
+ end
74
+ delegate [:config] => :configuration
75
+
76
+ def parser
77
+ OptionParser.new do |opts|
78
+ opts.banner = <<~BANNER
79
+ #{$PROGRAM_NAME} - A drop-in replacement for mail/mailx that will post messages to a Matrix room.
80
+
81
+ It tolerates all normal mail/mailx arguments, but ignores most of them. The only relevant ones are:
82
+ BANNER
83
+
84
+ opts.on("-sSUBJECT", "--subject=SUBJECT", "Used as a heading for the message") do |subject|
85
+ configuration.config.message.subject = subject
86
+ end
87
+
88
+ opts.on("-rFROM", "--from=FROM", "[Ignored]")
89
+
90
+ %w[- B D d E F i n t v ~ a c b r h A S].each do |x|
91
+ opts.on("-#{x}", "[Ignored]")
92
+ end
93
+
94
+ opts.on("-h", "--help", "Prints this help") do
95
+ puts opts
96
+ exit
97
+ end
98
+ end
99
+ end
100
+ end
101
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "dry-configurable"
4
+ require "inifile"
5
+
6
+ module Mail2Matrix
7
+ class Configuration
8
+ extend Dry::Configurable
9
+
10
+ setting :auth do
11
+ setting :username
12
+ setting :password
13
+ setting :token
14
+ setting :server
15
+ end
16
+
17
+ setting :message do
18
+ setting :room
19
+ setting :subject
20
+ setting :body
21
+ end
22
+
23
+ def self.load_from(path)
24
+ ini = IniFile.load path.to_s
25
+ ini.each do |section, k, v|
26
+ config.public_send(section.to_sym).public_send(:"#{k}=", v)
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Mail2Matrix
4
+ # Gem identity information.
5
+ module Identity
6
+ def self.name
7
+ "mail2matrix"
8
+ end
9
+
10
+ def self.label
11
+ "Mail2matrix"
12
+ end
13
+
14
+ def self.version
15
+ "0.1.0"
16
+ end
17
+
18
+ def self.version_label
19
+ "#{label} #{version}"
20
+ end
21
+ end
22
+ end
metadata ADDED
@@ -0,0 +1,252 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mail2matrix
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Paul Sadauskas
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2020-01-01 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: runcom
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '5.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '5.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: thor
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.20'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.20'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler-audit
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '0.6'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '0.6'
55
+ - !ruby/object:Gem::Dependency
56
+ name: gemsmith
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '13.7'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '13.7'
69
+ - !ruby/object:Gem::Dependency
70
+ name: git-cop
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '3.5'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '3.5'
83
+ - !ruby/object:Gem::Dependency
84
+ name: guard-rspec
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '4.7'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '4.7'
97
+ - !ruby/object:Gem::Dependency
98
+ name: pry
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '0.12'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '0.12'
111
+ - !ruby/object:Gem::Dependency
112
+ name: pry-byebug
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '3.7'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '3.7'
125
+ - !ruby/object:Gem::Dependency
126
+ name: rake
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '12.3'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: '12.3'
139
+ - !ruby/object:Gem::Dependency
140
+ name: reek
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: '5.4'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: '5.4'
153
+ - !ruby/object:Gem::Dependency
154
+ name: rspec
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - "~>"
158
+ - !ruby/object:Gem::Version
159
+ version: '3.8'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - "~>"
165
+ - !ruby/object:Gem::Version
166
+ version: '3.8'
167
+ - !ruby/object:Gem::Dependency
168
+ name: rubocop
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - "~>"
172
+ - !ruby/object:Gem::Version
173
+ version: '0.73'
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - "~>"
179
+ - !ruby/object:Gem::Version
180
+ version: '0.73'
181
+ - !ruby/object:Gem::Dependency
182
+ name: rubocop-performance
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - "~>"
186
+ - !ruby/object:Gem::Version
187
+ version: '1.4'
188
+ type: :development
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - "~>"
193
+ - !ruby/object:Gem::Version
194
+ version: '1.4'
195
+ - !ruby/object:Gem::Dependency
196
+ name: rubocop-rspec
197
+ requirement: !ruby/object:Gem::Requirement
198
+ requirements:
199
+ - - "~>"
200
+ - !ruby/object:Gem::Version
201
+ version: '1.33'
202
+ type: :development
203
+ prerelease: false
204
+ version_requirements: !ruby/object:Gem::Requirement
205
+ requirements:
206
+ - - "~>"
207
+ - !ruby/object:Gem::Version
208
+ version: '1.33'
209
+ description:
210
+ email:
211
+ - paul@sadauskas.com
212
+ executables:
213
+ - mail2matrix
214
+ extensions: []
215
+ extra_rdoc_files:
216
+ - README.md
217
+ - LICENSE.md
218
+ files:
219
+ - LICENSE.md
220
+ - README.md
221
+ - bin/mail2matrix
222
+ - lib/mail2matrix.rb
223
+ - lib/mail2matrix/cli.rb
224
+ - lib/mail2matrix/configuration.rb
225
+ - lib/mail2matrix/identity.rb
226
+ homepage: https://github.com/paul/mail2matrix
227
+ licenses:
228
+ - MIT
229
+ metadata:
230
+ source_code_uri: https://github.com/paul/mail2matrix
231
+ changelog_uri: https://github.com/paul/mail2matrix/blob/master/CHANGES.md
232
+ bug_tracker_uri: https://github.com/paul/mail2matrix/issues
233
+ post_install_message:
234
+ rdoc_options: []
235
+ require_paths:
236
+ - lib
237
+ required_ruby_version: !ruby/object:Gem::Requirement
238
+ requirements:
239
+ - - "~>"
240
+ - !ruby/object:Gem::Version
241
+ version: '2.6'
242
+ required_rubygems_version: !ruby/object:Gem::Requirement
243
+ requirements:
244
+ - - ">="
245
+ - !ruby/object:Gem::Version
246
+ version: '0'
247
+ requirements: []
248
+ rubygems_version: 3.1.2
249
+ signing_key:
250
+ specification_version: 4
251
+ summary: ''
252
+ test_files: []