xoopit-cloudquery 0.1.3 → 0.1.4

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.
Files changed (3) hide show
  1. data/VERSION.yml +1 -1
  2. data/lib/cloudquery.rb +57 -43
  3. metadata +2 -2
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :major: 0
3
3
  :minor: 1
4
- :patch: 3
4
+ :patch: 4
data/lib/cloudquery.rb CHANGED
@@ -127,17 +127,21 @@ module Cloudquery
127
127
  attr_writer :secret
128
128
 
129
129
  # Create a new instance of the client
130
- # +options = {}+ Acceptable options:
131
- # +:account+ => <account name> (default => nil)
132
- # +:secret+ => <API secret> (default => nil)
133
130
  #
134
- # +:document_id_method+ => <method name> (default => nil)
135
- # will call +:document_id_method+ during +add_documents+
136
- # and +update_documents+ which should inject an +'#.id'+
137
- # key-value pair as a simple way to tie app PKs to doc ids.
131
+ # It's highly recommended to set options <tt>:account</tt>
132
+ # and <tt>:secret</tt>. Creating a client without an account
133
+ # and secret isn't very useful.
138
134
  #
139
- # +:secure+ => Boolean (default => true, uses HTTPS)
140
- # +:secure => false+ will use HTTP
135
+ # ==== Acceptable options:
136
+ # :account => <account name> (default => nil)
137
+ # :secret => <API secret> (default => nil)
138
+ # :document_id_method => <method name> (default => nil)
139
+ # :secure => Boolean (use HTTPS, default => true)
140
+ #
141
+ # If +document_id_method+ is set, it will be called on each
142
+ # document as a part of +add_documents+ and +update_documents+
143
+ # which should inject an <tt>'#.id'</tt> key-value pair as a
144
+ # simple way to tie app PKs to doc ids.
141
145
  def initialize(options={})
142
146
  # unless options[:account] && options[:secret]
143
147
  # raise "Client requires :account => <account name> and :secret => <secret>"
@@ -154,7 +158,7 @@ module Cloudquery
154
158
 
155
159
  ## Account management
156
160
 
157
- # Retrieve the API secret for an account, using the password (uses HTTPS)
161
+ # Retrieve the API secret for an +account+, using the +password+ (uses HTTPS)
158
162
  def self.get_secret(account, password)
159
163
  auth = Request.new(:path => "#{PATH}/auth")
160
164
  curl = Curl::Easy.new(auth.url) do |c|
@@ -180,23 +184,26 @@ module Cloudquery
180
184
  end
181
185
 
182
186
  # Update the account document.
183
- # For example, you can use this method to change the API secret:
184
- # update_account({'secret' => 'your-new-secret'})
187
+ #
188
+ # Use this method to change the API secret:
189
+ # update_account({'secret' => 'your-new-secret'})
185
190
  def update_account(account_doc={})
186
191
  body = JSON.generate(account_doc)
187
192
  send_request put(account_path, body)
188
193
  end
189
194
 
190
- # Delete the account. BEWARE: THIS WILL ACTUALLY DELETE YOUR ACCOUNT.
191
- def delete_account
195
+ # Delete the account.
196
+ #
197
+ # ==== BEWARE: THIS WILL ACTUALLY DELETE YOUR ACCOUNT.
198
+ def delete_account!
192
199
  send_request delete(account_path)
193
200
  end
194
201
 
195
202
 
196
203
  ## Schema management
197
204
 
198
- # Add a schema to the account. xml can be a String
199
- # or File-like (responds to read)
205
+ # Add a schema to the account. +xml+ can be a +String+
206
+ # or +File+-like (responds to <tt>:read</tt>)
200
207
  def add_schema(xml)
201
208
  body = xml.respond_to?(:read) ? xml.read : xml
202
209
  request = post(build_path(API_PATHS[:schema]), body)
@@ -212,6 +219,7 @@ module Cloudquery
212
219
  end
213
220
 
214
221
  # Get the schemas for the account.
222
+ #
215
223
  # NOTE: returned format is not the same as accepted for input
216
224
  def get_schemas
217
225
  send_request get(build_path(API_PATHS[:schema]))
@@ -227,7 +235,7 @@ module Cloudquery
227
235
  end
228
236
 
229
237
  # Delete one or more indexes from the account, by name or id
230
- # +indexes = '*'+ will delete all indexes
238
+ # <tt>indexes = '*'</tt> will delete all indexes
231
239
  def delete_indexes(*indexes)
232
240
  indexes = url_pipe_join(indexes)
233
241
  send_request delete(build_path(API_PATHS[:indexes], indexes))
@@ -242,11 +250,12 @@ module Cloudquery
242
250
  ## Document management
243
251
 
244
252
  # Add documents to the specified +index+
245
- # +index = name or id+, +docs = {}+ or Array of {}.
246
253
  #
247
- # Documents with key +'#.id'+ and an existing value will be updated.
254
+ # <tt>index = name</tt> or +id+, <tt>docs = {}</tt> or +Array+ of <tt>{}</tt>.
255
+ #
256
+ # Documents with key <tt>'#.id'</tt> and an existing value will be updated.
248
257
  #
249
- # If +schemas+ is not nil, ensures existence of the
258
+ # If +schemas+ is not +nil+, ensures existence of the
250
259
  # specified schemas on each document.
