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.
Files changed (116) hide show
  1. data/README.md +11 -8
  2. data/lib/neuron-client/api.rb +5 -0
  3. data/lib/neuron-client/model/ad.rb +142 -0
  4. data/lib/neuron-client/model/ad_calculations.rb +325 -0
  5. data/lib/neuron-client/model/ad_zone.rb +45 -0
  6. data/lib/neuron-client/model/base.rb +233 -18
  7. data/lib/neuron-client/model/blocked_referer.rb +20 -0
  8. data/lib/neuron-client/model/blocked_user_agent.rb +21 -0
  9. data/lib/neuron-client/model/geo_target.rb +36 -0
  10. data/lib/neuron-client/model/pixel.rb +22 -0
  11. data/lib/neuron-client/model/report.rb +35 -0
  12. data/lib/neuron-client/model/s3_file.rb +30 -0
  13. data/lib/neuron-client/model/zone.rb +64 -0
  14. data/lib/neuron-client/model/zone_calculations.rb +37 -0
  15. data/lib/neuron-client/schema/ad.rb +406 -0
  16. data/lib/neuron-client/schema/ad_zone.rb +49 -0
  17. data/lib/neuron-client/schema/blocked_referer.rb +52 -0
  18. data/lib/neuron-client/schema/blocked_user_agent.rb +64 -0
  19. data/lib/neuron-client/schema/common.rb +220 -0
  20. data/lib/neuron-client/schema/event.rb +17 -0
  21. data/lib/neuron-client/schema/geo_target.rb +33 -0
  22. data/lib/neuron-client/schema/pixel.rb +39 -0
  23. data/lib/neuron-client/schema/report.rb +59 -0
  24. data/lib/neuron-client/schema/s3_file.rb +87 -0
  25. data/lib/neuron-client/schema/zone.rb +214 -0
  26. data/lib/neuron-client/version.rb +1 -1
  27. data/lib/neuron-client.rb +24 -59
  28. data/neuron-client.gemspec +3 -0
  29. data/spec/lib/admin_connection_spec.rb +234 -0
  30. data/spec/lib/api_spec.rb +41 -63
  31. data/spec/lib/model/ad_calculations_spec.rb +1146 -0
  32. data/spec/lib/model/ad_spec.rb +253 -0
  33. data/spec/lib/model/ad_zone_spec.rb +15 -0
  34. data/spec/lib/model/base_spec.rb +5 -83
  35. data/spec/lib/model/blocked_referer_spec.rb +36 -0
  36. data/spec/lib/model/blocked_user_agent_spec.rb +36 -0
  37. data/spec/lib/model/geo_target_spec.rb +28 -0
  38. data/spec/lib/model/pixel_spec.rb +36 -0
  39. data/spec/lib/model/report_spec.rb +17 -0
  40. data/spec/lib/{s3_file_spec.rb → model/s3_file_spec.rb} +6 -5
  41. data/spec/lib/model/zone_calculations_spec.rb +49 -0
  42. data/spec/lib/model/zone_spec.rb +155 -0
  43. data/spec/lib/schema/ad_spec.rb +515 -0
  44. data/spec/lib/schema/ad_zone_spec.rb +149 -0
  45. data/spec/lib/schema/blocked_referer_spec.rb +136 -0
  46. data/spec/lib/schema/blocked_user_agent_spec.rb +147 -0
  47. data/spec/lib/schema/geo_target_spec.rb +92 -0
  48. data/spec/lib/schema/pixel_spec.rb +125 -0
  49. data/spec/lib/schema/report_spec.rb +129 -0
  50. data/spec/lib/schema/s3_file_spec.rb +164 -0
  51. data/spec/lib/schema/zone_spec.rb +243 -0
  52. data/spec/spec_helper.rb +2 -1
  53. metadata +141 -121
  54. data/lib/neuron-client/model/admin/ad.rb +0 -22
  55. data/lib/neuron-client/model/admin/ad_zone.rb +0 -15
  56. data/lib/neuron-client/model/admin/base.rb +0 -91
  57. data/lib/neuron-client/model/admin/blocked_referer.rb +0 -12
  58. data/lib/neuron-client/model/admin/blocked_user_agent.rb +0 -12
  59. data/lib/neuron-client/model/admin/geo_target.rb +0 -16
  60. data/lib/neuron-client/model/admin/pixel.rb +0 -12
  61. data/lib/neuron-client/model/admin/report.rb +0 -15
  62. data/lib/neuron-client/model/admin/s3_file.rb +0 -12
  63. data/lib/neuron-client/model/admin/zone.rb +0 -15
  64. data/lib/neuron-client/model/common/ad.rb +0 -42
  65. data/lib/neuron-client/model/common/ad_calculations.rb +0 -329
  66. data/lib/neuron-client/model/common/ad_zone.rb +0 -17
  67. data/lib/neuron-client/model/common/base.rb +0 -67
  68. data/lib/neuron-client/model/common/blocked_referer.rb +0 -16
  69. data/lib/neuron-client/model/common/blocked_user_agent.rb +0 -16
  70. data/lib/neuron-client/model/common/geo_target.rb +0 -16
  71. data/lib/neuron-client/model/common/pixel.rb +0 -18
  72. data/lib/neuron-client/model/common/report.rb +0 -21
  73. data/lib/neuron-client/model/common/s3_file.rb +0 -16
  74. data/lib/neuron-client/model/common/zone.rb +0 -22
  75. data/lib/neuron-client/model/common/zone_calculations.rb +0 -41
  76. data/lib/neuron-client/model/membase/ad.rb +0 -49
  77. data/lib/neuron-client/model/membase/ad_zone.rb +0 -11
  78. data/lib/neuron-client/model/membase/blocked_referer.rb +0 -20
  79. data/lib/neuron-client/model/membase/blocked_user_agent.rb +0 -20
  80. data/lib/neuron-client/model/membase/geo_target.rb +0 -11
  81. data/lib/neuron-client/model/membase/pixel.rb +0 -22
  82. data/lib/neuron-client/model/membase/report.rb +0 -11
  83. data/lib/neuron-client/model/membase/s3_file.rb +0 -11
  84. data/lib/neuron-client/model/membase/zone.rb +0 -30
  85. data/lib/neuron-client/model/models.rb +0 -15
  86. data/spec/lib/model/admin/ad_spec.rb +0 -34
  87. data/spec/lib/model/admin/ad_zone_spec.rb +0 -19
  88. data/spec/lib/model/admin/base_spec.rb +0 -11
  89. data/spec/lib/model/admin/blocked_referer_spec.rb +0 -11
  90. data/spec/lib/model/admin/blocked_user_agent_spec.rb +0 -11
  91. data/spec/lib/model/admin/geo_target_spec.rb +0 -30
  92. data/spec/lib/model/admin/report_spec.rb +0 -21
  93. data/spec/lib/model/admin/s3_spec.rb +0 -11
  94. data/spec/lib/model/admin/zone_spec.rb +0 -21
  95. data/spec/lib/model/common/ad_calculations_spec.rb +0 -1151
  96. data/spec/lib/model/common/ad_spec.rb +0 -11
  97. data/spec/lib/model/common/ad_zone_spec.rb +0 -11
  98. data/spec/lib/model/common/base_spec.rb +0 -11
  99. data/spec/lib/model/common/blocked_referer_spec.rb +0 -11
  100. data/spec/lib/model/common/blocked_user_agent_spec.rb +0 -11
  101. data/spec/lib/model/common/geo_target_spec.rb +0 -11
  102. data/spec/lib/model/common/report_spec.rb +0 -11
  103. data/spec/lib/model/common/s3_spec.rb +0 -11
  104. data/spec/lib/model/common/zone_calculations_spec.rb +0 -54
  105. data/spec/lib/model/common/zone_spec.rb +0 -11
  106. data/spec/lib/model/membase/ad_spec.rb +0 -54
  107. data/spec/lib/model/membase/ad_zone_spec.rb +0 -11
  108. data/spec/lib/model/membase/base_spec.rb +0 -11
  109. data/spec/lib/model/membase/blocked_referer_spec.rb +0 -34
  110. data/spec/lib/model/membase/blocked_user_agent_spec.rb +0 -34
  111. data/spec/lib/model/membase/geo_target_spec.rb +0 -11
  112. data/spec/lib/model/membase/pixel_spec.rb +0 -34
  113. data/spec/lib/model/membase/report_spec.rb +0 -11
  114. data/spec/lib/model/membase/s3_spec.rb +0 -11
  115. data/spec/lib/model/membase/zone_spec.rb +0 -32
  116. data/spec/lib/old_spec.rb +0 -437
