swivel 0.0.2 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- data/README +53 -0
- data/Rakefile +1 -0
- data/bin/swivel +6 -0
- data/lib/swivel.rb +54 -2
- metadata +11 -2
data/README
CHANGED
@@ -313,3 +313,56 @@ Wanna write code with us? http://swivel.com/about/jobs
|
|
313
313
|
|
314
314
|
This software is licensed under the exact same license as Ruby itself. Peace
|
315
315
|
out.
|
316
|
+
|
317
|
+
upload options
|
318
|
+
mode
|
319
|
+
initial append replace
|
320
|
+
|
321
|
+
auto_estimate
|
322
|
+
ordered_column_names
|
323
|
+
ordered_column_types
|
324
|
+
column_separator
|
325
|
+
|
326
|
+
original_asset_name
|
327
|
+
original_asset_path
|
328
|
+
data (or data_content)
|
329
|
+
|
330
|
+
name
|
331
|
+
color
|
332
|
+
description
|
333
|
+
citation
|
334
|
+
citation_url
|
335
|
+
image_url
|
336
|
+
image_source_url
|
337
|
+
display_tags
|
338
|
+
public_tags
|
339
|
+
|
340
|
+
graph options
|
341
|
+
graph_type
|
342
|
+
BarGraph LineGraph HorizontalBarGraph PieGraph ScatterGraph
|
343
|
+
width
|
344
|
+
height
|
345
|
+
limit
|
346
|
+
image_url
|
347
|
+
name
|
348
|
+
description
|
349
|
+
display_tags
|
350
|
+
time_range
|
351
|
+
???
|
352
|
+
time_scale
|
353
|
+
hourly daily weekly quarterly yearly
|
354
|
+
scale
|
355
|
+
absolute average relative range percent
|
356
|
+
|
357
|
+
variant
|
358
|
+
default thumbnail sparkline preview share
|
359
|
+
|
360
|
+
columns
|
361
|
+
order_by_direction
|
362
|
+
asc desc unsorted alpha
|
363
|
+
order_by_column
|
364
|
+
x_axis_column
|
365
|
+
join_on_columns
|
366
|
+
group_by_columns
|
367
|
+
highlight_columns
|
368
|
+
|
data/Rakefile
CHANGED
data/bin/swivel
CHANGED
@@ -15,6 +15,12 @@ config.load
|
|
15
15
|
config.save
|
16
16
|
|
17
17
|
ARGV.options do |opts|
|
18
|
+
opts.banner = 'Usage: swivel < list, show, upload, append > [options]'
|
19
|
+
|
20
|
+
opts.separator ''
|
21
|
+
|
22
|
+
opts.separator 'Options:'
|
23
|
+
|
18
24
|
opts.on '-h', '--host=name', String,
|
19
25
|
"Swivel hostname or IP address.",
|
20
26
|
"Default: #{options[:host]}" do |v| options[:host] = v end
|
data/lib/swivel.rb
CHANGED
@@ -263,12 +263,23 @@ module Swivel
|
|
263
263
|
end
|
264
264
|
end
|
265
265
|
|
266
|
-
%w/DataColumn DataSet
|
266
|
+
%w/DataColumn DataSet User/.each do |class_name|
|
267
267
|
class_eval <<-LAZY
|
268
268
|
class #{class_name} < Response; end
|
269
269
|
LAZY
|
270
270
|
end
|
271
271
|
|
272
|
+
class Graph < Response
|
273
|
+
def image_url options = {}
|
274
|
+
host = @connection.config[:image_host]
|
275
|
+
if variant == 'transient'
|
276
|
+
"http://#{host}/graphs/get/#{digest}"
|
277
|
+
else
|
278
|
+
"http://#{host}/graphs/image/#{id}"
|
279
|
+
end
|
280
|
+
end
|
281
|
+
end
|
282
|
+
|
272
283
|
# Encapsulates lists of resources. Typically, items contained within the list are
|
273
284
|
# subclasses of Swivel::Response.
|
274
285
|
#
|
@@ -331,8 +342,9 @@ module Swivel
|
|
331
342
|
class Config
|
332
343
|
CONFIG_DIR = ENV['HOME']
|
333
344
|
CONFIG_FILE = '.swivelrc'
|
345
|
+
DEFAULT_HOST = 'api.swivel.com'
|
334
346
|
DEFAULT_CONFIG = { :api_key => '', :protocol => 'http://',
|
335
|
-
:host =>
|
347
|
+
:host => DEFAULT_HOST, :port => 80,
|
336
348
|
:timeout_up => 200, :timeout_down => 100 }
|
337
349
|
|
338
350
|
attr_accessor :config
|
@@ -354,6 +366,9 @@ module Swivel
|
|
354
366
|
else
|
355
367
|
YAML::load_file @filename
|
356
368
|
end
|
369
|
+
@config[:image_host] ||=
|
370
|
+
@config[:host] == DEFAULT_HOST ? 'www.swivel.com' : @config[:host]
|
371
|
+
@config
|
357
372
|
end
|
358
373
|
|
359
374
|
# Saves a configuration to the same file from which it was loaded.
|
@@ -416,6 +431,43 @@ module Swivel
|
|
416
431
|
xml || nil
|
417
432
|
end
|
418
433
|
|
434
|
+
# Calling all of those endpoints is tedious. For swivel's main objects
|
435
|
+
# there are some helper methods to get stuff:
|
436
|
+
#
|
437
|
+
# data_set = swivel.data_set 1
|
438
|
+
# data_set.class # => Swivel::DataSet
|
439
|
+
# data_set.id # => 1
|
440
|
+
#
|
441
|
+
# data_sets = swivel.data_sets
|
442
|
+
#
|
443
|
+
# some_graph = swivel.graph 1232132
|
444
|
+
#
|
445
|
+
# da_bomb = swivel.user 'visnu'
|
446
|
+
# da_bomb.name # => 'visnu'
|
447
|
+
#
|
448
|
+
# All these really do is prettify a get call to:
|
449
|
+
# /rest/object_type or /rest/object_type/id
|
450
|
+
|
451
|
+
%w/ data_columns data_sets graphs users /.each do |obj|
|
452
|
+
class_eval <<-LAZY
|
453
|
+
def #{obj} options = nil
|
454
|
+
case options
|
455
|
+
when Hash
|
456
|
+
if options[:id]
|
457
|
+
call "/rest/#{obj}/#\{options[:id]\}", options
|
458
|
+
else
|
459
|
+
call "/rest/#{obj}", options, :post
|
460
|
+
end
|
461
|
+
when Numeric, String, Symbol
|
462
|
+
call "/rest/#{obj}/#\{options\}"
|
463
|
+
else
|
464
|
+
call '/rest/#{obj}'
|
465
|
+
end
|
466
|
+
end
|
467
|
+
alias :#{obj.singularize} :#{obj}
|
468
|
+
LAZY
|
469
|
+
end
|
470
|
+
|
419
471
|
# Performs an upload, append, or replace. Set options[:mode] to one of "initial",
|
420
472
|
# "append", or "replace". If unset, options[:mode] defaults to "initial". Append
|
421
473
|
# and replace can also be called directly, without setting options[:mode].
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.2
|
|
3
3
|
specification_version: 1
|
4
4
|
name: swivel
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.0.
|
7
|
-
date: 2007-06-
|
6
|
+
version: 0.0.8
|
7
|
+
date: 2007-06-28 00:00:00 -07:00
|
8
8
|
summary: Ruby interface to the Swivel API.
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -64,3 +64,12 @@ dependencies:
|
|
64
64
|
- !ruby/object:Gem::Version
|
65
65
|
version: 0.0.0
|
66
66
|
version:
|
67
|
+
- !ruby/object:Gem::Dependency
|
68
|
+
name: cobravsmongoose
|
69
|
+
version_requirement:
|
70
|
+
version_requirements: !ruby/object:Gem::Version::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">"
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: 0.0.0
|
75
|
+
version:
|