neon_documents 0.0.1 → 0.0.3
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 +4 -4
- data/Gemfile.lock +10 -0
- data/lib/neon_documents.rb +1 -1
- data/lib/neon_documents/document_processor.rb +17 -2
- data/lib/neon_documents/handler.rb +5 -0
- data/lib/neon_documents/version.rb +1 -1
- data/neon_documents.gemspec +2 -0
- metadata +18 -4
- data/lib/neon_documents/consumer.rb +0 -30
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f9f55a44ae19d2e0a2217e1438fe48c1003db2af8e863d81bd037db887498c8f
|
4
|
+
data.tar.gz: 8c4fc37df108a91d6717a54274de6a24e3013caa76f17122c721a72b6720e09b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 56daf0f79b2131fa8336061c02c62bafe676d83822701f0a01724032a2468c14a917f8fe2cb825ca1eb8fe0a21e00071fe211a794a4bba6b3909bdc646c78c13
|
7
|
+
data.tar.gz: ba8fdd2582b24f60560de6bf829d3e5a91dc381404acd8e12cceb29576aa94b3c79465d19f646a94e3442ba2d3829f2908bf4e0e658595af5adb592fe585cb67
|
data/Gemfile.lock
CHANGED
@@ -2,11 +2,13 @@ PATH
|
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
4
|
neon_documents (0.0.1)
|
5
|
+
functions_framework (= 0.9.0)
|
5
6
|
|
6
7
|
GEM
|
7
8
|
remote: https://rubygems.org/
|
8
9
|
specs:
|
9
10
|
ast (2.4.2)
|
11
|
+
cloud_events (0.4.0)
|
10
12
|
coderay (1.1.3)
|
11
13
|
concurrent-ruby (1.1.8)
|
12
14
|
diff-lcs (1.4.4)
|
@@ -15,10 +17,15 @@ GEM
|
|
15
17
|
faker (2.17.0)
|
16
18
|
i18n (>= 1.6, < 2)
|
17
19
|
fixture_dependencies (1.10.0)
|
20
|
+
functions_framework (0.9.0)
|
21
|
+
cloud_events (~> 0.1)
|
22
|
+
puma (~> 4.3)
|
23
|
+
rack (~> 2.1)
|
18
24
|
i18n (1.8.10)
|
19
25
|
concurrent-ruby (~> 1.0)
|
20
26
|
method_source (1.0.0)
|
21
27
|
neon_postgres (0.0.1)
|
28
|
+
nio4r (2.5.7)
|
22
29
|
parallel (1.20.1)
|
23
30
|
parser (3.0.1.0)
|
24
31
|
ast (~> 2.4.1)
|
@@ -26,6 +33,9 @@ GEM
|
|
26
33
|
pry (0.14.1)
|
27
34
|
coderay (~> 1.1)
|
28
35
|
method_source (~> 1.0)
|
36
|
+
puma (4.3.8)
|
37
|
+
nio4r (~> 2.0)
|
38
|
+
rack (2.2.3)
|
29
39
|
rainbow (3.0.0)
|
30
40
|
rake (12.3.3)
|
31
41
|
regexp_parser (2.1.1)
|
data/lib/neon_documents.rb
CHANGED
@@ -9,14 +9,14 @@ module NeonDocuments
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def initialize(unprocessed_document_id:)
|
12
|
-
@unprocessed_document_id =
|
12
|
+
@unprocessed_document_id = unprocessed_document_id
|
13
13
|
end
|
14
14
|
|
15
15
|
def encode_and_store_document
|
16
16
|
filename = case document_template.name
|
17
17
|
when "Webpage Screenshot"
|
18
18
|
NeonDocuments::DocumentTemplates::WebpageScreenshot.processed_filename(
|
19
|
-
unprocessed_filename: unprocessed_document
|
19
|
+
unprocessed_filename: unprocessed_document
|
20
20
|
)
|
21
21
|
end
|
22
22
|
|
@@ -42,5 +42,20 @@ module NeonDocuments
|
|
42
42
|
id: unprocessed_document.fetch(:document_template_id)
|
43
43
|
)
|
44
44
|
end
|
45
|
+
|
46
|
+
def processed_document_filename
|
47
|
+
"#{documentable_type}/#{documentable_id}/#{filename}"
|
48
|
+
end
|
49
|
+
|
50
|
+
def filename
|
51
|
+
case document_template.name
|
52
|
+
when "Webpage Screenshot"
|
53
|
+
NeonDocuments::DocumentTemplates::WebpageScreenshot.processed_filename(
|
54
|
+
unprocessed_filename: unprocessed_document
|
55
|
+
)
|
56
|
+
else
|
57
|
+
document_template.name
|
58
|
+
end
|
59
|
+
end
|
45
60
|
end
|
46
61
|
end
|
data/neon_documents.gemspec
CHANGED
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: neon_documents
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
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:
|
11
|
+
date: 2021-06-18 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: functions_framework
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.9.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.9.0
|
13
27
|
description: |-
|
14
28
|
This gem contains tests and sequel setup to speak to
|
15
29
|
the Neon Law database
|
@@ -26,9 +40,9 @@ files:
|
|
26
40
|
- README.md
|
27
41
|
- Rakefile
|
28
42
|
- lib/neon_documents.rb
|
29
|
-
- lib/neon_documents/consumer.rb
|
30
43
|
- lib/neon_documents/document_processor.rb
|
31
44
|
- lib/neon_documents/document_templates/webpage_screenshot.rb
|
45
|
+
- lib/neon_documents/handler.rb
|
32
46
|
- lib/neon_documents/version.rb
|
33
47
|
- neon_documents.gemspec
|
34
48
|
homepage: https://github.com/neonlaw/codebase
|
@@ -1,30 +0,0 @@
|
|
1
|
-
require "kafka"
|
2
|
-
|
3
|
-
module NeonDocuments
|
4
|
-
class Consumer
|
5
|
-
def self.consume_messages
|
6
|
-
kafka = Kafka.new([ENV.fetch("KAFKA_URL") { "kafka:9092" }])
|
7
|
-
|
8
|
-
# Consumers with the same group id will form a Consumer Group together.
|
9
|
-
consumer = kafka.consumer(group_id: "documents")
|
10
|
-
|
11
|
-
# It's possible to subscribe to multiple topics by calling `subscribe`
|
12
|
-
# repeatedly.
|
13
|
-
consumer.subscribe("process_document")
|
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 "process_document"
|
23
|
-
NeonDocument::DocumentProcessor.encode_and_store_document(
|
24
|
-
unprocessed_document_id: message.value
|
25
|
-
)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|