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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ac10ee5c8b168a8c0962a03575afa4f2354eb2cc841f177ef406d52b4b13308d
4
- data.tar.gz: 794195193edefa7b7203a819fe88c0cdad46de2cbab605c26f558df54e4d38ab
3
+ metadata.gz: f9f55a44ae19d2e0a2217e1438fe48c1003db2af8e863d81bd037db887498c8f
4
+ data.tar.gz: 8c4fc37df108a91d6717a54274de6a24e3013caa76f17122c721a72b6720e09b
5
5
  SHA512:
6
- metadata.gz: 4344aaaa9f767494b1b13b4086e4dfdf70a8639cf01a6ab6e5c6762258ec6049c79160ee828794d7fa598cab1de4b911d2edc57387ade28084f544220894ac83
7
- data.tar.gz: df0996a61516f0f9a5df3275e410a30e38294f853de80470efecae51d3d898d9b7f10cf4bede3d0e8cd23a25557a6c0cf44144007bbd8cb16fe4168a9399a581
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)
@@ -1,5 +1,5 @@
1
1
  require "neon_documents/version"
2
- require "neon_documents/consumer"
2
+ require "neon_documents/handler"
3
3
  require "neon_documents/document_processor"
4
4
  Dir["#{__dir__}/neon_documents/document_templates/*"].sort.each { |file|
5
5
  require file
@@ -9,14 +9,14 @@ module NeonDocuments
9
9
  end
10
10
 
11
11
  def initialize(unprocessed_document_id:)
12
- @unprocessed_document_id = unprunprocessed_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.filename
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
@@ -0,0 +1,5 @@
1
+ require "functions_framework"
2
+
3
+ FunctionsFramework.cloud_event "neon_law.unprocessed_document" do |event|
4
+ FunctionsFramework.logger.info "I received an event of type #{event.type}!"
5
+ end
@@ -1,3 +1,3 @@
1
1
  module NeonDocuments
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -22,4 +22,6 @@ Gem::Specification.new do |spec|
22
22
  `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
23
23
  end
24
24
  spec.require_paths = ["lib"]
25
+
26
+ spec.add_runtime_dependency "functions_framework", "0.9.0"
25
27
  end
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.1
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-05-10 00:00:00.000000000 Z
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