romniture 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/README.markdown CHANGED
@@ -25,9 +25,10 @@ Here's an example of initializing with a few configuration options.
25
25
  username,
26
26
  shared_secret,
27
27
  :san_jose,
28
- :log => false, # Optionally turn off logging if it ticks you off
29
- :wait_time => 1 # Amount of seconds to wait in between pinging
30
- # Omniture's servers to see if a report is done processing (BEWARE OF TOKENS!)
28
+ :verify_mode => nil # Optionaly change the ssl verify mode.
29
+ :log => false, # Optionally turn off logging if it ticks you off
30
+ :wait_time => 1 # Amount of seconds to wait in between pinging
31
+ # Omniture's servers to see if a report is done processing (BEWARE OF TOKENS!)
31
32
  )
32
33
 
33
34
  ## usage
data/Rakefile CHANGED
@@ -1,10 +1,9 @@
1
+ require "rubygems"
1
2
  require "bundler/gem_tasks"
2
3
 
3
- namespace :test do
4
- desc "Run all tests in /test"
5
- task :all do
6
- Dir["test/**/*_test.rb"].each do |test_path|
7
- system "ruby #{test_path}"
8
- end
4
+ desc "Run all tests in /test"
5
+ task :test do
6
+ Dir["test/**/*_test.rb"].each do |test_path|
7
+ system "ruby #{test_path}"
9
8
  end
10
9
  end
@@ -2,7 +2,7 @@ module ROmniture
2
2
 
3
3
  class Client
4
4
 
5
- DEFAULT_REPORT_WAIT_TIME = 5
5
+ DEFAULT_REPORT_WAIT_TIME = 0.25
6
6
 
7
7
  ENVIRONMENTS = {
8
8
  :san_jose => "https://api.omniture.com/admin/1.2/rest/",
@@ -20,6 +20,7 @@ module ROmniture
20
20
 
21
21
  @wait_time = options[:wait_time] ? options[:wait_time] : DEFAULT_REPORT_WAIT_TIME
22
22
  @log = options[:log] ? options[:log] : false
23
+ @verify_mode = options[:verify_mode] ? options[:verify_mode] : false
23
24
  HTTPI.log = false
24
25
  end
25
26
 
@@ -70,6 +71,11 @@ module ROmniture
70
71
  log(Logger::INFO, "Created new nonce: #{@password}")
71
72
 
72
73
  request = HTTPI::Request.new
74
+
75
+ if @verify_mode
76
+ request.auth.ssl.verify_mode = @verify_mode
77
+ end
78
+
73
79
  request.url = @environment + "?method=#{method}"
74
80
  request.headers = request_headers
75
81
  request.body = data.to_json
@@ -124,8 +130,9 @@ module ROmniture
124
130
  end while !done && !error
125
131
 
126
132
  if error
127
- log(:error, "Unable to get data for report #{report_id}. Omniture returned a status of #{status}.")
128
- raise "Unable to get data for report #{report_id}. Omniture returned a status of #{status}."
133
+ msg = "Unable to get data for report #{report_id}. Status: #{status}. Error Code: #{json["error_code"]}. #{json["error_msg"]}."
134
+ log(:error, msg)
135
+ raise ROmniture::Exceptions::OmnitureReportException.new(json), msg
129
136
  end
130
137
 
131
138
  response = send_request("Report.GetReport", {"reportID" => "#{report_id}"})
@@ -136,5 +143,4 @@ module ROmniture
136
143
  JSON.parse(response.body)
137
144
  end
138
145
  end
139
-
140
146
  end
@@ -0,0 +1,13 @@
1
+ module ROmniture
2
+ module Exceptions
3
+
4
+ class OmnitureReportException < StandardError
5
+ attr_reader :data
6
+ def initialize(data)
7
+ @data = data
8
+ super
9
+ end
10
+ end
11
+
12
+ end
13
+ end
@@ -1,3 +1,3 @@
1
1
  module ROmniture
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
data/lib/romniture.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require "romniture/version"
2
2
  require "romniture/client"
3
+ require "romniture/exceptions"
3
4
 
4
5
  require "rubygems"
5
6
 
data/test/client_test.rb CHANGED
@@ -14,6 +14,7 @@ class ClientTest < Test::Unit::TestCase
14
14
  @config["username"],
15
15
  @config["shared_secret"],
16
16
  @config["environment"],
17
+ :verify_mode => @config['verify_mode'],
17
18
  :wait_time => @config["wait_time"]
18
19
  )
19
20
  end
@@ -39,4 +40,19 @@ class ClientTest < Test::Unit::TestCase
39
40
  assert(response["report"].has_key?("data"), "Returned hash has no data!")
40
41
  end
41
42
 
42
- end
43
+ def test_a_bad_request
44
+ # Bad request, mixing commerce and traffic variables
45
+ assert_raise(ROmniture::Exceptions::OmnitureReportException) do
46
+ response = @client.get_report("Report.QueueTrended", {
47
+ "reportDescription" => {
48
+ "reportSuiteID" => @config["report_suite_id"],
49
+ "dateFrom" => "2011-01-01",
50
+ "dateTo" => "2011-01-11",
51
+ "metrics" => [{"id" => "pageviews"}, {"id" => "event11"}],
52
+ "elements" => [{"id" => "siteSection"}]
53
+ }
54
+ })
55
+ end
56
+ end
57
+
58
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: romniture
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 3
10
- version: 0.0.3
9
+ - 4
10
+ version: 0.0.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Mike Sukmanowsky
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-09-18 00:00:00 -04:00
18
+ date: 2011-12-30 00:00:00 -05:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -63,6 +63,7 @@ files:
63
63
  - Rakefile
64
64
  - lib/romniture.rb
65
65
  - lib/romniture/client.rb
66
+ - lib/romniture/exceptions.rb
66
67
  - lib/romniture/version.rb
67
68
  - test/client_test.rb
68
69
  has_rdoc: true