gcloud 0.6.3 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (175) hide show
  1. checksums.yaml +8 -8
  2. data/AUTHENTICATION.md +13 -9
  3. data/CHANGELOG.md +8 -3
  4. data/OVERVIEW.md +46 -8
  5. data/lib/gcloud.rb +123 -117
  6. data/lib/gcloud/backoff.rb +43 -15
  7. data/lib/gcloud/bigquery.rb +211 -195
  8. data/lib/gcloud/bigquery/connection.rb +9 -9
  9. data/lib/gcloud/bigquery/copy_job.rb +15 -16
  10. data/lib/gcloud/bigquery/credentials.rb +3 -3
  11. data/lib/gcloud/bigquery/data.rb +12 -11
  12. data/lib/gcloud/bigquery/dataset.rb +162 -216
  13. data/lib/gcloud/bigquery/dataset/access.rb +59 -43
  14. data/lib/gcloud/bigquery/dataset/list.rb +3 -3
  15. data/lib/gcloud/bigquery/errors.rb +9 -5
  16. data/lib/gcloud/bigquery/extract_job.rb +18 -18
  17. data/lib/gcloud/bigquery/insert_response.rb +7 -4
  18. data/lib/gcloud/bigquery/job.rb +48 -44
  19. data/lib/gcloud/bigquery/job/list.rb +3 -3
  20. data/lib/gcloud/bigquery/load_job.rb +24 -25
  21. data/lib/gcloud/bigquery/project.rb +145 -204
  22. data/lib/gcloud/bigquery/query_data.rb +10 -9
  23. data/lib/gcloud/bigquery/query_job.rb +23 -32
  24. data/lib/gcloud/bigquery/table.rb +238 -280
  25. data/lib/gcloud/bigquery/table/list.rb +3 -3
  26. data/lib/gcloud/bigquery/table/schema.rb +79 -87
  27. data/lib/gcloud/bigquery/view.rb +69 -82
  28. data/lib/gcloud/credentials.rb +3 -9
  29. data/lib/gcloud/datastore.rb +194 -170
  30. data/lib/gcloud/datastore/connection.rb +12 -8
  31. data/lib/gcloud/datastore/credentials.rb +6 -4
  32. data/lib/gcloud/datastore/dataset.rb +74 -141
  33. data/lib/gcloud/datastore/dataset/lookup_results.rb +6 -4
  34. data/lib/gcloud/datastore/dataset/query_results.rb +6 -4
  35. data/lib/gcloud/datastore/entity.rb +81 -76
  36. data/lib/gcloud/datastore/errors.rb +10 -8
  37. data/lib/gcloud/datastore/key.rb +41 -77
  38. data/lib/gcloud/datastore/properties.rb +3 -3
  39. data/lib/gcloud/datastore/proto.rb +7 -4
  40. data/lib/gcloud/datastore/query.rb +26 -3
  41. data/lib/gcloud/datastore/transaction.rb +12 -8
  42. data/lib/gcloud/dns.rb +180 -152
  43. data/lib/gcloud/dns/change.rb +16 -16
  44. data/lib/gcloud/dns/change/list.rb +3 -3
  45. data/lib/gcloud/dns/connection.rb +9 -10
  46. data/lib/gcloud/dns/credentials.rb +3 -3
  47. data/lib/gcloud/dns/errors.rb +9 -5
  48. data/lib/gcloud/dns/importer.rb +17 -23
  49. data/lib/gcloud/dns/project.rb +42 -64
  50. data/lib/gcloud/dns/record.rb +58 -46
  51. data/lib/gcloud/dns/record/list.rb +6 -7
  52. data/lib/gcloud/dns/zone.rb +198 -289
  53. data/lib/gcloud/dns/zone/list.rb +3 -3
  54. data/lib/gcloud/dns/zone/transaction.rb +56 -72
  55. data/lib/gcloud/errors.rb +174 -3
  56. data/lib/gcloud/gce.rb +3 -4
  57. data/lib/gcloud/grpc_utils.rb +76 -0
  58. data/lib/gcloud/logging.rb +308 -0
  59. data/lib/gcloud/logging/credentials.rb +29 -0
  60. data/lib/gcloud/logging/entry.rb +303 -0
  61. data/lib/gcloud/logging/entry/http_request.rb +141 -0
  62. data/lib/gcloud/logging/entry/list.rb +111 -0
  63. data/lib/gcloud/logging/entry/operation.rb +90 -0
  64. data/lib/gcloud/logging/logger.rb +307 -0
  65. data/lib/gcloud/logging/metric.rb +175 -0
  66. data/lib/gcloud/logging/metric/list.rb +98 -0
  67. data/lib/gcloud/logging/project.rb +650 -0
  68. data/lib/gcloud/logging/resource.rb +95 -0
  69. data/lib/gcloud/logging/resource_descriptor.rb +140 -0
  70. data/lib/gcloud/logging/resource_descriptor/list.rb +78 -0
  71. data/lib/gcloud/logging/service.rb +258 -0
  72. data/lib/gcloud/logging/sink.rb +233 -0
  73. data/lib/gcloud/logging/sink/list.rb +97 -0
  74. data/lib/gcloud/pubsub.rb +241 -199
  75. data/lib/gcloud/pubsub/credentials.rb +3 -3
  76. data/lib/gcloud/pubsub/message.rb +26 -20
  77. data/lib/gcloud/pubsub/project.rb +166 -233
  78. data/lib/gcloud/pubsub/received_message.rb +28 -38
  79. data/lib/gcloud/pubsub/service.rb +323 -0
  80. data/lib/gcloud/pubsub/subscription.rb +172 -242
  81. data/lib/gcloud/pubsub/subscription/list.rb +11 -9
  82. data/lib/gcloud/pubsub/topic.rb +152 -271
  83. data/lib/gcloud/pubsub/topic/batch.rb +66 -0
  84. data/lib/gcloud/pubsub/topic/list.rb +9 -7
  85. data/lib/gcloud/resource_manager.rb +158 -138
  86. data/lib/gcloud/resource_manager/connection.rb +6 -5
  87. data/lib/gcloud/resource_manager/credentials.rb +3 -3
  88. data/lib/gcloud/resource_manager/errors.rb +9 -5
  89. data/lib/gcloud/resource_manager/manager.rb +54 -86
  90. data/lib/gcloud/resource_manager/project.rb +69 -88
  91. data/lib/gcloud/resource_manager/project/list.rb +4 -5
  92. data/lib/gcloud/resource_manager/project/updater.rb +12 -14
  93. data/lib/gcloud/search.rb +158 -135
  94. data/lib/gcloud/search/api_client.rb +7 -7
  95. data/lib/gcloud/search/connection.rb +8 -8
  96. data/lib/gcloud/search/credentials.rb +3 -3
  97. data/lib/gcloud/search/document.rb +64 -87
  98. data/lib/gcloud/search/document/list.rb +5 -5
  99. data/lib/gcloud/search/errors.rb +9 -5
  100. data/lib/gcloud/search/field_value.rb +32 -38
  101. data/lib/gcloud/search/field_values.rb +50 -80
  102. data/lib/gcloud/search/fields.rb +44 -65
  103. data/lib/gcloud/search/index.rb +163 -204
  104. data/lib/gcloud/search/index/list.rb +5 -5
  105. data/lib/gcloud/search/project.rb +31 -47
  106. data/lib/gcloud/search/result.rb +27 -31
  107. data/lib/gcloud/search/result/list.rb +6 -6
  108. data/lib/gcloud/storage.rb +224 -190
  109. data/lib/gcloud/storage/bucket.rb +202 -227
  110. data/lib/gcloud/storage/bucket/acl.rb +83 -170
  111. data/lib/gcloud/storage/bucket/cors.rb +31 -34
  112. data/lib/gcloud/storage/bucket/list.rb +3 -3
  113. data/lib/gcloud/storage/connection.rb +11 -7
  114. data/lib/gcloud/storage/credentials.rb +3 -3
  115. data/lib/gcloud/storage/errors.rb +11 -8
  116. data/lib/gcloud/storage/file.rb +129 -171
  117. data/lib/gcloud/storage/file/acl.rb +51 -99
  118. data/lib/gcloud/storage/file/list.rb +3 -3
  119. data/lib/gcloud/storage/file/verifier.rb +3 -2
  120. data/lib/gcloud/storage/project.rb +111 -132
  121. data/lib/gcloud/upload.rb +4 -7
  122. data/lib/gcloud/version.rb +2 -4
  123. data/lib/google/api/annotations.rb +14 -0
  124. data/lib/google/api/http.rb +30 -0
  125. data/lib/google/api/label.rb +24 -0
  126. data/lib/google/api/monitored_resource.rb +25 -0
  127. data/lib/google/datastore/v1beta3/datastore.rb +115 -0
  128. data/lib/google/datastore/v1beta3/datastore_services.rb +33 -0
  129. data/lib/google/datastore/v1beta3/entity.rb +63 -0
  130. data/lib/google/datastore/v1beta3/query.rb +128 -0
  131. data/lib/google/devtools/cloudtrace/v1/trace.rb +78 -0
  132. data/lib/google/devtools/cloudtrace/v1/trace_services.rb +32 -0
  133. data/lib/google/example/library/v1/library.rb +91 -0
  134. data/lib/google/example/library/v1/library_services.rb +40 -0
  135. data/lib/google/iam/v1/iam_policy.rb +33 -0
  136. data/lib/google/iam/v1/iam_policy_services.rb +30 -0
  137. data/lib/google/iam/v1/policy.rb +25 -0
  138. data/lib/google/logging/type/http_request.rb +28 -0
  139. data/lib/google/logging/type/log_severity.rb +27 -0
  140. data/lib/google/logging/v2/log_entry.rb +44 -0
  141. data/lib/google/logging/v2/logging.rb +56 -0
  142. data/lib/google/logging/v2/logging_config.rb +59 -0
  143. data/lib/google/logging/v2/logging_config_services.rb +32 -0
  144. data/lib/google/logging/v2/logging_metrics.rb +51 -0
  145. data/lib/google/logging/v2/logging_metrics_services.rb +32 -0
  146. data/lib/google/logging/v2/logging_services.rb +31 -0
  147. data/lib/google/longrunning/operations.rb +50 -0
  148. data/lib/google/longrunning/operations_services.rb +29 -0
  149. data/lib/google/protobuf/any.rb +17 -0
  150. data/lib/google/protobuf/api.rb +31 -0
  151. data/lib/google/protobuf/descriptor.rb +0 -0
  152. data/lib/google/protobuf/duration.rb +17 -0
  153. data/lib/google/protobuf/empty.rb +15 -0
  154. data/lib/google/protobuf/field_mask.rb +16 -0
  155. data/lib/google/protobuf/source_context.rb +16 -0
  156. data/lib/google/protobuf/struct.rb +35 -0
  157. data/lib/google/protobuf/timestamp.rb +17 -0
  158. data/lib/google/protobuf/type.rb +79 -0
  159. data/lib/google/protobuf/wrappers.rb +48 -0
  160. data/lib/google/pubsub/v1/pubsub.rb +129 -0
  161. data/lib/google/pubsub/v1/pubsub_services.rb +56 -0
  162. data/lib/google/pubsub/v1beta2/pubsub.rb +126 -0
  163. data/lib/google/pubsub/v1beta2/pubsub_services.rb +56 -0
  164. data/lib/google/rpc/code.rb +32 -0
  165. data/lib/google/rpc/error_details.rb +61 -0
  166. data/lib/google/rpc/status.rb +19 -0
  167. data/lib/google/type/color.rb +20 -0
  168. data/lib/google/type/date.rb +18 -0
  169. data/lib/google/type/dayofweek.rb +23 -0
  170. data/lib/google/type/latlng.rb +17 -0
  171. data/lib/google/type/money.rb +18 -0
  172. data/lib/google/type/timeofday.rb +19 -0
  173. metadata +101 -4
  174. data/lib/gcloud/pubsub/connection.rb +0 -295
  175. data/lib/gcloud/pubsub/errors.rb +0 -93
