rally-wsapi 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e8fcd6dfc98a371448591ac323e980f16b38220b
4
- data.tar.gz: 16fde94fe2cd3776b90ca3150f92cbc147634e65
3
+ metadata.gz: e5ce53a2efe584ea08f87c687cb53e1262c11b64
4
+ data.tar.gz: 1ee68746295ff7558b5a411681e6928b11cd892e
5
5
  SHA512:
6
- metadata.gz: df67aba1e91f9e1e650ca5d5304d6d9c16da733471df6e0f4bebc26d4637502a84da570f1cb754c7c67befdeb52ff277a690cf9c2034b336df8c5439fcc27d0a
7
- data.tar.gz: 51a297733c01698f72bb1aacd44f7385f7577683b304f0b7fca522e19870e364e039dbe3397ebacb237aee610fbc50e356e7a0a51526ad574670a51a42f09ffd
6
+ metadata.gz: d76be63543d5156c41896db4b30b6058428da8bf509e38e2fac8dbbad2a8a6261bbeaef71f9d14899d74322c0e9a6380c6df9bea5441807ac5f5df7c8cd4afa1
7
+ data.tar.gz: eaf84111aa0d65afc4e5069a6ebb48d9a40b969d436ea4b421af3bd86ec5565866ca7c5a48fda5229e5af7bfbc2631652873c90be08ce2aa457faba99f86cef9
data/Gemfile.lock CHANGED
@@ -35,7 +35,7 @@ GEM
35
35
  rdoc
36
36
  json (1.8.1)
37
37
  jwt (1.2.0)
38
- mini_portile (0.6.1)
38
+ mini_portile (0.6.2)
39
39
  multi_json (1.10.1)
40
40
  multi_xml (0.5.5)
41
41
  multipart-post (2.0.0)
@@ -47,7 +47,7 @@ GEM
47
47
  multi_json (~> 1.3)
48
48
  multi_xml (~> 0.5)
49
49
  rack (~> 1.2)
50
- rack (1.5.2)
50
+ rack (1.6.0)
51
51
  rake (10.4.2)
52
52
  rdoc (4.2.0)
53
53
  json (~> 1.4)
data/README.md CHANGED
@@ -14,6 +14,7 @@ s = Wsapi::Session.new("deadbeefdeadbeef")
14
14
  The constructor also accepts the following options:
15
15
  * `:workspace_id`, if not given, user's default workspace is used for queries
16
16
  * `:version`, WSAPI version, default is `3.0`
17
+ * `:timeout`, request time out in seconds
17
18
  * `oauth2`, see: (using WSAPI with OAuth2)[https://github.com/flowdock/rally-wsapi#using-wsapi-with-oauth2]
18
19
 
19
20
  ### Using WSAPI with OAuth2
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.2.0
data/lib/wsapi/session.rb CHANGED
@@ -16,6 +16,7 @@ module Wsapi
16
16
  class ApiError < StandardErrorWithResponse; end
17
17
  class ObjectNotFoundError < StandardErrorWithResponse; end
18
18
  class IpAddressLimited < StandardErrorWithResponse; end
19
+ class TimeoutError < StandardError; end
19
20
 
20
21
  WSAPI_URL = ENV['WSAPI_URL'] || 'https://rally1.rallydev.com/slm/webservice/'
21
22
  AUTH_URL = ENV['RALLY_AUTHENTICATION_URL'] || "https://rally1.rallydev.com/login/oauth2/token"
@@ -38,6 +39,7 @@ module Wsapi
38
39
  def initialize(session_id, opts = {})
39
40
  @api_version = opts[:version] || "3.0"
40
41
  @workspace_id = opts[:workspace_id]
42
+ @timeout = opts[:timeout]
41
43
  @conn = connection(session_id)
42
44
  end
43
45
 
@@ -148,16 +150,18 @@ module Wsapi
148
150
  end
149
151
 
150
152
  def wsapi_request_with_refresh_token(method, url, opts = {})
151
- response = @conn.send(method, url, opts)
153
+ response = @conn.send(method, url, opts) { |req| req.options.timeout = @timeout }
152
154
  if defined?(@oauth2) && response.status == 401
153
155
  refresh_token_response = refresh_token!
154
156
 
155
157
  access_token = MultiJson.load(refresh_token_response.body)["access_token"]
156
158
  @conn = connection(access_token)
157
- response = @conn.send(method, url, opts) # Try again with fresh token
159
+ response = @conn.send(method, url, opts) { |req| req.options.timeout = @timeout } # Try again with fresh token
158
160
  end
159
161
 
160
162
  response
163
+ rescue Faraday::TimeoutError
164
+ raise TimeoutError.new("Request timed out")
161
165
  end
162
166
 
163
167
  def refresh_token!
@@ -173,7 +177,7 @@ module Wsapi
173
177
  client_secret: @oauth2[:client_secret]
174
178
  }
175
179
 
176
- response = client.post AUTH_URL, refresh_params
180
+ response = client.post(AUTH_URL, refresh_params) { |req| req.options.timeout = @timeout }
177
181
 
178
182
  check_response_for_errors!(response)
179
183
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rally-wsapi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Antti Pitkänen
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-01-13 00:00:00.000000000 Z
12
+ date: 2015-01-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -122,7 +122,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
122
122
  version: '0'
123
123
  requirements: []
124
124
  rubyforge_project:
125
- rubygems_version: 2.4.3
125
+ rubygems_version: 2.4.5
126
126
  signing_key:
127
127
  specification_version: 4
128
128
  summary: Simple client for Rally WSAPI