oas 2.1.2 → 2.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 9e161b53e313c430fe6a3d5b85a2f40f438c6a8b
4
+ data.tar.gz: 97c26e5d6bf6b2003329b0c757f5e3787133a65f
5
+ SHA512:
6
+ metadata.gz: ab64f93c2c2a9fbfdccc822cf30199e017706f18db361ccb93acbb130640f823bacae7e5cc42ed6e41d9cd5f8d1f6415e9d05a050f5db81935ed654ea2fbb8c1
7
+ data.tar.gz: f4f05717814a22ee10b9fa881f1a1038e90147d1b8f5e39729ea10a5cf6b26a21c575120e81a58a95cac948aaf797787f7bb30ca81cd2e8086c33686ec3d540b
data/.gitignore CHANGED
@@ -1,6 +1,7 @@
1
- *.gem
2
- .bundle
3
- Gemfile.lock
4
- coverage/
5
- doc/
6
- pkg/
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ bin/
5
+ coverage/
6
+ doc/
7
+ pkg/
data/.travis.yml CHANGED
@@ -1,9 +1,9 @@
1
- language: ruby
2
- rvm:
3
- - 1.9.2
4
- - 1.9.3
5
- - jruby-19mode
6
- - rbx-19mode
7
- notifications:
8
- email:
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.2
4
+ - 1.9.3
5
+ - jruby-19mode
6
+ - rbx-19mode
7
+ notifications:
8
+ email:
9
9
  - dev@realmediadigital.com
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source "http://rubygems.org"
2
-
3
- # Specify your gem's dependencies in ruby-oas.gemspec
4
- gemspec
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in ruby-oas.gemspec
4
+ gemspec
data/LICENSE CHANGED
@@ -1,20 +1,20 @@
1
- Copyright (c) 2011 Realmedia Latin America
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining
4
- a copy of this software and associated documentation files (the
5
- "Software"), to deal in the Software without restriction, including
6
- without limitation the rights to use, copy, modify, merge, publish,
7
- distribute, sublicense, and/or sell copies of the Software, and to
8
- permit persons to whom the Software is furnished to do so, subject to
9
- the following conditions:
10
-
11
- The above copyright notice and this permission notice shall be
12
- included in all copies or substantial portions of the Software.
13
-
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1
+ Copyright (c) 2011 Realmedia Latin America
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -1,89 +1,89 @@
1
- # OAS Ruby Client [![Build Status](https://secure.travis-ci.org/realmedia/oas-ruby-client.png)][travis] [![Dependency Status](https://gemnasium.com/realmedia/oas-ruby-client.png?travis)][gemnasium]
2
- Ruby client for the OpenAdstream API
3
-
4
- [travis]: http://travis-ci.org/realmedia/oas-ruby-client
5
- [gemnasium]: https://gemnasium.com/realmedia/oas-ruby-client
6
-
7
- ## Installation
8
-
9
- `oas` is available through [Rubygems](http://rubygems.org/gems/oas) and can be installed via:
10
-
11
- gem install oas
12
-
13
- ## Usage
14
-
15
- Applications that make requests on behalf a single user to a single account can pass configuration options as a block to the `OAS.configure` method.
16
-
17
- ```ruby
18
- OAS.configure do |config|
19
- config.endpoint = OAS_ENDPOINT
20
- config.account = OAS_ACCOUNT
21
- config.username = OAS_USERNAME
22
- config.password = OAS_PASSWORD
23
- end
24
- ```
25
- Applications that make requests on behalf of multiple users to multiple accounts should avoid using the global configuration and instantiate `OAS::Client` objects. If the endpoint is the same, you can specify it globally.
26
-
27
- ```ruby
28
- OAS.configure do |config|
29
- config.endpoint = OAS_ENDPOINT
30
- end
31
-
32
- client = OAS::Client.new(
33
- :account => "oas_account",
34
- :username => "oas_username",
35
- :password => "oas_password"
36
- )
37
- ```
38
- Requests should be created using an `OAS::AdXML` object. Each request type will yield a `Nokogiri::XML::Builder` object.
39
-
40
- ```ruby
41
- doc = OAS::AdXML.new
42
- doc.request do |req|
43
- req.Advertiser do |xml|
44
- xml.Database(:action => 'read') {
45
- xml.Advertiser {
46
- xml.Id "DPadvtest"
47
- }
48
- }
49
- end
50
- end
51
- ```
52
- Multiple requests can be sent in the same call.
53
-
54
- ```ruby
55
- doc = OAS::AdXML.new
56
- doc.request do |req|
57
- req.Site do |xml|
58
- xml.Database(:action => "read") {
59
- xml.Site {
60
- xml.Id "247media"
61
- }
62
- }
63
- end
64
- req.Site do |xml|
65
- xml.Database(:action => "read") {
66
- xml.Site {
67
- xml.Id "realmedia"
68
- }
69
- }
70
- end
71
- end
72
- ```
73
- Executing the request
74
-
75
- ```ruby
76
- adxml = OAS.execute(doc) # or client.execute(doc)
77
- adxml.each_response do |res|
78
- if res.success?
79
- # res.to_hash
80
- else
81
- # res.error_code
82
- # res.error_text
83
- end
84
- end
85
- ```
86
-
87
- ## Copyright
88
- Copyright (c) 2011 Realmedia Latin America.
89
- See [LICENSE](https://github.com/realmedia/oas-ruby-client/blob/master/LICENSE) for details.
1
+ # OAS Ruby Client [![Build Status](https://secure.travis-ci.org/realmedia/oas-ruby-client.png)][travis] [![Dependency Status](https://gemnasium.com/realmedia/oas-ruby-client.png?travis)][gemnasium]
2
+ Ruby client for the OpenAdstream API
3
+
4
+ [travis]: http://travis-ci.org/realmedia/oas-ruby-client
5
+ [gemnasium]: https://gemnasium.com/realmedia/oas-ruby-client
6
+
7
+ ## Installation
8
+
9
+ `oas` is available through [Rubygems](http://rubygems.org/gems/oas) and can be installed via:
10
+
11
+ gem install oas
12
+
13
+ ## Usage
14
+
15
+ Applications that make requests on behalf a single user to a single account can pass configuration options as a block to the `OAS.configure` method.
16
+
17
+ ```ruby
18
+ OAS.configure do |config|
19
+ config.endpoint = OAS_ENDPOINT
20
+ config.account = OAS_ACCOUNT
21
+ config.username = OAS_USERNAME
22
+ config.password = OAS_PASSWORD
23
+ end
24
+ ```
25
+ Applications that make requests on behalf of multiple users to multiple accounts should avoid using the global configuration and instantiate `OAS::Client` objects. If the endpoint is the same, you can specify it globally.
26
+
27
+ ```ruby
28
+ OAS.configure do |config|
29
+ config.endpoint = OAS_ENDPOINT
30
+ end
31
+
32
+ client = OAS::Client.new(
33
+ :account => "oas_account",
34
+ :username => "oas_username",
35
+ :password => "oas_password"
36
+ )
37
+ ```
38
+ Requests should be created using an `OAS::AdXML` object. Each request type will yield a `Nokogiri::XML::Builder` object.
39
+
40
+ ```ruby
41
+ doc = OAS::AdXML.new
42
+ doc.request do |req|
43
+ req.Advertiser do |xml|
44
+ xml.Database(:action => 'read') {
45
+ xml.Advertiser {
46
+ xml.Id "DPadvtest"
47
+ }
48
+ }
49
+ end
50
+ end
51
+ ```
52
+ Multiple requests can be sent in the same call.
53
+
54
+ ```ruby
55
+ doc = OAS::AdXML.new
56
+ doc.request do |req|
57
+ req.Site do |xml|
58
+ xml.Database(:action => "read") {
59
+ xml.Site {
60
+ xml.Id "247media"
61
+ }
62
+ }
63
+ end
64
+ req.Site do |xml|
65
+ xml.Database(:action => "read") {
66
+ xml.Site {
67
+ xml.Id "realmedia"
68
+ }
69
+ }
70
+ end
71
+ end
72
+ ```
73
+ Executing the request
74
+
75
+ ```ruby
76
+ adxml = OAS.execute(doc) # or client.execute(doc)
77
+ adxml.each_response do |res|
78
+ if res.success?
79
+ # res.to_hash
80
+ else
81
+ # res.error_code
82
+ # res.error_text
83
+ end
84
+ end
85
+ ```
86
+
87
+ ## Copyright
88
+ Copyright (c) 2011 Realmedia Latin America.
89
+ See [LICENSE](https://github.com/realmedia/oas-ruby-client/blob/master/LICENSE) for details.
data/Rakefile CHANGED
@@ -1,11 +1,11 @@
1
- require 'bundler'
2
- Bundler::GemHelper.install_tasks
3
-
4
- require 'rake/testtask'
5
- Rake::TestTask.new do |t|
6
- t.libs = ["lib","test"]
7
- t.verbose = true
8
- t.test_files = FileList['test/**/test_*.rb']
9
- end
10
-
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
3
+
4
+ require 'rake/testtask'
5
+ Rake::TestTask.new do |t|
6
+ t.libs = ["lib","test"]
7
+ t.verbose = true
8
+ t.test_files = FileList['test/**/test_*.rb']
9
+ end
10
+
11
11
  task :default => :test
data/lib/oas.rb CHANGED
@@ -1,22 +1,22 @@
1
- require 'oas/error'
2
- require 'oas/configuration'
3
- require 'oas/client'
4
- require 'oas/version'
5
-
6
- module OAS
7
- extend Configuration
8
-
9
- def self.client(options={})
10
- @client = OAS::Client.new(options) unless defined?(@client)
11
- @client
12
- end
13
-
14
- def self.method_missing(method, *args, &block)
15
- return super unless client.respond_to?(method)
16
- client.send(method, *args, &block)
17
- end
18
-
19
- def self.respond_to_missing?(method, include_private = false)
20
- client.respond_to?(method, include_private)
21
- end
22
- end
1
+ require 'oas/error'
2
+ require 'oas/configuration'
3
+ require 'oas/client'
4
+ require 'oas/version'
5
+
6
+ module OAS
7
+ extend Configuration
8
+
9
+ def self.client(options={})
10
+ @client = OAS::Client.new(options) unless defined?(@client)
11
+ @client
12
+ end
13
+
14
+ def self.method_missing(method, *args, &block)
15
+ return super unless client.respond_to?(method)
16
+ client.send(method, *args, &block)
17
+ end
18
+
19
+ def self.respond_to_missing?(method, include_private = false)
20
+ client.respond_to?(method, include_private)
21
+ end
22
+ end
data/lib/oas/adxml.rb CHANGED
@@ -1,75 +1,92 @@
1
- require 'nokogiri'
2
-
3
- module OAS
4
- class AdXML
5
- def self.parse(str)
6
- new Nokogiri.XML(str)
7
- end
8
-
9
- module Utils
10
- def parser
11
- @parser ||= Nori.new(:advanced_typecasting => false, :convert_tags_to => lambda { |tag| tag.to_sym })
12
- end
13
- attr_writer :parser
14
-
15
- def to_s
16
- @doc.to_xml
17
- end
18
- alias_method :to_xml, :to_s
19
-
20
- def to_hash
21
- @hash ||= parser.parse(@doc.to_xml)
22
- end
23
- end
24
-
25
- class Request
26
- def initialize(root)
27
- @root = root
28
- end
29
-
30
- def method_missing method, *args, &block # :nodoc:
31
- Nokogiri::XML::Builder.with(@root) do |xml|
32
- xml.Request(:type => method.to_s) { |xml| block.call(xml) if block_given? }
33
- end
34
- end
35
- end
36
-
37
- class Response
38
- include Utils
39
-
40
- attr_reader :error_code
41
- attr_reader :error_text
42
-
43
- def initialize(doc)
44
- @doc = doc
45
- @error_code = @error_text = nil
46
- error = @doc.xpath('.//Exception').first rescue nil
47
- if error
48
- @error_code = error['errorCode'].to_i
49
- @error_text = error.text
50
- end
51
- end
52
-
53
- def success?
54
- !error_code
55
- end
56
- end
57
-
58
- include Utils
59
-
60
- def initialize(doc = nil)
61
- @doc = doc
62
- @doc = Nokogiri::XML::Builder.new(:encoding => 'UTF-8') { |xml| xml.AdXML }.doc if @doc.nil?
63
- end
64
-
65
- def request
66
- yield Request.new(@doc.root)
67
- end
68
-
69
- def each_response
70
- @doc.xpath('/AdXML/Response').each do |node|
71
- yield Response.new(node)
72
- end
73
- end
74
- end
1
+ require 'nokogiri'
2
+
3
+ module OAS
4
+ class AdXML
5
+ def self.parse(str)
6
+ new Nokogiri.XML(str)
7
+ end
8
+
9
+ module Utils
10
+ def parser
11
+ @parser ||= Nori.new(:advanced_typecasting => false, :convert_tags_to => lambda { |tag| tag.to_sym })
12
+ end
13
+ attr_writer :parser
14
+
15
+ def to_s
16
+ @doc.to_xml
17
+ end
18
+ alias_method :to_xml, :to_s
19
+
20
+ def to_hash
21
+ @hash ||= parser.parse(@doc.to_xml)
22
+ end
23
+ end
24
+
25
+ class Request
26
+ def initialize(root)
27
+ @root = root
28
+ end
29
+
30
+ def method_missing method, *args, &block # :nodoc:
31
+ Nokogiri::XML::Builder.with(@root) do |xml|
32
+ xml.Request(:type => method.to_s) { |xml| block.call(xml) if block_given? }
33
+ end
34
+ end
35
+ end
36
+
37
+ class Response
38
+ include Utils
39
+
40
+ attr_reader :error_code
41
+ attr_reader :error_text
42
+
43
+ def initialize(doc)
44
+ @doc = doc
45
+ @error_code = @error_text = nil
46
+ error = @doc.xpath('.//Exception').first rescue nil
47
+ if error
48
+ @error_code = error['errorCode'].to_i
49
+ @error_text = error.text
50
+ end
51
+ end
52
+
53
+ def success?
54
+ !error_code
55
+ end
56
+ end
57
+
58
+ include Utils
59
+
60
+ def initialize(doc = nil)
61
+ @doc = doc
62
+ @doc = Nokogiri::XML::Builder.new(:encoding => 'UTF-8') { |xml| xml.AdXML }.doc if @doc.nil?
63
+ end
64
+
65
+ def http_headers
66
+ @http_headers ||= {}
67
+ end
68
+ attr_writer :http_headers
69
+
70
+ def request
71
+ yield Request.new(@doc.root)
72
+ end
73
+
74
+ def response
75
+ responses.first
76
+ end
77
+
78
+ def responses
79
+ @responses ||= begin
80
+ res = []
81
+ @doc.xpath('/AdXML/Response').each { |node| res << Response.new(node) }
82
+ res
83
+ end
84
+ end
85
+
86
+ def each_response
87
+ responses.each do |res|
88
+ yield res
89
+ end
90
+ end
91
+ end
75
92
  end