zanox_publisher 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +15 -0
  3. data/.rspec +3 -0
  4. data/Gemfile +4 -0
  5. data/LICENSE.txt +22 -0
  6. data/README.md +178 -0
  7. data/Rakefile +10 -0
  8. data/lib/zanox_publisher/ad_medium.rb +232 -0
  9. data/lib/zanox_publisher/ad_space.rb +159 -0
  10. data/lib/zanox_publisher/base.rb +69 -0
  11. data/lib/zanox_publisher/category.rb +57 -0
  12. data/lib/zanox_publisher/connection.rb +291 -0
  13. data/lib/zanox_publisher/exclusive_incentive.rb +135 -0
  14. data/lib/zanox_publisher/format.rb +19 -0
  15. data/lib/zanox_publisher/incentive.rb +135 -0
  16. data/lib/zanox_publisher/incentive_base.rb +89 -0
  17. data/lib/zanox_publisher/policy.rb +42 -0
  18. data/lib/zanox_publisher/prize.rb +18 -0
  19. data/lib/zanox_publisher/product.rb +263 -0
  20. data/lib/zanox_publisher/profile.rb +123 -0
  21. data/lib/zanox_publisher/program.rb +241 -0
  22. data/lib/zanox_publisher/program_application.rb +135 -0
  23. data/lib/zanox_publisher/tracking_link.rb +42 -0
  24. data/lib/zanox_publisher/version.rb +3 -0
  25. data/lib/zanox_publisher/vertical.rb +19 -0
  26. data/lib/zanox_publisher.rb +39 -0
  27. data/spec/config/credentials.example.yml +2 -0
  28. data/spec/lib/requirements_spec.rb +9 -0
  29. data/spec/lib/zanox_publisher/ad_medium_spec.rb +162 -0
  30. data/spec/lib/zanox_publisher/ad_space_spec.rb +56 -0
  31. data/spec/lib/zanox_publisher/base_spec.rb +35 -0
  32. data/spec/lib/zanox_publisher/connection_spec.rb +68 -0
  33. data/spec/lib/zanox_publisher/exclusive_incentive_spec.rb +104 -0
  34. data/spec/lib/zanox_publisher/incentive_spec.rb +112 -0
  35. data/spec/lib/zanox_publisher/product_spec.rb +223 -0
  36. data/spec/lib/zanox_publisher/profile_spec.rb +26 -0
  37. data/spec/lib/zanox_publisher/program_application_spec.rb +51 -0
  38. data/spec/lib/zanox_publisher/program_spec.rb +192 -0
  39. data/spec/lib/zanox_ruby_spec.rb +17 -0
  40. data/spec/spec_helper.rb +21 -0
  41. data/spec/support/credentials.rb +3 -0
  42. data/spec/support/vcr.rb +8 -0
  43. data/spec/vcr_cassettes/.gitignore +4 -0
  44. data/zanox_publisher.gemspec +27 -0
  45. metadata +203 -0
