romniture 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ Y2MxNmZmZTA4YTA3ZGFjOGFiNGJmNGU4MTUwNjYxMzk5ZmQ0OGMyNQ==
5
+ data.tar.gz: !binary |-
6
+ NTkxY2NiOWE0MGNhYzkxMmNiMTViMDVjZTUxNWQ2MzU3MzdlODNmNQ==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ Y2FiMmU1ZmQ0N2E5ZTllNjZjMDkwYzJiYWYzMmRhOWYzMzRiYzQwNTA0OWE2
10
+ MzM1ZTUxNjdlNWJhNTFiNWNjZWQxMmJkMGNkY2Y5YTJmZTYxNjBiMWQ0N2Zm
11
+ NjQ5YTM4MzcxOWU1YjAxNTRhMDc1ODNjYzk3MGMzYjFmN2E3ZDE=
12
+ data.tar.gz: !binary |-
13
+ ZDlhYjllOWUyNWQ4MjUzZTAwYmNiZmE5ZmJlMzczMDY4NTdiZjljZWM4OGZl
14
+ NDBjOGRlMWMyMjZiODI1MzdjNWY0YTEwYjRjMmI5YmFkMTU2OWVkZGM4YWJj
15
+ MmRjM2NlNGVkY2NkZTBlMzU5MzQzOWM4ZjM3NjcxYmQ3OWEyNjg=
data/README.markdown CHANGED
@@ -12,12 +12,12 @@ Omniture's API is closed, you have to be a paying customer in order to access th
12
12
  ## initialization and authentication
13
13
  romniture requires you supply the `username`, `shared_secret` and `environment` which you can access within the Company > Web Services section of the Admin Console. The environment you'll use to connect to Omniture's API depends on which data center they're using to store your traffic data and will be one of:
14
14
 