251
260
  def add_documents(index, docs, *schemas)
252
261
  request = post(
@@ -257,11 +266,12 @@ module Cloudquery
257
266
  end
258
267
 
259
268
  # Update documents in the specified +index+
260
- # +index = name or id+, +docs = {}+ or Array of {}.
269
+
270
+ # <tt>index = name</tt> or +id+, <tt>docs = {}</tt> or +Array+ of <tt>{}</tt>.
261
271
  #
262
- # Documents lacking the key +'#.id'+ will be created.
272
+ # Documents lacking the key <tt>'#.id'</tt> will be created.
263
273
  #
264
- # If +schemas+ is not nil, ensures existence of the
274
+ # If +schemas+ is not +nil+, ensures existence of the
265
275
  # specified schemas on each document.
266
276
  def update_documents(index, docs, *schemas)
267
277
  request = put(
@@ -272,10 +282,11 @@ module Cloudquery
272
282
  end
273
283
 
274
284
  # Modify documents in the +index+ matching +query+
275
- # +modifications = {}+ to update all matching
285
+ #
286
+ # <tt>modifications = {...data...}</tt> to update all matching
276
287
  # documents.
277
288
  #
278
- # If +schemas+ is not nil, ensures existence of the
289
+ # If +schemas+ is not +nil+, ensures existence of the
279
290
  # specified schemas on each document.
280
291
  def modify_documents(index, query, modifications, *schemas)
281
292
  request = put(
@@ -287,13 +298,14 @@ module Cloudquery
287
298
 
288
299
  # Delete documents in the +index+ matching +query+
289
300
  #
290
- # +query+ defaults to +'*'+
291
- # BEWARE: If +query = nil+ this will delete ALL documents in +index+.
301
+ # query => defaults to '*'
302
+ # index => may be an id, index name, or Array of ids or names.
303
+ #
304
+ # Operates on all indexes if +index+ = +nil+ or <tt>'*'</tt>
292
305
  #
293
- # +index+ may be an id, index name, or Array of ids or names.
294
- # Operates on all indexes if +index = nil+ or +'*'+
306
+ # ==== BEWARE: If +query+ = +nil+ this will delete ALL documents in +index+.
295
307
  #
296
- # If +schemas+ is not nil, ensures existence of the
308
+ # If +schemas+ is not +nil+, ensures existence of the
297
309
  # specified schemas on each document.
298
310
  def delete_documents(index, query, *schemas)
299
311
  request = delete(
@@ -308,17 +320,18 @@ module Cloudquery
308
320
 
309
321
  # Get documents matching +query+
310
322
  #
311
- # +query+ defaults to +'*'+
312
- # +index+ may be an id, index name, or Array of ids or names.
313
- # Operates on all indexes if +index = nil+ or +'*'+
323
+ # query => defaults to '*'
324
+ # index => may be an id, index name, or Array of ids or names.
314
325
  #
315
- # +options = {}+ Acceptable options:
316
- # +:fields+ => a field name, a prefix match (e.g. +'trans*'+), or a list thereof (default => +'*'+)
317
- # +:sort+ => a string ("[+|-]schema.field"), or a list thereof (default => +'+#.number'+)
318
- # +:offset+ => integer offset into the result set (default => +0+)
319
- # +:limit+ => integer limit on number of documents returned per index (default => <no limit>)
326
+ # Operates on all indexes if +index+ = +nil+ or <tt>'*'</tt>
320
327
  #
321
- # If +schemas+ is not nil, ensures existence of the
328
+ # ==== Acceptable options:
329
+ # :fields => a field name, a prefix match (e.g. 'trans*'), or Array of fields (default => '*')
330
+ # :sort => a string ("[+|-]schema.field"), or a list thereof (default => '+#.number')
331
+ # :offset => integer offset into the result set (default => 0)
332
+ # :limit => integer limit on number of documents returned per index (default => <no limit>)
333
+ #
334
+ # If +schemas+ is not +nil+, ensures existence of the
322
335
  # specified schemas on each document.
323
336
  def get_documents(index, query, options={}, *schemas)
324
337
  if fields = options.delete(:fields)
@@ -343,11 +356,12 @@ module Cloudquery
343
356
 
344
357
  # Count documents matching +query+
345
358
  #
346
- # +query+ defaults to +'*'+
347
- # +index+ may be an id, index name, or Array of ids or names.
348
- # Operates on all indexes if +index = nil+ or +'*'+
359
+ # query => defaults to '*'
360
+ # index => may be an id, index name, or Array of ids or names.
361
+ #
362
+ # Operates on all indexes if +index+ = +nil+ or <tt>'*'</tt>
349
363
  #
350
- # If +schemas+ is not nil, ensures existence of the
364
+ # If +schemas+ is not +nil+, ensures existence of the
351
365
  # specified schemas on each document.
352
366
  def count_documents(index, query, *schemas)
353
367
  get_documents(index, query, {:fields => '@count'}, *schemas)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xoopit-cloudquery
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cameron Walters
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2009-05-03 00:00:00 -07:00
13
+ date: 2009-05-04 00:00:00 -07:00
14
14
  default_executable:
15
15
  dependencies: []
16
16