@@ -0,0 +1,192 @@
1
+ require 'spec_helper'
2
+
3
+ describe ZanoxPublisher::Program do
4
+ before(:all) { ZanoxPublisher::authenticate(credentials['connect_id'], credentials['secret_key']) }
5
+ after(:all) { ZanoxPublisher::authenticate(nil, nil) }
6
+
7
+ let(:query_phrase) { 'mobile' }
8
+ let(:query_contextual) { 'Discover everything iPhone, including the most advanced mobile OS in its most advanced form and great apps that let you be creative and productive.' }
9
+ let(:program_total) do
10
+ ZanoxPublisher::Program.page
11
+ ZanoxPublisher::Program.total
12
+ end
13
+ let(:start_date) { Date.new(2011, 3, 1)}
14
+ let(:region) { 'DE' }
15
+ let(:partnership_direct) { 'DIRECT' }
16
+ let(:partnership_indirect) { 'INDIRECT' }
17
+ let(:partnership_other) { 'random' }
18
+ let(:has_products) { true }
19
+ let(:has_no_products) { false }
20
+
21
+ describe '::page', :vcr do
22
+ subject(:programs) { ZanoxPublisher::Program.page }
23
+
24
+
25
+ it { is_expected.to be_kind_of Array }
26
+ it { expect(programs.first).to be_kind_of ZanoxPublisher::Program }
27
+
28
+ it { expect(programs.count).to be > 0 }
29
+ it 'to set the Program total count' do
30
+ ZanoxPublisher::Program.total = nil
31
+ programs
32
+ expect(ZanoxPublisher::Program.total).to be > 0
33
+ end
34
+
35
+ context 'with phrase query' do
36
+ subject(:programs) { ZanoxPublisher::Program.page(0, { query: query_phrase }) }
37
+
38
+ it 'limits results to programs associated with search string' do
39
+ programs
40
+ expect(ZanoxPublisher::Program.total).to be < program_total
41
+ end
42
+ end
43
+
44
+ context 'with contextual query' do
45
+ subject(:programs) { ZanoxPublisher::Program.page(0, { query: query_contextual }) }
46
+
47
+ it 'limits results to programs associated with search string' do
48
+ programs
49
+ expect(ZanoxPublisher::Program.total).to be < program_total
50
+ end
51
+ end
52
+
53
+ context 'with q' do
54
+ subject(:programs) { ZanoxPublisher::Program.page(0, { q: query_phrase }) }
55
+
56
+ it 'limits results to programs associated with search string' do
57
+ programs
58
+ expect(ZanoxPublisher::Program.total).to be < program_total
59
+ end
60
+ end
61
+
62
+ context 'with start_date' do
63
+ subject(:programs) { ZanoxPublisher::Program.page(0, { start_date: start_date }) }
64
+
65
+ it { expect(programs.all? { |program| program.start_date > start_date }).to be true }
66
+ end
67
+
68
+ context 'with region' do
69
+ subject(:programs) { ZanoxPublisher::Program.page(0, { region: region }) }
70
+
71
+ it { expect(programs.all? { |program| program.regions.include? region }).to be true }
72
+ end
73
+
74
+ context 'with direct partnership' do
75
+ subject(:programs) { ZanoxPublisher::Program.page(0, { partnership: partnership_direct }) }
76
+
77
+ it 'limits results to programs with mandatory application' do
78
+ programs
79
+ expect(ZanoxPublisher::Program.total).to be < program_total
80
+ end
81
+
82
+ it { expect(programs.all? { |o| o.application_required == true }).to be true }
83
+ end
84
+
85
+ context 'with indirect partnership' do
86
+ subject(:programs) { ZanoxPublisher::Program.page(0, { partnership: partnership_indirect }) }
87
+
88
+ it 'limits results to programs without application requirement' do
89
+ programs
90
+ expect(ZanoxPublisher::Program.total).to be < program_total
91
+ end
92
+
93
+ it { expect(programs.all? { |o| o.application_required == false }).to be true }
94
+ end
95
+
96
+ context 'with random partnership' do
97
+ subject(:programs) { ZanoxPublisher::Program.page(0, { partnership: partnership_other }) }
98
+
99
+ it { expect{ programs }.to raise_error(ZanoxPublisher::BadRequest) }
100
+ end
101
+
102
+ context 'with has_products' do
103
+ subject(:programs) { ZanoxPublisher::Program.page(0, { has_products: has_products })}
104
+
105
+ it 'limits results to programs with products' do
106
+ programs
107
+ expect(ZanoxPublisher::Program.total).to be < program_total
108
+ end
109
+ end
110
+
111
+ context 'with hasproducts' do
112
+ subject(:programs) { ZanoxPublisher::Program.page(0, { hasproducts: has_products })}
113
+
114
+ it 'limits results to programs with products' do
115
+ programs
116
+ expect(ZanoxPublisher::Program.total).to be < program_total
117
+ end
118
+ end
119
+
120
+ context 'with has_products other than true' do
121
+ subject(:programs) { ZanoxPublisher::Program.page(0, { has_products: has_no_products })}
122
+
123
+ it 'has no effect on results' do
124
+ programs
125
+ expect(ZanoxPublisher::Program.total).to be == program_total
126
+ end
127
+ end
128
+ end
129
+
130
+ describe '::all', :vcr do
131
+ subject(:programs) { ZanoxPublisher::Program.all region: region, has_products: true, partnership: partnership_direct }
132
+
133
+ it { is_expected.to be_kind_of Array }
134
+ it { expect(programs.first).to be_kind_of ZanoxPublisher::Program }
135
+
136
+ it { expect(programs.count).to be == ZanoxPublisher::Program.total }
137
+ it { expect(programs.all? { |program| program.regions.include?(region) and program.application_required == true }).to be true}
138
+ end
139
+
140
+ describe '::find', vcr: { record: :new_episodes } do
141
+ let(:first) do
142
+ ZanoxPublisher::Program.page.first
143
+ end
144
+
145
+ subject(:find) { ZanoxPublisher::Program.find(first.id) }
146
+
147
+ it { is_expected.to be_kind_of ZanoxPublisher::Program }
148
+
149
+ it { expect(find.id).to be == first.id }
150
+ it { expect(find.name).to be == first.name }
151
+ it { expect(find.adrank).to be == first.adrank }
152
+ it { expect(find.application_required).to be == first.application_required }
153
+ it { expect(find.description).to be == first.description }
154
+
155
+ context 'with Program parameter' do
156
+ subject(:find) { ZanoxPublisher::Program.find(first) }
157
+
158
+ it { is_expected.to be_kind_of ZanoxPublisher::Program }
159
+
160
+ it { expect(find.id).to be == first.id }
161
+ it { expect(find.name).to be == first.name }
162
+ it { expect(find.adrank).to be == first.adrank }
163
+ it { expect(find.application_required).to be == first.application_required }
164
+ it { expect(find.description).to be == first.description }
165
+ end
166
+ end
167
+
168
+ describe '::categories', :vcr do
169
+ subject { ZanoxPublisher::Program.categories }
170
+
171
+ it { is_expected.to be_kind_of Array }
172
+ it { expect(subject.first).to be_kind_of ZanoxPublisher::Category }
173
+ it { expect(subject.count).to be > 0 }
174
+ end
175
+
176
+ describe 'item', :vcr do
177
+ subject(:progam) { ZanoxPublisher::Program.page.first }
178
+
179
+ it 'responds to to_i with its ID' do
180
+ expect(progam.to_i).to be == progam.id
181
+ end
182
+ end
183
+
184
+ describe '#admedia_categories', vcr: { record: :new_episodes } do
185
+ subject(:progam) { ZanoxPublisher::Program.page.first }
186
+
187
+ it { is_expected.to respond_to :admedia_categories }
188
+ it { expect(progam.admedia_categories).to be_kind_of Array }
189
+ it { expect(progam.admedia_categories.count).to be > 0 }
190
+ it { expect(progam.admedia_categories.first).to be_kind_of ZanoxPublisher::Category }
191
+ end
192
+ end
@@ -0,0 +1,17 @@
1
+ require 'spec_helper'
2
+
3
+ describe ZanoxPublisher do
4
+ context "version" do
5
+ it "should be defined" do
6
+ expect(ZanoxPublisher::VERSION).not_to be_nil
7
+ end
8
+ end
9
+
10
+ context "::authenticate" do
11
+ it "should set connect ID and secret" do
12
+ ZanoxPublisher::authenticate(credentials['connect_id'], credentials['secret_key'])
13
+ expect(ZanoxPublisher::connect_id).to eql credentials['connect_id']
14
+ expect(ZanoxPublisher::secret_key).to eql credentials['secret_key']
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,21 @@
1
+ require 'zanox_publisher'
2
+ require 'support/vcr'
3
+ require 'support/credentials'
4
+
5
+ RSpec.configure do |config|
6
+ config.filter_run :focus
7
+ config.run_all_when_everything_filtered = true
8
+
9
+ config.order = :random
10
+ Kernel.srand config.seed
11
+
12
+ config.expect_with :rspec do |expectations|
13
+ expectations.syntax = :expect
14
+ end
15
+
16
+ config.mock_with :rspec do |mocks|
17
+ mocks.syntax = :expect
18
+
19
+ mocks.verify_partial_doubles = true
20
+ end
21
+ end
@@ -0,0 +1,3 @@
1
+ def credentials
2
+ @credentials ||= YAML.load_file("#{File.dirname(__FILE__)}/../config/credentials.yml")
3
+ end
@@ -0,0 +1,8 @@
1
+ require 'vcr'
2
+
3
+ VCR.configure do |c|
4
+ c.cassette_library_dir = 'spec/vcr_cassettes'
5
+ c.allow_http_connections_when_no_cassette = true
6
+ c.hook_into :webmock
7
+ c.configure_rspec_metadata!
8
+ end
@@ -0,0 +1,4 @@
1
+ # Ignore everything in this directory
2
+ *
3
+ # Except this file
4
+ !.gitignore
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'zanox_publisher/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'zanox_publisher'
8
+ spec.version = ZanoxPublisher::VERSION
9
+ spec.authors = ['Oliver Prater']
10
+ spec.email = ['oliver.prater@gmail.com']
11
+ spec.summary = %q{A ruby wrapper for the ZANOX Publisher API.}
12
+ spec.homepage = 'http://rubygems.org/gems/zanox_publisher'
13
+ spec.license = 'MIT'
14
+
15
+ spec.files = `git ls-files -z`.split("\x0")
16
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
17
+ spec.require_paths = ['lib']
18
+
19
+ spec.add_development_dependency 'bundler', '~> 1.7'
20
+ spec.add_development_dependency 'rake', '~> 10.0'
21
+ spec.add_development_dependency 'yard', '~> 0.8.7'
22
+ spec.add_development_dependency 'rspec', '~> 3.1'
23
+ spec.add_development_dependency 'webmock', '~> 1.20'
24
+ spec.add_development_dependency 'vcr', '~> 2.9'
25
+
26
+ spec.add_dependency 'httparty', '~> 0.13'
27
+ end
metadata ADDED
@@ -0,0 +1,203 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: zanox_publisher
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Oliver Prater
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-03-18 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: yard
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 0.8.7
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 0.8.7
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.1'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.1'
69
+ - !ruby/object:Gem::Dependency
70
+ name: webmock
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.20'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.20'
83
+ - !ruby/object:Gem::Dependency
84
+ name: vcr
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '2.9'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '2.9'
97
+ - !ruby/object:Gem::Dependency
98
+ name: httparty
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '0.13'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '0.13'
111
+ description:
112
+ email:
113
+ - oliver.prater@gmail.com
114
+ executables: []
115
+ extensions: []
116
+ extra_rdoc_files: []
117
+ files:
118
+ - ".gitignore"
119
+ - ".rspec"
120
+ - Gemfile
121
+ - LICENSE.txt
122
+ - README.md
123
+ - Rakefile
124
+ - lib/zanox_publisher.rb
125
+ - lib/zanox_publisher/ad_medium.rb
126
+ - lib/zanox_publisher/ad_space.rb
127
+ - lib/zanox_publisher/base.rb
128
+ - lib/zanox_publisher/category.rb
129
+ - lib/zanox_publisher/connection.rb
130
+ - lib/zanox_publisher/exclusive_incentive.rb
131
+ - lib/zanox_publisher/format.rb
132
+ - lib/zanox_publisher/incentive.rb
133
+ - lib/zanox_publisher/incentive_base.rb
134
+ - lib/zanox_publisher/policy.rb
135
+ - lib/zanox_publisher/prize.rb
136
+ - lib/zanox_publisher/product.rb
137
+ - lib/zanox_publisher/profile.rb
138
+ - lib/zanox_publisher/program.rb
139
+ - lib/zanox_publisher/program_application.rb
140
+ - lib/zanox_publisher/tracking_link.rb
141
+ - lib/zanox_publisher/version.rb
142
+ - lib/zanox_publisher/vertical.rb
143
+ - spec/config/credentials.example.yml
144
+ - spec/lib/requirements_spec.rb
145
+ - spec/lib/zanox_publisher/ad_medium_spec.rb
146
+ - spec/lib/zanox_publisher/ad_space_spec.rb
147
+ - spec/lib/zanox_publisher/base_spec.rb
148
+ - spec/lib/zanox_publisher/connection_spec.rb
149
+ - spec/lib/zanox_publisher/exclusive_incentive_spec.rb
150
+ - spec/lib/zanox_publisher/incentive_spec.rb
151
+ - spec/lib/zanox_publisher/product_spec.rb
152
+ - spec/lib/zanox_publisher/profile_spec.rb
153
+ - spec/lib/zanox_publisher/program_application_spec.rb
154
+ - spec/lib/zanox_publisher/program_spec.rb
155
+ - spec/lib/zanox_ruby_spec.rb
156
+ - spec/spec_helper.rb
157
+ - spec/support/credentials.rb
158
+ - spec/support/vcr.rb
159
+ - spec/vcr_cassettes/.gitignore
160
+ - zanox_publisher.gemspec
161
+ homepage: http://rubygems.org/gems/zanox_publisher
162
+ licenses:
163
+ - MIT
164
+ metadata: {}
165
+ post_install_message:
166
+ rdoc_options: []
167
+ require_paths:
168
+ - lib
169
+ required_ruby_version: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - ">="
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ required_rubygems_version: !ruby/object:Gem::Requirement
175
+ requirements:
176
+ - - ">="
177
+ - !ruby/object:Gem::Version
178
+ version: '0'
179
+ requirements: []
180
+ rubyforge_project:
181
+ rubygems_version: 2.4.5
182
+ signing_key:
183
+ specification_version: 4
184
+ summary: A ruby wrapper for the ZANOX Publisher API.
185
+ test_files:
186
+ - spec/config/credentials.example.yml
187
+ - spec/lib/requirements_spec.rb
188
+ - spec/lib/zanox_publisher/ad_medium_spec.rb
189
+ - spec/lib/zanox_publisher/ad_space_spec.rb
190
+ - spec/lib/zanox_publisher/base_spec.rb
191
+ - spec/lib/zanox_publisher/connection_spec.rb
192
+ - spec/lib/zanox_publisher/exclusive_incentive_spec.rb
193
+ - spec/lib/zanox_publisher/incentive_spec.rb
194
+ - spec/lib/zanox_publisher/product_spec.rb
195
+ - spec/lib/zanox_publisher/profile_spec.rb
196
+ - spec/lib/zanox_publisher/program_application_spec.rb
197
+ - spec/lib/zanox_publisher/program_spec.rb
198
+ - spec/lib/zanox_ruby_spec.rb
199
+ - spec/spec_helper.rb
200
+ - spec/support/credentials.rb
201
+ - spec/support/vcr.rb
202
+ - spec/vcr_cassettes/.gitignore
203
+ has_rdoc: