neon_operations 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: ee06454f2b8cc9eb84b6399068b6cbae7f0c4ab30a96f2ce0247e992f459a020
4
+ data.tar.gz: b357c634e70488b51dc5316e910b76cd6eff4d3ef5e8f2fb6c3e74461efbca55
5
+ SHA512:
6
+ metadata.gz: d3d0ccc9ec32f7574a099d26e5805b32dba7dd7e4b457d7f1bb50169723bf986b203832d2aa1838ddb1b8a7fb474db9c55554c4cabff6712fcafc8d47878400b
7
+ data.tar.gz: 90164987ec62d7f417cad4685aae497f399ce9d191b40c8139f2f25a825eb08a4de03ca8fe10dbad3508d4fb0c45ec1a63f7b8d75169ce45b40fa8420ec1f899
data/.gitignore ADDED
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
12
+ *.gem
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.7
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in neon_postgres.gemspec
4
+ gemspec
5
+
6
+ gem "rake", "~> 12.0"
7
+ gem "rspec", "~> 3.0"
8
+ gem "standard"
data/Gemfile.lock ADDED
@@ -0,0 +1,61 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ neon_operations (0.0.1)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ ast (2.4.2)
10
+ diff-lcs (1.4.4)
11
+ parallel (1.20.1)
12
+ parser (3.0.1.0)
13
+ ast (~> 2.4.1)
14
+ rainbow (3.0.0)
15
+ rake (12.3.3)
16
+ regexp_parser (2.1.1)
17
+ rexml (3.2.5)
18
+ rspec (3.10.0)
19
+ rspec-core (~> 3.10.0)
20
+ rspec-expectations (~> 3.10.0)
21
+ rspec-mocks (~> 3.10.0)
22
+ rspec-core (3.10.1)
23
+ rspec-support (~> 3.10.0)
24
+ rspec-expectations (3.10.1)
25
+ diff-lcs (>= 1.2.0, < 2.0)
26
+ rspec-support (~> 3.10.0)
27
+ rspec-mocks (3.10.2)
28
+ diff-lcs (>= 1.2.0, < 2.0)
29
+ rspec-support (~> 3.10.0)
30
+ rspec-support (3.10.2)
31
+ rubocop (1.12.1)
32
+ parallel (~> 1.10)
33
+ parser (>= 3.0.0.0)
34
+ rainbow (>= 2.2.2, < 4.0)
35
+ regexp_parser (>= 1.8, < 3.0)
36
+ rexml
37
+ rubocop-ast (>= 1.2.0, < 2.0)
38
+ ruby-progressbar (~> 1.7)
39
+ unicode-display_width (>= 1.4.0, < 3.0)
40
+ rubocop-ast (1.4.1)
41
+ parser (>= 2.7.1.5)
42
+ rubocop-performance (1.10.1)
43
+ rubocop (>= 0.90.0, < 2.0)
44
+ rubocop-ast (>= 0.4.0)
45
+ ruby-progressbar (1.11.0)
46
+ standard (1.0.5)
47
+ rubocop (= 1.12.1)
48
+ rubocop-performance (= 1.10.1)
49
+ unicode-display_width (2.0.0)
50
+
51
+ PLATFORMS
52
+ ruby
53
+
54
+ DEPENDENCIES
55
+ neon_operations!
56
+ rake (~> 12.0)
57
+ rspec (~> 3.0)
58
+ standard
59
+
60
+ BUNDLED WITH
61
+ 2.1.4
data/README.md ADDED
@@ -0,0 +1,30 @@
1
+ # Neon Operations
2
+
3
+ This gem is a thin wrapper around Dry-RB libraries to standardize our use
4
+ testable, incremental functional programming written in Ruby.
5
+
6
+ ## API
7
+
8
+ This gem only exposes two classes, `Operation` and `GCPFunctionsManager`.
9
+
10
+ ### `Operation`
11
+
12
+ This is the base class from which all Dry-RB Operations (Monads) should inherit
13
+ from. We mandate that:
14
+
15
+ * all operations contain a schema_contract from the `NeonSchemas` gem
16
+ * all operations contain one class method `self.call` with one param, `input`.
17
+ This `input` should be a hash that can be validated against the passed in
18
+ schema_contract
19
+ * the method `validate_input` **always** be the first function applied in the
20
+ chain of functions within an operation.
21
+
22
+ ### `GCPFunctionsManager`
23
+
24
+ This class takes GCP Cloud Functions events and invokes the `call` method on an
25
+ operation. This class is specific to Google Cloud Platform.
26
+
27
+ ## Contributing
28
+
29
+ Bug reports and pull requests are welcome on GitHub at
30
+ https://github.com/neonlaw/codebase.
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task default: :spec
@@ -0,0 +1,38 @@
1
+ require "neon_operations/version"
2
+
3
+ module NeonOperations
4
+ class GCPFunctionsManager
5
+ def self.invoke_operation(operation, gcp_functions_event)
6
+ data = JSON.parse(
7
+ Base64.strict_decode64(
8
+ gcp_functions_event.data.fetch("message").fetch("data")
9
+ )
10
+ )
11
+
12
+ operation.call(input: data)
13
+ end
14
+ end
15
+
16
+ class Operation
17
+ def self.call(input:)
18
+ new(input: input).call
19
+ end
20
+
21
+ def initialize(input:, schema_contract: nil)
22
+ @input = input
23
+ @schema_contract = schema_contract
24
+ end
25
+
26
+ def call
27
+ validate_input
28
+ end
29
+
30
+ private
31
+
32
+ attr_reader :input, :schema_contract
33
+
34
+ def validate_input
35
+ schema_contract.validate(input)
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,3 @@
1
+ module NeonOperations
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,24 @@
1
+ require_relative "lib/neon_operations/version"
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "neon_operations"
5
+ spec.version = NeonOperations::VERSION
6
+ spec.authors = ["Neon Law"]
7
+ spec.email = ["support@neonlaw.com"]
8
+
9
+ spec.summary = "A gem to standardize our use of Dry-RB"
10
+ spec.description = spec.summary
11
+ spec.homepage = "https://github.com/neonlaw/codebase"
12
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
13
+
14
+ spec.metadata["homepage_uri"] = spec.homepage
15
+ spec.metadata["source_code_uri"] = spec.homepage
16
+ spec.metadata["changelog_uri"] = spec.homepage
17
+
18
+ # Specify which files should be added to the gem when it is released.
19
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
20
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
21
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
22
+ end
23
+ spec.require_paths = ["lib"]
24
+ end
metadata ADDED
@@ -0,0 +1,55 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: neon_operations
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Neon Law
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2021-06-29 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: A gem to standardize our use of Dry-RB
14
+ email:
15
+ - support@neonlaw.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - ".gitignore"
21
+ - ".rspec"
22
+ - ".ruby-version"
23
+ - Gemfile
24
+ - Gemfile.lock
25
+ - README.md
26
+ - Rakefile
27
+ - lib/neon_operations.rb
28
+ - lib/neon_operations/version.rb
29
+ - neon_operations.gemspec
30
+ homepage: https://github.com/neonlaw/codebase
31
+ licenses: []
32
+ metadata:
33
+ homepage_uri: https://github.com/neonlaw/codebase
34
+ source_code_uri: https://github.com/neonlaw/codebase
35
+ changelog_uri: https://github.com/neonlaw/codebase
36
+ post_install_message:
37
+ rdoc_options: []
38
+ require_paths:
39
+ - lib
40
+ required_ruby_version: !ruby/object:Gem::Requirement
41
+ requirements:
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ version: 2.3.0
45
+ required_rubygems_version: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: '0'
50
+ requirements: []
51
+ rubygems_version: 3.2.15
52
+ signing_key:
53
+ specification_version: 4
54
+ summary: A gem to standardize our use of Dry-RB
55
+ test_files: []