rally_api 1.0.1 → 1.1.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: f088541d07551f9eeaaa0f67d0d041c051e9cb9d
4
- data.tar.gz: 08086c868c3bd8a2c64a5676bdea99ec8aa9be8b
3
+ metadata.gz: ea0a19168c476d4b65823670994a6d071f565dea
4
+ data.tar.gz: 16f577b50c4f35b6eb1a6a76489c39bca5762e5c
5
5
  SHA512:
6
- metadata.gz: 82c225cf0621301ab0e218e639bc6f6cafb16f680b391adc089900991f5f2a51b076a944967c2de48fbcec43d90ca6b73d76ecd2bcc719d22f1b843c231462a0
7
- data.tar.gz: d3da317367171bb40b9c42262dc91d118f4a483b9c8f594a2a87ea598a965a445ab605ec1b07e97116331a416a0a941f04a64156e8b094ca3d9b50a2ea0dca2f
6
+ metadata.gz: e913f261c487f443dfacf0afb7996c914a64a76ce82d44645fffa36a52214e7d1cc828bf14b01284bae26dcba7f956e38cd4f9a363f6d67f907dd58b6334a079
7
+ data.tar.gz: cd9c6b9c511c777f9a239c08211115dd4a16178f2ceae0a8110c28639b6a0c00eceb2ab230ca9063ae5a563947e801c7860819e44a8f3af5f0a72a7e9363898f
data/README.md CHANGED
@@ -56,6 +56,10 @@ Making a connection to Rally
56
56
  config[:headers] = headers #from RallyAPI::CustomHttpHeader.new()
57
57
 
58
58
 
59
+ #### User Authentication
60
+ A Rally API Key can be used for user authentication. If an API Key is provided, the username and password are ignored. (This is true even if the API Key is invalid, blank, or nil.)
61
+
62
+
59
63
  ### Querying Rally
60
64
 
61
65
  #type names are stored in rally.rally_objects hash, you can inspect there for a list
@@ -141,3 +145,9 @@ Making a connection to Rally
141
145
  story1.rank_below(story2)
142
146
  story1.rank_to_bottom
143
147
  story1.rank_to_top
148
+
149
+ ### Revision History
150
+ Version 1.1.0 (September 2014) - Appends workspace to Rally API requests to enable correct retrieval
151
+ of allowed values from a user's non-default workspace. Updates gem development dependencies and
152
+ test files structure.
153
+
data/Rakefile CHANGED
@@ -7,11 +7,11 @@ end
7
7
 
8
8
  desc "run all api tests"
9
9
  RSpec::Core::RakeTask.new('api_tests') do |t|
10
- t.pattern = ['test/*_spec.rb']
10
+ t.pattern = ['spec/*_spec.rb']
11
11
  end
12
12
 
13
13
  desc "run api create tests"
14
14
  RSpec::Core::RakeTask.new('api_create_tests') do |t|
15
- t.pattern = ['test/*create_spec.rb']
15
+ t.pattern = ['spec/*create_spec.rb']
16
16
  end
17
17
 
@@ -95,6 +95,32 @@ module RallyAPI
95
95
  self
96
96
  end
97
97
 
98
+ def send_request(url = nil, args = nil, params = {})
99
+ if params[:workspace].nil? && rally_workspace_object
100
+ params[:workspace] = rally_workspace_object['_ref']
101
+ end
102
+ if params[:workspace]
103
+ wksp_id = params[:workspace].match(/workspace\/(\d*)/)[1]
104
+ url += "?/workspace=/workspace/#{wksp_id}"
105
+ end
106
+ @rally_connection.send_request(url, args, params)
107
+ end
108
+
109
+
110
+ def rally_workspace_object(new_wksp = nil)
111
+ return @rally_default_workspace if new_wksp.nil?
112
+ if new_wksp.instance_of?(String)
113
+ if new_wksp.match(/rallydev.com/)
114
+ @rally_default_workspace = find_workspace(new_wksp, '_ref')
115
+ else
116
+ @rally_default_workspace = find_workspace(new_wksp, 'Name')
117
+ end
118
+ else
119
+ @rally_default_workspace = new_wksp
120
+ end
121
+ return @rally_default_workspace
122
+ end
123
+
98
124
  def debug_logging_on
