rally_api 0.9.5 → 0.9.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -124,6 +124,22 @@ module RallyAPI
124
124
  json_obj
125
125
  end
126
126
 
127
+ def check_for_errors(result)
128
+ errors = []
129
+ warnings = []
130
+ if !result["OperationResult"].nil?
131
+ errors = result["OperationResult"]["Errors"]
132
+ warnings = result["OperationResult"]["Warnings"]
133
+ elsif !result["QueryResult"].nil?
134
+ errors = result["QueryResult"]["Errors"]
135
+ warnings = result["QueryResult"]["Warnings"]
136
+ elsif !result["CreateResult"].nil?
137
+ errors = result["CreateResult"]["Errors"]
138
+ warnings = result["CreateResult"]["Warnings"]
139
+ end
140
+ {:errors => errors, :warnings => warnings}
141
+ end
142
+
127
143
  private
128
144
 
129
145
  def run_threads(query_array)
@@ -159,22 +175,6 @@ module RallyAPI
159
175
  @logger.debug(message) unless @logger.nil?
160
176
  end
161
177
 
162
- def check_for_errors(result)
163
- errors = []
164
- warnings = []
165
- if !result["OperationResult"].nil?
166
- errors = result["OperationResult"]["Errors"]
167
- warnings = result["OperationResult"]["Warnings"]
168
- elsif !result["QueryResult"].nil?
169
- errors = result["QueryResult"]["Errors"]
170
- warnings = result["QueryResult"]["Warnings"]
171
- elsif !result["CreateResult"].nil?
172
- errors = result["CreateResult"]["Errors"]
173
- warnings = result["CreateResult"]["Warnings"]
174
- end
175
- {:errors => errors, :warnings => warnings}
176
- end
177
-
178
178
  end
179
179
 
180
180
 
@@ -11,12 +11,13 @@ module RallyAPI
11
11
  #
12
12
  class RallyObject
13
13
 
14
- attr_reader :rally_object, :type
14
+ attr_reader :rally_object, :type, :warnings
15
15
 
16
- def initialize(rally_rest, json_hash)
16
+ def initialize(rally_rest, json_hash, warnings = {})
17
17
  @type = json_hash["_type"] || json_hash["_ref"].split("/")[-2]
18
18
  @rally_object = json_hash
19
19
  @rally_rest = rally_rest
20
+ @warnings = warnings[:warnings]
20
21
  end
21
22
 
22
23
  def update(fields, params = nil)
@@ -8,12 +8,13 @@ module RallyAPI
8
8
  class RallyQueryResult
9
9
  include Enumerable
10
10
 
11
- attr_reader :results, :total_result_count
11
+ attr_reader :results, :total_result_count, :warnings
12
12
 
13
- def initialize(rally_rest, json_results)
13
+ def initialize(rally_rest, json_results, warnings={})
14
14
  @results = json_results["QueryResult"]["Results"]
15
15
  @total_result_count = json_results["QueryResult"]["TotalResultCount"]
16
16
  @rally_rest = rally_rest
17
+ @warnings = warnings[:warnings]
17
18
  end
18
19
 
19
20
  def each
@@ -130,7 +130,7 @@ module RallyAPI
130
130
  args = { :method => :get }
131
131
  json_response = @rally_connection.send_request(make_get_url("user"), args)
132
132
  rally_type = json_response.keys[0]
133
- RallyObject.new(self, json_response[rally_type])
133
+ RallyObject.new(self, json_response[rally_type], warnings(json_response))
134
134
  end
135
135
 
136
136
 
@@ -151,7 +151,7 @@ module RallyAPI
151
151
  #json_response = @rally_connection.create_object(make_create_url(rally_type), args, object2create)
152
152
  json_response = @rally_connection.send_request(make_create_url(type), args, params)
153
153
  #todo - check for warnings
154
- RallyObject.new(self, json_response["CreateResult"]["Object"]).read()
154
+ RallyObject.new(self, json_response["CreateResult"]["Object"], warnings(json_response)).read()
155
155
  end
156
156
 
157
157
 
@@ -162,7 +162,7 @@ module RallyAPI
162
162
  args = { :method => :get }
163
163
  json_response = @rally_connection.send_request(ref, args, params)
164
164
  rally_type = json_response.keys[0]
165
- RallyObject.new(self, json_response[rally_type])
165
+ RallyObject.new(self, json_response[rally_type], warnings(json_response))
166
166
  end