@@ -1,4 +1,3 @@
1
- #--
2
1
  # Copyright 2015 Google Inc. All rights reserved.
3
2
  #
4
3
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -13,22 +12,24 @@
13
12
  # See the License for the specific language governing permissions and
14
13
  # limitations under the License.
15
14
 
15
+
16
16
  module Gcloud
17
17
  module Search
18
18
  ##
19
- # = FieldValue
19
+ # # FieldValue
20
20
  #
21
21
  # FieldValue is used to represent a value that belongs to a field. (See
22
- # Fields and FieldValues)
22
+ # {Fields} and {FieldValues})
23
23
  #
24
24
  # A field value must have a type. A value that is a Numeric will default to
25
25
  # `:number`, while a DateTime will default to `:datetime`. If a type is not
26
26
  # provided it will be determined by looking at the value.
27
27
  #
28
28
  # String values (text, html, atom) can also specify a lang value, which is
29
- # an {ISO 639-1
30
- # code}[https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes].
29
+ # an [ISO 639-1
30
+ # code](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes).
31
31
  #
32
+ # @example
32
33
  # require "gcloud"
33
34
  #
34
35
  # gcloud = Gcloud.new
@@ -41,8 +42,8 @@ module Gcloud
41
42
  # puts "* #{value} (#{value.type}) [#{value.lang}]"
