gapic-generator 0.5.0 → 0.6.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +31 -0
- data/gem_templates/dockerfile.erb +1 -1
- data/gem_templates/entrypoint.erb +1 -0
- data/gem_templates/gemspec.erb +0 -1
- data/lib/gapic/file_formatter.rb +0 -1
- data/lib/gapic/generator/version.rb +1 -1
- data/lib/gapic/generators/default_generator.rb +3 -3
- data/lib/gapic/{path_template.rb → path_pattern.rb} +9 -8
- data/lib/gapic/path_pattern/parser.rb +146 -0
- data/lib/gapic/path_pattern/pattern.rb +80 -0
- data/lib/gapic/path_pattern/segment.rb +276 -0
- data/lib/gapic/presenters/field_presenter.rb +12 -0
- data/lib/gapic/presenters/gem_presenter.rb +39 -3
- data/lib/gapic/presenters/method_presenter.rb +10 -5
- data/lib/gapic/presenters/package_presenter.rb +4 -3
- data/lib/gapic/presenters/resource_presenter.rb +23 -31
- data/lib/gapic/presenters/service_presenter.rb +14 -12
- data/lib/gapic/runner.rb +3 -1
- data/lib/gapic/schema/api.rb +7 -0
- data/lib/gapic/schema/wrappers.rb +24 -20
- data/lib/gapic/uri_template.rb +36 -0
- data/lib/gapic/uri_template/parser.rb +50 -0
- data/lib/google/protobuf/compiler/plugin.pb.rb +5 -1
- data/lib/google/protobuf/descriptor.pb.rb +1 -0
- data/templates/default/gem/gemfile.erb +0 -3
- data/templates/default/gem/gemspec.erb +4 -5
- data/templates/default/lib/_service.erb +2 -0
- data/templates/default/service/client/_client.erb +2 -0
- data/templates/default/service/client/_config.erb +1 -1
- data/templates/default/service/client/_operations.erb +2 -0
- data/templates/default/service/client/resource/_doc.erb +1 -1
- data/templates/default/service/test/client.erb +1 -3
- data/templates/default/service/test/client_operations.erb +1 -3
- data/templates/default/service/test/client_paths.erb +1 -3
- data/templates/default/service/test/method/_bidi.erb +10 -2
- data/templates/default/service/test/method/_client.erb +10 -2
- data/templates/default/service/test/method/_normal.erb +6 -0
- data/templates/default/service/test/method/_server.erb +9 -1
- data/templates/default/service/test/method/_setup.erb +2 -2
- metadata +10 -21
- data/lib/gapic/path_template/parser.rb +0 -83
- data/lib/gapic/path_template/segment.rb +0 -74
@@ -1,74 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# Copyright 2019 Google LLC
|
4
|
-
#
|
5
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
-
# you may not use this file except in compliance with the License.
|
7
|
-
# You may obtain a copy of the License at
|
8
|
-
#
|
9
|
-
# https://www.apache.org/licenses/LICENSE-2.0
|
10
|
-
#
|
11
|
-
# Unless required by applicable law or agreed to in writing, software
|
12
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
-
# See the License for the specific language governing permissions and
|
15
|
-
# limitations under the License.
|
16
|
-
|
17
|
-
module Gapic
|
18
|
-
module PathTemplate
|
19
|
-
# A segment in a URI path template.
|
20
|
-
#
|
21
|
-
# @see https://tools.ietf.org/html/rfc6570 URI Template
|
22
|
-
#
|
23
|
-
# @!attribute [r] name
|
24
|
-
# @return [String, Integer] The name of a named segment, or the position
|
25
|
-
# of a positional segment.
|
26
|
-
# @!attribute [r] pattern
|
27
|
-
# @return [String, nil] The pattern of the segment, nil if not set.
|
28
|
-
class Segment
|
29
|
-
attr_reader :name, :pattern
|
30
|
-
|
31
|
-
def initialize name, pattern
|
32
|
-
@name = name
|
33
|
-
@pattern = pattern
|
34
|
-
end
|
35
|
-
|
36
|
-
# Determines if the segment is positional (has a number for a name).
|
37
|
-
#
|
38
|
-
# @return [Boolean]
|
39
|
-
def positional?
|
40
|
-
name.is_a? Integer
|
41
|
-
end
|
42
|
-
|
43
|
-
# Determines if the segment is named (has a string for a name).
|
44
|
-
#
|
45
|
-
# @return [Boolean]
|
46
|
-
def named?
|
47
|
-
!positional?
|
48
|
-
end
|
49
|
-
|
50
|
-
# Determines if the segment has a pattern. Positional segments always
|
51
|
-
# have a pattern. Named segments may have a pattern if provided in the
|
52
|
-
# URI path template.
|
53
|
-
#
|
54
|
-
# @return [Boolean]
|
55
|
-
def pattern?
|
56
|
-
!@pattern.nil?
|
57
|
-
end
|
58
|
-
|
59
|
-
# Determines if the segment has a nontrivial pattern (i.e. not `*` or `**`).
|
60
|
-
#
|
61
|
-
# @return [Boolean]
|
62
|
-
def nontrivial_pattern?
|
63
|
-
@pattern && @pattern != "*" && @pattern != "**"
|
64
|
-
end
|
65
|
-
|
66
|
-
# @private
|
67
|
-
def == other
|
68
|
-
return false unless other.is_a? self.class
|
69
|
-
|
70
|
-
(name == other.name) && (pattern == other.pattern)
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|