raki 0.0.3 → 0.1.0
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/LICENSE +1 -1
- data/README.md +152 -2
- data/lib/raki/builder.rb +27 -41
- data/lib/raki/chain.rb +40 -0
- data/lib/raki/idem.rb +3 -6
- data/lib/raki/lint.rb +9 -19
- data/lib/raki/merge.rb +3 -3
- data/lib/raki/middleware.rb +33 -0
- data/lib/raki/require.rb +2 -3
- data/lib/raki/slice.rb +3 -3
- data/lib/raki/version.rb +5 -2
- data/lib/raki/version.rb.bak +4 -10
- data/lib/raki.rb +21 -11
- data/lib/raki.rb.bak +25 -0
- metadata +33 -30
- data/lib/raki/block.rb +0 -12
- data/lib/raki/cache.rb +0 -28
- data/lib/raki/middleware_base.rb +0 -16
- data/lib/raki/nil.rb +0 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b9fd5bc673e5339421fabb11056856de910aaeadc073f90b90e0dfcdc1e55b2e
|
4
|
+
data.tar.gz: e4d2408df565ffcbb84f628dc5c2363d037d6975ec0519cfa080a0130c04d492
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2e5bb4e3770618c9fac8c25f6f9376d2acfde1003a8963ad1fcdb4271fb8cead7ff61ed1a15cc6492eac25a68ac51cde6091cee3bde33699268929c1f571371d
|
7
|
+
data.tar.gz: 94ebb8db09a7f187130902b0715a04814336bb3388adb174fb61fb735bceffea763b4ed8ae7d24b7a25fedbea319b0b0cef07514e9d7e122794fde373f558eb8
|
data/LICENSE
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
MIT License
|
2
2
|
|
3
|
-
Copyright (c) 2020 Dittmar Krall - www.matique.com
|
3
|
+
Copyright (c) 2020-2021 Dittmar Krall - www.matique.com
|
4
4
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
data/README.md
CHANGED
@@ -1,3 +1,153 @@
|
|
1
|
-
#
|
1
|
+
# Raki
|
2
|
+
[](http://badge.fury.io/rb/raki)
|
2
3
|
|
3
|
-
|
4
|
+
The Raki specification enables a kind of piping objects.
|
5
|
+
|
6
|
+
The composing is done by Raki::Chain and Raki::Builder.
|
7
|
+
|
8
|
+
## Specification
|
9
|
+
|
10
|
+
A Raki is a Ruby object (not a class) that responds to "call".
|
11
|
+
It takes exactly one argument, a Hash, and returns a result, again a Hash.
|
12
|
+
|
13
|
+
Rakis are stackable due to the generality of its argument and result.
|
14
|
+
|
15
|
+
Sometimes it is expected that a Raki delivers an array of strings as
|
16
|
+
part of the result.
|
17
|
+
The convention is that this array is accessed as "result[:body]".
|
18
|
+
|
19
|
+
## Simple Raki
|
20
|
+
|
21
|
+
A simple Raki (a proc/lambda can be a Raki):
|
22
|
+
|
23
|
+
~~~
|
24
|
+
raki = ->(hsh) { {body: ["Hello World!"]} }
|
25
|
+
~~~
|
26
|
+
|
27
|
+
and a little more complex:
|
28
|
+
|
29
|
+
~~~
|
30
|
+
raki = ->(hsh) { {body: ["Hi #{hsh[:name]!", "Nice to meet you."] } }
|
31
|
+
~~~
|
32
|
+
|
33
|
+
## Middleware
|
34
|
+
|
35
|
+
A Raki::Middleware is a Raki that calls another Raki enabling
|
36
|
+
"before" and "after" code, i.e. operations around the second Raki.
|
37
|
+
|
38
|
+
A Raki middleware is ready to be stacked.
|
39
|
+
|
40
|
+
A sample for a Raki middleware:
|
41
|
+
|
42
|
+
~~~~
|
43
|
+
# already included in "gem raki"
|
44
|
+
module Raki
|
45
|
+
class Middleware
|
46
|
+
def initialize(app)
|
47
|
+
@app = app
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
|
53
|
+
# your sample
|
54
|
+
class SampleMiddleware < Raki::Middleware
|
55
|
+
def call(env)
|
56
|
+
# do something before
|
57
|
+
result = @app.call(env) # if @app
|
58
|
+
# do something after
|
59
|
+
result[:body] << "My grain of salt."
|
60
|
+
result
|
61
|
+
end
|
62
|
+
end
|
63
|
+
~~~~
|
64
|
+
|
65
|
+
## Composing
|
66
|
+
|
67
|
+
### Raki::Chain
|
68
|
+
|
69
|
+
Raki::Chain chains Rakis.
|
70
|
+
In particular, it will forward the result of a previous Raki
|
71
|
+
as the argument of the next one.
|
72
|
+
The argument for the first Raki is the arguent of the "call".
|
73
|
+
The return value is the result of the last Raki.
|
74
|
+
|
75
|
+
A sample:
|
76
|
+
|
77
|
+
~~~
|
78
|
+
class Cl < Raki::Base
|
79
|
+
def call(env)
|
80
|
+
env + @args.first
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
proca = ->(env) { env + "a" }
|
85
|
+
app = Raki::Chain.new do
|
86
|
+
add Cl, "C"
|
87
|
+
add proca
|
88
|
+
add { |env| env + "b" }
|
89
|
+
add ->(env) { env + "c" }
|
90
|
+
end
|
91
|
+
|
92
|
+
app.call("") # --> "Cabc"
|
93
|
+
~~~
|
94
|
+
|
95
|
+
### Raki::Builder
|
96
|
+
|
97
|
+
Raki::Builder chains Raki::Middleware.
|
98
|
+
In particular, the "@app" is initialized for each middleware.
|
99
|
+
The last middleware "@app" is initialized to "nil".
|
100
|
+
|
101
|
+
It is expected that each middleware takes care to call the next one.
|
102
|
+
|
103
|
+
A sample:
|
104
|
+
|
105
|
+
~~~
|
106
|
+
class MW < Raki::Middleware
|
107
|
+
def call(env)
|
108
|
+
result = env + @args.first
|
109
|
+
return result unless @app
|
110
|
+
|
111
|
+
@app.call(result)
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
app = Raki::Builder.new do
|
116
|
+
add MW, "a"
|
117
|
+
add MW, "b"
|
118
|
+
end
|
119
|
+
|
120
|
+
app.call("") # --> "ab"
|
121
|
+
|
122
|
+
~~~
|
123
|
+
|
124
|
+
### Recommendations
|
125
|
+
|
126
|
+
Implement a Raki as idempotent, i.e. same arguments delivers same results.
|
127
|
+
|
128
|
+
It is always a good idea to avoid side-effects.
|
129
|
+
|
130
|
+
Frozen arguments may avoid some strange behaviour.
|
131
|
+
|
132
|
+
## Installation
|
133
|
+
|
134
|
+
Install the gem:
|
135
|
+
|
136
|
+
~~~
|
137
|
+
gem install raki
|
138
|
+
~~~
|
139
|
+
|
140
|
+
Or in your Gemfile:
|
141
|
+
|
142
|
+
~~~
|
143
|
+
# Gemfile
|
144
|
+
gem 'raki'
|
145
|
+
~~~
|
146
|
+
|
147
|
+
## Miscellaneous
|
148
|
+
|
149
|
+
Heavily inspired by Rack.
|
150
|
+
|
151
|
+
Raki is released under the MIT License.
|
152
|
+
|
153
|
+
[Code of Conduct](https://github.com/matique/matique/blob/main/CODE_OF_CONDUCT.md)
|
data/lib/raki/builder.rb
CHANGED
@@ -1,59 +1,45 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# see also
|
4
|
-
# cat ~/test/rack/lib/rack/builder.rb
|
5
|
-
|
6
|
-
# inspired by Rack::Builder
|
7
3
|
module Raki
|
8
|
-
class Builder
|
9
|
-
|
10
|
-
@added = []
|
11
|
-
@runs = [default_app].compact
|
12
|
-
instance_eval(&block) if block_given?
|
13
|
-
end
|
4
|
+
class Builder < Raki::Base
|
5
|
+
# attr_accessor :stack
|
14
6
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
7
|
+
def initialize(&block)
|
8
|
+
@stack = []
|
9
|
+
instance_eval(&block) if block
|
10
|
+
chain
|
19
11
|
end
|
20
12
|
|
21
13
|
def add(middleware, *args, &block)
|
22
|
-
|
23
|
-
|
24
|
-
@added <<
|
14
|
+
@stack <<
|
25
15
|
if middleware.instance_of?(Class)
|
26
|
-
|
16
|
+
middleware.new(*args, &block)
|
27
17
|
else
|
28
|
-
|
18
|
+
middleware
|
29
19
|
end
|
30
20
|
end
|
31
|
-
ruby2_keywords(:add) if respond_to?(:ruby2_keywords, true)
|
32
21
|
|
33
|
-
def
|
34
|
-
|
22
|
+
def chain
|
23
|
+
previous = nil
|
24
|
+
@stack.each do |app|
|
25
|
+
previous.app = app if previous
|
26
|
+
previous = app
|
27
|
+
end
|
35
28
|
end
|
36
29
|
|
37
|
-
def
|
38
|
-
|
39
|
-
@added.reverse.inject(app) { |a, e| e[a] }
|
30
|
+
def call(hsh = {})
|
31
|
+
@stack.first&.call(hsh)
|
40
32
|
end
|
41
33
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
body << b unless b.empty?
|
53
|
-
}
|
54
|
-
|
55
|
-
[status, hsh, body.flatten]
|
56
|
-
end
|
57
|
-
end
|
34
|
+
# def to_s(pre = "")
|
35
|
+
# next_pre = pre + " "
|
36
|
+
# res = []
|
37
|
+
# res << "#{pre}#{self.class.name} #{object_id}"
|
38
|
+
# res << "#{pre}@stack.length #{@stack.length}"
|
39
|
+
# @stack.each_with_index { |mv, idx|
|
40
|
+
# res << "#{pre}[#{idx}] #{mv.to_s(next_pre)}"
|
41
|
+
# }
|
42
|
+
# res.flatten.join("\n")
|
43
|
+
# end
|
58
44
|
end
|
59
45
|
end
|
data/lib/raki/chain.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Raki
|
4
|
+
class Chain < Base
|
5
|
+
def initialize(*args, &block)
|
6
|
+
super
|
7
|
+
@stack = []
|
8
|
+
instance_eval(&block) if block
|
9
|
+
end
|
10
|
+
|
11
|
+
def add(middleware = nil, *args, &block)
|
12
|
+
middleware ||= block
|
13
|
+
@stack <<
|
14
|
+
if middleware.instance_of?(Class)
|
15
|
+
middleware.new(*args, &block)
|
16
|
+
else
|
17
|
+
middleware
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def call(hsh)
|
22
|
+
my_hsh = hsh
|
23
|
+
@stack.each { |app| my_hsh = app.call(my_hsh) }
|
24
|
+
my_hsh
|
25
|
+
end
|
26
|
+
|
27
|
+
# def to_s(pre = "")
|
28
|
+
# next_pre = pre + " "
|
29
|
+
# res = []
|
30
|
+
# res << "#{pre}#{self.class.name} #{object_id}"
|
31
|
+
# res << "#{pre}args #{@args}"
|
32
|
+
# # res << @app.to_s(next_pre) if @app
|
33
|
+
# res << "#{pre}@app #{@app.object_id}" if @app
|
34
|
+
# @stack.each_with_index { |mv, idx|
|
35
|
+
# res << "#{pre}[#{idx}] #{mv.to_s(next_pre)}"
|
36
|
+
# }
|
37
|
+
# res.flatten.join("\n")
|
38
|
+
# end
|
39
|
+
end
|
40
|
+
end
|
data/lib/raki/idem.rb
CHANGED
@@ -1,13 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
#
|
3
|
+
# Rreturns "env" (doing nothing)
|
4
4
|
module Raki
|
5
|
-
class Idem < Raki::
|
5
|
+
class Idem < Raki::Middleware
|
6
6
|
def call(env)
|
7
|
-
|
8
|
-
|
9
|
-
@block&.call(env)
|
10
|
-
@app.call(env)
|
7
|
+
env
|
11
8
|
end
|
12
9
|
end
|
13
10
|
end
|
data/lib/raki/lint.rb
CHANGED
@@ -1,31 +1,21 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
#
|
4
|
-
|
5
|
-
# see also:
|
6
|
-
# cat ~/test/rack/lib/rack/lint.rb
|
7
|
-
# cat ~/test/rack/SPEC.rdoc
|
3
|
+
# validates according to Raki definition.
|
8
4
|
module Raki
|
9
5
|
class LintError < RuntimeError; end
|
10
6
|
|
11
|
-
class Lint < Raki::
|
7
|
+
class Lint < Raki::Middleware
|
12
8
|
def call(env)
|
13
|
-
assert(
|
14
|
-
assert(
|
15
|
-
|
16
|
-
@block&.call(env)
|
17
|
-
response = @app.call(env)
|
9
|
+
assert("No env given") { env }
|
10
|
+
# assert("Run complained") { @block.call(env) } if @block
|
18
11
|
|
19
|
-
|
20
|
-
assert(
|
21
|
-
|
22
|
-
assert('Second item must be a Hash') { response[1].class == Hash }
|
23
|
-
assert('Third item must be an Array') { response[2].class == Array }
|
24
|
-
|
25
|
-
response
|
12
|
+
result = @app&.call(env)
|
13
|
+
assert("Expected hash") { result.instance_of?(Hash) }
|
14
|
+
result
|
26
15
|
end
|
27
16
|
|
28
|
-
|
17
|
+
private
|
18
|
+
|
29
19
|
def assert(message)
|
30
20
|
return if yield
|
31
21
|
|
data/lib/raki/merge.rb
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
# Middleware Merge.
|
4
4
|
module Raki
|
5
|
-
class Merge < Raki::
|
5
|
+
class Merge < Raki::Middleware
|
6
6
|
def call(env)
|
7
7
|
my_env = env.merge(*@args)
|
8
|
-
@block
|
9
|
-
|
8
|
+
app = @block || @app
|
9
|
+
app.call(my_env)
|
10
10
|
end
|
11
11
|
end
|
12
12
|
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Base for middleware
|
4
|
+
module Raki
|
5
|
+
class Middleware
|
6
|
+
attr_accessor :app
|
7
|
+
|
8
|
+
def initialize(*args, &block)
|
9
|
+
@app = nil
|
10
|
+
@args = args
|
11
|
+
@block = block
|
12
|
+
end
|
13
|
+
|
14
|
+
def call(env)
|
15
|
+
my_env = env
|
16
|
+
result = ZERO
|
17
|
+
app = @block || @app
|
18
|
+
return result unless app
|
19
|
+
|
20
|
+
app.call(my_env)
|
21
|
+
end
|
22
|
+
|
23
|
+
# def to_s(pre = "")
|
24
|
+
# # next_pre = pre + " "
|
25
|
+
# res = []
|
26
|
+
# res << "#{pre}#{self.class.name} #{object_id}"
|
27
|
+
# res << "#{pre}args #{@args}"
|
28
|
+
# # res << @app.to_s(next_pre) if @app
|
29
|
+
# res << "#{pre}@app #{@app.object_id}" if @app
|
30
|
+
# res.flatten.join("\n")
|
31
|
+
# end
|
32
|
+
end
|
33
|
+
end
|
data/lib/raki/require.rb
CHANGED
@@ -4,14 +4,13 @@
|
|
4
4
|
module Raki
|
5
5
|
class RequireError < RuntimeError; end
|
6
6
|
|
7
|
-
class Require < Raki::
|
7
|
+
class Require < Raki::Middleware
|
8
8
|
def call(env)
|
9
9
|
expected = @args.flatten.sort
|
10
10
|
bool = env.keys.sort == expected
|
11
11
|
raise(RequireError, "Expected <#{expected.join}>") unless bool
|
12
12
|
|
13
|
-
@
|
14
|
-
@app.call(env)
|
13
|
+
@app&.call(env)
|
15
14
|
end
|
16
15
|
end
|
17
16
|
end
|
data/lib/raki/slice.rb
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
# Middleware Slice.
|
4
4
|
module Raki
|
5
|
-
class Slice < Raki::
|
5
|
+
class Slice < Raki::Middleware
|
6
6
|
def call(env)
|
7
7
|
my_env = env.slice(*@args.flatten)
|
8
|
-
@block
|
9
|
-
|
8
|
+
app = @block || @app
|
9
|
+
app.call(my_env)
|
10
10
|
end
|
11
11
|
end
|
12
12
|
end
|
data/lib/raki/version.rb
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Raki
|
4
|
-
VERSION =
|
5
|
-
#
|
4
|
+
VERSION = "0.1.0" # 2021-11-03
|
5
|
+
# VERSION = "0.0.5" # 2021-07-01
|
6
|
+
# VERSION = '0.0.4' # 2021-06-25
|
7
|
+
# VERSION = '0.0.3' # 2020-07-14
|
8
|
+
# VERSION = '0.0.2'
|
6
9
|
end
|
data/lib/raki/version.rb.bak
CHANGED
@@ -1,14 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Raki is freely distributable under the terms of an MIT-style license.
|
4
|
-
# See MIT-LICENSE or https://opensource.org/licenses/MIT.
|
5
|
-
|
6
|
-
# The Raki main module, serving as a namespace for all core Raki
|
7
|
-
# modules and classes.
|
8
|
-
#
|
9
|
-
# All modules meant for use in your application are <tt>autoload</tt>ed here,
|
10
|
-
# so it should be enough just to <tt>require 'rack'</tt> in your code.
|
11
|
-
|
12
3
|
module Raki
|
13
|
-
VERSION =
|
4
|
+
VERSION = "0.0.5" # 2021-07-01
|
5
|
+
# VERSION = '0.0.4' # 2021-06-25
|
6
|
+
# VERSION = '0.0.3' # 2020-07-14
|
7
|
+
# VERSION = '0.0.2'
|
14
8
|
end
|
data/lib/raki.rb
CHANGED
@@ -1,15 +1,25 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Raki
|
4
|
-
autoload :
|
5
|
-
autoload :
|
6
|
-
autoload :
|
7
|
-
autoload :
|
8
|
-
autoload :
|
9
|
-
autoload :
|
10
|
-
autoload :
|
11
|
-
autoload :
|
12
|
-
autoload :
|
13
|
-
|
14
|
-
|
4
|
+
autoload :Builder, "raki/builder"
|
5
|
+
autoload :Chain, "raki/chain"
|
6
|
+
autoload :Idem, "raki/idem"
|
7
|
+
autoload :Lint, "raki/lint"
|
8
|
+
autoload :Merge, "raki/merge"
|
9
|
+
autoload :Middleware, "raki/middleware"
|
10
|
+
autoload :Params, "raki/params"
|
11
|
+
autoload :Require, "raki/require"
|
12
|
+
autoload :Slice, "raki/slice"
|
13
|
+
|
14
|
+
ZERO = {body: []}
|
15
|
+
|
16
|
+
class Base
|
17
|
+
def initialize(*args)
|
18
|
+
@args = args
|
19
|
+
end
|
20
|
+
|
21
|
+
def call(env)
|
22
|
+
ZERO
|
23
|
+
end
|
24
|
+
end
|
15
25
|
end
|
data/lib/raki.rb.bak
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Raki
|
4
|
+
autoload :Builder, "raki/builder"
|
5
|
+
autoload :Chain, "raki/chain"
|
6
|
+
autoload :Idem, "raki/idem"
|
7
|
+
autoload :Lint, "raki/lint"
|
8
|
+
autoload :Merge, "raki/merge"
|
9
|
+
autoload :Middleware, "raki/middleware"
|
10
|
+
autoload :Params, "raki/params"
|
11
|
+
autoload :Require, "raki/require"
|
12
|
+
autoload :Slice, "raki/slice"
|
13
|
+
|
14
|
+
ZERO = {body: []}
|
15
|
+
|
16
|
+
class Base
|
17
|
+
def initialize(*args)
|
18
|
+
@args = args
|
19
|
+
end
|
20
|
+
|
21
|
+
def call(env)
|
22
|
+
ZERO
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
metadata
CHANGED
@@ -1,74 +1,77 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: raki
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dittmar Krall
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-11-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '0'
|
20
20
|
type: :development
|
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: '
|
26
|
+
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '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
|
-
version: '
|
40
|
+
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: minitest
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: minitest-global_expectations
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - "
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
69
|
-
description:
|
68
|
+
version: '0'
|
69
|
+
description: |
|
70
|
+
Raki enables chaining of objects.
|
71
|
+
It is based on the definition of an interface and
|
72
|
+
some builders.
|
70
73
|
|
71
|
-
|
74
|
+
Chained Rakis must conforms to the Raki definition.
|
72
75
|
email: dittmar.krall@matique.de
|
73
76
|
executables: []
|
74
77
|
extensions: []
|
@@ -77,14 +80,13 @@ files:
|
|
77
80
|
- LICENSE
|
78
81
|
- README.md
|
79
82
|
- lib/raki.rb
|
80
|
-
- lib/raki
|
83
|
+
- lib/raki.rb.bak
|
81
84
|
- lib/raki/builder.rb
|
82
|
-
- lib/raki/
|
85
|
+
- lib/raki/chain.rb
|
83
86
|
- lib/raki/idem.rb
|
84
87
|
- lib/raki/lint.rb
|
85
88
|
- lib/raki/merge.rb
|
86
|
-
- lib/raki/
|
87
|
-
- lib/raki/nil.rb
|
89
|
+
- lib/raki/middleware.rb
|
88
90
|
- lib/raki/require.rb
|
89
91
|
- lib/raki/slice.rb
|
90
92
|
- lib/raki/version.rb
|
@@ -92,7 +94,8 @@ files:
|
|
92
94
|
homepage: https://matique.com
|
93
95
|
licenses:
|
94
96
|
- MIT
|
95
|
-
metadata:
|
97
|
+
metadata:
|
98
|
+
source_code_uri: https://github.com/matique/raki
|
96
99
|
post_install_message:
|
97
100
|
rdoc_options: []
|
98
101
|
require_paths:
|
@@ -101,15 +104,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
101
104
|
requirements:
|
102
105
|
- - ">="
|
103
106
|
- !ruby/object:Gem::Version
|
104
|
-
version: '
|
107
|
+
version: '0'
|
105
108
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
106
109
|
requirements:
|
107
110
|
- - ">="
|
108
111
|
- !ruby/object:Gem::Version
|
109
112
|
version: '0'
|
110
113
|
requirements: []
|
111
|
-
rubygems_version: 3.
|
114
|
+
rubygems_version: 3.2.22
|
112
115
|
signing_key:
|
113
116
|
specification_version: 4
|
114
|
-
summary:
|
117
|
+
summary: Kind of chaining objects
|
115
118
|
test_files: []
|
data/lib/raki/block.rb
DELETED
data/lib/raki/cache.rb
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'crimp'
|
4
|
-
|
5
|
-
# not yet finished
|
6
|
-
# requires a Rails environment! (see Rails below)
|
7
|
-
# middleware for caching.
|
8
|
-
|
9
|
-
module Raki
|
10
|
-
class Cache < Raki::MiddlewareBase
|
11
|
-
def call(env)
|
12
|
-
@block&.call(env)
|
13
|
-
kache(Crimp.signature(env)) {
|
14
|
-
@app.call(env)
|
15
|
-
}
|
16
|
-
end
|
17
|
-
|
18
|
-
private
|
19
|
-
def kache(key)
|
20
|
-
# raise 'Missing Rails environment' unless defined?(Rails.cache)
|
21
|
-
return yield unless defined?(Rails.cache)
|
22
|
-
|
23
|
-
Rails.cache.fetch(key, expires_in: 1.hour) {
|
24
|
-
yield
|
25
|
-
}
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
data/lib/raki/middleware_base.rb
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# Middleware just passing over or returning the params.
|
4
|
-
module Raki
|
5
|
-
class MiddlewareBase
|
6
|
-
def initialize(app = nil, *args, &block)
|
7
|
-
@app = app
|
8
|
-
@args = args
|
9
|
-
@block = block
|
10
|
-
end
|
11
|
-
|
12
|
-
def call(_env)
|
13
|
-
raise '#call must be overwritten by a middleware raki'
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|