42
43
  # end
43
44
  #
44
- # For more information see {Documents and
45
- # fields}[https://cloud.google.com/search/documents_indexes].
45
+ # @see https://cloud.google.com/search/documents_indexes Documents and
46
+ # fields
46
47
  #
47
48
  class FieldValue < DelegateClass(::Object)
48
49
  attr_reader :type, :lang, :name
@@ -51,40 +52,33 @@ module Gcloud
51
52
  # Disabled because there are links in the docs that are long.
52
53
 
53
54
  ##
54
- # Create a new FieldValue object.
55
- #
56
- # === Parameters
55
+ # @private Create a new FieldValue object.
57
56
  #
58
- # +value+::
59
- # The value to add to the field. (+String+ or +Datetime+ or +Float+)
60
- # +type+::
61
- # The type of the field value. A field can have multiple values with
57
+ # @param [String, Datetime, Float] value The value to add to the field.
58
+ # @param [Symbol] type The type of the field value. A field can have multiple values with
62
59
  # same or different types; however, it cannot have multiple Timestamp or
63
- # number values. (+Symbol+)
60
+ # number values.
64
61
  #
65
62
  # The following values are supported:
66
- # * +:text+ - The value is a string with maximum length 1024**2
63
+ #
64
+ # * `:text` - The value is a string with maximum length 1024**2
67
65
  # characters.
