api_recipes 2.9.0 → 2.10.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/lib/api_recipes/api.rb +1 -1
- data/lib/api_recipes/configuration.rb +37 -2
- data/lib/api_recipes/endpoint.rb +0 -1
- data/lib/api_recipes/response.rb +1 -1
- data/lib/api_recipes/route.rb +1 -1
- data/lib/api_recipes/settings.rb +3 -1
- data/lib/api_recipes/version.rb +1 -1
- data/lib/api_recipes.rb +1 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c808d9077305dc07cd888f517b57f1522490866a548dc769a3c96c083d24ce27
|
4
|
+
data.tar.gz: 205b4aaaa135b8682f7d7f0d44f471263852e997f2b1791fe60eea4efc0a2ee3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 89acbd66ece24f8cd88100eb447c45e3b73c30c9f894b51a5995aa7697f6a76b92bae0b41c117dbc0b38f993876ca8b4efd17f64eaf7ca1ae31e0d04b5544120
|
7
|
+
data.tar.gz: a831d53f7a337cc65ec28d09eb74ca8efa69123cf34ae835776c5414dd58725cc0223e7ee7aa70d0c1dbbebfff924f8d3d8340227ade47f42d7be4e3ffd877dd
|
data/lib/api_recipes/api.rb
CHANGED
@@ -4,7 +4,7 @@ module ApiRecipes
|
|
4
4
|
attr_accessor :name, :configs, :authorization, :basic_auth
|
5
5
|
attr_reader :base_configs, :object
|
6
6
|
|
7
|
-
BASE_CONFIGS_KEYS = [:protocol, :host, :port, :api_version, :timeout, :on_bad_code, :verify_with]
|
7
|
+
BASE_CONFIGS_KEYS = [:protocol, :host, :port, :api_version, :timeout, :on_bad_code, :mime_type, :verify_with]
|
8
8
|
|
9
9
|
def initialize(name, configs, object)
|
10
10
|
@name = name
|
@@ -1,12 +1,15 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
require 'erb'
|
3
|
+
|
1
4
|
module ApiRecipes
|
2
5
|
class Configuration
|
3
6
|
|
4
|
-
attr_accessor :log_to, :log_level, :print_urls
|
7
|
+
attr_accessor :log_to, :log_level, :print_urls, :apis_files_paths
|
5
8
|
|
6
9
|
def apis_configs=(configs = {})
|
7
10
|
raise ArgumentError, 'apis_configs must be an Hash' unless configs.is_a? Hash
|
11
|
+
|
8
12
|
@apis_configs = configs.deep_symbolize_keys
|
9
|
-
ApiRecipes._aprcps_define_global_apis
|
10
13
|
end
|
11
14
|
|
12
15
|
def apis_configs
|
@@ -16,6 +19,34 @@ module ApiRecipes
|
|
16
19
|
@apis_configs
|
17
20
|
end
|
18
21
|
|
22
|
+
def apis_files_paths=(paths = [])
|
23
|
+
raise ArgumentError, 'apis_files_paths must be an Array' unless paths.is_a? Array
|
24
|
+
|
25
|
+
@apis_files_paths = paths
|
26
|
+
@apis_files_paths.each do |file_path|
|
27
|
+
template = ERB.new File.read File.expand_path(file_path)
|
28
|
+
data = begin
|
29
|
+
YAML.load(template.result(binding), aliases: true)
|
30
|
+
rescue ArgumentError
|
31
|
+
YAML.load(template.result binding)
|
32
|
+
end.deep_symbolize_keys
|
33
|
+
# Merge file contents into apis_configs
|
34
|
+
data.each do |api, params|
|
35
|
+
if apis_configs[api]
|
36
|
+
logger.warn "File at #{file_path} overrides config for '#{api}' API"
|
37
|
+
end
|
38
|
+
apis_configs[api] = params
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def apis_files_paths
|
44
|
+
unless @apis_files_paths
|
45
|
+
@apis_files_paths = []
|
46
|
+
end
|
47
|
+
@apis_files_paths
|
48
|
+
end
|
49
|
+
|
19
50
|
def logger=(logger)
|
20
51
|
@logger = logger
|
21
52
|
end
|
@@ -31,6 +62,10 @@ module ApiRecipes
|
|
31
62
|
@logger
|
32
63
|
end
|
33
64
|
|
65
|
+
def setup
|
66
|
+
ApiRecipes._aprcps_define_global_apis
|
67
|
+
end
|
68
|
+
|
34
69
|
private
|
35
70
|
|
36
71
|
# @private
|
data/lib/api_recipes/endpoint.rb
CHANGED
data/lib/api_recipes/response.rb
CHANGED
data/lib/api_recipes/route.rb
CHANGED
data/lib/api_recipes/settings.rb
CHANGED
@@ -10,7 +10,8 @@ module ApiRecipes
|
|
10
10
|
timeout: 3,
|
11
11
|
on_bad_code: 'raise',
|
12
12
|
endpoints: {},
|
13
|
-
verify_with: nil
|
13
|
+
verify_with: nil,
|
14
|
+
mime_type: nil
|
14
15
|
}
|
15
16
|
|
16
17
|
DEFAULT_ROUTE_ATTRIBUTES = {
|
@@ -20,6 +21,7 @@ module ApiRecipes
|
|
20
21
|
ok_code: nil,
|
21
22
|
timeout: DEFAULT[:timeout],
|
22
23
|
on_bad_code: DEFAULT[:on_bad_code],
|
24
|
+
mime_type: DEFAULT[:mime_type],
|
23
25
|
verify_with: DEFAULT[:verify_with]
|
24
26
|
}
|
25
27
|
|
data/lib/api_recipes/version.rb
CHANGED
data/lib/api_recipes.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: api_recipes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alessandro Verlato
|
@@ -68,7 +68,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
68
68
|
- !ruby/object:Gem::Version
|
69
69
|
version: '0'
|
70
70
|
requirements: []
|
71
|
-
rubygems_version: 3.
|
71
|
+
rubygems_version: 3.3.7
|
72
72
|
signing_key:
|
73
73
|
specification_version: 4
|
74
74
|
summary: Consume HTTP APIs with style
|