yieldmanager 0.9.1 → 0.9.2
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/.gitignore +25 -0
- data/.rvmrc +1 -0
- data/Gemfile +3 -0
- data/HOW_TO_UPDATE_API_VERSION +3 -2
- data/README.md +94 -60
- data/Rakefile +10 -83
- data/lib/yieldmanager/client.rb +14 -14
- data/lib/yieldmanager/report.rb +16 -18
- data/lib/yieldmanager/version.rb +3 -0
- data/yieldmanager.gemspec +17 -69
- metadata +24 -17
- data/VERSION +0 -1
data/.gitignore
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
## MAC OS
|
2
|
+
.DS_Store
|
3
|
+
|
4
|
+
## TEXTMATE
|
5
|
+
*.tmproj
|
6
|
+
tmtags
|
7
|
+
|
8
|
+
## EMACS
|
9
|
+
*~
|
10
|
+
\#*
|
11
|
+
.\#*
|
12
|
+
|
13
|
+
## VIM
|
14
|
+
*.swp
|
15
|
+
|
16
|
+
## PROJECT::GENERAL
|
17
|
+
coverage
|
18
|
+
rdoc
|
19
|
+
pkg
|
20
|
+
|
21
|
+
## RDoc
|
22
|
+
rdoc/
|
23
|
+
|
24
|
+
## PROJECT::SPECIFIC
|
25
|
+
Gemfile.lock
|
data/.rvmrc
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
rvm 1.9.3@yieldmanager
|
data/Gemfile
ADDED
data/HOW_TO_UPDATE_API_VERSION
CHANGED
@@ -4,7 +4,8 @@ When RightMedia updates their release (say, from 1.33 to 1.34), do this:
|
|
4
4
|
- Edit the API_VERSION file to match the new release
|
5
5
|
- Visit the main API doc page (https://api.yieldmanager.com/doc/) and make sure the AVAILABLE_SERVICES file exactly matches the services listed in the sidebar.
|
6
6
|
- Run all the specs using 'rake' to ensure nothing broke
|
7
|
-
- Bump the
|
8
|
-
- 'rake release' to cut a version
|
7
|
+
- Bump the VERSION in lib/yieldmanager/version.rb appropriately
|
8
|
+
- 'rake release' to cut a version and push to rubygems.org
|
9
|
+
- git push to store on github
|
9
10
|
|
10
11
|
And you're done!
|
data/README.md
CHANGED
@@ -13,37 +13,49 @@ The current API version is stored in the API_VERSION file.
|
|
13
13
|
|
14
14
|
Yieldmanager is available as a gem for easy installation.
|
15
15
|
|
16
|
-
|
16
|
+
```
|
17
|
+
sudo gem install yieldmanager
|
18
|
+
```
|
17
19
|
|
18
20
|
or if you're using [RVM](https://rvm.beginrescueend.com/) (and why on earth wouldn't you?)
|
19
21
|
|
20
|
-
|
21
|
-
|
22
|
+
```
|
23
|
+
gem install yieldmanager
|
24
|
+
```
|
25
|
+
|
22
26
|
The project is available for review/forking on github.com
|
23
|
-
|
24
|
-
|
27
|
+
|
28
|
+
```
|
29
|
+
git clone git://github.com/billgathen/yieldmanager.git
|
30
|
+
```
|
25
31
|
|
26
32
|
To use in a Rails project, add this to config/environment.rb:
|
27
33
|
|
28
|
-
|
34
|
+
```ruby
|
35
|
+
config.gem 'yieldmanager'
|
36
|
+
```
|
29
37
|
|
30
38
|
### Creating a Yieldmanager::Client
|
31
39
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
40
|
+
```ruby
|
41
|
+
require 'yieldmanager'
|
42
|
+
|
43
|
+
@ym = Yieldmanager::Client.new(
|
44
|
+
:user => "bob",
|
45
|
+
:pass => "secret"
|
46
|
+
)
|
47
|
+
```
|
48
|
+
|
39
49
|
The default environment is production.
|
40
50
|
To access the test environment, use this:
|
41
51
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
52
|
+
```ruby
|
53
|
+
@ym = Yieldmanager::Client.new(
|
54
|
+
:user => "bob",
|
55
|
+
:pass => "secret"
|
56
|
+
:env => "test"
|
57
|
+
)
|
58
|
+
```
|
47
59
|
|
48
60
|
The keys can also be passed as strings: 'user', 'pass' and 'env'.
|
49
61
|
|
@@ -53,44 +65,54 @@ The keys can also be passed as strings: 'user', 'pass' and 'env'.
|
|
53
65
|
|
54
66
|
To check (or log) the current API version, execute the following:
|
55
67
|
|
56
|
-
|
68
|
+
```ruby
|
69
|
+
Yieldmanager::Client.api_version
|
70
|
+
```
|
57
71
|
|
58
72
|
### Finding available services
|
59
73
|
|
60
|
-
|
74
|
+
```ruby
|
75
|
+
@ym.available_services
|
76
|
+
```
|
61
77
|
|
62
78
|
### Using a service
|
63
79
|
|
64
|
-
|
65
|
-
|
66
|
-
|
80
|
+
```ruby
|
81
|
+
@ym.session do |token|
|
82
|
+
@currencies = @ym.dictionary.getCurrencies(token)
|
83
|
+
end
|
84
|
+
```
|
67
85
|
|
68
86
|
**GOTCHA** In projects with ActiveRecord enabled (i.e., Rails projects)
|
69
87
|
SOAP will identify returned data as AR objects if there's a
|
70
88
|
naming collision. For example, if you're running
|
71
89
|
|
72
|
-
|
90
|
+
```ruby
|
91
|
+
@ym.creative.get(token,123)
|
92
|
+
```
|
73
93
|
|
74
94
|
and you have an AR objects for a **creatives** table in the db, the
|
75
95
|
SOAP parser will interpret the returned SOAP object as
|
76
96
|
an AR Creative object, resulting in bizarre errors. Uniquely
|
77
|
-
re-name your AR object to eliminate the conflict.
|
78
|
-
|
97
|
+
re-name your AR object to eliminate the conflict.
|
98
|
+
|
79
99
|
### Pagination
|
80
100
|
|
81
101
|
Some calls return datasets too large to retrieve all at once.
|
82
102
|
Pagination allows you to pull them back incrementally, handling
|
83
103
|
the partial dataset on-the-fly or accumulating it for later use.
|
84
104
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
105
|
+
```ruby
|
106
|
+
BLOCK_SIZE = 50
|
107
|
+
id = 1
|
108
|
+
@ym.session do |token|
|
109
|
+
@ym.paginate(BLOCK_SIZE) do |block|
|
110
|
+
(lines,tot) = @ym.line_item.getByBuyer(token,id,BLOCK_SIZE,block)
|
111
|
+
# ...do something with lines...
|
112
|
+
tot # remember to return total!
|
93
113
|
end
|
114
|
+
end
|
115
|
+
```
|
94
116
|
|
95
117
|
|
96
118
|
### Pulling reports
|
@@ -100,20 +122,24 @@ functionality in the UI to get your request XML, or have
|
|
100
122
|
crafted one from scratch. Assuming it's in a variable called
|
101
123
|
**request_xml**, you'd access the data this way:
|
102
124
|
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
125
|
+
```ruby
|
126
|
+
@ym.session do |token|
|
127
|
+
report = @ym.pull_report(token, request_xml)
|
128
|
+
puts report.headers.join("\t")
|
129
|
+
report.data.each do |row|
|
130
|
+
puts row.join("\t")
|
109
131
|
end
|
132
|
+
end
|
133
|
+
```
|
110
134
|
|
111
135
|
Column data can be accessed either by index or column name:
|
112
136
|
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
137
|
+
```ruby
|
138
|
+
report.headers # => ['advertiser_name','seller_imps']
|
139
|
+
report.data[0][0] # => "Bob's Ads"
|
140
|
+
report.data[0].by_name('advertiser_name') # => "Bob's Ads"
|
141
|
+
report.data[0].by_name(:advertiser_name) # => "Bob's Ads"
|
142
|
+
```
|
117
143
|
|
118
144
|
If you call **by_name** with a non-existent column, it will throw an
|
119
145
|
**ArgumentError** telling you so.
|
@@ -121,8 +147,10 @@ If you call **by_name** with a non-existent column, it will throw an
|
|
121
147
|
Or you can extract the report to an array of named hashes, removing
|
122
148
|
dependencies on the gem for consumers of the data (say, across an API):
|
123
149
|
|
124
|
-
|
125
|
-
|
150
|
+
```ruby
|
151
|
+
hashes = report.to_hashes
|
152
|
+
hashes[0]['advertiser_name'] # => "Bob's Ads"
|
153
|
+
```
|
126
154
|
|
127
155
|
**NOTE** Any totals columns your xml requests will be interpreted
|
128
156
|
as ordinary data.
|
@@ -132,11 +160,13 @@ as ordinary data.
|
|
132
160
|
When simulating report calls without actually hitting Yieldmanager, you can
|
133
161
|
create your own reports.
|
134
162
|
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
163
|
+
```ruby
|
164
|
+
rpt = Yieldmanager::Report.new
|
165
|
+
rpt.headers = ["first","second"]
|
166
|
+
rpt.add_row([1,2])
|
167
|
+
rpt.data.first.by_name("first").should == 1
|
168
|
+
rpt.data.first.by_name("second").should == 2
|
169
|
+
```
|
140
170
|
|
141
171
|
### Wiredumps (SOAP logging)
|
142
172
|
|
@@ -144,20 +174,24 @@ To see the nitty-gritty of what's going over the wire (Yahoo tech support often
|
|
144
174
|
you can activate a "wiredump" on a per-service basis. Typically you just echo it to standard out.
|
145
175
|
For instance:
|
146
176
|
|
147
|
-
|
148
|
-
|
149
|
-
|
177
|
+
```ruby
|
178
|
+
client.entity.wiredump_dev = $stdout # on
|
179
|
+
adv = client.entity.get(token,12345)
|
180
|
+
client.entity.wiredump_dev = nil # off
|
181
|
+
```
|
150
182
|
|
151
183
|
For Rails in a passenger environment, standard out doesn't end up in the logfiles.
|
152
184
|
Instead, redirect to a file:
|
153
185
|
|
154
|
-
|
155
|
-
|
186
|
+
```ruby
|
187
|
+
wiredump = File.new("#{Rails.root}/log/wiredump_entity_#{Time.new.strftime('%H%M%S')}.log",'w')
|
188
|
+
client.entity.wiredump_dev = wiredump # on
|
156
189
|
|
157
|
-
|
190
|
+
adv = client.entity.get(token,12345)
|
158
191
|
|
159
|
-
|
160
|
-
|
192
|
+
wiredump.flush # make sure everything gets in there before it closes
|
193
|
+
client.entity.wiredump_dev = nil # off
|
194
|
+
```
|
161
195
|
|
162
196
|
The last 2 lines belong in an ensure block, so the file is created even
|
163
197
|
when there's an error (which is probably why you're doing this).
|
@@ -179,7 +213,7 @@ in 1.9. If you're interested in what's been done, check out **lib/soap4r_19_patc
|
|
179
213
|
and [Tomor Doron's blog post](http://tomerdoron.blogspot.com/2009/10/fixing-soap4r-for-ruby-19.html).
|
180
214
|
|
181
215
|
## Note on Patches/Pull Requests
|
182
|
-
|
216
|
+
|
183
217
|
* Fork the project.
|
184
218
|
* Make your feature addition or bug fix.
|
185
219
|
* Add specs for it. This is important so I don't break it in a
|
data/Rakefile
CHANGED
@@ -1,91 +1,18 @@
|
|
1
|
-
require '
|
2
|
-
|
1
|
+
require 'bundler'
|
2
|
+
Bundler::GemHelper.install_tasks
|
3
3
|
|
4
|
-
|
5
|
-
require
|
6
|
-
Jeweler::Tasks.new do |gem|
|
7
|
-
gem.name = "yieldmanager"
|
8
|
-
gem.summary = %Q{Interact with RightMedia's YieldManager API and Reportware products}
|
9
|
-
gem.description = %Q{This gem offers full access to YieldManager's API tools (read/write) as well as ad-hoc reporting through the Reportware tool}
|
10
|
-
gem.email = "bill@billgathen.com"
|
11
|
-
gem.homepage = "http://github.com/billgathen/yieldmanager"
|
12
|
-
gem.authors = ["Bill Gathen"]
|
13
|
-
gem.add_development_dependency "rspec", ">= 1.2.9"
|
14
|
-
gem.add_development_dependency "rdoc"
|
15
|
-
gem.add_dependency "hpricot", "= 0.8.2"
|
16
|
-
gem.add_dependency "soap4r", "= 1.5.8"
|
17
|
-
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
18
|
-
end
|
19
|
-
Jeweler::GemcutterTasks.new
|
20
|
-
rescue LoadError
|
21
|
-
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
22
|
-
end
|
23
|
-
|
24
|
-
#
|
25
|
-
# Handle 1.8 + rspec-1 OR 1.9 + rspec-2
|
26
|
-
# based on http://relishapp.com/rspec/rspec-core/v/2-6/file/upgrade -> "Upgrading from rspec-1.x"
|
27
|
-
#
|
28
|
-
if (RUBY_VERSION.start_with?("1.9"))
|
29
|
-
# rspec-2
|
30
|
-
require 'rspec/core/rake_task'
|
4
|
+
if RUBY_VERSION.start_with?("1.9")
|
5
|
+
require "rspec/core/rake_task" # RSpec 2.0
|
31
6
|
|
32
|
-
RSpec::Core::RakeTask.new do |
|
33
|
-
|
34
|
-
t.pattern = 'spec/**/*_spec.rb'
|
7
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
8
|
+
spec.pattern = 'spec/yieldmanager/*_spec.rb'
|
35
9
|
end
|
36
|
-
|
37
|
-
RSpec
|
38
|
-
t.rcov_opts = %q[--exclude "spec"]
|
39
|
-
end
|
40
|
-
else # 1.8
|
41
|
-
#rspec-1
|
42
|
-
require 'spec/rake/spectask'
|
10
|
+
else
|
11
|
+
require "spec/rake/spectask" # RSpec 1.3
|
43
12
|
|
44
13
|
Spec::Rake::SpecTask.new(:spec) do |spec|
|
45
|
-
spec.
|
46
|
-
spec.spec_files = FileList['spec/**/*_spec.rb']
|
47
|
-
end
|
48
|
-
|
49
|
-
Spec::Rake::SpecTask.new(:rcov) do |spec|
|
50
|
-
spec.libs << 'lib' << 'spec'
|
51
|
-
spec.pattern = 'spec/**/*_spec.rb'
|
52
|
-
spec.rcov = true
|
14
|
+
spec.spec_files = FileList['spec/yieldmanager/*_spec.rb']
|
53
15
|
end
|
54
16
|
end
|
55
17
|
|
56
|
-
task :
|
57
|
-
|
58
|
-
task :default => :spec
|
59
|
-
|
60
|
-
require 'rdoc/task'
|
61
|
-
RDoc::Task.new do |rdoc|
|
62
|
-
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
63
|
-
|
64
|
-
rdoc.rdoc_dir = 'rdoc'
|
65
|
-
rdoc.title = "yieldmanager #{version}"
|
66
|
-
rdoc.rdoc_files.include('README*')
|
67
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
68
|
-
end
|
69
|
-
|
70
|
-
namespace :yieldmanager do
|
71
|
-
desc "Build wsdls for API version in API_VERSION file"
|
72
|
-
task :build_wsdls do
|
73
|
-
require './lib/yieldmanager/builder'
|
74
|
-
Yieldmanager::Builder.build_wsdls_for(api_version)
|
75
|
-
end
|
76
|
-
|
77
|
-
desc "Delete wsdls for API version in API_VERSION file"
|
78
|
-
task :delete_wsdls do
|
79
|
-
require './lib/yieldmanager/builder'
|
80
|
-
Yieldmanager::Builder.delete_wsdls_for(api_version)
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
def api_version
|
85
|
-
version_file = "API_VERSION"
|
86
|
-
path = File.join(File.dirname(__FILE__), version_file)
|
87
|
-
unless File.exists?(path)
|
88
|
-
fail "Put the API version in a file called #{version_file}"
|
89
|
-
end
|
90
|
-
File.open(path){ |f| f.readline.chomp }
|
91
|
-
end
|
18
|
+
task :default => :spec
|
data/lib/yieldmanager/client.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'rubygems' unless RUBY_VERSION.start_with?("1.9")
|
2
2
|
require 'soap/wsdlDriver'
|
3
3
|
require 'open-uri'
|
4
|
-
require '
|
4
|
+
require 'nokogiri'
|
5
5
|
|
6
6
|
# 1.8.7 uses Hash#index as the norm, but 1.9.2 uses Hash#key
|
7
7
|
if RUBY_VERSION[0,3] == "1.9"
|
@@ -13,9 +13,9 @@ if RUBY_VERSION[0,3] == "1.9"
|
|
13
13
|
if nsdef && namedef
|
14
14
|
type_qname = XSD::QName.new(nsdef, namedef)
|
15
15
|
elsif mapped_class
|
16
|
-
# Ruby 1.8.7 way:
|
16
|
+
# Ruby 1.8.7 way:
|
17
17
|
# type_qname = TypeMap.index(mapped_class)
|
18
|
-
# Ruby 1.9.2 way:
|
18
|
+
# Ruby 1.9.2 way:
|
19
19
|
type_qname = TypeMap.key(mapped_class)
|
20
20
|
end
|
21
21
|
case io_type
|
@@ -39,7 +39,7 @@ if RUBY_VERSION[0,3] == "1.9"
|
|
39
39
|
end
|
40
40
|
end
|
41
41
|
end
|
42
|
-
|
42
|
+
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
@@ -83,7 +83,7 @@ module Yieldmanager
|
|
83
83
|
BASE_URL = "https://api.yieldmanager.com/api-"
|
84
84
|
BASE_URL_TEST = "https://api-test.yieldmanager.com/api-"
|
85
85
|
WSDL_DIR = File.join(File.dirname(__FILE__), '..', '..', 'wsdls')
|
86
|
-
|
86
|
+
|
87
87
|
# Creates interface object.
|
88
88
|
#
|
89
89
|
# Options:
|
@@ -109,7 +109,7 @@ module Yieldmanager
|
|
109
109
|
@wsdl_dir = "#{WSDL_DIR}/#{@api_version}/#{@env}"
|
110
110
|
wrap_services
|
111
111
|
end
|
112
|
-
|
112
|
+
|
113
113
|
def available_services
|
114
114
|
available_services = []
|
115
115
|
available_services_file = "AVAILABLE_SERVICES"
|
@@ -122,11 +122,11 @@ module Yieldmanager
|
|
122
122
|
end
|
123
123
|
available_services
|
124
124
|
end
|
125
|
-
|
125
|
+
|
126
126
|
def camel_to_under s
|
127
127
|
s.gsub(/(.)([A-Z])/,'\1_\2').downcase
|
128
128
|
end
|
129
|
-
|
129
|
+
|
130
130
|
# Manages Yieldmanager session
|
131
131
|
#
|
132
132
|
# Returns block with token string to be used in API/report calls
|
@@ -140,21 +140,21 @@ module Yieldmanager
|
|
140
140
|
end_session token
|
141
141
|
end
|
142
142
|
end
|
143
|
-
|
143
|
+
|
144
144
|
# Opens Yieldmanager session
|
145
145
|
#
|
146
146
|
# Use #session if possible: it guarantees no hanging sessions
|
147
147
|
def start_session
|
148
148
|
contact.login(@user,@pass,{'errors_level' => 'throw_errors','multiple_sessions' => '1'})
|
149
149
|
end
|
150
|
-
|
150
|
+
|
151
151
|
# Closes Yieldmanager session
|
152
152
|
#
|
153
153
|
# Use #session if possible: it guarantees no hanging sessions
|
154
154
|
def end_session token
|
155
155
|
contact.logout(token)
|
156
156
|
end
|
157
|
-
|
157
|
+
|
158
158
|
# Allows looping over datasets too large to pull back in one call
|
159
159
|
#
|
160
160
|
# Block must return total rows in dataset to know when to stop!
|
@@ -167,7 +167,7 @@ module Yieldmanager
|
|
167
167
|
page += 1
|
168
168
|
end until (block_size * (page-1)) > total
|
169
169
|
end
|
170
|
-
|
170
|
+
|
171
171
|
# Pulls report from RightMedia, returned as Yieldmanager::Report
|
172
172
|
#
|
173
173
|
# Must be called within the context of a session
|
@@ -187,7 +187,7 @@ module Yieldmanager
|
|
187
187
|
end
|
188
188
|
|
189
189
|
private
|
190
|
-
|
190
|
+
|
191
191
|
def wrap_services
|
192
192
|
available_services.each do |s|
|
193
193
|
self.class.send(:attr_writer, s.to_sym)
|
@@ -200,7 +200,7 @@ private
|
|
200
200
|
}
|
201
201
|
end
|
202
202
|
end
|
203
|
-
|
203
|
+
|
204
204
|
def load_service name
|
205
205
|
# FIXME Local wsdl hit throws "unknown element: {http://schemas.xmlsoap.org/wsdl/}definitions"
|
206
206
|
# wsdl_path = "file://#{@wsdl_dir}/#{name}.wsdl"
|
data/lib/yieldmanager/report.rb
CHANGED
@@ -23,16 +23,16 @@ module Yieldmanager
|
|
23
23
|
# report.data[0][0] # => "Bob's Ads"
|
24
24
|
# report.data[0].by_name('advertiser_name') # => "Bob's Ads"
|
25
25
|
# report.data[0].by_name(:advertiser_name) # => "Bob's Ads"
|
26
|
-
#
|
26
|
+
#
|
27
27
|
# Column order is stored in the *headers* array.
|
28
28
|
class Report
|
29
29
|
attr_accessor :headers, :data
|
30
|
-
|
30
|
+
|
31
31
|
def initialize
|
32
|
-
|
33
|
-
|
32
|
+
@headers = []
|
33
|
+
@data = []
|
34
34
|
end
|
35
|
-
|
35
|
+
|
36
36
|
def pull token, report, xml
|
37
37
|
report_token = request_report_token token, report, xml
|
38
38
|
report_url = retrieve_report_url token, report, report_token
|
@@ -62,7 +62,7 @@ module Yieldmanager
|
|
62
62
|
end
|
63
63
|
|
64
64
|
private
|
65
|
-
|
65
|
+
|
66
66
|
def request_report_token token, report, xml
|
67
67
|
report.requestViaXML(token,xml)
|
68
68
|
end
|
@@ -71,32 +71,30 @@ private
|
|
71
71
|
report_url = nil
|
72
72
|
60.times do |secs| # Poll until report ready
|
73
73
|
report_url = report.status(token,report_token)
|
74
|
-
break if report_url
|
74
|
+
break if report_url
|
75
75
|
pause
|
76
76
|
end
|
77
77
|
report_url
|
78
78
|
end
|
79
|
-
|
79
|
+
|
80
80
|
def retrieve_data url
|
81
81
|
retries = 5
|
82
82
|
doc = nil
|
83
83
|
while (doc == nil && retries > 0) do
|
84
84
|
begin
|
85
85
|
doc = parse_data(url)
|
86
|
-
rescue Exception
|
86
|
+
rescue Exception
|
87
87
|
retries = retries - 1
|
88
88
|
pause
|
89
89
|
end
|
90
90
|
end
|
91
91
|
raise "Failed pulling report data from #{url}" unless doc
|
92
92
|
|
93
|
-
(doc
|
94
|
-
|
95
|
-
|
96
|
-
(doc/"row").each_with_index do |row_elems,idx|
|
97
|
-
# TODO cast elements to appropriate types based on column attrs
|
93
|
+
(doc.css "HEADER COLUMN").each { |col| headers << col.inner_html }
|
94
|
+
|
95
|
+
(doc.css "ROW").each_with_index do |row_elems,idx|
|
98
96
|
row = ReportRow.new(self)
|
99
|
-
(row_elems
|
97
|
+
(row_elems.css "COLUMN").each do |col|
|
100
98
|
row << col.inner_html
|
101
99
|
end
|
102
100
|
data << row
|
@@ -104,14 +102,14 @@ private
|
|
104
102
|
end
|
105
103
|
|
106
104
|
def parse_data url
|
107
|
-
open(url)
|
105
|
+
Nokogiri::XML(open(url))
|
108
106
|
end
|
109
|
-
|
107
|
+
|
110
108
|
class ReportRow < Array
|
111
109
|
def initialize report
|
112
110
|
@report = report
|
113
111
|
end
|
114
|
-
|
112
|
+
|
115
113
|
def by_name name
|
116
114
|
idx = @report.headers.index(name.to_s)
|
117
115
|
raise ArgumentError.new("Column not found: '#{name}'") if idx.nil?
|
data/yieldmanager.gemspec
CHANGED
@@ -1,75 +1,23 @@
|
|
1
|
-
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
1
|
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "yieldmanager/version"
|
5
4
|
|
6
5
|
Gem::Specification.new do |s|
|
7
|
-
s.name
|
8
|
-
s.version
|
6
|
+
s.name = "yieldmanager"
|
7
|
+
s.version = Yieldmanager::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Bill Gathen"]
|
10
|
+
s.email = ["bill@billgathen.com"]
|
11
|
+
s.homepage = "http://github.com/billgathen/yieldmanager"
|
12
|
+
s.summary = %q{YieldManager API Tool}
|
13
|
+
s.description = %q{This gem offers full access to YieldManager's API tools (read/write) as well as ad-hoc reporting through the Reportware tool}
|
9
14
|
|
10
|
-
s.
|
11
|
-
s.
|
12
|
-
s.date = "2012-08-24"
|
13
|
-
s.description = "This gem offers full access to YieldManager's API tools (read/write) as well as ad-hoc reporting through the Reportware tool"
|
14
|
-
s.email = "bill@billgathen.com"
|
15
|
-
s.extra_rdoc_files = [
|
16
|
-
"LICENSE",
|
17
|
-
"README.md",
|
18
|
-
"TODO"
|
19
|
-
]
|
20
|
-
s.files = [
|
21
|
-
".document",
|
22
|
-
".rspec",
|
23
|
-
"API_VERSION",
|
24
|
-
"AVAILABLE_SERVICES",
|
25
|
-
"HOW_TO_UPDATE_API_VERSION",
|
26
|
-
"LICENSE",
|
27
|
-
"README.md",
|
28
|
-
"Rakefile",
|
29
|
-
"TODO",
|
30
|
-
"VERSION",
|
31
|
-
"lib/patch_detector.rb",
|
32
|
-
"lib/soap4r_19_patch/soap/generator.rb",
|
33
|
-
"lib/soap4r_19_patch/soap/property.rb",
|
34
|
-
"lib/soap4r_19_patch/xsd/charset.rb",
|
35
|
-
"lib/soap4r_19_patch/xsd/iconvcharset.rb",
|
36
|
-
"lib/soap4r_19_patch/xsd/xmlparser.rb",
|
37
|
-
"lib/wsdl/patch.rb",
|
38
|
-
"lib/yieldmanager.rb",
|
39
|
-
"lib/yieldmanager/client.rb",
|
40
|
-
"lib/yieldmanager/report.rb",
|
41
|
-
"spec/patch_detector_spec.rb",
|
42
|
-
"spec/reports/sample_report.xml",
|
43
|
-
"spec/spec.opts",
|
44
|
-
"spec/spec_helper.rb",
|
45
|
-
"spec/yieldmanager/client_spec.rb",
|
46
|
-
"spec/yieldmanager/report_spec.rb",
|
47
|
-
"yieldmanager.gemspec"
|
48
|
-
]
|
49
|
-
s.homepage = "http://github.com/billgathen/yieldmanager"
|
15
|
+
s.files = `git ls-files`.split("\n")
|
16
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
50
17
|
s.require_paths = ["lib"]
|
51
|
-
s.rubygems_version = "1.8.24"
|
52
|
-
s.summary = "Interact with RightMedia's YieldManager API and Reportware products"
|
53
|
-
|
54
|
-
if s.respond_to? :specification_version then
|
55
|
-
s.specification_version = 3
|
56
|
-
|
57
|
-
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
58
|
-
s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
|
59
|
-
s.add_development_dependency(%q<rdoc>, [">= 0"])
|
60
|
-
s.add_runtime_dependency(%q<hpricot>, ["= 0.8.2"])
|
61
|
-
s.add_runtime_dependency(%q<soap4r>, ["= 1.5.8"])
|
62
|
-
else
|
63
|
-
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
64
|
-
s.add_dependency(%q<rdoc>, [">= 0"])
|
65
|
-
s.add_dependency(%q<hpricot>, ["= 0.8.2"])
|
66
|
-
s.add_dependency(%q<soap4r>, ["= 1.5.8"])
|
67
|
-
end
|
68
|
-
else
|
69
|
-
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
70
|
-
s.add_dependency(%q<rdoc>, [">= 0"])
|
71
|
-
s.add_dependency(%q<hpricot>, ["= 0.8.2"])
|
72
|
-
s.add_dependency(%q<soap4r>, ["= 1.5.8"])
|
73
|
-
end
|
74
|
-
end
|
75
18
|
|
19
|
+
s.add_development_dependency("rspec")
|
20
|
+
s.add_development_dependency("rdoc")
|
21
|
+
s.add_runtime_dependency("nokogiri", [">= 1.5.5"])
|
22
|
+
s.add_runtime_dependency("soap4r", ["= 1.5.8"])
|
23
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yieldmanager
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-11-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
@@ -18,7 +18,7 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version:
|
21
|
+
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -26,7 +26,7 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - ! '>='
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version:
|
29
|
+
version: '0'
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: rdoc
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
@@ -44,21 +44,21 @@ dependencies:
|
|
44
44
|
- !ruby/object:Gem::Version
|
45
45
|
version: '0'
|
46
46
|
- !ruby/object:Gem::Dependency
|
47
|
-
name:
|
47
|
+
name: nokogiri
|
48
48
|
requirement: !ruby/object:Gem::Requirement
|
49
49
|
none: false
|
50
50
|
requirements:
|
51
|
-
- - '
|
51
|
+
- - ! '>='
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version:
|
53
|
+
version: 1.5.5
|
54
54
|
type: :runtime
|
55
55
|
prerelease: false
|
56
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
57
|
none: false
|
58
58
|
requirements:
|
59
|
-
- - '
|
59
|
+
- - ! '>='
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: 1.5.5
|
62
62
|
- !ruby/object:Gem::Dependency
|
63
63
|
name: soap4r
|
64
64
|
requirement: !ruby/object:Gem::Requirement
|
@@ -77,24 +77,24 @@ dependencies:
|
|
77
77
|
version: 1.5.8
|
78
78
|
description: This gem offers full access to YieldManager's API tools (read/write)
|
79
79
|
as well as ad-hoc reporting through the Reportware tool
|
80
|
-
email:
|
80
|
+
email:
|
81
|
+
- bill@billgathen.com
|
81
82
|
executables: []
|
82
83
|
extensions: []
|
83
|
-
extra_rdoc_files:
|
84
|
-
- LICENSE
|
85
|
-
- README.md
|
86
|
-
- TODO
|
84
|
+
extra_rdoc_files: []
|
87
85
|
files:
|
88
86
|
- .document
|
87
|
+
- .gitignore
|
89
88
|
- .rspec
|
89
|
+
- .rvmrc
|
90
90
|
- API_VERSION
|
91
91
|
- AVAILABLE_SERVICES
|
92
|
+
- Gemfile
|
92
93
|
- HOW_TO_UPDATE_API_VERSION
|
93
94
|
- LICENSE
|
94
95
|
- README.md
|
95
96
|
- Rakefile
|
96
97
|
- TODO
|
97
|
-
- VERSION
|
98
98
|
- lib/patch_detector.rb
|
99
99
|
- lib/soap4r_19_patch/soap/generator.rb
|
100
100
|
- lib/soap4r_19_patch/soap/property.rb
|
@@ -105,6 +105,7 @@ files:
|
|
105
105
|
- lib/yieldmanager.rb
|
106
106
|
- lib/yieldmanager/client.rb
|
107
107
|
- lib/yieldmanager/report.rb
|
108
|
+
- lib/yieldmanager/version.rb
|
108
109
|
- spec/patch_detector_spec.rb
|
109
110
|
- spec/reports/sample_report.xml
|
110
111
|
- spec/spec.opts
|
@@ -135,5 +136,11 @@ rubyforge_project:
|
|
135
136
|
rubygems_version: 1.8.24
|
136
137
|
signing_key:
|
137
138
|
specification_version: 3
|
138
|
-
summary:
|
139
|
-
test_files:
|
139
|
+
summary: YieldManager API Tool
|
140
|
+
test_files:
|
141
|
+
- spec/patch_detector_spec.rb
|
142
|
+
- spec/reports/sample_report.xml
|
143
|
+
- spec/spec.opts
|
144
|
+
- spec/spec_helper.rb
|
145
|
+
- spec/yieldmanager/client_spec.rb
|
146
|
+
- spec/yieldmanager/report_spec.rb
|
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
0.9.1
|