68
- # * +:html+ - The value is an HTML-formatted string with maximum length
66
+ # * `:html` - The value is an HTML-formatted string with maximum length
69
67
  # 1024**2 characters.
70
- # * +:atom+ - The value is a string with maximum length 500 characters.
71
- # * +:geo+ - The value is a point on earth described by latitude and
68
+ # * `:atom` - The value is a string with maximum length 500 characters.
69
+ # * `:geo` - The value is a point on earth described by latitude and
72
70
  # longitude coordinates, represented in string with any of the listed
73
- # {ways of writing
74
- # coordinates}[http://en.wikipedia.org/wiki/Geographic_coordinate_conversion].
75
- # * +:datetime+ - The value is a +DateTime+.
76
- # * +:number+ - The value is a +Numeric+ between -2,147,483,647 and
71
+ # [ways of writing
72
+ # coordinates](http://en.wikipedia.org/wiki/Geographic_coordinate_conversion).
73
+ # * `:datetime` - The value is a `DateTime`.
74
+ # * `:number` - The value is a `Numeric` between -2,147,483,647 and
77
75
  # 2,147,483,647. The value will be stored as a double precision
78
76
  # floating point value in Cloud Search.
79
- # +lang+::
80
- # The language of a string value. Must be a valid {ISO 639-1
81
- # code}[https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes].
82
- # (+String+)
83
- # +name+::
84
- # The name of the field. New values will be configured with this name.
85
- # (+String+)
77
+ # @param [String] lang The language of a string value. Must be a valid [ISO 639-1
78
+ # code](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes).
79
+ # @param [String] name The name of the field. New values will be configured with this name.
86
80
  #
87
- def initialize value, type: nil, lang: nil, name: nil #:nodoc:
81
+ def initialize value, type: nil, lang: nil, name: nil
88
82
  super value
89
83
  if type
90
84
  @type = type.to_s.downcase.to_sym
@@ -105,14 +99,14 @@ module Gcloud
105
99
  end
106
100
 
107
101
  ##
108
- # Get the original value object.
109
- def value #:nodoc:
102
+ # @private Get the original value object.
103
+ def value
110
104
  __getobj__
111
105
  end
112
106
 
113
107
  ##
114
- # Create a new FieldValue instance from a value Hash.
115
- def self.from_raw field_value, name = nil #:nodoc:
108
+ # @private Create a new FieldValue instance from a value Hash.
109
+ def self.from_raw field_value, name = nil
116
110
  value = field_value["stringValue"]
117
111
  type = field_value["stringFormat"]
118
112
  if field_value["timestampValue"]
@@ -130,8 +124,8 @@ module Gcloud
130
124
  end
131
125
 
132
126
  ##
133
- # Create a raw Hash object containing the field value.
134
- def to_raw #:nodoc:
127
+ # @private Create a raw Hash object containing the field value.
128
+ def to_raw
135
129
  case type
136
130
  when :atom, :default, :html, :text
137
131
  {
@@ -150,7 +144,7 @@ module Gcloud
150
144
 
151
145
  protected
152
146
 
153
- def infer_type #:nodoc:
147
+ def infer_type
154
148
  if respond_to? :rfc3339
155
149
  :datetime
156
150
  elsif value.is_a? Numeric # must call on original object...
@@ -1,4 +1,3 @@
1
- #--
2
1
  # Copyright 2015 Google Inc. All rights reserved.
3
2
  #
4
3
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -13,12 +12,13 @@
13
12
  # See the License for the specific language governing permissions and
14
13
  # limitations under the License.
15
14
 
15
+
16
16
  require "gcloud/search/field_value"
17
17
 
18
18
  module Gcloud
19
19
  module Search
20
20
  ##
21
- # = FieldValues
21
+ # # FieldValues
22
22
  #
23
23
  # The list of values for a field.
24
24
  #
@@ -30,8 +30,9 @@ module Gcloud
30
30
  # Each field on a document can have multiple values. FieldValues is the
31
31
  # object that manages the multiple values. Values can be the same or
32
32
  # different types; however, it cannot have multiple datetime (DateTime) or
33
- # number (Float) values. (See FieldValue)
33
+ # number (Float) values. (See {FieldValue})
34
34
  #
35
+ # @example
35
36
  # require "gcloud"
36
37
  #
37
38
  # gcloud = Gcloud.new
@@ -44,25 +45,20 @@ module Gcloud
44
45
  # puts "* #{value} (#{value.type}) [#{value.lang}]"
45
46
  # end
46
47
  #
47
- # For more information see {Documents and
48
- # fields}[https://cloud.google.com/search/documents_indexes].
48
+ # @see https://cloud.google.com/search/documents_indexes Documents and
49
+ # Indexes
49
50
  #
50
51
  class FieldValues
51
52
  include Enumerable
52
53
 
53
54
  ##
54
- # Create a new FieldValues object.
55
- #
56
- # === Parameters
55
+ # @private Create a new FieldValues object.
57
56
  #
58
- # +name+::
59
- # The name of the field. New values will be configured with this name.
60
- # (+String+)
61
- # +values+::
62
- # A list of values to add to the field. (+Array+ of +FieldValue+
63
- # objects)
57
+ # @param [String] name The name of the field. New values will be
58
+ # configured with this name.
59
+ # @param [Array<FieldValue>] values A list of values to add to the field.
64
60
  #
65
- def initialize name, values = [] # :nodoc:
61
+ def initialize name, values = []
66
62
  @name = name
67
63
  @values = values
68
64
  end
@@ -77,58 +73,47 @@ module Gcloud
77
73
  # before an element. Additionally, an empty array is returned when the
78
74
  # starting index for an element range is at the end of the array.
79
75
  #
80
- # Returns nil if the index (or starting index) are out of range.
76
+ # @return [FieldValue, nil] Returns nil if the index (or starting index)
77
+ # are out of range.
81
78
  def [] index
82
79
  @values[index]
83
80
  end
84
81
 
85
- # rubocop:disable Metrics/LineLength
86
- # Disabled because there are links in the docs that are long.
87
-
88
82
  ##
89
- # Add a new value. The field name will be added to the value object. If
83
+ # Add a new value. If the field name does not exist it will be added. If
90
84
  # the field value is a DateTime or Numeric, or the type is set to
91
- # +:datetime+ or +:number+, then the added value will replace any existing
85
+ # `:datetime` or `:number`, then the added value will replace any existing
92
86
  # values of the same type (since there can be only one).
93
87
  #
94
- # === Parameters
95
- #
96
- # +value+::
97
- # The value to add to the field. (+String+ or +Datetime+ or +Float+)
98
- # +type+::
99
- # The type of the field value. An attempt is made to set the correct
100
- # type when this option is missing, although it must be provided for
101
- # +:geo+ values. A field can have multiple values with same or different
102
- # types; however, it cannot have multiple +:datetime+ or +:number+
103
- # values. (+Symbol+)
88
+ # @param [String, Datetime, Float] value The value to add to the field.
89
+ # @param [Symbol] type The type of the field value. An attempt is made to
90
+ # set the correct type when this option is missing, although it must be
91
+ # provided for `:geo` values. A field can have multiple values with same
92
+ # or different types; however, it cannot have multiple `:datetime` or
93
+ # `:number` values.
104
94
  #
105
95
  # The following values are supported:
106
- # * +:default+ - The value is a string. The format will be automatically
96
+ #
97
+ # * `:default` - The value is a string. The format will be automatically
107
98
  # detected. This is the default value for strings.
108
- # * +:text+ - The value is a string with maximum length 1024**2
99
+ # * `:text` - The value is a string with maximum length 1024**2
109
100
  # characters.
110
- # * +:html+ - The value is an HTML-formatted string with maximum length
101
+ # * `:html` - The value is an HTML-formatted string with maximum length
111
102
  # 1024**2 characters.
112
- # * +:atom+ - The value is a string with maximum length 500 characters.
113
- # * +:geo+ - The value is a point on earth described by latitude and
103
+ # * `:atom` - The value is a string with maximum length 500 characters.
104
+ # * `:geo` - The value is a point on earth described by latitude and
114
105
  # longitude coordinates, represented in string with any of the listed
115
- # {ways of writing
116
- # coordinates}[http://en.wikipedia.org/wiki/Geographic_coordinate_conversion].
117
- # * +:datetime+ - The value is a +DateTime+.
118
- # * +:number+ - The value is a +Numeric+ between -2,147,483,647 and
106
+ # [ways of writing coordinates](http://en.wikipedia.org/wiki/Geographic_coordinate_conversion).
107
+ # * `:datetime` - The value is a `DateTime`.
108
+ # * `:number` - The value is a `Numeric` between -2,147,483,647 and
119
109
  # 2,147,483,647. The value will be stored as a double precision
120
110
  # floating point value in Cloud Search.
121
- # +lang+::
122
- # The language of a string value. Must be a valid {ISO 639-1
123
- # code}[https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes].
124
- # (+String+)
111
+ # @param [String] lang The language of a string value. Must be a valid
112
+ # [ISO 639-1 code](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes).
125
113
  #
126
- # === Returns
127
- #
128
- # FieldValue
129
- #
130
- # === Example
114
+ # @return [FieldValue]
131
115
  #
116
+ # @example
132
117
  # require "gcloud"
133
118
  #
134
119
  # gcloud = Gcloud.new
@@ -151,22 +136,15 @@ module Gcloud
151
136
  @values << new_field
152
137
  end
153
138
 
154
- # rubocop:enable Metrics/LineLength
155
-
156
139
  ##
157
140
  # Deletes all values that are equal to value.
158
141
  #
159
- # === Parameters
160
- #
161
- # +value+::
162
- # The value to remove from the list of values.
142
+ # @param [String] value The value to remove from the list of values.
163
143
  #
164
- # === Returns
165
- #
166
- # The last deleted +FieldValue+, or +nil+ if no matching value is found.
167
- #
168
- # === Example
144
+ # @return [FieldValue, nil] The last deleted `FieldValue`, or `nil` if no
145
+ # matching value is found.
169
146
  #
147
+ # @example
170
148
  # require "gcloud"
171
149
  #
172
150
  # gcloud = Gcloud.new
@@ -185,22 +163,15 @@ module Gcloud
185
163
 
186
164
  ##
187
165
  # Deletes the value at the specified index, returning that FieldValue, or
188
- # +nil+ if the index is out of range.
189
- ##
190
- # Deletes all values that are equal to value.
166
+ # `nil` if the index is out of range.
191
167
  #
192
- # === Parameters
168
+ # @param [String] index The index of the value to be removed from the list
169
+ # of values.
193
170
  #
194
- # +index+::
195
- # The index of the value to be removed from the list of values.
196
- #
197
- # === Returns
198
- #
199
- # The deleted +FieldValue+ found at the specified index, or # +nil+ if the
200
- # index is out of range.
201
- #
202
- # === Example
171
+ # @return [FieldValue] The deleted `FieldValue` found at the specified
172
+ # index, or # `nil` if the index is out of range.
203
173
  #
174
+ # @example
204
175
  # require "gcloud"
205
176
  #
206
177
  # gcloud = Gcloud.new
@@ -222,8 +193,7 @@ module Gcloud
222
193
  #
223
194
  # An Enumerator is returned if no block is given.
224
195
  #
225
- # === Example
226
- #
196
+ # @example
227
197
  # require "gcloud"
228
198
  #
229
199
  # gcloud = Gcloud.new
@@ -241,21 +211,21 @@ module Gcloud
241
211
  end
242
212
 
243
213
  ##
244
- # Returns +true+ if there are no values.
214
+ # Returns `true` if there are no values.
245
215
  def empty?
246
216
  @values.empty?
247
217
  end
248
218
 
249
219
  ##
250
- # Create a new FieldValues instance from a name and values Hash.
251
- def self.from_raw name, values #:nodoc:
220
+ # @private Create a new FieldValues instance from a name and values Hash.
221
+ def self.from_raw name, values
252
222
  field_values = values.map { |value| FieldValue.from_raw value, name }
253
223
  FieldValues.new name, field_values
254
224
  end
255
225
 
256
226
  ##
257
- # Create a raw Hash object containing all the field values.
258
- def to_raw #:nodoc:
227
+ # @private Create a raw Hash object containing all the field values.
228
+ def to_raw
259
229
  { "values" => @values.map(&:to_raw) }
260
230
  end
261
231
  end
@@ -1,4 +1,3 @@
1
- #--
2
1
  # Copyright 2015 Google Inc. All rights reserved.
3
2
  #
4
3
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -13,13 +12,14 @@
13
12
  # See the License for the specific language governing permissions and
14
13
  # limitations under the License.
15
14
 
15
+
16
16
  require "gcloud/search/field_values"
17
17
  require "gcloud/search/field_value"
18
18
 
19
19
  module Gcloud
20
20
  module Search
21
21
  ##
22
- # = Fields
22
+ # # Fields
23
23
  #
24
24
  # Fields is the object that provides access to a document's fields.
25
25
  #
@@ -30,8 +30,9 @@ module Gcloud
30
30
  #
31
31
  # A field can have multiple values with same or different types; however, it
32
32
  # cannot have multiple datetime (DateTime) or number (Float) values. (See
33
- # FieldValues and FieldValue)
33
+ # {FieldValues} and {FieldValue})
34
34
  #
35
+ # @example
35
36
  # require "gcloud"
36
37
  #
37
38
  # gcloud = Gcloud.new
@@ -47,33 +48,27 @@ module Gcloud
47
48
  # end
48
49
  # end
49
50
  #
50
- # For more information see {Documents and
51
- # fields}[https://cloud.google.com/search/documents_indexes].
51
+ # @see https://cloud.google.com/search/documents_indexes Documents and
52
+ # fields
52
53
  #
53
54
  class Fields
54
55
  include Enumerable
55
56
 
56
57
  ##
57
- # Create a new empty fields object.
58
- def initialize #:nodoc:
58
+ # @private Create a new empty fields object.
59
+ def initialize
59
60
  @hash = {}
60
61
  end
61
62
 
62
63
  ##
63
64
  # Retrieve the field values associated to a field name.
64
65
  #
65
- # === Parameters
66
- #
67
- # +name+::
68
- # The name of the field. New values will be configured with this name.
69
- # (+String+)
70
- #
71
- # === Returns
66
+ # @param [String] name The name of the field. New values will be
67
+ # configured with this name.
72
68
  #
73
- # FieldValues
74
- #
75
- # === Example
69
+ # @return [FieldValues]
76
70
  #
71
+ # @example
77
72
  # require "gcloud"
78
73
  #
79
74
  # gcloud = Gcloud.new
@@ -90,51 +85,40 @@ module Gcloud
90
85
  @hash[name] ||= FieldValues.new name
91
86
  end
92
87
 
93
- # rubocop:disable Metrics/LineLength
94
- # Disabled because there are links in the docs that are long.
95
-
96
88
  ##
97
89
  # Add a new value. If the field name does not exist it will be added. If
98
90
  # the field value is a DateTime or Numeric, or the type is set to
99
- # +:datetime+ or +:number+, then the added value will replace any existing
91
+ # `:datetime` or `:number`, then the added value will replace any existing
100
92
  # values of the same type (since there can be only one).
101
93
  #
102
- # === Parameters
103
- #
104
- # +name+::
105
- # The name of the field. (+String+)
106
- # +value+::
107
- # The value to add to the field. (+String+ or +Datetime+ or +Float+)
108
- # +type+::
109
- # The type of the field value. An attempt is made to set the correct
110
- # type when this option is missing, although it must be provided for
111
- # +:geo+ values. A field can have multiple values with same or different
112
- # types; however, it cannot have multiple +:datetime+ or +:number+
113
- # values. (+Symbol+)
94
+ # @param [String] name The name of the field.
95
+ # @param [String, Datetime, Float] value The value to add to the field.
96
+ # @param [Symbol] type The type of the field value. An attempt is made to
97
+ # set the correct type when this option is missing, although it must be
98
+ # provided for `:geo` values. A field can have multiple values with same
99
+ # or different types; however, it cannot have multiple `:datetime` or
100
+ # `:number` values.
114
101
  #
115
102
  # The following values are supported:
116
- # * +:default+ - The value is a string. The format will be automatically
103
+ #
104
+ # * `:default` - The value is a string. The format will be automatically
117
105
  # detected. This is the default value for strings.
118
- # * +:text+ - The value is a string with maximum length 1024**2
106
+ # * `:text` - The value is a string with maximum length 1024**2
119
107
  # characters.
120
- # * +:html+ - The value is an HTML-formatted string with maximum length
108
+ # * `:html` - The value is an HTML-formatted string with maximum length
121
109
  # 1024**2 characters.
122
- # * +:atom+ - The value is a string with maximum length 500 characters.
123
- # * +:geo+ - The value is a point on earth described by latitude and
110
+ # * `:atom` - The value is a string with maximum length 500 characters.
111
+ # * `:geo` - The value is a point on earth described by latitude and
124
112
  # longitude coordinates, represented in string with any of the listed
125
- # {ways of writing
126
- # coordinates}[http://en.wikipedia.org/wiki/Geographic_coordinate_conversion].
127
- # * +:datetime+ - The value is a +DateTime+.
128
- # * +:number+ - The value is a +Numeric+ between -2,147,483,647 and
113
+ # [ways of writing coordinates](http://en.wikipedia.org/wiki/Geographic_coordinate_conversion).
114
+ # * `:datetime` - The value is a `DateTime`.
115
+ # * `:number` - The value is a `Numeric` between -2,147,483,647 and
129
116
  # 2,147,483,647. The value will be stored as a double precision
130
117
  # floating point value in Cloud Search.
131
- # +lang+::
132
- # The language of a string value. Must be a valid {ISO 639-1
133
- # code}[https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes].
134
- # (+String+)
135
- #
136
- # === Example
118
+ # @param [String] lang The language of a string value. Must be a valid
119
+ # [ISO 639-1 code](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes).
137
120
  #
121
+ # @example
138
122
  # require "gcloud"
139
123
  #
140
124
  # gcloud = Gcloud.new
@@ -154,18 +138,12 @@ module Gcloud
154
138
  @hash[name].add value, type: type, lang: lang
155
139
  end
156
140
 
157
- # rubocop:enable Metrics/LineLength
158
-
159
141
  ##
160
142
  # Deletes a field and all values.
161
143
  #
162
- # === Parameters
163
- #
164
- # +name+::
165
- # The name of the field. (+String+)
166
- #
167
- # === Example
144
+ # @param [String] name The name of the field.
168
145
  #
146
+ # @example
169
147
  # require "gcloud"
170
148
  #
171
149
  # gcloud = Gcloud.new
@@ -183,8 +161,7 @@ module Gcloud
183
161
  # Calls block once for each field, passing the field name and values pair
184
162
  # as parameters. If no block is given an enumerator is returned instead.
185
163
  #
186
- # === Example
187
- #
164
+ # @example
188
165
  # require "gcloud"
189
166
  #
190
167
  # gcloud = Gcloud.new
@@ -208,6 +185,7 @@ module Gcloud
208
185
  ##
209
186
  # Returns a new array populated with all the field names.
210
187
  #
188
+ # @example
211
189
  # require "gcloud"
212
190
  #
213
191
  # gcloud = Gcloud.new
@@ -226,8 +204,8 @@ module Gcloud
226
204
  end
227
205
 
228
206
  ##
229
- # Create a new Fields instance from a raw Hash.
230
- def self.from_raw raw #:nodoc:
207
+ # @private Create a new Fields instance from a raw Hash.
208
+ def self.from_raw raw
231
209
  hsh = {}
232
210
  raw.each do |k, v|
233
211
  hsh[k] = FieldValues.from_raw k, v["values"]
@@ -238,8 +216,9 @@ module Gcloud
238
216
  end
239
217
 
240
218
  ##
241
- # Create a raw Hash object containing all the field names and values.
242
- def to_raw #:nodoc:
219
+ # @private Create a raw Hash object containing all the field names and
220
+ # values.
221
+ def to_raw
243
222
  hsh = {}
244
223
  @hash.each do |k, v|
245
224
  hsh[k] = v.to_raw unless v.empty?
@@ -250,8 +229,8 @@ module Gcloud
250
229
  protected
251
230
 
252
231
  ##
253
- # Find all the fields that have values. This is needed because a field is
254
- # required to have at least one value.
232
+ # @private Find all the fields that have values. This is needed because a
233
+ # field is required to have at least one value.
255
234
  #
256
235
  # Users can remove all values, and the empty FieldValues object will
257
236
  # remain in the internal hash. This is the same as not having that field.
@@ -259,7 +238,7 @@ module Gcloud
259
238
  # Users can also reference the field by name before adding a value. So we
260
239
  # have multiple valid use cases which add an empty FieldValues object to
261
240
  # the hash.
262
- def fields_with_values #:nodoc:
241
+ def fields_with_values
263
242
  @hash.select { |_name, values| values.any? }
264
243
  end
265
244
  end