api_recipes 3.0.0.beta2 → 3.0.0.beta4
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/README.md +704 -81
- data/UPGRADING.md +149 -46
- data/lib/api_recipes/api.rb +14 -10
- data/lib/api_recipes/cli/code.rb +153 -0
- data/lib/api_recipes/cli/convert/migration.rb +624 -0
- data/lib/api_recipes/cli/convert/snippet.rb +67 -0
- data/lib/api_recipes/cli/convert.rb +533 -0
- data/lib/api_recipes/cli/recipes/git.rb +197 -0
- data/lib/api_recipes/cli/recipes/lock_file.rb +34 -0
- data/lib/api_recipes/cli/recipes/summary.rb +245 -0
- data/lib/api_recipes/cli/recipes.rb +287 -0
- data/lib/api_recipes/cli/routes.rb +8 -3
- data/lib/api_recipes/cli/upgrade/project.rb +194 -0
- data/lib/api_recipes/cli/upgrade.rb +361 -24
- data/lib/api_recipes/cli.rb +161 -8
- data/lib/api_recipes/configuration.rb +68 -18
- data/lib/api_recipes/endpoint.rb +10 -4
- data/lib/api_recipes/errors.rb +2 -1
- data/lib/api_recipes/internals/compiler.rb +174 -33
- data/lib/api_recipes/internals/context.rb +87 -20
- data/lib/api_recipes/internals/declaration.rb +18 -18
- data/lib/api_recipes/internals/definition.rb +76 -23
- data/lib/api_recipes/internals/level.rb +54 -43
- data/lib/api_recipes/internals/option_value.rb +92 -0
- data/lib/api_recipes/internals/path_template.rb +29 -4
- data/lib/api_recipes/internals/plain_yaml.rb +133 -0
- data/lib/api_recipes/internals/recipe.rb +297 -0
- data/lib/api_recipes/internals/recipe_lock.rb +115 -0
- data/lib/api_recipes/internals/registry.rb +61 -15
- data/lib/api_recipes/internals/request.rb +42 -14
- data/lib/api_recipes/internals/template.rb +17 -5
- data/lib/api_recipes/version.rb +1 -1
- data/lib/api_recipes.rb +8 -3
- metadata +14 -1
|
@@ -3,12 +3,24 @@
|
|
|
3
3
|
module ApiRecipes
|
|
4
4
|
module Internals
|
|
5
5
|
# A string with {name} variables, used for the host, the base_url and the
|
|
6
|
-
#
|
|
6
|
+
# values of the headers and of the query parameters sent with every request.
|
|
7
|
+
# How a value is checked depends on the position.
|
|
7
8
|
class Template
|
|
8
9
|
VARIABLE = /\{([A-Za-z_]\w*)\}/
|
|
9
10
|
HOST_VALUE = /\A[A-Za-z0-9._-]+\z/
|
|
10
11
|
CONTROL = /[\x00-\x1F\x7F]/
|
|
11
|
-
POSITIONS = %i[host base_url header].freeze
|
|
12
|
+
POSITIONS = %i[host base_url header param].freeze
|
|
13
|
+
|
|
14
|
+
# value as one segment of a path: what base_url and the path of an
|
|
15
|
+
# endpoint do with the value of a variable.
|
|
16
|
+
def self.segment(value, name, api)
|
|
17
|
+
text = value.to_s
|
|
18
|
+
if value.nil? || text.empty? || text == '.' || text == '..'
|
|
19
|
+
raise InvalidVariable.new(api, name, 'must not be blank, "." or ".."')
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
PathTemplate.escape(text)
|
|
23
|
+
end
|
|
12
24
|
|
|
13
25
|
def initialize(string, position)
|
|
14
26
|
raise ArgumentError, "unknown template position '#{position}'" unless POSITIONS.include?(position)
|
|
@@ -56,9 +68,9 @@ module ApiRecipes
|
|
|
56
68
|
when :host
|
|
57
69
|
reject(api, name, 'must contain only letters, digits, dots, hyphens and underscores') unless HOST_VALUE.match?(bytes)
|
|
58
70
|
text
|
|
59
|
-
when :base_url
|
|
60
|
-
|
|
61
|
-
|
|
71
|
+
when :base_url then self.class.segment(value, name, api)
|
|
72
|
+
# http.rb encodes the name and the value of a query parameter.
|
|
73
|
+
when :param then text
|
|
62
74
|
else
|
|
63
75
|
reject(api, name, 'must not contain control characters') if CONTROL.match?(bytes)
|
|
64
76
|
text
|
data/lib/api_recipes/version.rb
CHANGED
data/lib/api_recipes.rb
CHANGED
|
@@ -8,8 +8,12 @@ require 'api_recipes/internals/credential'
|
|
|
8
8
|
require 'api_recipes/internals/level'
|
|
9
9
|
require 'api_recipes/internals/path_template'
|
|
10
10
|
require 'api_recipes/internals/template'
|
|
11
|
+
require 'api_recipes/internals/option_value'
|
|
12
|
+
require 'api_recipes/internals/plain_yaml'
|
|
11
13
|
require 'api_recipes/internals/definition'
|
|
12
14
|
require 'api_recipes/internals/compiler'
|
|
15
|
+
require 'api_recipes/internals/recipe'
|
|
16
|
+
require 'api_recipes/internals/recipe_lock'
|
|
13
17
|
require 'api_recipes/internals/context'
|
|
14
18
|
require 'api_recipes/internals/request'
|
|
15
19
|
require 'api_recipes/response'
|
|
@@ -40,7 +44,7 @@ module ApiRecipes
|
|
|
40
44
|
|
|
41
45
|
draft = configuration.dup
|
|
42
46
|
yield draft
|
|
43
|
-
Internals::Registry.install(draft) { @configuration = draft }
|
|
47
|
+
Internals::Registry.install(draft) { @configuration = draft.close_draft }
|
|
44
48
|
nil
|
|
45
49
|
end
|
|
46
50
|
|
|
@@ -56,8 +60,9 @@ module ApiRecipes
|
|
|
56
60
|
|
|
57
61
|
def self.apis = Internals::Registry.current.apis
|
|
58
62
|
|
|
59
|
-
# Removes the global apis and their methods, the configuration
|
|
60
|
-
#
|
|
63
|
+
# Removes the global apis and their methods, the configuration, the values
|
|
64
|
+
# of the application and those assigned to objects. What a class gives to
|
|
65
|
+
# `api` is part of its code and stays.
|
|
61
66
|
def self.reset!
|
|
62
67
|
Internals::Registry.reset! { @configuration = nil }
|
|
63
68
|
nil
|
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: 3.0.0.
|
|
4
|
+
version: 3.0.0.beta4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Alessandro Verlato
|
|
@@ -57,14 +57,23 @@ files:
|
|
|
57
57
|
- lib/api_recipes.rb
|
|
58
58
|
- lib/api_recipes/api.rb
|
|
59
59
|
- lib/api_recipes/cli.rb
|
|
60
|
+
- lib/api_recipes/cli/code.rb
|
|
61
|
+
- lib/api_recipes/cli/convert.rb
|
|
62
|
+
- lib/api_recipes/cli/convert/migration.rb
|
|
63
|
+
- lib/api_recipes/cli/convert/snippet.rb
|
|
60
64
|
- lib/api_recipes/cli/import.rb
|
|
61
65
|
- lib/api_recipes/cli/import/document.rb
|
|
62
66
|
- lib/api_recipes/cli/import/security.rb
|
|
63
67
|
- lib/api_recipes/cli/import/server.rb
|
|
64
68
|
- lib/api_recipes/cli/import/tree.rb
|
|
65
69
|
- lib/api_recipes/cli/import/writer.rb
|
|
70
|
+
- lib/api_recipes/cli/recipes.rb
|
|
71
|
+
- lib/api_recipes/cli/recipes/git.rb
|
|
72
|
+
- lib/api_recipes/cli/recipes/lock_file.rb
|
|
73
|
+
- lib/api_recipes/cli/recipes/summary.rb
|
|
66
74
|
- lib/api_recipes/cli/routes.rb
|
|
67
75
|
- lib/api_recipes/cli/upgrade.rb
|
|
76
|
+
- lib/api_recipes/cli/upgrade/project.rb
|
|
68
77
|
- lib/api_recipes/configuration.rb
|
|
69
78
|
- lib/api_recipes/endpoint.rb
|
|
70
79
|
- lib/api_recipes/errors.rb
|
|
@@ -75,7 +84,11 @@ files:
|
|
|
75
84
|
- lib/api_recipes/internals/definition.rb
|
|
76
85
|
- lib/api_recipes/internals/handles.rb
|
|
77
86
|
- lib/api_recipes/internals/level.rb
|
|
87
|
+
- lib/api_recipes/internals/option_value.rb
|
|
78
88
|
- lib/api_recipes/internals/path_template.rb
|
|
89
|
+
- lib/api_recipes/internals/plain_yaml.rb
|
|
90
|
+
- lib/api_recipes/internals/recipe.rb
|
|
91
|
+
- lib/api_recipes/internals/recipe_lock.rb
|
|
79
92
|
- lib/api_recipes/internals/registry.rb
|
|
80
93
|
- lib/api_recipes/internals/request.rb
|
|
81
94
|
- lib/api_recipes/internals/template.rb
|