neuron-client 0.2.6 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +11 -8
- data/lib/neuron-client/api.rb +5 -0
- data/lib/neuron-client/model/ad.rb +142 -0
- data/lib/neuron-client/model/ad_calculations.rb +325 -0
- data/lib/neuron-client/model/ad_zone.rb +45 -0
- data/lib/neuron-client/model/base.rb +233 -18
- data/lib/neuron-client/model/blocked_referer.rb +20 -0
- data/lib/neuron-client/model/blocked_user_agent.rb +21 -0
- data/lib/neuron-client/model/geo_target.rb +36 -0
- data/lib/neuron-client/model/pixel.rb +22 -0
- data/lib/neuron-client/model/report.rb +35 -0
- data/lib/neuron-client/model/s3_file.rb +30 -0
- data/lib/neuron-client/model/zone.rb +64 -0
- data/lib/neuron-client/model/zone_calculations.rb +37 -0
- data/lib/neuron-client/schema/ad.rb +406 -0
- data/lib/neuron-client/schema/ad_zone.rb +49 -0
- data/lib/neuron-client/schema/blocked_referer.rb +52 -0
- data/lib/neuron-client/schema/blocked_user_agent.rb +64 -0
- data/lib/neuron-client/schema/common.rb +220 -0
- data/lib/neuron-client/schema/event.rb +17 -0
- data/lib/neuron-client/schema/geo_target.rb +33 -0
- data/lib/neuron-client/schema/pixel.rb +39 -0
- data/lib/neuron-client/schema/report.rb +59 -0
- data/lib/neuron-client/schema/s3_file.rb +87 -0
- data/lib/neuron-client/schema/zone.rb +214 -0
- data/lib/neuron-client/version.rb +1 -1
- data/lib/neuron-client.rb +24 -59
- data/neuron-client.gemspec +3 -0
- data/spec/lib/admin_connection_spec.rb +234 -0
- data/spec/lib/api_spec.rb +41 -63
- data/spec/lib/model/ad_calculations_spec.rb +1146 -0
- data/spec/lib/model/ad_spec.rb +253 -0
- data/spec/lib/model/ad_zone_spec.rb +15 -0
- data/spec/lib/model/base_spec.rb +5 -83
- data/spec/lib/model/blocked_referer_spec.rb +36 -0
- data/spec/lib/model/blocked_user_agent_spec.rb +36 -0
- data/spec/lib/model/geo_target_spec.rb +28 -0
- data/spec/lib/model/pixel_spec.rb +36 -0
- data/spec/lib/model/report_spec.rb +17 -0
- data/spec/lib/{s3_file_spec.rb → model/s3_file_spec.rb} +6 -5
- data/spec/lib/model/zone_calculations_spec.rb +49 -0
- data/spec/lib/model/zone_spec.rb +155 -0
- data/spec/lib/schema/ad_spec.rb +515 -0
- data/spec/lib/schema/ad_zone_spec.rb +149 -0
- data/spec/lib/schema/blocked_referer_spec.rb +136 -0
- data/spec/lib/schema/blocked_user_agent_spec.rb +147 -0
- data/spec/lib/schema/geo_target_spec.rb +92 -0
- data/spec/lib/schema/pixel_spec.rb +125 -0
- data/spec/lib/schema/report_spec.rb +129 -0
- data/spec/lib/schema/s3_file_spec.rb +164 -0
- data/spec/lib/schema/zone_spec.rb +243 -0
- data/spec/spec_helper.rb +2 -1
- metadata +141 -121
- data/lib/neuron-client/model/admin/ad.rb +0 -22
- data/lib/neuron-client/model/admin/ad_zone.rb +0 -15
- data/lib/neuron-client/model/admin/base.rb +0 -91
- data/lib/neuron-client/model/admin/blocked_referer.rb +0 -12
- data/lib/neuron-client/model/admin/blocked_user_agent.rb +0 -12
- data/lib/neuron-client/model/admin/geo_target.rb +0 -16
- data/lib/neuron-client/model/admin/pixel.rb +0 -12
- data/lib/neuron-client/model/admin/report.rb +0 -15
- data/lib/neuron-client/model/admin/s3_file.rb +0 -12
- data/lib/neuron-client/model/admin/zone.rb +0 -15
- data/lib/neuron-client/model/common/ad.rb +0 -42
- data/lib/neuron-client/model/common/ad_calculations.rb +0 -329
- data/lib/neuron-client/model/common/ad_zone.rb +0 -17
- data/lib/neuron-client/model/common/base.rb +0 -67
- data/lib/neuron-client/model/common/blocked_referer.rb +0 -16
- data/lib/neuron-client/model/common/blocked_user_agent.rb +0 -16
- data/lib/neuron-client/model/common/geo_target.rb +0 -16
- data/lib/neuron-client/model/common/pixel.rb +0 -18
- data/lib/neuron-client/model/common/report.rb +0 -21
- data/lib/neuron-client/model/common/s3_file.rb +0 -16
- data/lib/neuron-client/model/common/zone.rb +0 -22
- data/lib/neuron-client/model/common/zone_calculations.rb +0 -41
- data/lib/neuron-client/model/membase/ad.rb +0 -49
- data/lib/neuron-client/model/membase/ad_zone.rb +0 -11
- data/lib/neuron-client/model/membase/blocked_referer.rb +0 -20
- data/lib/neuron-client/model/membase/blocked_user_agent.rb +0 -20
- data/lib/neuron-client/model/membase/geo_target.rb +0 -11
- data/lib/neuron-client/model/membase/pixel.rb +0 -22
- data/lib/neuron-client/model/membase/report.rb +0 -11
- data/lib/neuron-client/model/membase/s3_file.rb +0 -11
- data/lib/neuron-client/model/membase/zone.rb +0 -30
- data/lib/neuron-client/model/models.rb +0 -15
- data/spec/lib/model/admin/ad_spec.rb +0 -34
- data/spec/lib/model/admin/ad_zone_spec.rb +0 -19
- data/spec/lib/model/admin/base_spec.rb +0 -11
- data/spec/lib/model/admin/blocked_referer_spec.rb +0 -11
- data/spec/lib/model/admin/blocked_user_agent_spec.rb +0 -11
- data/spec/lib/model/admin/geo_target_spec.rb +0 -30
- data/spec/lib/model/admin/report_spec.rb +0 -21
- data/spec/lib/model/admin/s3_spec.rb +0 -11
- data/spec/lib/model/admin/zone_spec.rb +0 -21
- data/spec/lib/model/common/ad_calculations_spec.rb +0 -1151
- data/spec/lib/model/common/ad_spec.rb +0 -11
- data/spec/lib/model/common/ad_zone_spec.rb +0 -11
- data/spec/lib/model/common/base_spec.rb +0 -11
- data/spec/lib/model/common/blocked_referer_spec.rb +0 -11
- data/spec/lib/model/common/blocked_user_agent_spec.rb +0 -11
- data/spec/lib/model/common/geo_target_spec.rb +0 -11
- data/spec/lib/model/common/report_spec.rb +0 -11
- data/spec/lib/model/common/s3_spec.rb +0 -11
- data/spec/lib/model/common/zone_calculations_spec.rb +0 -54
- data/spec/lib/model/common/zone_spec.rb +0 -11
- data/spec/lib/model/membase/ad_spec.rb +0 -54
- data/spec/lib/model/membase/ad_zone_spec.rb +0 -11
- data/spec/lib/model/membase/base_spec.rb +0 -11
- data/spec/lib/model/membase/blocked_referer_spec.rb +0 -34
- data/spec/lib/model/membase/blocked_user_agent_spec.rb +0 -34
- data/spec/lib/model/membase/geo_target_spec.rb +0 -11
- data/spec/lib/model/membase/pixel_spec.rb +0 -34
- data/spec/lib/model/membase/report_spec.rb +0 -11
- data/spec/lib/model/membase/s3_spec.rb +0 -11
- data/spec/lib/model/membase/zone_spec.rb +0 -32
- data/spec/lib/old_spec.rb +0 -437
@@ -1,22 +0,0 @@
|
|
1
|
-
module Neuron
|
2
|
-
module Client
|
3
|
-
module Model
|
4
|
-
module Membase
|
5
|
-
class Pixel < Common::Pixel
|
6
|
-
|
7
|
-
class << self
|
8
|
-
def find(id)
|
9
|
-
self.connection.local_cache.fetch("Neuron::Client::Model::Pixel:#{id}") do
|
10
|
-
pixel = nil
|
11
|
-
membase_key = "Pixel:#{id}"
|
12
|
-
cached_json = self.connection.get(membase_key)
|
13
|
-
pixel = self.new(Yajl.load(cached_json)[superclass.resource_name]) if cached_json.present?
|
14
|
-
pixel
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
module Neuron
|
2
|
-
module Client
|
3
|
-
module Model
|
4
|
-
module Membase
|
5
|
-
class Zone < Common::Zone
|
6
|
-
|
7
|
-
ADS_BY_PRIORITY_TTL = 60
|
8
|
-
|
9
|
-
def ads_by_priority
|
10
|
-
self.class.connection.fetch("Zone:#{id}:ads_by_priority", ADS_BY_PRIORITY_TTL) do
|
11
|
-
calculate_ads_by_priority
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
class << self
|
16
|
-
def find(id)
|
17
|
-
self.connection.local_cache.fetch("Neuron::Client::Model::Zone:#{id}") do
|
18
|
-
zone = nil
|
19
|
-
membase_key = "Zone:#{id}"
|
20
|
-
cached_json = self.connection.get(membase_key)
|
21
|
-
zone = self.new(Yajl.load(cached_json)[superclass.resource_name]) if cached_json.present?
|
22
|
-
zone
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
module Neuron
|
2
|
-
module Client
|
3
|
-
module Model
|
4
|
-
class Ad < Base; end
|
5
|
-
class AdZone < Base; end
|
6
|
-
class BlockedReferer < Base; end
|
7
|
-
class BlockedUserAgent < Base; end
|
8
|
-
class GeoTarget < Base; end
|
9
|
-
class Pixel < Base; end
|
10
|
-
class Report < Base; end
|
11
|
-
class S3File < Base; end
|
12
|
-
class Zone < Base; end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
@@ -1,34 +0,0 @@
|
|
1
|
-
module Neuron
|
2
|
-
module Client
|
3
|
-
module Model
|
4
|
-
module Admin
|
5
|
-
describe Ad do
|
6
|
-
describe "recent(statistic, parameters)" do
|
7
|
-
it "should call the expecte method and return the expected result" do
|
8
|
-
a = Ad.allocate
|
9
|
-
c = stub(:connection)
|
10
|
-
a.class.should_receive(:connection).and_return(c)
|
11
|
-
a.should_receive(:id).and_return(7)
|
12
|
-
p = stub(:parameters)
|
13
|
-
c.should_receive(:get).with('ads/7/recent/statistic_value', p).and_return('return_value')
|
14
|
-
|
15
|
-
a.recent('statistic_value', p).should == 'return_value'
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
describe "unlink(ad_id)" do
|
20
|
-
it "should call the expected method and return the expected result" do
|
21
|
-
a = Ad.allocate
|
22
|
-
c = stub(:connection)
|
23
|
-
a.class.should_receive(:connection).and_return(c)
|
24
|
-
a.should_receive(:id).and_return(7)
|
25
|
-
c.should_receive(:delete).with('ads/7/zones/33').and_return('return_value')
|
26
|
-
|
27
|
-
a.unlink(33).should == 'return_value'
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
module Neuron
|
2
|
-
module Client
|
3
|
-
module Model
|
4
|
-
module Admin
|
5
|
-
describe AdZone do
|
6
|
-
describe "self.unlink(ad_id, zone_id)" do
|
7
|
-
it "should call the expected method and return the expected value" do
|
8
|
-
c = stub(:connection)
|
9
|
-
AdZone.should_receive(:connection).and_return(c)
|
10
|
-
c.should_receive(:delete).with('zones/1/ads/2').and_return('return_value')
|
11
|
-
|
12
|
-
AdZone.unlink(2, 1).should == 'return_value'
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
module Neuron
|
2
|
-
module Client
|
3
|
-
module Model
|
4
|
-
module Admin
|
5
|
-
describe GeoTarget do
|
6
|
-
describe "self.query(parameters)" do
|
7
|
-
it "should call the expected methods and return the expected value" do
|
8
|
-
c = stub(:connection)
|
9
|
-
GeoTarget.should_receive(:connection).and_return(c)
|
10
|
-
p = stub(:parameters)
|
11
|
-
gta = stub(:geo_target_attributes)
|
12
|
-
gta2 = stub(:geo_target_attributes)
|
13
|
-
r = [
|
14
|
-
{'geo_target' => gta},
|
15
|
-
{'geo_target' => gta2}
|
16
|
-
]
|
17
|
-
c.should_receive(:get).with('geo_targets', p).and_return(r)
|
18
|
-
g = stub(:geo_target)
|
19
|
-
g2 = stub(:geo_target2)
|
20
|
-
GeoTarget.should_receive(:new).with(gta).and_return(g)
|
21
|
-
GeoTarget.should_receive(:new).with(gta2).and_return(g2)
|
22
|
-
|
23
|
-
GeoTarget.query(p).should == [g, g2]
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
module Neuron
|
2
|
-
module Client
|
3
|
-
module Model
|
4
|
-
module Admin
|
5
|
-
describe Report do
|
6
|
-
describe "result" do
|
7
|
-
it "should call the expected methods and return the expected result" do
|
8
|
-
r = Report.allocate
|
9
|
-
c = stub(:connection)
|
10
|
-
Report.should_receive(:connection).and_return(c)
|
11
|
-
r.should_receive(:id).and_return(7)
|
12
|
-
c.should_receive(:get).with('reports/7/result', :format => '').and_return('result_value')
|
13
|
-
|
14
|
-
r.result.should == 'result_value'
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
module Neuron
|
2
|
-
module Client
|
3
|
-
module Model
|
4
|
-
module Admin
|
5
|
-
describe Zone do
|
6
|
-
describe "unlink(ad_id)" do
|
7
|
-
it "should call the expected method and return the expected results" do
|
8
|
-
z = Zone.allocate
|
9
|
-
c = stub(:connection)
|
10
|
-
Zone.should_receive(:connection).and_return(c)
|
11
|
-
z.should_receive(:id).and_return(1)
|
12
|
-
c.should_receive(:delete).with('zones/1/ads/2').and_return('result_value')
|
13
|
-
|
14
|
-
z.unlink(2).should == 'result_value'
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|