rally_rest_api 0.7.4 → 0.7.5
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.
data/Manifest.txt
CHANGED
data/Rakefile
CHANGED
@@ -22,7 +22,7 @@ RELEASE_TYPES = %w( gem ) # can use: gem, tar, zip
|
|
22
22
|
|
23
23
|
NAME = "rally_rest_api"
|
24
24
|
REV = nil # UNCOMMENT IF REQUIRED: File.read(".svn/entries")[/committed-rev="(d+)"/, 1] rescue nil
|
25
|
-
VERS = ENV['VERSION'] || (RallyRestVersion::
|
25
|
+
VERS = ENV['VERSION'] || (RallyRestVersion::LIBRARY_VERSION::STRING + (REV ? ".#{REV}" : ""))
|
26
26
|
CLEAN.include ['**/.*.sw?', '*.gem', '.config']
|
27
27
|
RDOC_OPTS = ['--quiet', '--title', "rally_rest_api documentation",
|
28
28
|
"--opname", "index.html",
|
@@ -0,0 +1,22 @@
|
|
1
|
+
class CustomHttpHeader
|
2
|
+
attr_accessor :name, :version, :vendor
|
3
|
+
attr_reader :library, :os, :platform
|
4
|
+
|
5
|
+
HTTP_HEADER_FIELDS = [:name, :vendor, :version, :library, :platform, :os]
|
6
|
+
HTTP_HEADER_PREFIX = 'X-RallyIntegration'
|
7
|
+
|
8
|
+
def initialize
|
9
|
+
@os = RUBY_PLATFORM
|
10
|
+
@platform = "Ruby #{RUBY_VERSION}"
|
11
|
+
@library = "RallyRestAPI version #{RallyRestVersion::LIBRARY_VERSION::STRING}"
|
12
|
+
end
|
13
|
+
|
14
|
+
def add_headers(req)
|
15
|
+
headers = {}
|
16
|
+
HTTP_HEADER_FIELDS.each do |field|
|
17
|
+
value = self.send(field)
|
18
|
+
next if value.nil?
|
19
|
+
req.add_field("#{HTTP_HEADER_PREFIX}#{field.to_s.capitalize}", value)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -18,15 +18,16 @@ class RallyRestAPI
|
|
18
18
|
# new - Create an instance of RallyRestAPI. Each instance corresponds to one named user.
|
19
19
|
#
|
20
20
|
# options (as a Hash):
|
21
|
-
# * username
|
22
|
-
# * password
|
23
|
-
# * base_url
|
24
|
-
# * version
|
21
|
+
# * username - The Rally username
|
22
|
+
# * password - The password for the named user
|
23
|
+
# * base_url - The base url of the system. Defaults to https://rally1.rallydev.com/slm
|
24
|
+
# * version - The RallyWebservices Version. Defaults to 'current', which will always be the most
|
25
25
|
# recent version of the api. Pass the value as a String, "1.0", "1.01" for example.
|
26
|
-
# * logger
|
26
|
+
# * logger - a Logger to log to.
|
27
|
+
# * http_headers - an instace of CustomHttpHeader that will send application information with the request
|
27
28
|
#
|
28
29
|
def initialize(options = {})
|
29
|
-
parse_options
|
30
|
+
parse_options(options)
|
30
31
|
end
|
31
32
|
|
32
33
|
def parse_options(options)
|
@@ -35,12 +36,13 @@ class RallyRestAPI
|
|
35
36
|
@base_url = options[:base_url] || "https://rally1.rallydev.com/slm"
|
36
37
|
@version = options[:version] || "current"
|
37
38
|
@logger = options[:logger]
|
39
|
+
@http_headers = options[:http_headers] || CustomHttpHeader.new
|
38
40
|
@parse_collections_as_hash = options[:parse_collections_as_hash] || false
|
39
41
|
|
40
42
|
if options[:builder]
|
41
43
|
builder = options[:builder]
|
42
44
|
else
|
43
|
-
builder = RestBuilder.new(@base_url, @username, @password, @version)
|
45
|
+
builder = RestBuilder.new(@base_url, @username, @password, @version, @http_headers)
|
44
46
|
end
|
45
47
|
builder.logger = @logger if @logger
|
46
48
|
@builder = builder
|
@@ -6,11 +6,11 @@ require 'builder'
|
|
6
6
|
|
7
7
|
class RestBuilder # :nodoc:
|
8
8
|
|
9
|
-
attr_reader :base_url, :username, :password
|
9
|
+
attr_reader :base_url, :username, :password, :http_headers
|
10
10
|
attr_accessor :logger
|
11
11
|
|
12
|
-
def initialize(base_url, username, password, version = "current")
|
13
|
-
@base_url, @username, @password, @version = base_url, username, password, version
|
12
|
+
def initialize(base_url, username, password, version = "current", http_headers = CustomHttpHeader.new)
|
13
|
+
@base_url, @username, @password, @version, @http_headers = base_url, username, password, version, http_headers
|
14
14
|
end
|
15
15
|
|
16
16
|
def marshal_dump
|
@@ -79,6 +79,7 @@ class RestBuilder # :nodoc:
|
|
79
79
|
end
|
80
80
|
|
81
81
|
def send_request(url, req, username, password)
|
82
|
+
@http_headers.add_headers(req)
|
82
83
|
req.basic_auth username, password
|
83
84
|
req.content_type = 'text/xml'
|
84
85
|
proxy = ENV['http_proxy'] ? URI.parse(ENV['http_proxy']) : OpenStruct.new
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
describe "A CustomHttpHeader" do
|
4
|
+
|
5
|
+
before(:each) do
|
6
|
+
@custom_http_header = CustomHttpHeader.new
|
7
|
+
@sample_values = {
|
8
|
+
:library => RallyRestVersion::LIBRARY_VERSION::STRING,
|
9
|
+
:platform => RUBY_VERSION,
|
10
|
+
:os => RUBY_PLATFORM,
|
11
|
+
:name => 'Guacamole',
|
12
|
+
:vendor => "The Big Enchilda's Burrito Company",
|
13
|
+
:version => '0.3.2'
|
14
|
+
}
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should set library, platform, and os automatically" do
|
18
|
+
@custom_http_header.library.should == @sample_values[:library]
|
19
|
+
@custom_http_header.platform.should == @sample_values[:platform]
|
20
|
+
@custom_http_header.os.should == @sample_values[:os]
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'should allow name, version, and vendor to be set' do
|
24
|
+
[:name, :vendor, :version].each do |field, value|
|
25
|
+
@custom_http_header.send("#{field}=".to_sym, value)
|
26
|
+
@custom_http_header.send(field).should == value
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'should set the HTTP headers appropriately' do
|
31
|
+
req = mock("HTTP Request")
|
32
|
+
[:name, :vendor, :version].each do |field|
|
33
|
+
@custom_http_header.send("#{field}=", @sample_values[field])
|
34
|
+
end
|
35
|
+
|
36
|
+
@sample_values.each do |header, value|
|
37
|
+
hdr = "#{CustomHttpHeader::HTTP_HEADER_PREFIX}#{header.to_s.capitalize}"
|
38
|
+
req.should_receive(:add_field).with(hdr, value)
|
39
|
+
end
|
40
|
+
@custom_http_header.add_headers(req)
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.2
|
|
3
3
|
specification_version: 1
|
4
4
|
name: rally_rest_api
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.7.
|
7
|
-
date: 2007-10-
|
6
|
+
version: 0.7.5
|
7
|
+
date: 2007-10-29 00:00:00 -06:00
|
8
8
|
summary: A ruby-ized interface to Rally's REST webservices API
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -42,6 +42,7 @@ files:
|
|
42
42
|
- lib/rally_rest_api/typedef.rb
|
43
43
|
- lib/rally_rest_api/ruport.rb
|
44
44
|
- lib/rally_rest_api/version.rb
|
45
|
+
- lib/rally_rest_api/custom_http_header.rb
|
45
46
|
- Manifest.txt
|
46
47
|
- Rakefile
|
47
48
|
- README.txt
|
@@ -57,6 +58,7 @@ files:
|
|
57
58
|
- test/rest_builder_spec.rb
|
58
59
|
test_files:
|
59
60
|
- test/attribute_definition_spec.rb
|
61
|
+
- test/custom_http_header_spec.rb
|
60
62
|
- test/query_result_spec.rb
|
61
63
|
- test/rest_builder_spec.rb
|
62
64
|
- test/rest_object_spec.rb
|