99
125
  @low_debug = true
100
126
  @rally_connection.low_debug = true
@@ -105,12 +131,13 @@ module RallyAPI
105
131
  @rally_connection.low_debug = false
106
132
  end
107
133
 
108
- def find_workspace(workspace_name)
134
+ def find_workspace(workspace_name, matcher_ref = 'Name')
135
+ # use matcher_ref to search for 'Name' or '_ref'
109
136
  sub = self.user["Subscription"].read({:fetch => "Workspaces,Name,State"})
110
137
  workspace = nil
111
138
  sub.Workspaces.each do |ws|
112
139
  #ws.read
113
- if (ws["Name"] == workspace_name) && (ws["State"] == "Open")
140
+ if (ws[matcher_ref] == workspace_name) && (ws["State"] == "Open")
114
141
  workspace = ws
115
142
  break #doing a break for performance some customers have 100+ workspaces - no need to do the others
116
143
  end
@@ -137,7 +164,7 @@ module RallyAPI
137
164
 
138
165
  def user(params = {})
139
166
  args = { :method => :get }
140
- json_response = @rally_connection.send_request(make_get_url("user"), args, params)
167
+ json_response = send_request(make_get_url("user"), args, params)
141
168
  rally_type = json_response.keys[0]
142
169
  RallyObject.new(self, json_response[rally_type], warnings(json_response))
143
170
  end
@@ -145,7 +172,7 @@ module RallyAPI
145
172
  def create(type, fields, params = {})
146
173
  type = check_type(type)
147
174
  if (fields["Workspace"].nil? && fields["Project"].nil?)
148
- fields["Workspace"] = @rally_default_workspace._ref unless @rally_default_workspace.nil?
175
+ fields["Workspace"] = rally_workspace_object._ref unless rally_workspace_object.nil?
149
176
  fields["Project"] = @rally_default_project._ref unless @rally_default_project.nil?
150
177
  end
151
178
 
@@ -157,7 +184,7 @@ module RallyAPI
157
184
  object2create = { type => check_fields(fields) }
158
185
  args = { :method => :post, :payload => object2create }
159
186
  #json_response = @rally_connection.create_object(make_create_url(rally_type), args, object2create)
160
- json_response = @rally_connection.send_request(make_create_url(type), args, params)
187
+ json_response = send_request(make_create_url(type), args, params)
161
188
  #todo - check for warnings
162
189
  RallyObject.new(self, json_response["CreateResult"]["Object"], warnings(json_response)).read()
163
190
  end
@@ -166,9 +193,9 @@ module RallyAPI
166
193
  def read(type, obj_id, params = {})
167
194
  type = check_type(type)
168
195
  ref = check_id(type.to_s, obj_id)
169
- params[:workspace] = @rally_default_workspace.ref if params[:workspace].nil?
196
+ params[:workspace] = rally_workspace_object.ref if params[:workspace].nil?
170
197
  args = { :method => :get }
171
- json_response = @rally_connection.send_request(ref, args, params)
198
+ json_response = send_request(ref, args, params)
172
199
  rally_type = json_response.keys[0]
173
200
  RallyObject.new(self, json_response[rally_type], warnings(json_response))
174
201
  end
@@ -176,7 +203,7 @@ module RallyAPI
176
203
  def delete(ref_to_delete)
177
204
  args = { :method => :delete }
178
205
  #json_response = @rally_connection.delete_object(ref_to_delete, args)
179
- json_response = @rally_connection.send_request(ref_to_delete, args)
206
+ json_response = send_request(ref_to_delete, args)
180
207
  json_response["OperationResult"]
181
208
  end
182
209
 
@@ -186,7 +213,7 @@ module RallyAPI
186
213
  params[:workspace] = json_object['Workspace']['_ref']
187
214
  end
188
215
  #json_response = @rally_connection.read_object(json_object["_ref"], args, params)
