rally_api 0.5.0 → 0.5.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.
@@ -15,11 +15,13 @@ module RallyAPI
15
15
 
16
16
  DEFAULT_PAGE_SIZE = 200
17
17
 
18
- attr_accessor :rally_headers, :retries, :retry_list
18
+ attr_accessor :rally_headers, :retries, :retry_list, :low_debug, :logger
19
19
 
20
20
  def initialize(headers, low_debug, proxy_info)
21
21
  @rally_headers = headers
22
22
  @low_debug = low_debug
23
+ @logger = nil
24
+
23
25
  @retries = 0
24
26
  @retry_list = {}
25
27
 
@@ -36,7 +38,7 @@ module RallyAPI
36
38
  def read_object(url, args, params = nil)
37
39
  args[:method] = :get
38
40
  result = send_json_request(url, args, params)
39
- puts result if @low_debug
41
+ log_info(result) if @low_debug
40
42
  rally_type = result.keys[0]
41
43
  result[rally_type]
42
44
  end
@@ -45,9 +47,9 @@ module RallyAPI
45
47
  args[:method] = :post
46
48
  text_json = rally_object.to_json
47
49
  args[:payload] = text_json
48
- puts "payload json: #{text_json}" if @low_debug
50
+ log_info("create - payload json: #{text_json}") if @low_debug
49
51
  result = send_json_request(url, args)
50
- puts result if @low_debug
52
+ log_info("create - result: #{result}") if @low_debug
51
53
  result["CreateResult"]["Object"]
52
54
  end
53
55
 
@@ -55,9 +57,9 @@ module RallyAPI
55
57
  args[:method] = :post
56
58
  text_json = rally_fields.to_json
57
59
  args[:payload] = text_json
58
- puts "payload json: #{text_json}" if @low_debug
60
+ log_info("update payload json: #{text_json}") if @low_debug
59
61
  result = send_json_request(url, args)
60
- puts result if @low_debug
62
+ log_info("update - result: #{result}") if @low_debug
61
63
  result["OperationResult"]
62
64
  end
63
65
 
@@ -72,7 +74,7 @@ module RallyAPI
72
74
  def delete_object(url,args)
73
75
  args[:method] = :delete
74
76
  result = send_json_request(url,args)
75
- puts result if @low_debug
77
+ log_info("delete result - #{result}") if @low_debug
76
78
  result["OperationResult"]
77
79
  end
78
80
 
@@ -160,11 +162,11 @@ module RallyAPI
160
162
 
161
163
  begin
162
164
  req = RestClient::Request.new(request_args)
163
- puts req.url if @low_debug
165
+ log_info(req.url) if @low_debug
164
166
  response = req.execute
165
167
  rescue => ex
166
168
  msg = "Rally Rest Json: - rescued exception - #{ex.message} on request to #{url} with params #{url_params}"
167
- puts msg
169
+ log_info(msg)
168
170
  if !@retry_list.has_key?(req.url)
169
171
  @retry_list[req.url] = 0
170
172
  end
@@ -175,13 +177,17 @@ module RallyAPI
175
177
  raise StandardError, msg
176
178
  end
177
179
  @retry_list.delete(req.url)
178
- puts response if @low_debug
180
+ log_info(response) if @low_debug
179
181
  json_obj = JSON.parse(response.body) #todo handle null post error
180
182
  errs = check_for_errors(json_obj)
181
183
  raise StandardError, "\nError on request - #{url} - \n#{errs}" if errs[:errors].length > 0
182
184
  json_obj
183
185
  end
184
186
 
187
+ def log_info(message)
188
+ puts message
189
+ @logger.debug(message) unless @logger.nil?
190
+ end
185
191
 
186
192
  def check_for_errors(result)
187
193
  errors = []
@@ -18,19 +18,12 @@ require_relative "rally_query_result"
18
18
  #
19
19
  # ===Getting Started
20
20
  # RallyAPI::RallyRestJson is the starting point for working in Ruby with Rally's REST WSAPI
21
- #
22
21
  # config = {:base_url => "https://rally1.rallydev.com/slm"}
23
- #
24
22
  # config[:username] = "user@company.com"
25
- #
26
23
  # config[:password] = "password"
27
- #
28
24
  # config[:workspace] = "Workspace Name"
29
- #
30
25
  # config[:project] = "Project Name"
31
- #
32
26
  # config[:headers] = headers #from RallyAPI::CustomHttpHeader.new()
33
- #
34
27
  # @rally = RallyAPI::RallyRestJson.new(config)
35
28
 
36
29
 
@@ -55,7 +48,7 @@ module RallyAPI
55
48
 
56
49
  attr_accessor :rally_url, :rally_user, :rally_password, :rally_workspace_name, :rally_project_name, :wsapi_version
57
50
  attr_accessor :rally_headers, :rally_default_workspace, :rally_default_project, :low_debug, :proxy_info, :retries
58
- attr_accessor :rally_rest_api_compat
51
+ attr_accessor :rally_rest_api_compat, :logger
59
52
 
60
53
  attr_reader :rally_objects
61
54
 
@@ -71,12 +64,12 @@ module RallyAPI
71
64
  @retries = args[:retries] || 0
72
65
  @rally_rest_api_compat = args[:rally_rest_api_compat] || false
73
66
 
74
- @low_debug = args[:debug] || false
67
+ @low_debug = args[:debug] || false
68
+ @logger = args[:logger] || nil #assumes this is an instance of Logger
75
69
 
76
70
  @rally_connection = RallyJsonConnection.new(@rally_headers, @low_debug, @proxy_info)
77
- if @retries > 0
78
- @rally_connection.retries = @retries
79
- end
71
+ @rally_connection.logger = @logger unless @logger.nil?
72
+ @rally_connection.retries = @retries if @retries > 0
80
73
 
81
74
  @rally_objects = { :typedefinition => "TypeDefinition" }
82
75
  cache_rally_objects()
@@ -94,6 +87,16 @@ module RallyAPI
94
87
  self
95
88
  end
96
89
 
90
+ def debug_logging_on
91
+ @low_debug = true
92
+ @rally_connection.low_debug = true
93
+ end
94
+
95
+ def debug_logging_off
96
+ @low_debug = false
97
+ @rally_connection.low_debug = false
98
+ end
99
+
97
100
  def find_workspace(workspace_name)
98
101
  sub = self.user["Subscription"].read({:fetch => "Workspaces,Name,State"})
99
102
  workspace = nil
@@ -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.5.0"
7
+ VERSION = "0.5.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.5.0
4
+ version: 0.5.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-06-28 00:00:00.000000000Z
12
+ date: 2012-08-13 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rest-client
16
- requirement: &70134702100760 !ruby/object:Gem::Requirement
16
+ requirement: &70123374137900 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: 1.6.7
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70134702100760
24
+ version_requirements: *70123374137900
25
25
  description: API wrapper for Rally's JSON REST web services api
26
26
  email:
27
27
  - dsmith@rallydev.com
@@ -40,7 +40,7 @@ files:
40
40
  - lib/rally_api/rally_rest_json.rb
41
41
  - lib/rally_api/version.rb
42
42
  - lib/rally_api.rb
43
- homepage: http://developer.rallydev.com/help
43
+ homepage: https://github.com/RallyTools/RallyRestToolkitForRuby
44
44
  licenses: []
45
45
  post_install_message:
46
46
  rdoc_options: []