activefunction 0.3.5 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -1
- data/README.md +182 -69
- data/lib/.rbnext/2.7/active_function/functions/strong_parameters.rb +84 -41
- data/lib/.rbnext/3.0/active_function/base.rb +58 -0
- data/lib/.rbnext/3.0/active_function/functions/response.rb +38 -19
- data/lib/.rbnext/3.0/active_function.rb +63 -0
- data/lib/.rbnext/3.1/active_function/functions/response.rb +49 -0
- data/lib/active_function/base.rb +52 -14
- data/lib/active_function/functions/callbacks.rb +58 -58
- data/lib/active_function/functions/rendering.rb +36 -9
- data/lib/active_function/functions/response.rb +38 -19
- data/lib/active_function/functions/strong_parameters.rb +84 -41
- data/lib/active_function/version.rb +1 -1
- data/lib/active_function.rb +54 -3
- metadata +55 -26
- data/bin/console +0 -15
- data/bin/rake +0 -27
- data/bin/rubocop +0 -27
- data/bin/ruby-next +0 -16
- data/bin/setup +0 -8
- data/lib/.rbnext/3.0/active_function/functions/core.rb +0 -49
- data/lib/active_function/functions/core.rb +0 -49
data/lib/active_function.rb
CHANGED
@@ -1,12 +1,63 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "active_function_core"
|
4
|
+
require "active_function/version"
|
5
|
+
require "active_function/base"
|
4
6
|
|
5
7
|
RubyNext::Language.setup_gem_load_path(transpile: true)
|
6
8
|
|
7
9
|
module ActiveFunction
|
8
|
-
class
|
10
|
+
class << self
|
11
|
+
# Configure ActiveFunction through DSL method calls.
|
12
|
+
# Setups {ActiveFunction::Base} with provided internal and custom plugins.
|
13
|
+
# Also freezes plugins and {ActiveFunction::Base}.
|
14
|
+
#
|
15
|
+
# @example
|
16
|
+
# ActiveFunction.config do
|
17
|
+
# plugin :callbacks
|
18
|
+
# end
|
19
|
+
#
|
20
|
+
# @param block [Proc] class_eval'ed block in ActiveFunction module.
|
21
|
+
# @return [void]
|
22
|
+
def config(&block)
|
23
|
+
class_eval(&block)
|
24
|
+
@_plugins.freeze
|
25
|
+
self::Base.freeze
|
26
|
+
end
|
9
27
|
|
10
|
-
|
11
|
-
|
28
|
+
# List of registered internal plugins.
|
29
|
+
def plugins = @_plugins ||= {}
|
30
|
+
|
31
|
+
# Register internal Symbol'ed plugin.
|
32
|
+
#
|
33
|
+
# @param [Symbol] symbol name of internal plugin,
|
34
|
+
# should match file name in ./lib/active_function/functions/*.rb
|
35
|
+
# @param [Module] mod module to register.
|
36
|
+
def register_plugin(symbol, mod)
|
37
|
+
plugins[symbol] = mod
|
38
|
+
end
|
39
|
+
|
40
|
+
# Add plugin to ActiveFunction::Base.
|
41
|
+
#
|
42
|
+
# @example
|
43
|
+
# ActiveFunction.plugin :callbacks
|
44
|
+
# ActiveFunction.plugin CustomPlugin
|
45
|
+
#
|
46
|
+
# @param [Symbol, Module] mod
|
47
|
+
# @return [void]
|
48
|
+
def plugin(mod)
|
49
|
+
if mod.is_a? Symbol
|
50
|
+
begin
|
51
|
+
require "active_function/functions/#{mod}"
|
52
|
+
mod = plugins.fetch(mod)
|
53
|
+
rescue LoadError
|
54
|
+
raise ArgumentError, "Unknown plugin #{mod}"
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
self::Base.include(mod)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
plugin :response
|
12
63
|
end
|
metadata
CHANGED
@@ -1,43 +1,57 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activefunction
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nerbyk
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-01-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activefunction-core
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
19
|
+
version: 0.2.2
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.
|
26
|
+
version: 0.2.2
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '13.0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '13.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: ruby-next
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 1.0.0
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 1.0.0
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: minitest
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -66,11 +80,30 @@ dependencies:
|
|
66
80
|
- - "~>"
|
67
81
|
- !ruby/object:Gem::Version
|
68
82
|
version: 1.4.3
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: mocha
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 2.1.0
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 2.1.0
|
97
|
+
description: "\n ActiveFunction is a collection of gems designed to be used with
|
98
|
+
Function as a Service (FaaS) computing instances. Inspired by aws-sdk v3 gem structure
|
99
|
+
and rails/activesupport.\n\n Features:\n - Ruby Version Compatibility: Implemented
|
100
|
+
with most of Ruby 3.2+ features, with support for Ruby versions >= 2.6 through the
|
101
|
+
RubyNext transpiler (CI'ed).\n - Type Safety: Achieves type safety through the
|
102
|
+
use of RBS and Steep (CI'ed) [Note: disabled due to the presence of Ruby::UnsupportedSyntax
|
103
|
+
errors].\n - Plugins System: Provides a simple Plugin system inspired by Polishing
|
104
|
+
Ruby Programming by Jeremy Evans to load gem plugins and self-defined plugins.\n
|
105
|
+
\ - Gem Collection: Offers a collection of gems designed for use within ActiveFunction
|
106
|
+
or as standalone components.\n "
|
74
107
|
email:
|
75
108
|
- danil.maximov2000@gmail.com
|
76
109
|
executables: []
|
@@ -80,18 +113,14 @@ files:
|
|
80
113
|
- CHANGELOG.md
|
81
114
|
- LICENSE.txt
|
82
115
|
- README.md
|
83
|
-
- bin/console
|
84
|
-
- bin/rake
|
85
|
-
- bin/rubocop
|
86
|
-
- bin/ruby-next
|
87
|
-
- bin/setup
|
88
116
|
- lib/.rbnext/2.7/active_function/functions/strong_parameters.rb
|
89
|
-
- lib/.rbnext/3.0/active_function
|
117
|
+
- lib/.rbnext/3.0/active_function.rb
|
118
|
+
- lib/.rbnext/3.0/active_function/base.rb
|
90
119
|
- lib/.rbnext/3.0/active_function/functions/response.rb
|
120
|
+
- lib/.rbnext/3.1/active_function/functions/response.rb
|
91
121
|
- lib/active_function.rb
|
92
122
|
- lib/active_function/base.rb
|
93
123
|
- lib/active_function/functions/callbacks.rb
|
94
|
-
- lib/active_function/functions/core.rb
|
95
124
|
- lib/active_function/functions/rendering.rb
|
96
125
|
- lib/active_function/functions/response.rb
|
97
126
|
- lib/active_function/functions/strong_parameters.rb
|
@@ -105,7 +134,7 @@ metadata:
|
|
105
134
|
homepage_uri: https://github.com/DanilMaximov/activefunction
|
106
135
|
source_code_uri: https://github.com/DanilMaximov/activefunction
|
107
136
|
changelog_uri: https://github.com/DanilMaximov/activefunction/CHANGELOG.md
|
108
|
-
post_install_message:
|
137
|
+
post_install_message:
|
109
138
|
rdoc_options: []
|
110
139
|
require_paths:
|
111
140
|
- lib
|
@@ -120,9 +149,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
120
149
|
- !ruby/object:Gem::Version
|
121
150
|
version: '0'
|
122
151
|
requirements: []
|
123
|
-
rubygems_version: 3.4
|
124
|
-
signing_key:
|
152
|
+
rubygems_version: 3.5.4
|
153
|
+
signing_key:
|
125
154
|
specification_version: 4
|
126
|
-
summary:
|
127
|
-
|
155
|
+
summary: Playground gem for Ruby 3.2+ features and more, designed for FaaS computing
|
156
|
+
instances, but mostly used for experiments.
|
128
157
|
test_files: []
|
data/bin/console
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
require "bundler/setup"
|
5
|
-
require "active_function"
|
6
|
-
|
7
|
-
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
-
# with your gem easier. You can also use a different console, if you like.
|
9
|
-
|
10
|
-
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
-
# require "pry"
|
12
|
-
# Pry.start
|
13
|
-
|
14
|
-
require "irb"
|
15
|
-
IRB.start(__FILE__)
|
data/bin/rake
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
#
|
5
|
-
# This file was generated by Bundler.
|
6
|
-
#
|
7
|
-
# The application 'rake' is installed as part of a gem, and
|
8
|
-
# this file is here to facilitate running it.
|
9
|
-
#
|
10
|
-
|
11
|
-
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
|
12
|
-
|
13
|
-
bundle_binstub = File.expand_path("bundle", __dir__)
|
14
|
-
|
15
|
-
if File.file?(bundle_binstub)
|
16
|
-
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
|
17
|
-
load(bundle_binstub)
|
18
|
-
else
|
19
|
-
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
20
|
-
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
require "rubygems"
|
25
|
-
require "bundler/setup"
|
26
|
-
|
27
|
-
load Gem.bin_path("rake", "rake")
|
data/bin/rubocop
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
#
|
5
|
-
# This file was generated by Bundler.
|
6
|
-
#
|
7
|
-
# The application 'rubocop' is installed as part of a gem, and
|
8
|
-
# this file is here to facilitate running it.
|
9
|
-
#
|
10
|
-
|
11
|
-
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
|
12
|
-
|
13
|
-
bundle_binstub = File.expand_path("bundle", __dir__)
|
14
|
-
|
15
|
-
if File.file?(bundle_binstub)
|
16
|
-
if File.read(bundle_binstub, 300).include?("This file was generated by Bundler")
|
17
|
-
load(bundle_binstub)
|
18
|
-
else
|
19
|
-
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
20
|
-
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
require "rubygems"
|
25
|
-
require "bundler/setup"
|
26
|
-
|
27
|
-
load Gem.bin_path("rubocop", "rubocop")
|
data/bin/ruby-next
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
lib_path = File.expand_path("../lib", __dir__)
|
4
|
-
$LOAD_PATH.unshift(lib_path) unless $LOAD_PATH.include?(lib_path)
|
5
|
-
|
6
|
-
require "ruby-next/cli"
|
7
|
-
|
8
|
-
begin
|
9
|
-
cli = RubyNext::CLI.new
|
10
|
-
cli.run(ARGV)
|
11
|
-
rescue => e
|
12
|
-
raise e if $DEBUG
|
13
|
-
STDERR.puts e.message
|
14
|
-
STDERR.puts e.backtrace.join("\n") if ENV["RUBY_NEXT_DEBUG"] == "1"
|
15
|
-
exit 1
|
16
|
-
end
|
data/bin/setup
DELETED
@@ -1,49 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module ActiveFunction
|
4
|
-
class MissingRouteMethod < Error
|
5
|
-
MESSAGE_TEMPLATE = "Missing function route: %s"
|
6
|
-
|
7
|
-
attr_reader :message
|
8
|
-
|
9
|
-
def initialize(context)
|
10
|
-
@message = MESSAGE_TEMPLATE % context
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
class NotRenderedError < Error
|
15
|
-
MESSAGE_TEMPLATE = "render was not called: %s"
|
16
|
-
|
17
|
-
attr_reader :message
|
18
|
-
|
19
|
-
def initialize(context)
|
20
|
-
@message = MESSAGE_TEMPLATE % context
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
module Functions
|
25
|
-
module Core
|
26
|
-
attr_reader :action_name, :request, :response
|
27
|
-
|
28
|
-
def dispatch(action_name, request, response)
|
29
|
-
@action_name = action_name
|
30
|
-
@request = request
|
31
|
-
@response = response
|
32
|
-
|
33
|
-
raise MissingRouteMethod, @action_name unless respond_to?(action_name)
|
34
|
-
|
35
|
-
process(@action_name)
|
36
|
-
|
37
|
-
raise NotRenderedError, @action_name unless performed?
|
38
|
-
|
39
|
-
@response.to_h
|
40
|
-
end
|
41
|
-
|
42
|
-
private
|
43
|
-
|
44
|
-
def process(action) ; public_send(action); end
|
45
|
-
|
46
|
-
def performed? ; @response.committed?; end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
@@ -1,49 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module ActiveFunction
|
4
|
-
class MissingRouteMethod < Error
|
5
|
-
MESSAGE_TEMPLATE = "Missing function route: %s"
|
6
|
-
|
7
|
-
attr_reader :message
|
8
|
-
|
9
|
-
def initialize(context)
|
10
|
-
@message = MESSAGE_TEMPLATE % context
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
class NotRenderedError < Error
|
15
|
-
MESSAGE_TEMPLATE = "render was not called: %s"
|
16
|
-
|
17
|
-
attr_reader :message
|
18
|
-
|
19
|
-
def initialize(context)
|
20
|
-
@message = MESSAGE_TEMPLATE % context
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
module Functions
|
25
|
-
module Core
|
26
|
-
attr_reader :action_name, :request, :response
|
27
|
-
|
28
|
-
def dispatch(action_name, request, response)
|
29
|
-
@action_name = action_name
|
30
|
-
@request = request
|
31
|
-
@response = response
|
32
|
-
|
33
|
-
raise MissingRouteMethod, @action_name unless respond_to?(action_name)
|
34
|
-
|
35
|
-
process(@action_name)
|
36
|
-
|
37
|
-
raise NotRenderedError, @action_name unless performed?
|
38
|
-
|
39
|
-
@response.to_h
|
40
|
-
end
|
41
|
-
|
42
|
-
private
|
43
|
-
|
44
|
-
def process(action) = public_send(action)
|
45
|
-
|
46
|
-
def performed? = @response.committed?
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|