189
- json_response = @rally_connection.send_request(json_object["_ref"], args, params)
216
+ json_response = send_request(json_object["_ref"], args, params)
190
217
  rally_type = json_response.keys[0]
191
218
  json_response[rally_type]
192
219
  end
@@ -209,7 +236,7 @@ module RallyAPI
209
236
  fields = RallyAPI::RallyRestJson.fix_case(fields) if @rally_rest_api_compat
210
237
  json_update = {type.to_s => check_fields(fields)}
211
238
  args = {:method => :post, :payload => json_update}
212
- json_response = @rally_connection.send_request(ref, args, params)
239
+ json_response = send_request(ref, args, params)
213
240
  #todo check for warnings on json_response["OperationResult"]
214
241
  RallyObject.new(self, reread({"_ref" => ref}), warnings(json_response))
215
242
  end
@@ -243,7 +270,7 @@ module RallyAPI
243
270
  yield query_obj if block_given?
244
271
 
245
272
  if query_obj.workspace.nil?
246
- query_obj.workspace = @rally_default_workspace unless @rally_default_workspace.nil?
273
+ query_obj.workspace = rally_workspace_object unless rally_workspace_object.nil?
247
274
  end
248
275
 
249
276
  errs = query_obj.validate()
@@ -272,7 +299,7 @@ module RallyAPI
272
299
  json_update = { get_type_from_ref(ref_to_rank) => {"_ref" => ref_to_rank} }
273
300
  args = { :method => :put, :payload => json_update }
274
301
  #update = @rally_connection.put_object(ref, args, params, json_update)
275
- json_response = @rally_connection.send_request(ref, args, params)
302
+ json_response = send_request(ref, args, params)
276
303
  RallyObject.new(self, json_response["OperationResult"]["Object"], warnings(json_response))
277
304
  end
278
305
 
@@ -284,7 +311,7 @@ module RallyAPI
284
311
  params[:fetch] = "true"
285
312
  json_update = { get_type_from_ref(ref_to_rank) => {"_ref" => ref_to_rank} }
286
313
  args = { :method => :put, :payload => json_update }
287
- json_response = @rally_connection.send_request(ref, args, params)
314
+ json_response = send_request(ref, args, params)
288
315
  RallyObject.new(self, json_response["OperationResult"]["Object"], warnings(json_response))
289
316
  end
290
317
 
@@ -295,11 +322,11 @@ module RallyAPI
295
322
  params[:fetch] = "true"
296
323
  json_update = { get_type_from_ref(ref_to_rank) => {"_ref" => ref_to_rank} }
297
324
  args = { :method => :put, :payload => json_update }
298
- json_response = @rally_connection.send_request(ref, args, params)
325
+ json_response = send_request(ref, args, params)
299
326
  RallyObject.new(self, json_response["OperationResult"]["Object"], warnings(json_response))
300
327
  end
301
328
 
302
- def get_typedef_for(type, workspace = @rally_default_workspace)
329
+ def get_typedef_for(type, workspace = rally_workspace_object)
303
330
  type = type.to_s if type.class == Symbol
304
331
  type = check_type(type)
305
332
  type_def_query = RallyQuery.new()
@@ -311,7 +338,7 @@ module RallyAPI
311
338
  type_def.first
312
339
  end
313
340
 
314
- def get_fields_for(type, workspace = @rally_default_workspace)
341
+ def get_fields_for(type, workspace = rally_workspace_object)
315
342
  type_def = get_typedef_for(type, workspace)
316
343
  return nil if type_def.nil?
317
344
  fields = {}
@@ -323,7 +350,9 @@ module RallyAPI
323
350
  end
324
351
 
325
352
  #todo - check support for portfolio item fields
326
- def allowed_values(type, field, workspace = @rally_default_workspace)
353
+ def allowed_values(type, field, workspace = nil)
354
+ rally_workspace_object(workspace)
355
+
327
356
  type_def = get_typedef_for(type, workspace)
328
357
  allowed_vals = {}
329
358
  type_def["Attributes"].each do |attr|