15
- * San Jose (https://api.omniture.com/admin/1.2/rest/)
16
- * Dallas (https://api2.omniture.com/admin/1.2/rest/)
17
- * London (https://api3.omniture.com/admin/1.2/rest/)
18
- * San Jose Beta (https://beta-api.omniture.com/admin/1.2/rest/)
19
- * Dallas (beta) (https://beta-api2.omniture.com/admin/1.2/rest/)
20
- * Sandbox (https://api-sbx1.omniture.com/admin/1.2/rest/)
15
+ * San Jose (https://api.omniture.com/admin/1.3/rest/)
16
+ * Dallas (https://api2.omniture.com/admin/1.3/rest/)
17
+ * London (https://api3.omniture.com/admin/1.3/rest/)
18
+ * San Jose Beta (https://beta-api.omniture.com/admin/1.3/rest/)
19
+ * Dallas (beta) (https://beta-api2.omniture.com/admin/1.3/rest/)
20
+ * Sandbox (https://api-sbx1.omniture.com/admin/1.3/rest/)
21
21
 
22
22
  Here's an example of initializing with a few configuration options.
23
23
 
@@ -5,12 +5,12 @@ module ROmniture
5
5
  DEFAULT_REPORT_WAIT_TIME = 0.25
6
6
 
7
7
  ENVIRONMENTS = {
8
- :san_jose => "https://api.omniture.com/admin/1.2/rest/",
9
- :dallas => "https://api2.omniture.com/admin/1.2/rest/",
10
- :london => "https://api3.omniture.com/admin/1.2/rest/",
11
- :san_jose_beta => "https://beta-api.omniture.com/admin/1.2/rest/",
12
- :dallas_beta => "https://beta-api2.omniture.com/admin/1.2/rest/",
13
- :sandbox => "https://api-sbx1.omniture.com/admin/1.2/rest/"
8
+ :san_jose => "https://api.omniture.com/admin/1.3/rest/",
9
+ :dallas => "https://api2.omniture.com/admin/1.3/rest/",
10
+ :london => "https://api3.omniture.com/admin/1.3/rest/",
11
+ :san_jose_beta => "https://beta-api.omniture.com/admin/1.3/rest/",
12
+ :dallas_beta => "https://beta-api2.omniture.com/admin/1.3/rest/",
13
+ :sandbox => "https://api-sbx1.omniture.com/admin/1.3/rest/"
14
14
  }
15
15
 
16
16
  def initialize(username, shared_secret, environment, options={})
@@ -26,8 +26,15 @@ module ROmniture
26
26
 
27
27
  def request(method, parameters = {})
28
28
  response = send_request(method, parameters)
29
-
30
- JSON.parse(response.body)
29
+
30
+ begin
31
+ JSON.parse(response.body)
32
+ rescue JSON::ParserError => pe
33
+ response.body
34
+ rescue Exception => e
35
+ log(Logger::ERROR, "Error in request response:\n#{response.body}")
36
+ raise "Error in request response:\n#{response.body}"
37
+ end
31
38
  end
32
39
 
33
40
  def get_report(method, report_description)
@@ -143,4 +150,4 @@ module ROmniture
143
150
  JSON.parse(response.body)
144
151
  end
145
152
  end
146
- end
153
+ end
@@ -1,3 +1,3 @@
1
1
  module ROmniture
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
data/test/client_test.rb CHANGED
@@ -2,14 +2,15 @@ require 'rubygems'
2
2
  require 'test/unit'
3
3
  require 'yaml'
4
4
 
5
+ $:.unshift File.expand_path('../../lib', __FILE__)
5
6
  require 'romniture'
6
7
 
7
8
  class ClientTest < Test::Unit::TestCase
8
-
9
+
9
10
  def setup
10
11
  config = YAML::load(File.open("test/config.yml"))
11
12
  @config = config["omniture"]
12
-
13
+
13
14
  @client = ROmniture::Client.new(
14
15
  @config["username"],
15
16
  @config["shared_secret"],
@@ -18,14 +19,14 @@ class ClientTest < Test::Unit::TestCase
18
19
  :wait_time => @config["wait_time"]
19
20
  )
20
21
  end
21
-
22
+
22
23
  def test_simple_request
23
24
  response = @client.request('Company.GetReportSuites')
24
-
25
+
25
26
  assert_instance_of Hash, response, "Returned object is not a hash."
26
27
  assert(response.has_key?("report_suites"), "Returned hash does not contain any report suites.")
27
28
  end
28
-
29
+
29
30
  def test_report_request
30
31
  response = @client.get_report "Report.QueueOvertime", {
31
32
  "reportDescription" => {
@@ -35,11 +36,11 @@ class ClientTest < Test::Unit::TestCase
35
36
  "metrics" => [{"id" => "pageviews"}]
36
37
  }
37
38
  }
38
-
39
+
39
40
  assert_instance_of Hash, response, "Returned object is not a hash."
40
41
  assert(response["report"].has_key?("data"), "Returned hash has no data!")
41
42
  end
42
-
43
+
43
44
  def test_a_bad_request
44
45
  # Bad request, mixing commerce and traffic variables
45
46
  assert_raise(ROmniture::Exceptions::OmnitureReportException) do
@@ -54,5 +55,9 @@ class ClientTest < Test::Unit::TestCase
54
55
  })
55
56
  end
56
57
  end
57
-
58
+
59
+ def test_return_response_body_on_parse_error
60
+ non_json_response = @client.request('Company.GetTokenCount')
61
+ assert_instance_of String, non_json_response, "Company.GetTokenCount returned #{non_json_response}."
62
+ end
58
63
  end
metadata CHANGED
@@ -1,61 +1,50 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: romniture
3
- version: !ruby/object:Gem::Version
4
- hash: 23
5
- prerelease:
6
- segments:
7
- - 0
8
- - 0
9
- - 4
10
- version: 0.0.4
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.5
11
5
  platform: ruby
12
- authors:
6
+ authors:
13
7
  - Mike Sukmanowsky
14
8
  autorequire:
15
9
  bindir: bin
16
10
  cert_chain: []
17
-
18
- date: 2011-12-30 00:00:00 -05:00
19
- default_executable:
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
11
+ date: 2013-07-07 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
22
14
  name: httpi
23
- prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
25
- none: false
26
- requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- hash: 3
30
- segments:
31
- - 0
32
- version: "0"
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ! '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
33
20
  type: :runtime
34
- version_requirements: *id001
35
- - !ruby/object:Gem::Dependency
36
- name: json
37
21
  prerelease: false
38
- requirement: &id002 !ruby/object:Gem::Requirement
39
- none: false
40
- requirements:
41
- - - ">="
42
- - !ruby/object:Gem::Version
43
- hash: 3
44
- segments:
45
- - 0
46
- version: "0"
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ! '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: json
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
47
34
  type: :runtime
48
- version_requirements: *id002
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ! '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
49
41
  description: A library that allows access to Omniture's REST API libraries (developer.omniture.com)
50
- email:
42
+ email:
51
43
  - mike.sukmanowsky@gmail.com
52
44
  executables: []
53
-
54
45
  extensions: []
55
-
56
46
  extra_rdoc_files: []
57
-
58
- files:
47
+ files:
59
48
  - .gitignore
60
49
  - Gemfile
61
50
  - README.markdown
@@ -66,39 +55,28 @@ files:
66
55
  - lib/romniture/exceptions.rb
67
56
  - lib/romniture/version.rb
68
57
  - test/client_test.rb
69
- has_rdoc: true
70
58
  homepage: http://github.com/msukmanowsky/ROmniture
71
59
  licenses: []
72
-
60
+ metadata: {}
73
61
  post_install_message:
74
62
  rdoc_options: []
75
-
76
- require_paths:
63
+ require_paths:
77
64
  - lib
78
- required_ruby_version: !ruby/object:Gem::Requirement
79
- none: false
80
- requirements:
81
- - - ">="
82
- - !ruby/object:Gem::Version
83
- hash: 3
84
- segments:
85
- - 0
86
- version: "0"
87
- required_rubygems_version: !ruby/object:Gem::Requirement
88
- none: false
89
- requirements:
90
- - - ">="
91
- - !ruby/object:Gem::Version
92
- hash: 3
93
- segments:
94
- - 0
95
- version: "0"
65
+ required_ruby_version: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ required_rubygems_version: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ! '>='
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
96
75
  requirements: []
97
-
98
76
  rubyforge_project: romniture
99
- rubygems_version: 1.5.0
77
+ rubygems_version: 2.0.3
100
78
  signing_key:
101
- specification_version: 3
79
+ specification_version: 4
102
80
  summary: Use Omniture's REST API with ease.
103
- test_files:
81
+ test_files:
104
82
  - test/client_test.rb