neon_email 0.0.1 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gcloudignore +17 -0
- data/.ruby-version +1 -0
- data/Gemfile +4 -2
- data/Gemfile.lock +84 -6
- data/README.md +11 -3
- data/app.rb +9 -0
- data/lib/neon_email.rb +0 -1
- data/lib/neon_email/greeting_mailer.rb +2 -0
- data/lib/neon_email/version.rb +1 -1
- data/neon_email.gemspec +5 -3
- metadata +36 -10
- data/lib/neon_email/consumer.rb +0 -30
- data/lib/neon_email/producer.rb +0 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '08c8b22c41e226259fc405001baef9de188da57c0f281d32948d67fece337c6b'
|
4
|
+
data.tar.gz: e90c79d2a1ee993af5d0066d34732983e126b29f846b5237371808a585f36e0d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e246399d8f834bb77145fe4537068747cb529b194996ed325cec3ced10a701f8509b446905ad18a0f6599195a6af130b76c55cc16ef6b3fa4e8d8c337c9921af
|
7
|
+
data.tar.gz: c141597c95755e79ce4a99044d83842ace1a83e98274bfe7c7f8312df55477fdfa774ffcc2db5d2d14d365cba4cf2a1ee38fba99e0a4009453861e532e730589
|
data/.gcloudignore
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# This file specifies files that are *not* uploaded to Google Cloud Platform
|
2
|
+
# using gcloud. It follows the same syntax as .gitignore, with the addition of
|
3
|
+
# "#!include" directives (which insert the entries of the given .gitignore-style
|
4
|
+
# file at that point).
|
5
|
+
#
|
6
|
+
# For more information, run:
|
7
|
+
# $ gcloud topic gcloudignore
|
8
|
+
#
|
9
|
+
.gcloudignore
|
10
|
+
# If you would like to upload your .git directory, .gitignore file or files
|
11
|
+
# from your .gitignore file, remove the corresponding line
|
12
|
+
# below:
|
13
|
+
.git
|
14
|
+
.gitignore
|
15
|
+
|
16
|
+
node_modules
|
17
|
+
#!include:.gitignore
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.7
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,23 +1,92 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
neon_email (0.0.
|
4
|
+
neon_email (0.0.8)
|
5
|
+
functions_framework (= 0.9.0)
|
6
|
+
neon_schemas (= 0.1.1)
|
5
7
|
|
6
8
|
GEM
|
7
9
|
remote: https://rubygems.org/
|
8
10
|
specs:
|
11
|
+
addressable (2.7.0)
|
12
|
+
public_suffix (>= 2.0.2, < 5.0)
|
9
13
|
ast (2.4.2)
|
14
|
+
avro (1.10.2)
|
15
|
+
multi_json (~> 1)
|
16
|
+
cloud_events (0.4.0)
|
10
17
|
coderay (1.1.3)
|
11
18
|
concurrent-ruby (1.1.8)
|
12
19
|
diff-lcs (1.4.4)
|
13
|
-
digest-crc (0.6.3)
|
14
|
-
rake (>= 12.0.0, < 14.0.0)
|
15
20
|
faker (2.17.0)
|
16
21
|
i18n (>= 1.6, < 2)
|
22
|
+
faraday (1.4.1)
|
23
|
+
faraday-excon (~> 1.1)
|
24
|
+
faraday-net_http (~> 1.0)
|
25
|
+
faraday-net_http_persistent (~> 1.1)
|
26
|
+
multipart-post (>= 1.2, < 3)
|
27
|
+
ruby2_keywords (>= 0.0.4)
|
28
|
+
faraday-excon (1.1.0)
|
29
|
+
faraday-net_http (1.0.1)
|
30
|
+
faraday-net_http_persistent (1.1.0)
|
17
31
|
fixture_dependencies (1.10.0)
|
32
|
+
functions-framework-ruby (9001.0)
|
33
|
+
functions_framework (0.9.0)
|
34
|
+
cloud_events (~> 0.1)
|
35
|
+
puma (~> 4.3)
|
36
|
+
rack (~> 2.1)
|
37
|
+
gapic-common (0.4.1)
|
38
|
+
faraday (~> 1.3)
|
39
|
+
google-protobuf (~> 3.15, >= 3.15.2)
|
40
|
+
googleapis-common-protos (>= 1.3.11, < 2.0)
|
41
|
+
googleapis-common-protos-types (>= 1.0.6, < 2.0)
|
42
|
+
googleauth (~> 0.15, >= 0.15.1)
|
43
|
+
grpc (~> 1.36)
|
44
|
+
google-cloud-core (1.6.0)
|
45
|
+
google-cloud-env (~> 1.0)
|
46
|
+
google-cloud-errors (~> 1.0)
|
47
|
+
google-cloud-env (1.5.0)
|
48
|
+
faraday (>= 0.17.3, < 2.0)
|
49
|
+
google-cloud-errors (1.1.0)
|
50
|
+
google-cloud-pubsub (2.6.1)
|
51
|
+
concurrent-ruby (~> 1.1)
|
52
|
+
google-cloud-core (~> 1.5)
|
53
|
+
google-cloud-pubsub-v1 (~> 0.0)
|
54
|
+
google-cloud-pubsub-v1 (0.4.0)
|
55
|
+
gapic-common (~> 0.3)
|
56
|
+
google-cloud-errors (~> 1.0)
|
57
|
+
grpc-google-iam-v1 (>= 0.6.10, < 2.0)
|
58
|
+
google-protobuf (3.17.0)
|
59
|
+
googleapis-common-protos (1.3.11)
|
60
|
+
google-protobuf (~> 3.14)
|
61
|
+
googleapis-common-protos-types (>= 1.0.6, < 2.0)
|
62
|
+
grpc (~> 1.27)
|
63
|
+
googleapis-common-protos-types (1.0.6)
|
64
|
+
google-protobuf (~> 3.14)
|
65
|
+
googleauth (0.16.2)
|
66
|
+
faraday (>= 0.17.3, < 2.0)
|
67
|
+
jwt (>= 1.4, < 3.0)
|
68
|
+
memoist (~> 0.16)
|
69
|
+
multi_json (~> 1.11)
|
70
|
+
os (>= 0.9, < 2.0)
|
71
|
+
signet (~> 0.14)
|
72
|
+
grpc (1.37.1)
|
73
|
+
google-protobuf (~> 3.15)
|
74
|
+
googleapis-common-protos-types (~> 1.0)
|
75
|
+
grpc-google-iam-v1 (0.6.11)
|
76
|
+
google-protobuf (~> 3.14)
|
77
|
+
googleapis-common-protos (>= 1.3.11, < 2.0)
|
78
|
+
grpc (~> 1.27)
|
18
79
|
i18n (1.8.10)
|
19
80
|
concurrent-ruby (~> 1.0)
|
81
|
+
jwt (2.2.3)
|
82
|
+
memoist (0.16.2)
|
20
83
|
method_source (1.0.0)
|
84
|
+
multi_json (1.15.0)
|
85
|
+
multipart-post (2.1.1)
|
86
|
+
neon_schemas (0.1.1)
|
87
|
+
avro (~> 1.10)
|
88
|
+
nio4r (2.5.7)
|
89
|
+
os (1.1.1)
|
21
90
|
parallel (1.20.1)
|
22
91
|
parser (3.0.1.0)
|
23
92
|
ast (~> 2.4.1)
|
@@ -25,6 +94,10 @@ GEM
|
|
25
94
|
pry (0.14.1)
|
26
95
|
coderay (~> 1.1)
|
27
96
|
method_source (~> 1.0)
|
97
|
+
public_suffix (4.0.6)
|
98
|
+
puma (4.3.8)
|
99
|
+
nio4r (~> 2.0)
|
100
|
+
rack (2.2.3)
|
28
101
|
rainbow (3.0.0)
|
29
102
|
rake (12.3.3)
|
30
103
|
regexp_parser (2.1.1)
|
@@ -56,13 +129,17 @@ GEM
|
|
56
129
|
rubocop-performance (1.10.1)
|
57
130
|
rubocop (>= 0.90.0, < 2.0)
|
58
131
|
rubocop-ast (>= 0.4.0)
|
59
|
-
ruby-kafka (1.3.0)
|
60
|
-
digest-crc
|
61
132
|
ruby-progressbar (1.11.0)
|
133
|
+
ruby2_keywords (0.0.4)
|
62
134
|
ruby_http_client (3.5.2)
|
63
135
|
sendgrid-ruby (6.4.0)
|
64
136
|
ruby_http_client (~> 3.4)
|
65
137
|
sequel (5.43.0)
|
138
|
+
signet (0.15.0)
|
139
|
+
addressable (~> 2.3)
|
140
|
+
faraday (>= 0.17.3, < 2.0)
|
141
|
+
jwt (>= 1.5, < 3.0)
|
142
|
+
multi_json (~> 1.10)
|
66
143
|
standard (1.0.5)
|
67
144
|
rubocop (= 1.12.1)
|
68
145
|
rubocop-performance (= 1.10.1)
|
@@ -74,12 +151,13 @@ PLATFORMS
|
|
74
151
|
DEPENDENCIES
|
75
152
|
faker (~> 2.17)
|
76
153
|
fixture_dependencies (~> 1.10)
|
154
|
+
functions-framework-ruby (~> 9001.0)
|
155
|
+
google-cloud-pubsub (~> 2.6)
|
77
156
|
neon_email!
|
78
157
|
pg (~> 1.2)
|
79
158
|
pry (~> 0.14.1)
|
80
159
|
rake (~> 12.0)
|
81
160
|
rspec (~> 3.0)
|
82
|
-
ruby-kafka (~> 1.3)
|
83
161
|
sendgrid-ruby (~> 6.4)
|
84
162
|
sequel (~> 5.43)
|
85
163
|
standard
|
data/README.md
CHANGED
@@ -3,10 +3,18 @@
|
|
3
3
|
This gem is used to listen to email messages to Kafka and then interact with the
|
4
4
|
Sendgrid API.
|
5
5
|
|
6
|
-
##
|
6
|
+
## Doppler Setup
|
7
7
|
|
8
|
-
|
9
|
-
|
8
|
+
You can use the `email` project in Doppler and access the `dev` environment when
|
9
|
+
developing locally. The `stg` and `prd` environments are used for staging and
|
10
|
+
production respectively.
|
11
|
+
|
12
|
+
Local development requires you to start the GCP Pub/Sub locally if you want to
|
13
|
+
test the gem end-to-end, _however_ you will most likely __not__ need to start the
|
14
|
+
GCP server because we can depend on the arity defined in the `neon_schemas` gem
|
15
|
+
as a contract that this is how objects in this gem will be initialized and have
|
16
|
+
their methods invoked. You should be able to develop the functionality needed
|
17
|
+
here fully using POROs and necessary email APIs like Sendgrid.
|
10
18
|
|
11
19
|
## Contributing
|
12
20
|
|
data/app.rb
ADDED
data/lib/neon_email.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require "sendgrid-ruby"
|
2
|
+
# require "neon_secrets"
|
2
3
|
|
3
4
|
module NeonEmail
|
4
5
|
class GreetingMailer
|
@@ -20,6 +21,7 @@ module NeonEmail
|
|
20
21
|
mail = SendGrid::Mail.new(from, subject, to, content)
|
21
22
|
|
22
23
|
sg = SendGrid::API.new(api_key: ENV["SENDGRID_API_KEY"])
|
24
|
+
# sg = SendGrid::API.new(api_key: NeonSecrets::Getter.get(secret_name: "sendgrid_api_key"))
|
23
25
|
response = sg.client.mail._("send").post(request_body: mail.to_json)
|
24
26
|
|
25
27
|
puts response
|
data/lib/neon_email/version.rb
CHANGED
data/neon_email.gemspec
CHANGED
@@ -6,9 +6,8 @@ Gem::Specification.new do |spec|
|
|
6
6
|
spec.authors = ["Neon Law"]
|
7
7
|
spec.email = ["support@neonlaw.com"]
|
8
8
|
|
9
|
-
spec.summary = "A gem to
|
10
|
-
spec.description =
|
11
|
-
the Neon Law database'
|
9
|
+
spec.summary = "A gem to handle outbound_email messages in Neon Law software space."
|
10
|
+
spec.description = spec.summary
|
12
11
|
spec.homepage = "https://github.com/neonlaw/codebase"
|
13
12
|
spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
|
14
13
|
|
@@ -22,4 +21,7 @@ Gem::Specification.new do |spec|
|
|
22
21
|
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
23
22
|
end
|
24
23
|
spec.require_paths = ["lib"]
|
24
|
+
|
25
|
+
spec.add_runtime_dependency "neon_schemas", "0.1.1"
|
26
|
+
spec.add_runtime_dependency "functions_framework", "0.9.0"
|
25
27
|
end
|
metadata
CHANGED
@@ -1,35 +1,61 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: neon_email
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Neon Law
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
12
|
-
dependencies:
|
13
|
-
|
14
|
-
|
15
|
-
|
11
|
+
date: 2021-06-14 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: neon_schemas
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.1.1
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.1.1
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: functions_framework
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.9.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.9.0
|
41
|
+
description: A gem to handle outbound_email messages in Neon Law software space.
|
16
42
|
email:
|
17
43
|
- support@neonlaw.com
|
18
44
|
executables: []
|
19
45
|
extensions: []
|
20
46
|
extra_rdoc_files: []
|
21
47
|
files:
|
48
|
+
- ".gcloudignore"
|
22
49
|
- ".gitignore"
|
23
50
|
- ".rspec"
|
24
|
-
- ".
|
51
|
+
- ".ruby-version"
|
25
52
|
- Gemfile
|
26
53
|
- Gemfile.lock
|
27
54
|
- README.md
|
28
55
|
- Rakefile
|
56
|
+
- app.rb
|
29
57
|
- lib/neon_email.rb
|
30
|
-
- lib/neon_email/consumer.rb
|
31
58
|
- lib/neon_email/greeting_mailer.rb
|
32
|
-
- lib/neon_email/producer.rb
|
33
59
|
- lib/neon_email/version.rb
|
34
60
|
- neon_email.gemspec
|
35
61
|
homepage: https://github.com/neonlaw/codebase
|
@@ -56,5 +82,5 @@ requirements: []
|
|
56
82
|
rubygems_version: 3.2.15
|
57
83
|
signing_key:
|
58
84
|
specification_version: 4
|
59
|
-
summary: A gem to
|
85
|
+
summary: A gem to handle outbound_email messages in Neon Law software space.
|
60
86
|
test_files: []
|
data/lib/neon_email/consumer.rb
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
require "kafka"
|
2
|
-
|
3
|
-
module NeonEmail
|
4
|
-
class Consumer
|
5
|
-
def self.consume_messages
|
6
|
-
kafka = Kafka.new(["localhost:9092"])
|
7
|
-
|
8
|
-
# Consumers with the same group id will form a Consumer Group together.
|
9
|
-
consumer = kafka.consumer(group_id: "email")
|
10
|
-
|
11
|
-
# It's possible to subscribe to multiple topics by calling `subscribe`
|
12
|
-
# repeatedly.
|
13
|
-
consumer.subscribe("greetings")
|
14
|
-
|
15
|
-
# Stop the consumer when the SIGTERM signal is sent to the process.
|
16
|
-
# It's better to shut down gracefully than to kill the process.
|
17
|
-
trap("TERM") { consumer.stop }
|
18
|
-
|
19
|
-
# This will loop indefinitely, yielding each message in turn.
|
20
|
-
consumer.each_message do |message|
|
21
|
-
case message.topic
|
22
|
-
when "greetings"
|
23
|
-
NeonEmail::GreetingMailer.deliver(message: message.value)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
NeonEmail::Consumer.consume_messages
|
data/lib/neon_email/producer.rb
DELETED