rally_api 0.8.0 → 0.8.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -275,21 +275,33 @@ module RallyAPI
275
275
  RallyObject.new(self, update["OperationResult"]["Object"])
276
276
  end
277
277
 
278
- #todo - check support for portfolio item fields
279
- def allowed_values(type, field)
280
- if type.class == Symbol
281
- query_type = @rally_objects[type.to_s]
282
- else
283
- query_type = type
278
+ def get_typedef_for(type)
279
+ type = type.to_s if type.class == Symbol
280
+ type = @rally_objects[type.downcase]
281
+ type_def_query = RallyQuery.new()
282
+ type_def_query.type = "typedefinition"
283
+ type_def_query.fetch = true
284
+ type_def_query.query_string= "(TypePath = \"#{type}\")"
285
+ type_def = find(type_def_query)
286
+ type_def.first
287
+ end
288
+
289
+ def get_fields_for(type)
290
+ type_def = get_typedef_for(type)
291
+ return nil if type_def.nil?
292
+ fields = {}
293
+ type_def["Attributes"].each do |attr|
294
+ field_name = attr["ElementName"]
295
+ fields[field_name] = attr
284
296
  end
285
- type_defs_query = RallyQuery.new()
286
- type_defs_query.type = "typedefinition"
287
- type_defs_query.fetch = true
288
- type_defs_query.query_string= "(ElementName = \"#{query_type}\")"
289
- type_defs = find(type_defs_query)
297
+ fields
298
+ end
290
299
 
300
+ #todo - check support for portfolio item fields
301
+ def allowed_values(type, field)
302
+ type_def = get_typedef_for(type)
291
303
  allowed_vals = {}
292
- type_defs[0]["Attributes"].each do |attr|
304
+ type_def["Attributes"].each do |attr|
293
305
  next if attr["ElementName"] != field
294
306
  attr["AllowedValues"].each do |val_ref|
295
307
  val = val_ref["StringValue"]
@@ -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.8.0"
7
+ VERSION = "0.8.1"
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.8.0
4
+ version: 0.8.1
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: 2012-12-13 00:00:00.000000000Z
12
+ date: 2012-12-21 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: httpclient
16
- requirement: &70263207772720 !ruby/object:Gem::Requirement
16
+ requirement: &70135989896340 !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: *70263207772720
24
+ version_requirements: *70135989896340
25
25
  description: API wrapper for Rally's JSON REST web services api
26
26
  email:
27
27
  - dsmith@rallydev.com