167
167
 
168
168
  def delete(ref_to_delete)
@@ -191,7 +191,7 @@ module RallyAPI
191
191
  args = {:method => :post, :payload => json_update}
192
192
  json_response = @rally_connection.send_request(ref, args, params)
193
193
  #todo check for warnings on json_response["OperationResult"]
194
- RallyObject.new(self, reread({"_ref" => ref}))
194
+ RallyObject.new(self, reread({"_ref" => ref}), warnings(json_response))
195
195
  end
196
196
  alias :update_ref :update
197
197
 
@@ -235,7 +235,7 @@ module RallyAPI
235
235
  query_params = query_obj.make_query_params
236
236
  args = {:user => @rally_user, :password => @rally_password}
237
237
  json_response = @rally_connection.get_all_json_results(query_url, args, query_params, query_obj.limit)
238
- RallyQueryResult.new(self, json_response)
238
+ RallyQueryResult.new(self, json_response, warnings(json_response))
239
239
  end
240
240
 
241
241
  def adjust_find_threads(num_threads)
@@ -252,8 +252,8 @@ module RallyAPI
252
252
  json_update = { get_type_from_ref(ref_to_rank) => {"_ref" => ref_to_rank} }
253
253
  args = { :method => :put, :payload => json_update }
254
254
  #update = @rally_connection.put_object(ref, args, params, json_update)
255
- update = @rally_connection.send_request(ref, args, params)
256
- RallyObject.new(self, update["OperationResult"]["Object"])
255
+ json_response = @rally_connection.send_request(ref, args, params)
256
+ RallyObject.new(self, json_response["OperationResult"]["Object"], warnings(json_response))
257
257
  end
258
258
 
259
259
  #ref to object.js? rankBelow=%2Fhierarchicalrequirement%2F4624552599
@@ -264,8 +264,8 @@ module RallyAPI
264
264
  params[:fetch] = "true"
265
265
  json_update = { get_type_from_ref(ref_to_rank) => {"_ref" => ref_to_rank} }
266
266
  args = { :method => :put, :payload => json_update }
267
- update = @rally_connection.send_request(ref, args, params)
268
- RallyObject.new(self, update["OperationResult"]["Object"])
267
+ json_response = @rally_connection.send_request(ref, args, params)
268
+ RallyObject.new(self, json_response["OperationResult"]["Object"], warnings(json_response))
269
269
  end
270
270
 
271
271
  def rank_to(ref_to_rank, location = "TOP")
@@ -275,8 +275,8 @@ module RallyAPI
275
275
  params[:fetch] = "true"
276
276
  json_update = { get_type_from_ref(ref_to_rank) => {"_ref" => ref_to_rank} }
277
277
  args = { :method => :put, :payload => json_update }
278
- update = @rally_connection.send_request(ref, args, params)
279
- RallyObject.new(self, update["OperationResult"]["Object"])
278
+ json_response = @rally_connection.send_request(ref, args, params)
279
+ RallyObject.new(self, json_response["OperationResult"]["Object"], warnings(json_response))
280
280
  end
281
281
 
282
282
  def get_typedef_for(type)
@@ -339,6 +339,10 @@ module RallyAPI
339
339
  "/#{ref_pieces[-2]}/#{ref_pieces[-1].split(".js")[0]}"
340
340
  end
341
341
 
342
+ def warnings(json_obj)
343
+ @rally_connection.check_for_errors(json_obj)
344
+ end
345
+
342
346
  #check for an alias of a type - eg userstory => hierarchicalrequirement
343
347
  #you can add to @rally_alias_types as desired
344
348
  def check_type(type_name)
@@ -4,5 +4,5 @@
4
4
  #of the applicable Subscription Agreement between your company and
5
5
  #Rally Software Development Corp.
6
6
  module RallyAPI
7
- VERSION = "0.9.5"
7
+ VERSION = "0.9.6"
8
8
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rally_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.5
4
+ version: 0.9.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-25 00:00:00.000000000Z
12
+ date: 2013-03-27 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: httpclient
16
- requirement: &70214079476860 !ruby/object:Gem::Requirement
16
+ requirement: &70241199964080 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: 2.2.4
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70214079476860
24
+ version_requirements: *70241199964080
25
25
  description: API wrapper for Rally's JSON REST web services api
26
26
  email:
27
27
  - dsmith@rallydev.com