strum-cache 0.0.5 → 0.1.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/.gitignore +1 -0
- data/lib/strum/cache.rb +23 -6
- data/lib/strum/cache/version.rb +1 -1
- data/lib/strum/cache_utils/build_resource_url.rb +17 -19
- data/lib/strum/cache_utils/build_resources_url.rb +16 -17
- data/lib/strum/cache_utils/find.rb +7 -6
- data/lib/strum/cache_utils/redis.rb +13 -12
- data/lib/strum/cache_utils/redis_storage.rb +8 -1
- data/lib/strum/cache_utils/search.rb +7 -7
- data/lib/strum/cache_utils/send_request.rb +92 -20
- data/lib/strum/cache_utils/shared/mixins/url.rb +27 -0
- data/strum-cache.gemspec +18 -11
- metadata +60 -23
- data/.rspec +0 -3
- data/.rubocop.yml +0 -26
- data/.travis.yml +0 -6
- data/Gemfile +0 -13
- data/Gemfile.lock +0 -122
- data/README.md +0 -70
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '02513390f401ce8a38fe1ce2b718def9e485bec07e70b6991bc59e54374a7daa'
|
4
|
+
data.tar.gz: da63fa1d376507d2e556f5be5819d1449c127cb014fb237a5a44db2950aa76c6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 45e3dd0e9921dfb795ced1722b8c9e6426f1ebdb5bed5f1f7e29e2b41b826af4f8c5ccb378ca884d7aba144c5e3f685455b2ac4b4aca2e2a41402e810effa966
|
7
|
+
data.tar.gz: 0ee7672065f0c14ce9cb6dbe42a2c2c9cd3d61f40ba1222c2f8f36888c0e1ce68dfdec9da3a53b841ba6afb37cb3fe13b5deaa22944134e6e0f0354706c5cb8a
|
data/.gitignore
CHANGED
data/lib/strum/cache.rb
CHANGED
@@ -1,15 +1,17 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "dry/inflector"
|
4
|
+
require "dry/configurable"
|
3
5
|
require "strum/cache/version"
|
4
6
|
require "strum/service"
|
5
7
|
require "strum/pipe"
|
6
|
-
require "
|
7
|
-
require "dry/configurable"
|
8
|
+
require "strum/json"
|
8
9
|
require "strum/cache_utils/redis"
|
9
10
|
require "strum/cache_utils/find"
|
10
11
|
require "strum/cache_utils/search"
|
11
12
|
|
12
13
|
module Strum
|
14
|
+
# rubocop: disable Style/Documentation
|
13
15
|
module Cache
|
14
16
|
extend Dry::Configurable
|
15
17
|
|
@@ -18,6 +20,7 @@ module Strum
|
|
18
20
|
|
19
21
|
class Error < StandardError; end
|
20
22
|
|
23
|
+
# rubocop: disable Metrics/AbcSize,Metrics/MethodLength
|
21
24
|
def self.const_missing(resource_name)
|
22
25
|
# Strum::Cache::Entity::Find.(id)
|
23
26
|
# Strum::Cache::Entity::Search.(params)
|
@@ -55,7 +58,7 @@ module Strum
|
|
55
58
|
include Strum::Service
|
56
59
|
|
57
60
|
define_method :call do
|
58
|
-
if entity = from_cache_by_id(input) || find_by_id(input)
|
61
|
+
if (entity = from_cache_by_id(input) || find_by_id(input))
|
59
62
|
output(entity)
|
60
63
|
else
|
61
64
|
not_found
|
@@ -78,7 +81,13 @@ module Strum
|
|
78
81
|
end
|
79
82
|
|
80
83
|
define_method :find_by_id do |resource_id|
|
81
|
-
Strum::CacheUtils::Find.call(resource_code: resource_code, resource_id: resource_id)
|
84
|
+
Strum::CacheUtils::Find.call(resource_code: resource_code, resource_id: resource_id) do |m|
|
85
|
+
m.success { |result| result }
|
86
|
+
m.failure do |errors|
|
87
|
+
add_errors(errors)
|
88
|
+
nil
|
89
|
+
end
|
90
|
+
end
|
82
91
|
end
|
83
92
|
|
84
93
|
define_method :not_found do
|
@@ -90,7 +99,7 @@ module Strum
|
|
90
99
|
include Strum::Service
|
91
100
|
|
92
101
|
define_method :call do
|
93
|
-
if entity = from_cache_by_params || search_by_params
|
102
|
+
if (entity = from_cache_by_params || search_by_params)
|
94
103
|
output(entity)
|
95
104
|
else
|
96
105
|
not_found
|
@@ -112,7 +121,13 @@ module Strum
|
|
112
121
|
end
|
113
122
|
|
114
123
|
define_method :search_by_params do
|
115
|
-
Strum::CacheUtils::Search.call(resource_code: resource_code, params: input)
|
124
|
+
Strum::CacheUtils::Search.call(resource_code: resource_code, params: input) do |m|
|
125
|
+
m.success { |result| result }
|
126
|
+
m.failure do |errors|
|
127
|
+
add_errors(errors)
|
128
|
+
nil
|
129
|
+
end
|
130
|
+
end
|
116
131
|
end
|
117
132
|
|
118
133
|
define_method :not_found do
|
@@ -121,5 +136,7 @@ module Strum
|
|
121
136
|
end)
|
122
137
|
end
|
123
138
|
end
|
139
|
+
# rubocop: enable Metrics/AbcSize,Metrics/MethodLength
|
124
140
|
end
|
141
|
+
# rubocop: enable Style/Documentation
|
125
142
|
end
|
data/lib/strum/cache/version.rb
CHANGED
@@ -1,34 +1,32 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "strum/cache_utils/shared/mixins/url"
|
3
4
|
require "strum/cache_utils/build_resources_url"
|
4
5
|
|
5
6
|
module Strum
|
6
7
|
module CacheUtils
|
8
|
+
# Resource url builder
|
7
9
|
class BuildResourceUrl
|
8
10
|
include Strum::Service
|
11
|
+
include Shared::Mixins::Url
|
9
12
|
|
10
|
-
|
11
|
-
underscore_resource_code = inflector.underscore(resource_code)
|
12
|
-
base_url = ENV.fetch("#{underscore_resource_code.upcase}_RESOURCE_URL") do
|
13
|
-
host = ENV.fetch("BASE_RESOURCE_URL")
|
14
|
-
File.join(host, inflector.pluralize(underscore_resource_code.gsub(/_/, "-")))
|
15
|
-
end
|
16
|
-
output(url: File.join(base_url, resource_id.to_s))
|
17
|
-
rescue KeyError
|
18
|
-
Strum::CacheUtils::BuildResourcesUrl.call(resource_code: resource_code, params: { id: resource_id }) do |m|
|
19
|
-
m.success { |result| output(result) }
|
20
|
-
m.failure { |errors| add_errors(errors) }
|
21
|
-
end
|
22
|
-
end
|
13
|
+
private
|
23
14
|
|
24
|
-
|
25
|
-
|
26
|
-
end
|
15
|
+
RESOURCE_SUFIX_URL = "RESOURCE_URL"
|
16
|
+
HOST = "BASE_RESOURCE_URL"
|
27
17
|
|
28
|
-
|
18
|
+
def audit
|
19
|
+
required(:resource_code, :resource_id)
|
20
|
+
sliced(:resource_code, :resource_id)
|
21
|
+
end
|
29
22
|
|
30
|
-
def
|
31
|
-
|
23
|
+
def call
|
24
|
+
output(url: File.join(base_url, resource_id.to_s))
|
25
|
+
rescue KeyError
|
26
|
+
Strum::CacheUtils::BuildResourcesUrl.call(resource_code: resource_code, params: { id: resource_id }) do |m|
|
27
|
+
m.success { |result| output(result) }
|
28
|
+
m.failure { |errors| add_errors(errors) }
|
29
|
+
end
|
32
30
|
end
|
33
31
|
end
|
34
32
|
end
|
@@ -1,32 +1,31 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "uri"
|
4
|
+
require "strum/cache_utils/shared/mixins/url"
|
4
5
|
|
5
6
|
module Strum
|
6
7
|
module CacheUtils
|
8
|
+
# Build url to resource
|
7
9
|
class BuildResourcesUrl
|
8
10
|
include Strum::Service
|
11
|
+
include Shared::Mixins::Url
|
9
12
|
|
10
|
-
|
11
|
-
underscore_resource_code = inflector.underscore(resource_code)
|
12
|
-
base_url = ENV.fetch("#{underscore_resource_code.upcase}_RESOURCE_SEARCH_URL") do
|
13
|
-
host = ENV.fetch("BASE_RESOURCE_SEARCH_URL")
|
14
|
-
File.join(host, inflector.pluralize(underscore_resource_code.gsub(/_/, "-")))
|
15
|
-
end
|
16
|
-
output(url: base_url, params: params)
|
17
|
-
rescue KeyError
|
18
|
-
add_error("#{resource_code} SEARCH ENV", :not_found)
|
19
|
-
end
|
13
|
+
private
|
20
14
|
|
21
|
-
|
22
|
-
|
23
|
-
add_error(:params, :hash_required) unless params.is_a?(Hash)
|
24
|
-
end
|
15
|
+
RESOURCE_SUFIX_URL = "RESOURCE_SEARCH_URL"
|
16
|
+
HOST = "BASE_RESOURCE_SEARCH_URL"
|
25
17
|
|
26
|
-
|
18
|
+
def audit
|
19
|
+
required(:resource_code, :params)
|
20
|
+
sliced(:resource_code, :params)
|
21
|
+
|
22
|
+
add_error(:params, :hash_required) unless params.is_a?(Hash)
|
23
|
+
end
|
27
24
|
|
28
|
-
def
|
29
|
-
|
25
|
+
def call
|
26
|
+
output(url: base_url, params: params)
|
27
|
+
rescue KeyError
|
28
|
+
add_error("#{resource_code} SEARCH ENV", :not_found)
|
30
29
|
end
|
31
30
|
end
|
32
31
|
end
|
@@ -1,26 +1,27 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "strum/json_deserializer"
|
4
3
|
require "strum/cache_utils/build_resource_url"
|
5
4
|
|
6
5
|
module Strum
|
7
6
|
module CacheUtils
|
7
|
+
# Find service
|
8
8
|
class Find
|
9
9
|
include Strum::Service
|
10
10
|
|
11
|
+
def audit
|
12
|
+
required(:resource_code, :resource_id)
|
13
|
+
sliced(:resource_code, :resource_id)
|
14
|
+
end
|
15
|
+
|
11
16
|
def call
|
12
17
|
Strum::Pipe.call(Strum::CacheUtils::BuildResourceUrl,
|
13
18
|
Strum::CacheUtils::SendRequest,
|
14
|
-
Strum::
|
19
|
+
Strum::Json::Deserializer,
|
15
20
|
input: input) do |m|
|
16
21
|
m.success { |responce| output(responce) }
|
17
22
|
m.failure { |errors| add_errors(errors) }
|
18
23
|
end
|
19
24
|
end
|
20
|
-
|
21
|
-
def audit
|
22
|
-
required(:resource_code, :resource_id)
|
23
|
-
end
|
24
25
|
end
|
25
26
|
end
|
26
27
|
end
|
@@ -6,23 +6,24 @@ require "strum/cache_utils/redis_storage"
|
|
6
6
|
|
7
7
|
module Strum
|
8
8
|
module CacheUtils
|
9
|
+
# Redis storage
|
9
10
|
class Redis
|
10
11
|
include Strum::Service
|
11
12
|
|
12
|
-
|
13
|
-
if (entity = redis_connection.hgetall(resource_id)).key?("id")
|
14
|
-
redis_connection.expire(resource_id, redis_resource_expire)
|
15
|
-
output(entity)
|
16
|
-
else
|
17
|
-
add_error(:entity, :not_found)
|
18
|
-
end
|
19
|
-
end
|
13
|
+
private
|
20
14
|
|
21
|
-
|
22
|
-
|
23
|
-
|
15
|
+
def audit
|
16
|
+
required(:resource_code, :resource_id)
|
17
|
+
end
|
24
18
|
|
25
|
-
|
19
|
+
def call
|
20
|
+
if (entity = redis_connection.hgetall(resource_id)).key?("id")
|
21
|
+
redis_connection.expire(resource_id, redis_resource_expire)
|
22
|
+
output(entity)
|
23
|
+
else
|
24
|
+
add_error(:entity, :not_found)
|
25
|
+
end
|
26
|
+
end
|
26
27
|
|
27
28
|
def redis_connection
|
28
29
|
Strum::CacheUtils::RedisStorage.const_get(resource_code.to_s.capitalize, false).instance.redis
|
@@ -5,7 +5,9 @@ require "redis"
|
|
5
5
|
|
6
6
|
module Strum
|
7
7
|
module CacheUtils
|
8
|
+
# Redis storage
|
8
9
|
module RedisStorage
|
10
|
+
# rubocop: disable Metrics/MethodLength, Metrics/AbcSize
|
9
11
|
def self.const_missing(resource_name)
|
10
12
|
const_set(resource_name.to_s.strip.capitalize, Class.new do
|
11
13
|
include Singleton
|
@@ -13,10 +15,15 @@ module Strum
|
|
13
15
|
|
14
16
|
define_method :initialize do
|
15
17
|
redis_url = ENV.fetch("#{resource_name.upcase}_CACHE_REDIS_URL", ENV.fetch("CACHE_REDIS_URL", nil))
|
16
|
-
@redis =
|
18
|
+
@redis = if redis_url
|
19
|
+
Strum::Cache.config.redis_class.new(url: redis_url)
|
20
|
+
else
|
21
|
+
Strum::Cache.config.redis_class.new
|
22
|
+
end
|
17
23
|
end
|
18
24
|
end)
|
19
25
|
end
|
26
|
+
# rubocop: enable Metrics/MethodLength, Metrics/AbcSize
|
20
27
|
end
|
21
28
|
end
|
22
29
|
end
|
@@ -1,28 +1,28 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "strum/pipe"
|
4
3
|
require "strum/cache_utils/build_resources_url"
|
5
4
|
require "strum/cache_utils/send_request"
|
6
|
-
require "strum/json_deserializer"
|
7
5
|
|
8
6
|
module Strum
|
9
7
|
module CacheUtils
|
8
|
+
# Search entity
|
10
9
|
class Search
|
11
10
|
include Strum::Service
|
12
11
|
|
12
|
+
def audit
|
13
|
+
required(:resource_code, :params)
|
14
|
+
sliced(:resource_code, :params)
|
15
|
+
end
|
16
|
+
|
13
17
|
def call
|
14
18
|
Strum::Pipe.call(Strum::CacheUtils::BuildResourcesUrl,
|
15
19
|
Strum::CacheUtils::SendRequest,
|
16
|
-
Strum::
|
20
|
+
Strum::Json::Deserializer,
|
17
21
|
input: input) do |m|
|
18
22
|
m.success { |responce| output(responce) }
|
19
23
|
m.failure { |errors| add_errors(errors) }
|
20
24
|
end
|
21
25
|
end
|
22
|
-
|
23
|
-
def audit
|
24
|
-
required(:resource_code, :params)
|
25
|
-
end
|
26
26
|
end
|
27
27
|
end
|
28
28
|
end
|
@@ -1,32 +1,104 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "faraday"
|
4
|
-
require "
|
4
|
+
require "faraday_middleware"
|
5
5
|
|
6
6
|
module Strum
|
7
7
|
module CacheUtils
|
8
|
+
# Send request to entity source
|
8
9
|
class SendRequest
|
9
10
|
include Strum::Service
|
10
11
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
end
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
12
|
+
private
|
13
|
+
|
14
|
+
TIMEOUT = ENV.fetch("STRUM_CACHE_TIMEOUT", 50).to_i.freeze
|
15
|
+
OPEN_TIMEOUT = ENV.fetch("STRUM_CACHE_OPEN_TIMEOUT", 5).to_i.freeze
|
16
|
+
|
17
|
+
def audit
|
18
|
+
required(:url)
|
19
|
+
sliced(:url, :params)
|
20
|
+
end
|
21
|
+
|
22
|
+
def call
|
23
|
+
output(send_request.body)
|
24
|
+
rescue Faraday::ConnectionFailed => e
|
25
|
+
connection_error_handler(e)
|
26
|
+
rescue Faraday::TimeoutError => e
|
27
|
+
timeout_error_handler(e)
|
28
|
+
rescue Faraday::ParsingError => e
|
29
|
+
parsing_error_handler(e)
|
30
|
+
rescue Faraday::Error => e
|
31
|
+
error_handler(e)
|
32
|
+
end
|
33
|
+
|
34
|
+
def send_request
|
35
|
+
create_faraday_inst.get do |req|
|
36
|
+
req.headers["Accept"] = "application/json"
|
37
|
+
req.headers["Content-Type"] = "application/json"
|
38
|
+
req.params = params if input[:params]
|
39
|
+
cache_headers.each { |k, v| req.headers[k] = v }
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def create_faraday_inst
|
44
|
+
Faraday.new(url: url) do |f|
|
45
|
+
f.response :json
|
46
|
+
f.options.timeout = TIMEOUT
|
47
|
+
f.options.open_timeout = OPEN_TIMEOUT
|
48
|
+
f.use Faraday::Response::RaiseError
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def cache_headers
|
53
|
+
Strum::Cache.config.cache_headers.is_a?(Hash) ? Strum::Cache.config.cache_headers : {}
|
54
|
+
end
|
55
|
+
|
56
|
+
def connection_error_handler(error)
|
57
|
+
add_error(:send_request, :connection_error)
|
58
|
+
add_error(:connection_error, [{ info: { error_message: error.message, url: url, method: :get } }])
|
59
|
+
end
|
60
|
+
|
61
|
+
def timeout_error_handler(error)
|
62
|
+
add_error(:send_request, :timeout_error)
|
63
|
+
add_error(:timeout_error, [{ info: { error_message: error.message, url: url, method: :get } }])
|
64
|
+
end
|
65
|
+
|
66
|
+
def parsing_error_handler(error) # rubocop: disable Metrics/AbcSize, Style/CommentedKeyword
|
67
|
+
info = {
|
68
|
+
error_message: error.message,
|
69
|
+
request_headers: error.response.env.request_headers,
|
70
|
+
response_status: error.response.env.status,
|
71
|
+
response_headers: error.response.env.response_headers,
|
72
|
+
response_body: error.response.env.response_body
|
73
|
+
}
|
74
|
+
add_error(:payload, error)
|
75
|
+
add_error(:send_request, :json_parse_error)
|
76
|
+
add_error(:json_parse_error, [build_format_info(info)])
|
77
|
+
end
|
78
|
+
|
79
|
+
def error_handler(error)
|
80
|
+
info = {
|
81
|
+
error_message: error.message,
|
82
|
+
request_headers: error.response[:request][:headers],
|
83
|
+
response_status: error.response[:status],
|
84
|
+
response_headers: error.response[:headers],
|
85
|
+
response_body: error.response[:body]
|
86
|
+
}
|
87
|
+
|
88
|
+
add_error(:connection, error)
|
89
|
+
add_error(:send_request, :http_error)
|
90
|
+
add_error(:http_error, [build_format_info(info)])
|
91
|
+
end
|
92
|
+
|
93
|
+
def build_format_info(info)
|
94
|
+
{
|
95
|
+
info: {
|
96
|
+
error_message: info[:error_message], method: :get, url: url,
|
97
|
+
request: { headers: info[:request_headers] },
|
98
|
+
response: { status: info[:response_status], headers: info[:response_headers], body: info[:response_body] }
|
99
|
+
}
|
100
|
+
}
|
101
|
+
end
|
30
102
|
end
|
31
103
|
end
|
32
104
|
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Strum
|
4
|
+
module CacheUtils
|
5
|
+
module Shared
|
6
|
+
module Mixins
|
7
|
+
# General methods for url builders
|
8
|
+
module Url
|
9
|
+
def base_url
|
10
|
+
ENV.fetch("#{underscore_resource_code.upcase}_#{self.class::RESOURCE_SUFIX_URL}") do
|
11
|
+
host = ENV.fetch(self.class::HOST)
|
12
|
+
File.join(host, inflector.pluralize(underscore_resource_code.gsub(/_/, "-")))
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def underscore_resource_code
|
17
|
+
@underscore_resource_code ||= inflector.underscore(resource_code)
|
18
|
+
end
|
19
|
+
|
20
|
+
def inflector
|
21
|
+
@inflector ||= Dry::Inflector.new
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/strum-cache.gemspec
CHANGED
@@ -9,28 +9,35 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.email = ["sn@nazarov.com.ua"]
|
10
10
|
|
11
11
|
spec.summary = "Cache resources"
|
12
|
-
spec.homepage = "https://
|
13
|
-
spec.required_ruby_version = Gem::Requirement.new(">= 2.
|
12
|
+
spec.homepage = "https://gitlab.com/strum-rb/strum-cache"
|
13
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.7.0")
|
14
14
|
|
15
15
|
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
16
16
|
|
17
17
|
spec.metadata["homepage_uri"] = spec.homepage
|
18
|
-
spec.metadata["source_code_uri"] = "https://
|
19
|
-
spec.metadata["changelog_uri"] = "https://
|
18
|
+
spec.metadata["source_code_uri"] = "https://gitlab.com/strum-rb/strum-cache"
|
19
|
+
spec.metadata["changelog_uri"] = "https://gitlab.com/strum-rb/strum-cache/CHANGELOG.md"
|
20
20
|
|
21
21
|
# Specify which files should be added to the gem when it is released.
|
22
22
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
23
23
|
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
24
|
-
`git ls-files -z`.split("\x0").reject
|
24
|
+
`git ls-files -z`.split("\x0").reject do |f|
|
25
|
+
f.match(
|
26
|
+
/^(test|spec|features|\.rubocop.yml|\.ruby-version|Gemfile.lock|Gemfile|\.gitlab-ci.yml|README|\.travis.yml|CHANGELOG|\.rspec)/ # rubocop:disable Layout/LineLength
|
27
|
+
)
|
28
|
+
end
|
25
29
|
end
|
26
30
|
spec.bindir = "exe"
|
27
31
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
28
32
|
spec.require_paths = ["lib"]
|
29
33
|
|
30
|
-
spec.
|
31
|
-
spec.
|
32
|
-
spec.
|
33
|
-
spec.
|
34
|
-
spec.
|
35
|
-
spec.
|
34
|
+
spec.add_runtime_dependency "dry-configurable", "~> 0.12.1"
|
35
|
+
spec.add_runtime_dependency "dry-inflector", "~> 0.2"
|
36
|
+
spec.add_runtime_dependency "faraday", "~> 1.4"
|
37
|
+
spec.add_runtime_dependency "faraday_middleware", "~> 1.0"
|
38
|
+
spec.add_runtime_dependency "json", "~> 2.3"
|
39
|
+
spec.add_runtime_dependency "redis", "~> 4.2"
|
40
|
+
spec.add_runtime_dependency "strum-json", "~> 0.0.3"
|
41
|
+
spec.add_runtime_dependency "strum-pipe", "~> 0.0.3"
|
42
|
+
spec.add_runtime_dependency "strum-service", "~> 0.1"
|
36
43
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: strum-cache
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Serhiy Nazarov
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-08-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dry-configurable
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 0.12.1
|
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:
|
26
|
+
version: 0.12.1
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: dry-inflector
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -44,14 +44,28 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '1.
|
47
|
+
version: '1.4'
|
48
48
|
type: :runtime
|
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: '1.
|
54
|
+
version: '1.4'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: faraday_middleware
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.0'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: json
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -81,19 +95,47 @@ dependencies:
|
|
81
95
|
- !ruby/object:Gem::Version
|
82
96
|
version: '4.2'
|
83
97
|
- !ruby/object:Gem::Dependency
|
84
|
-
name: strum
|
98
|
+
name: strum-json
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
86
100
|
requirements:
|
87
|
-
- - "
|
101
|
+
- - "~>"
|
88
102
|
- !ruby/object:Gem::Version
|
89
|
-
version:
|
103
|
+
version: 0.0.3
|
90
104
|
type: :runtime
|
91
105
|
prerelease: false
|
92
106
|
version_requirements: !ruby/object:Gem::Requirement
|
93
107
|
requirements:
|
94
|
-
- - "
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 0.0.3
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: strum-pipe
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: 0.0.3
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: 0.0.3
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: strum-service
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0.1'
|
132
|
+
type: :runtime
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
95
137
|
- !ruby/object:Gem::Version
|
96
|
-
version: '0'
|
138
|
+
version: '0.1'
|
97
139
|
description:
|
98
140
|
email:
|
99
141
|
- sn@nazarov.com.ua
|
@@ -102,14 +144,8 @@ extensions: []
|
|
102
144
|
extra_rdoc_files: []
|
103
145
|
files:
|
104
146
|
- ".gitignore"
|
105
|
-
- ".rspec"
|
106
|
-
- ".rubocop.yml"
|
107
|
-
- ".travis.yml"
|
108
147
|
- CODE_OF_CONDUCT.md
|
109
|
-
- Gemfile
|
110
|
-
- Gemfile.lock
|
111
148
|
- LICENSE.txt
|
112
|
-
- README.md
|
113
149
|
- Rakefile
|
114
150
|
- bin/console
|
115
151
|
- bin/setup
|
@@ -122,14 +158,15 @@ files:
|
|
122
158
|
- lib/strum/cache_utils/redis_storage.rb
|
123
159
|
- lib/strum/cache_utils/search.rb
|
124
160
|
- lib/strum/cache_utils/send_request.rb
|
161
|
+
- lib/strum/cache_utils/shared/mixins/url.rb
|
125
162
|
- strum-cache.gemspec
|
126
|
-
homepage: https://
|
163
|
+
homepage: https://gitlab.com/strum-rb/strum-cache
|
127
164
|
licenses: []
|
128
165
|
metadata:
|
129
166
|
allowed_push_host: https://rubygems.org
|
130
|
-
homepage_uri: https://
|
131
|
-
source_code_uri: https://
|
132
|
-
changelog_uri: https://
|
167
|
+
homepage_uri: https://gitlab.com/strum-rb/strum-cache
|
168
|
+
source_code_uri: https://gitlab.com/strum-rb/strum-cache
|
169
|
+
changelog_uri: https://gitlab.com/strum-rb/strum-cache/CHANGELOG.md
|
133
170
|
post_install_message:
|
134
171
|
rdoc_options: []
|
135
172
|
require_paths:
|
@@ -138,14 +175,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
138
175
|
requirements:
|
139
176
|
- - ">="
|
140
177
|
- !ruby/object:Gem::Version
|
141
|
-
version: 2.
|
178
|
+
version: 2.7.0
|
142
179
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
143
180
|
requirements:
|
144
181
|
- - ">="
|
145
182
|
- !ruby/object:Gem::Version
|
146
183
|
version: '0'
|
147
184
|
requirements: []
|
148
|
-
rubygems_version: 3.
|
185
|
+
rubygems_version: 3.1.6
|
149
186
|
signing_key:
|
150
187
|
specification_version: 4
|
151
188
|
summary: Cache resources
|
data/.rspec
DELETED
data/.rubocop.yml
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
AllCops:
|
2
|
-
TargetRubyVersion: 2.6
|
3
|
-
NewCops: enable
|
4
|
-
|
5
|
-
# Use Ruby >= 1.9 syntax for hashes. Prefer { a: :b } over { :a => :b }.
|
6
|
-
Style/HashSyntax:
|
7
|
-
Enabled: true
|
8
|
-
|
9
|
-
# Method definitions after `private` or `protected` isolated calls need one
|
10
|
-
# extra level of indentation.
|
11
|
-
Layout/IndentationConsistency:
|
12
|
-
Enabled: true
|
13
|
-
EnforcedStyle: indented_internal_methods
|
14
|
-
|
15
|
-
# Two spaces, no tabs (for indentation).
|
16
|
-
Layout/IndentationWidth:
|
17
|
-
Enabled: true
|
18
|
-
|
19
|
-
# Check quotes usage according to lint rule below.
|
20
|
-
Style/StringLiterals:
|
21
|
-
Enabled: true
|
22
|
-
EnforcedStyle: double_quotes
|
23
|
-
|
24
|
-
Layout/LineLength:
|
25
|
-
Max: 120
|
26
|
-
IgnoredPatterns: ['\A#']
|
data/.travis.yml
DELETED
data/Gemfile
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
source "https://rubygems.org"
|
4
|
-
|
5
|
-
# Specify your gem's dependencies in strum-cache.gemspec
|
6
|
-
gemspec
|
7
|
-
|
8
|
-
gem "bundler", "~> 2.1.4"
|
9
|
-
gem "rspec", "~> 3"
|
10
|
-
gem "rubocop", "~> 0.90.0"
|
11
|
-
|
12
|
-
gem "debase", "~> 0.2.4"
|
13
|
-
gem "ruby-debug-ide", "~> 0.7.0"
|
data/Gemfile.lock
DELETED
@@ -1,122 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
strum-cache (0.0.5)
|
5
|
-
dry-configurable (~> 0.11)
|
6
|
-
dry-inflector (~> 0.2)
|
7
|
-
faraday (~> 1.1)
|
8
|
-
json (~> 2.3)
|
9
|
-
redis (~> 4.2)
|
10
|
-
strum
|
11
|
-
|
12
|
-
GEM
|
13
|
-
remote: https://rubygems.org/
|
14
|
-
specs:
|
15
|
-
addressable (2.7.0)
|
16
|
-
public_suffix (>= 2.0.2, < 5.0)
|
17
|
-
ast (2.4.1)
|
18
|
-
concurrent-ruby (1.1.9)
|
19
|
-
debase (0.2.4.1)
|
20
|
-
debase-ruby_core_source (>= 0.10.2)
|
21
|
-
debase-ruby_core_source (0.10.11)
|
22
|
-
diff-lcs (1.4.4)
|
23
|
-
dry-configurable (0.12.1)
|
24
|
-
concurrent-ruby (~> 1.0)
|
25
|
-
dry-core (~> 0.5, >= 0.5.0)
|
26
|
-
dry-container (0.7.2)
|
27
|
-
concurrent-ruby (~> 1.0)
|
28
|
-
dry-configurable (~> 0.1, >= 0.1.3)
|
29
|
-
dry-core (0.6.0)
|
30
|
-
concurrent-ruby (~> 1.0)
|
31
|
-
dry-inflector (0.2.0)
|
32
|
-
dry-logic (1.2.0)
|
33
|
-
concurrent-ruby (~> 1.0)
|
34
|
-
dry-core (~> 0.5, >= 0.5)
|
35
|
-
dry-struct (1.4.0)
|
36
|
-
dry-core (~> 0.5, >= 0.5)
|
37
|
-
dry-types (~> 1.5)
|
38
|
-
ice_nine (~> 0.11)
|
39
|
-
dry-types (1.5.1)
|
40
|
-
concurrent-ruby (~> 1.0)
|
41
|
-
dry-container (~> 0.3)
|
42
|
-
dry-core (~> 0.5, >= 0.5)
|
43
|
-
dry-inflector (~> 0.1, >= 0.1.2)
|
44
|
-
dry-logic (~> 1.0, >= 1.0.2)
|
45
|
-
faraday (1.4.2)
|
46
|
-
faraday-em_http (~> 1.0)
|
47
|
-
faraday-em_synchrony (~> 1.0)
|
48
|
-
faraday-excon (~> 1.1)
|
49
|
-
faraday-net_http (~> 1.0)
|
50
|
-
faraday-net_http_persistent (~> 1.1)
|
51
|
-
multipart-post (>= 1.2, < 3)
|
52
|
-
ruby2_keywords (>= 0.0.4)
|
53
|
-
faraday-em_http (1.0.0)
|
54
|
-
faraday-em_synchrony (1.0.0)
|
55
|
-
faraday-excon (1.1.0)
|
56
|
-
faraday-net_http (1.0.1)
|
57
|
-
faraday-net_http_persistent (1.1.0)
|
58
|
-
ice_nine (0.11.2)
|
59
|
-
json (2.5.1)
|
60
|
-
json-schema (2.8.1)
|
61
|
-
addressable (>= 2.4)
|
62
|
-
multipart-post (2.1.1)
|
63
|
-
parallel (1.20.1)
|
64
|
-
parser (3.0.0.0)
|
65
|
-
ast (~> 2.4.1)
|
66
|
-
public_suffix (4.0.6)
|
67
|
-
rainbow (3.0.0)
|
68
|
-
rake (13.0.3)
|
69
|
-
redis (4.2.5)
|
70
|
-
regexp_parser (2.0.3)
|
71
|
-
rexml (3.2.4)
|
72
|
-
rspec (3.10.0)
|
73
|
-
rspec-core (~> 3.10.0)
|
74
|
-
rspec-expectations (~> 3.10.0)
|
75
|
-
rspec-mocks (~> 3.10.0)
|
76
|
-
rspec-core (3.10.1)
|
77
|
-
rspec-support (~> 3.10.0)
|
78
|
-
rspec-expectations (3.10.1)
|
79
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
80
|
-
rspec-support (~> 3.10.0)
|
81
|
-
rspec-mocks (3.10.1)
|
82
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
83
|
-
rspec-support (~> 3.10.0)
|
84
|
-
rspec-support (3.10.1)
|
85
|
-
rubocop (0.90.0)
|
86
|
-
parallel (~> 1.10)
|
87
|
-
parser (>= 2.7.1.1)
|
88
|
-
rainbow (>= 2.2.2, < 4.0)
|
89
|
-
regexp_parser (>= 1.7)
|
90
|
-
rexml
|
91
|
-
rubocop-ast (>= 0.3.0, < 1.0)
|
92
|
-
ruby-progressbar (~> 1.7)
|
93
|
-
unicode-display_width (>= 1.4.0, < 2.0)
|
94
|
-
rubocop-ast (0.8.0)
|
95
|
-
parser (>= 2.7.1.5)
|
96
|
-
ruby-debug-ide (0.7.2)
|
97
|
-
rake (>= 0.8.1)
|
98
|
-
ruby-progressbar (1.11.0)
|
99
|
-
ruby2_keywords (0.0.4)
|
100
|
-
sequel (5.44.0)
|
101
|
-
strum (0.1.3)
|
102
|
-
dry-inflector (~> 0.2.0)
|
103
|
-
dry-struct (~> 1.2)
|
104
|
-
json-schema (~> 2.8.1)
|
105
|
-
sequel (~> 5.29)
|
106
|
-
thor (~> 0.20)
|
107
|
-
thor (0.20.3)
|
108
|
-
unicode-display_width (1.7.0)
|
109
|
-
|
110
|
-
PLATFORMS
|
111
|
-
ruby
|
112
|
-
|
113
|
-
DEPENDENCIES
|
114
|
-
bundler (~> 2.1.4)
|
115
|
-
debase (~> 0.2.4)
|
116
|
-
rspec (~> 3)
|
117
|
-
rubocop (~> 0.90.0)
|
118
|
-
ruby-debug-ide (~> 0.7.0)
|
119
|
-
strum-cache!
|
120
|
-
|
121
|
-
BUNDLED WITH
|
122
|
-
2.1.4
|
data/README.md
DELETED
@@ -1,70 +0,0 @@
|
|
1
|
-
# Strum::Cache
|
2
|
-
|
3
|
-
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/strum/cache`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
-
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
6
|
-
|
7
|
-
## Installation
|
8
|
-
|
9
|
-
Add this line to your application's Gemfile:
|
10
|
-
|
11
|
-
```ruby
|
12
|
-
gem 'strum-cache'
|
13
|
-
```
|
14
|
-
|
15
|
-
And then execute:
|
16
|
-
|
17
|
-
$ bundle install
|
18
|
-
|
19
|
-
Or install it yourself as:
|
20
|
-
|
21
|
-
$ gem install strum-cache
|
22
|
-
|
23
|
-
## Usage
|
24
|
-
|
25
|
-
###ENV variables:
|
26
|
-
|
27
|
-
`CACHE_REDIS_URL` - connection string to Redis
|
28
|
-
|
29
|
-
`{RESOURCE}_CACHE_REDIS_URL` - separated Redis connection string for resource
|
30
|
-
|
31
|
-
`BASE_RESOURCE_URL` - full url to resource find endpoint. example: "http://example.com/entities"
|
32
|
-
|
33
|
-
`{RESOURCE}_RESOURCE_URL` - separated full url to resource find endpoint. example: "http://example.com/entities"
|
34
|
-
|
35
|
-
`BASE_RESOURCE_SEARCH_URL` - full url to resource search endpoint. example: "http://example.com/entities/search"
|
36
|
-
|
37
|
-
`{RESOURCE}_RESOURCE_SEARCH_URL` - separated full url to resource search endpoint. example: "http://example.com/entities/search"
|
38
|
-
|
39
|
-
###Configurable
|
40
|
-
|
41
|
-
`Strum::Cache.config.cache_headers` - hash with headers that should be sent on http request
|
42
|
-
|
43
|
-
`Strum::Cache::config.redis_class` - class of Redis. Default is `Redis`, can be changed for mock
|
44
|
-
|
45
|
-
###How to use
|
46
|
-
|
47
|
-
`Strum::Cache::Entity::Find.(id)` - find Entity by id
|
48
|
-
|
49
|
-
`Strum::Cache::Entity::Search.(params)` - search Entity by params
|
50
|
-
|
51
|
-
`Strum::Cache::Entity::Push.(params)` - push Entity to cache
|
52
|
-
|
53
|
-
## Development
|
54
|
-
|
55
|
-
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
56
|
-
|
57
|
-
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
58
|
-
|
59
|
-
## Contributing
|
60
|
-
|
61
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/strum-cache. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/strum-cache/blob/master/CODE_OF_CONDUCT.md).
|
62
|
-
|
63
|
-
|
64
|
-
## License
|
65
|
-
|
66
|
-
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
67
|
-
|
68
|
-
## Code of Conduct
|
69
|
-
|
70
|
-
Everyone interacting in the Strum::Cache project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/strum-cache/blob/master/CODE_OF_CONDUCT.md).
|