cloud-queues 1.0.0 → 1.0.1

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.
@@ -4,6 +4,9 @@ module CloudQueues
4
4
  attr_accessor :client_id
5
5
  attr_accessor :token
6
6
  attr_accessor :tenant
7
+
8
+ attr :default_region
9
+ attr :api_host
7
10
 
8
11
  def initialize(options = {})
9
12
  [:username, :api_key].each do |arg|
@@ -50,25 +53,26 @@ module CloudQueues
50
53
  response = request(method: :post, path: "/v2.0/tokens", body: request)
51
54
  end
52
55
 
56
+ @default_region = response.body["access"]["user"]["RAX-AUTH:defaultRegion"]
57
+
53
58
  url_type = @internal ? "internalURL" : "publicURL"
54
59
  queues = response.body["access"]["serviceCatalog"].select{|service| service["name"] == "cloudQueues" }
55
60
  endpoints = queues[0]["endpoints"]
56
61
 
57
- url = if @region.nil?
58
- # pick the first region
59
- # TODO when cloud queues goes GA, change this to response.body["access"]["user"]["RAX-AUTH:defaultRegion"]
60
- endpoints[0][url_type].split('/')
61
- else
62
- endpoint = endpoints.select { |endpoint| endpoint["region"] == @region.to_s.upcase }
63
- raise ArgumentError.new "Region #{@region.to_s.upcase} does not exist!" if endpoint.count == 0
64
- endpoint[0][url_type].split('/')
65
- end
66
-
67
- host = url[0..2].join('/')
62
+ # default to the account's preferred region
63
+ unless @region
64
+ @region = @default_region
65
+ end
66
+
67
+ endpoint = endpoints.select { |endpoint| endpoint["region"] == @region.to_s.upcase }
68
+ raise ArgumentError.new "Region #{@region.to_s.upcase} does not exist!" if endpoint.count == 0
69
+ url = endpoint[0][url_type].split('/')
70
+
71
+ @api_host = url[0..2].join('/')
68
72
  @base_path = "/" + url[3..-1].join('/')
69
73
  @tenant = url[-1]
70
74
 
71
- @client = Excon.new(host)
75
+ @client = Excon.new(@api_host, tcp_nodelay: true)
72
76
  end
73
77
 
74
78
  def request(options = {}, second_try = false)
@@ -85,7 +89,6 @@ module CloudQueues
85
89
  options[:headers]["X-Auth-Token"] = @token if @token
86
90
  options[:headers]["X-Project-ID"] = @tenant
87
91
 
88
- options[:tcp_nodelay] = true if options[:tcp_nodelay].nil?
89
92
  options[:expects] ||= 200
90
93
 
91
94
  puts options if @debug
@@ -1,3 +1,3 @@
1
1
  module CloudQueues
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cloud-queues
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,14 +9,14 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-10-13 00:00:00.000000000 Z
12
+ date: 2013-11-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: excon
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
- - - ~>
19
+ - - ! '>'
20
20
  - !ruby/object:Gem::Version
21
21
  version: 0.25.0
22
22
  type: :runtime
@@ -24,7 +24,7 @@ dependencies:
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  none: false
26
26
  requirements:
27
- - - ~>
27
+ - - ! '>'
28
28
  - !ruby/object:Gem::Version
29
29
  version: 0.25.0
30
30
  - !ruby/object:Gem::Dependency