@@ -337,7 +366,7 @@ module RallyAPI
337
366
  allowed_vals
338
367
  end
339
368
 
340
- def custom_fields_for(type, workspace = @rally_default_workspace)
369
+ def custom_fields_for(type, workspace = rally_workspace_object)
341
370
  @custom_fields_for_type[workspace.ObjectID] = {} if @custom_fields_for_type[workspace.ObjectID].nil?
342
371
  if @custom_fields_for_type[workspace.ObjectID][type].nil?
343
372
  @custom_fields_for_type[workspace.ObjectID][type] = {}
@@ -424,7 +453,7 @@ module RallyAPI
424
453
  query.query_string = "(FormattedID = #{fid})"
425
454
  query.limit = 20
426
455
  query.fetch = "FormattedID"
427
- query.workspace = @rally_default_workspace
456
+ query.workspace = rally_workspace_object
428
457
 
429
458
  results = find(query)
430
459
  return results.first["_ref"] if results.length > 0
@@ -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 = "1.0.1"
7
+ VERSION = "1.1.0"
8
8
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rally_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dave Smith
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-02 00:00:00.000000000 Z
11
+ date: 2014-10-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httpclient
@@ -16,84 +16,70 @@ dependencies:
16
16
  requirements:
17
17
  - - ~>
18
18
  - !ruby/object:Gem::Version
19
- version: 2.3.0
19
+ version: 2.4.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ~>
25
25
  - !ruby/object:Gem::Version
26
- version: 2.3.0
26
+ version: 2.4.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: simplecov
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - '='
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: 0.9.1
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - '='
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
40
+ version: 0.9.1
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - '='
46
46
  - !ruby/object:Gem::Version
47
- version: '0'
47
+ version: 3.1.0
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - '='
53
53
  - !ruby/object:Gem::Version
54
- version: '0'
54
+ version: 3.1.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rake
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '>='
59
+ - - '='
60
60
  - !ruby/object:Gem::Version
61
- version: '0'
61
+ version: 10.3.2
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '>='
66
+ - - '='
67
67
  - !ruby/object:Gem::Version
68
- version: '0'
68
+ version: 10.3.2
69
69
  - !ruby/object:Gem::Dependency
70
- name: cucumber
70
+ name: pry
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - '>='
73
+ - - '='
74
74
  - !ruby/object:Gem::Version
75
- version: '0'
75
+ version: 0.10.1
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - '>='
80
+ - - '='
81
81
  - !ruby/object:Gem::Version
82
- version: '0'
83
- - !ruby/object:Gem::Dependency
84
- name: aruba
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - '>='
88
- - !ruby/object:Gem::Version
89
- version: '0'
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - '>='
95
- - !ruby/object:Gem::Version
96
- version: '0'
82
+ version: 0.10.1
97
83
  description: API wrapper for Rally's JSON REST web services api
98
84
  email:
99
85
  - dsmith@rallydev.com
@@ -103,6 +89,7 @@ extra_rdoc_files: []
103
89
  files:
104
90
  - README.md
105
91
  - Rakefile
92
+ - lib/rally_api.rb
106
93
  - lib/rally_api/custom_http_header.rb
107
94
  - lib/rally_api/lookback_api_query.rb
108
95
  - lib/rally_api/rally_collection.rb
@@ -112,7 +99,6 @@ files:
112
99
  - lib/rally_api/rally_query_result.rb
113
100
  - lib/rally_api/rally_rest_json.rb
114
101
  - lib/rally_api/version.rb
115
- - lib/rally_api.rb
116
102
  homepage: https://github.com/RallyTools/RallyRestToolkitForRuby
117
103
  licenses:
118
104
  - MIT
@@ -133,7 +119,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
133
119
  version: '0'
134
120
  requirements: []
135
121
  rubyforge_project: rally_api
136
- rubygems_version: 2.0.3
122
+ rubygems_version: 2.2.2
137
123
  signing_key:
138
124
  specification_version: 4
139
125
  summary: A wrapper for the Rally Web Services API using json