@@ -1,11 +0,0 @@
1
- module Neuron
2
- module Client
3
- module Model
4
- module Membase
5
- class GeoTarget < Common::GeoTarget
6
-
7
- end
8
- end
9
- end
10
- end
11
- end
@@ -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,11 +0,0 @@
1
- module Neuron
2
- module Client
3
- module Model
4
- module Membase
5
- class Report < Common::Report
6
-
7
- end
8
- end
9
- end
10
- end
11
- end
@@ -1,11 +0,0 @@
1
- module Neuron
2
- module Client
3
- module Model
4
- module Membase
5
- class S3File < Common::S3File
6
-
7
- end
8
- end
9
- end
10
- end
11
- 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,11 +0,0 @@
1
- module Neuron
2
- module Client
3
- module Model
4
- module Admin
5
- describe Base do
6
-
7
- end
8
- end
9
- end
10
- end
11
- end
@@ -1,11 +0,0 @@
1
- module Neuron
2
- module Client
3
- module Model
4
- module Admin
5
- describe BlockedReferer do
6
-
7
- end
8
- end
9
- end
10
- end
11
- end
@@ -1,11 +0,0 @@
1
- module Neuron
2
- module Client
3
- module Model
4
- module Admin
5
- describe BlockedUserAgent do
6
-
7
- end
8
- end
9
- end
10
- end
11
- 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,11 +0,0 @@
1
- module Neuron
2
- module Client
3
- module Model
4
- module Admin
5
- describe S3File do
6
-
7
- end
8
- end
9
- end
10
- end
11
- 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