devcreek 0.3 → 0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +4 -0
- data/Manifest.txt +0 -1
- data/README.txt +504 -504
- data/Rakefile +1 -1
- data/lib/devcreek.rb +1 -1
- data/lib/devcreek_record_template.rb +2 -0
- data/lib/devcreek_transmitter.rb +12 -5
- data/test/testsuite_spec.rb +2 -2
- metadata +3 -4
- data/lib/digest_auth.rb +0 -37
data/Rakefile
CHANGED
@@ -14,7 +14,7 @@ Hoe.new('devcreek', DevCreek::VERSION) do |p|
|
|
14
14
|
p.url = 'http://rubyforge.org/projects/devcreek/'
|
15
15
|
p.summary = 'The DevCreek gem enables programmers to collect and transmit metrics from their Ruby test framework to a DevCreek server.'
|
16
16
|
p.description = p.paragraphs_of('README.txt', 2..5).join("\n\n")
|
17
|
-
p.changes = p.paragraphs_of('History.txt', 0..
|
17
|
+
p.changes = p.paragraphs_of('History.txt', 0..10).join("\n\n")
|
18
18
|
p.extra_deps << ["uuidtools", ">= 1.0.1"]
|
19
19
|
end
|
20
20
|
|
data/lib/devcreek.rb
CHANGED
@@ -6,6 +6,7 @@
|
|
6
6
|
|
7
7
|
module DevCreek
|
8
8
|
TRANSMISSION_RECORD_TEMPLATE = %{
|
9
|
+
<records>
|
9
10
|
<record>
|
10
11
|
<core.principal><%= DevCreek::Core.instance.principal %></core.principal>
|
11
12
|
<core.project><%= DevCreek::Core.instance.project %></core.project>
|
@@ -63,5 +64,6 @@ module DevCreek
|
|
63
64
|
<unittest.testRunLauncher>manual</unittest.testRunLauncher>
|
64
65
|
<unittest.testRunStatus>ENDED</unittest.testRunStatus>
|
65
66
|
</record>
|
67
|
+
</records>
|
66
68
|
}.gsub(/^ /, '').freeze
|
67
69
|
end
|
data/lib/devcreek_transmitter.rb
CHANGED
@@ -5,13 +5,13 @@
|
|
5
5
|
# Licensed under the LGPL, see the file README.txt in the distribution
|
6
6
|
|
7
7
|
require 'net/http'
|
8
|
-
require '
|
8
|
+
require 'zlib'
|
9
9
|
require 'devcreek_core'
|
10
10
|
|
11
11
|
module DevCreek
|
12
12
|
module Transmitter
|
13
13
|
|
14
|
-
SUBMIT_URL = "
|
14
|
+
SUBMIT_URL = "https://devcreek.com/submitData2/"
|
15
15
|
|
16
16
|
def Transmitter.submit(session_id, xml_data)
|
17
17
|
|
@@ -20,13 +20,20 @@ module DevCreek
|
|
20
20
|
DevCreek::Core.instance().user.nil? or
|
21
21
|
DevCreek::Core.instance().password.nil?
|
22
22
|
|
23
|
-
url = URI.parse("#{SUBMIT_URL}#{DevCreek::Core.instance().project}
|
23
|
+
url = URI.parse("#{SUBMIT_URL}#{DevCreek::Core.instance().project}")
|
24
24
|
response = nil
|
25
25
|
Net::HTTP.start(url.host) do |http|
|
26
26
|
res = http.head(url.request_uri)
|
27
27
|
req = Net::HTTP::Post.new(url.path)
|
28
|
-
|
29
|
-
|
28
|
+
|
29
|
+
#gzip the request_data
|
30
|
+
strio = StringIO.new('', 'w')
|
31
|
+
gz = Zlib::GzipWriter.new(strio)
|
32
|
+
gz.write xml_data
|
33
|
+
gz.close
|
34
|
+
req.body= strio.string
|
35
|
+
req.add_field('Content-Encoding', 'gzip')
|
36
|
+
req.basic_auth(DevCreek::Core.instance().user, DevCreek::Core.instance().password)
|
30
37
|
response = http.request(req)
|
31
38
|
end
|
32
39
|
return response
|
data/test/testsuite_spec.rb
CHANGED
@@ -89,7 +89,7 @@ describe DevCreek::TestSuite do
|
|
89
89
|
DevCreek::Core.instance().principal = "Skinnard"
|
90
90
|
DevCreek::Core.instance().project= "Foo"
|
91
91
|
|
92
|
-
doc = REXML::Document.new(
|
92
|
+
doc = REXML::Document.new(@suite.to_xml('unique'))
|
93
93
|
doc.get_elements('//core.principal').each {|tag| tag.text.should eql("Skinnard") }
|
94
94
|
doc.get_elements('//core.principal').each {|tag| tag.text.should eql("Skinnard") }
|
95
95
|
doc.get_elements('//core.project').each {|tag| tag.text.should eql("Foo") }
|
@@ -124,7 +124,7 @@ describe DevCreek::TestSuite do
|
|
124
124
|
@suite.test_results['test1(OtherClass)'].has_finished
|
125
125
|
@suite.has_finished
|
126
126
|
|
127
|
-
doc = REXML::Document.new(
|
127
|
+
doc = REXML::Document.new(@suite.to_xml('unique'))
|
128
128
|
doc.get_elements('//record').size.should eql(8)
|
129
129
|
doc.get_elements('//unittest.testCount')[0].text.should eql('3')
|
130
130
|
doc.get_elements('//unittest.errorTotal')[0].text.should eql('1')
|
metadata
CHANGED
@@ -3,15 +3,15 @@ rubygems_version: 0.9.4
|
|
3
3
|
specification_version: 1
|
4
4
|
name: devcreek
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: "0.
|
7
|
-
date:
|
6
|
+
version: "0.4"
|
7
|
+
date: 2008-01-02 00:00:00 -05:00
|
8
8
|
summary: The DevCreek gem enables programmers to collect and transmit metrics from their Ruby test framework to a DevCreek server.
|
9
9
|
require_paths:
|
10
10
|
- lib
|
11
11
|
email: caleb.powell@gmail.com
|
12
12
|
homepage: http://rubyforge.org/projects/devcreek/
|
13
13
|
rubyforge_project: devcreek
|
14
|
-
description: "The DevCreek gem enables programmers to collect and transmit metrics from their Ruby Test::Unit and RSpec test suites to a DevCreek server. Please visit the DevCreek site (http://devcreek.com/index.html) for more info. == FEATURES/PROBLEMS: Supported frameworks include Test::Unit and
|
14
|
+
description: "The DevCreek gem enables programmers to collect and transmit metrics from their Ruby Test::Unit and RSpec test suites to a DevCreek server. Please visit the DevCreek site (http://devcreek.com/index.html) for more info. == FEATURES/PROBLEMS: Supported frameworks include Test::Unit and RSpec (> 1.10). == SYNOPSIS: The DevCreek Ruby Gem is library that, when loaded, will automatically listen to and collect metrics from your Test::Unit/RSpec unit tests. All you have to do is load the DevCreek library in your code and give it your DevCreek account info so that it can transmit the metrics to the server. Here is the simplest example of how to load DevCreek: -------- #Load the devcreek gem require 'rubygems' require 'devcreek' #set your account info DevCreek::Core.instance().load_from_yaml(\"#{ENV['HOME']}/.yoursettingsfile.devcreek.yml\") -------- There are two ways to provide DevCreek with your account settings. The first (as shown above) is to point DevCreek to a settings file. The 'enabled' attribute tells devcreek whether or not it should actually transmit the metrics that it collects. The yaml file would like this: -------- user: your_devcreek_username password: your_devcreek_password project: your_devcreek_project enabled: true -------- The other way to provide DevCreek with your settings is via a hash. So, instead of loading a yaml file, you could do this: -------- #Load the devcreek gem require 'rubygems' require 'devcreek' #set your account info DevCreek::Core.instance().load( :user => 'your_devcreek_username', :password => 'your_devcreek_password', :project => 'your_devcreek_project', :enabled => true ) -------- The first method is preferrable because it allows you to keep your account settings outside of your project (and therefore your source control tool). If you only have 1 test file, you can place the code to load devcreek in the test file and your done. However, most projects will have many test files. In this case, you need to make sure that the Ruby interpreter loads devcreek before running the test classes. This can be done via the Ruby '-r' option. For example, assuming your code to load devcreek is in a file called foo.rb, you would run your tests from the command line like this: ruby -r foo.rb test/test_* If you run your tests from a Rakefile, then you need to tell rake to include the -r option when it runs the tests (rake runs it's tests in a separate Ruby process). You can do this pretty easily in your Rakefile, like so; -------- require 'rake/testtask' Rake::TestTask.new('all_tests') do |t| t.ruby_opts = ['-r foo.rb'] t.test_files = ['test/test_*.rb'] end --------"
|
15
15
|
autorequire:
|
16
16
|
default_executable:
|
17
17
|
bindir: bin
|
@@ -41,7 +41,6 @@ files:
|
|
41
41
|
- lib/devcreek_testrunnermediator.rb
|
42
42
|
- lib/devcreek_testsuite.rb
|
43
43
|
- lib/devcreek_transmitter.rb
|
44
|
-
- lib/digest_auth.rb
|
45
44
|
- test/load_devcreek.rb
|
46
45
|
- test/load_devcreek_for_specs.rb
|
47
46
|
- test/test_fiction_testunit.rb
|
data/lib/digest_auth.rb
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
# Written by Eric Hodel <drbrain@segment7.net>
|
2
|
-
|
3
|
-
require 'digest/md5'
|
4
|
-
require 'net/http'
|
5
|
-
|
6
|
-
module Net
|
7
|
-
module HTTPHeader
|
8
|
-
@@nonce_count = -1
|
9
|
-
CNONCE = Digest::MD5::hexdigest("%x" % (Time.now.to_i + rand(65535)))
|
10
|
-
def digest_auth(user, password, response) # based on http://segment7.net/projects/ruby/snippets/digest_auth.rb
|
11
|
-
@@nonce_count += 1
|
12
|
-
response['www-authenticate'] =~ /^(\w+) (.*)/
|
13
|
-
params = {}
|
14
|
-
$2.gsub(/(\w+)="(.*?)"/) { params[$1] = $2 }
|
15
|
-
a_1 = "#{user}:#{params['realm']}:#{password}"
|
16
|
-
a_2 = "#{@method}:#{@path}"
|
17
|
-
request_digest = ''
|
18
|
-
request_digest << Digest::MD5.hexdigest(a_1)
|
19
|
-
request_digest << ':' << params['nonce']
|
20
|
-
request_digest << ':' << ('%08x' % @@nonce_count)
|
21
|
-
request_digest << ':' << CNONCE
|
22
|
-
request_digest << ':' << params['qop']
|
23
|
-
request_digest << ':' << Digest::MD5.hexdigest(a_2)
|
24
|
-
header = []
|
25
|
-
header << "Digest username=\"#{user}\""
|
26
|
-
header << "realm=\"#{params['realm']}\""
|
27
|
-
header << "qop=#{params['qop']}"
|
28
|
-
header << "algorithm=MD5"
|
29
|
-
header << "uri=\"#{@path}\""
|
30
|
-
header << "nonce=\"#{params['nonce']}\""
|
31
|
-
header << "nc=#{'%08x' % @@nonce_count}"
|
32
|
-
header << "cnonce=\"#{CNONCE}\""
|
33
|
-
header << "response=\"#{Digest::MD5.hexdigest(request_digest)}\""
|
34
|
-
@header['Authorization'] = header
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|