yieldmanager 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +20 -0
- data/VERSION +1 -1
- data/lib/yieldmanager/report.rb +12 -0
- data/spec/yieldmanager/report_spec.rb +10 -1
- data/yieldmanager.gemspec +2 -2
- metadata +4 -4
data/README.rdoc
CHANGED
@@ -103,9 +103,29 @@ Column data can be accessed either by index or column name:
|
|
103
103
|
report.data[0].by_name('advertiser_name') # => "Bob's Ads"
|
104
104
|
report.data[0].by_name(:advertiser_name) # => "Bob's Ads"
|
105
105
|
|
106
|
+
If you call *by_name* with a non-existent column, it will throw an
|
107
|
+
*ArgumentError* telling you so.
|
108
|
+
|
109
|
+
Or you can extract the report to an array of named hashes, removing
|
110
|
+
dependencies on the gem for consumers of the data (say, across an API):
|
111
|
+
|
112
|
+
hashes = report.to_hashes
|
113
|
+
hashes[0]['advertiser_name'] # => "Bob's Ads"
|
114
|
+
|
106
115
|
*NOTE* Any totals columns your xml requests will be interpreted
|
107
116
|
as ordinary data.
|
108
117
|
|
118
|
+
=== Mocking reports
|
119
|
+
|
120
|
+
When simulating report calls without actually hitting Yieldmanager, you can
|
121
|
+
create your own reports.
|
122
|
+
|
123
|
+
rpt = Yieldmanager::Report.new
|
124
|
+
rpt.headers = ["first","second"]
|
125
|
+
rpt.add_row([1,2])
|
126
|
+
rpt.data.first.by_name("first").should == 1
|
127
|
+
rpt.data.first.by_name("second").should == 2
|
128
|
+
|
109
129
|
=== session vs. start_session/end_session
|
110
130
|
|
111
131
|
The *session* method opens a session, gives you a token to use in your service
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.6.0
|
data/lib/yieldmanager/report.rb
CHANGED
@@ -32,6 +32,18 @@ module Yieldmanager
|
|
32
32
|
data << row
|
33
33
|
end
|
34
34
|
|
35
|
+
def to_hashes
|
36
|
+
hashes = []
|
37
|
+
data.each do |row|
|
38
|
+
row_hash = {}
|
39
|
+
row.each_with_index do |ele,idx|
|
40
|
+
row_hash[headers[idx]] = ele
|
41
|
+
end
|
42
|
+
hashes << row_hash
|
43
|
+
end
|
44
|
+
hashes
|
45
|
+
end
|
46
|
+
|
35
47
|
private
|
36
48
|
|
37
49
|
def request_report_token token, report, xml
|
@@ -56,12 +56,21 @@ describe "A Yieldmanager report request" do
|
|
56
56
|
report.data[0][0].should == "one"
|
57
57
|
end
|
58
58
|
|
59
|
-
it "offers data
|
59
|
+
it "offers data by name" do
|
60
60
|
report = Yieldmanager::Report.new
|
61
61
|
report.send(:retrieve_data, @sample_report)
|
62
62
|
report.data[0].by_name('first').should == "one"
|
63
63
|
report.data[1].by_name(:second).should == "2"
|
64
64
|
end
|
65
|
+
|
66
|
+
it "offers data as array of hashes" do
|
67
|
+
report = Yieldmanager::Report.new
|
68
|
+
report.send(:retrieve_data, @sample_report)
|
69
|
+
hashes = report.to_hashes
|
70
|
+
hashes.size.should == 2
|
71
|
+
hashes[0]['first'].should == "one"
|
72
|
+
hashes[1]['second'].should == "2"
|
73
|
+
end
|
65
74
|
|
66
75
|
it "by_name returns 'column not found' error when missing" do
|
67
76
|
report = Yieldmanager::Report.new
|
data/yieldmanager.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{yieldmanager}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.6.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Bill Gathen"]
|
12
|
-
s.date = %q{2010-
|
12
|
+
s.date = %q{2010-10-05}
|
13
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}
|
14
14
|
s.email = %q{bill@billgathen.com}
|
15
15
|
s.extra_rdoc_files = [
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yieldmanager
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 7
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
8
|
+
- 6
|
9
9
|
- 0
|
10
|
-
version: 0.
|
10
|
+
version: 0.6.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Bill Gathen
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-
|
18
|
+
date: 2010-10-05 00:00:00 -04:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|