swivel 0.0.20 → 0.0.21
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/swivel.rb +14 -6
- metadata +3 -2
data/lib/swivel.rb
CHANGED
@@ -459,10 +459,6 @@ module Swivel
|
|
459
459
|
end
|
460
460
|
@headers = options[:headers] || Hash.new
|
461
461
|
@headers.merge! 'Accept' => 'application/xml'
|
462
|
-
if @config.has_key?(:api_key) && !@config[:api_key].blank?
|
463
|
-
encoded = Base64.encode64(':' + @config[:api_key])
|
464
|
-
@headers.merge! 'Authorization' => "Basic #{encoded}"
|
465
|
-
end
|
466
462
|
end
|
467
463
|
|
468
464
|
# Call Swivel's REST endpoint. This method actually performs the HTTP stuff
|
@@ -501,7 +497,8 @@ module Swivel
|
|
501
497
|
def call path, params = Hash.new, method = :get
|
502
498
|
response =
|
503
499
|
Net::HTTP.start @config[:host], @config[:port] do |http|
|
504
|
-
|
500
|
+
request_class = "Net::HTTP::#{method.to_s.camelize}".constantize
|
501
|
+
request = request_class.new path, headers
|
505
502
|
if [:delete, :post, :put].include? method
|
506
503
|
http.read_timeout = @config[:timeout_up]
|
507
504
|
http.request request, params.to_query_string
|
@@ -515,8 +512,9 @@ module Swivel
|
|
515
512
|
doc = REXML::Document.new xml
|
516
513
|
Response.class_for(doc.root.elements[1].name).new xml, self
|
517
514
|
rescue Exception => e
|
518
|
-
raise e
|
519
515
|
#xml.blank? ? nil : xml
|
516
|
+
warn "Failure while communicating with swivel: #{xml}\n"
|
517
|
+
raise e
|
520
518
|
end
|
521
519
|
|
522
520
|
%w/ data_columns data_sets graphs users /.each do |obj|
|
@@ -702,5 +700,15 @@ module Swivel
|
|
702
700
|
end
|
703
701
|
call '/rest/graphs', options, :post
|
704
702
|
end
|
703
|
+
|
704
|
+
protected
|
705
|
+
def headers
|
706
|
+
if @config.has_key?(:api_key) && !@config[:api_key].blank?
|
707
|
+
encoded = Base64.encode64(':' + @config[:api_key])
|
708
|
+
@headers.merge 'Authorization' => "Basic #{encoded}"
|
709
|
+
else
|
710
|
+
@headers
|
711
|
+
end
|
712
|
+
end
|
705
713
|
end
|
706
714
|
end
|
metadata
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.9.
|
2
|
+
rubygems_version: 0.9.4
|
3
3
|
specification_version: 1
|
4
4
|
name: swivel
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.0.
|
6
|
+
version: 0.0.21
|
7
7
|
date: 2007-08-08 00:00:00 -07:00
|
8
8
|
summary: Ruby interface to the Swivel API.
|
9
9
|
require_paths:
|
@@ -33,6 +33,7 @@ files:
|
|
33
33
|
- README
|
34
34
|
- Rakefile
|
35
35
|
- lib/swivel.rb
|
36
|
+
- lib/test
|
36
37
|
- bin/swivel
|
37
38
|
- CHANGELOG
|
38
39
|
test_files: []
|