neuron-client 0.2.0 → 0.2.1
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/.rvmrc +21 -1
- data/Rakefile +1 -1
- data/environment.rb +3 -0
- data/lib/neuron-client.rb +3 -0
- data/lib/neuron-client/api.rb +4 -1
- data/lib/neuron-client/membase_connection.rb +28 -3
- data/lib/neuron-client/model/admin/base.rb +3 -3
- data/lib/neuron-client/model/base.rb +2 -2
- data/lib/neuron-client/model/common/ad_calculations.rb +1 -1
- data/lib/neuron-client/model/membase/ad.rb +16 -0
- data/lib/neuron-client/model/membase/zone.rb +9 -0
- data/lib/neuron-client/version.rb +1 -1
- data/neuron-client.gemspec +2 -1
- data/spec/fixtures/vcr_cassettes/s3_file.yml +170 -354
- data/spec/lib/admin_connection_spec.rb +117 -19
- data/spec/lib/membase_connection_spec.rb +3 -3
- data/spec/lib/model/common/ad_calculations_spec.rb +12 -9
- data/spec/lib/model/membase/ad_spec.rb +1 -1
- metadata +53 -29
data/.rvmrc
CHANGED
@@ -1 +1,21 @@
|
|
1
|
-
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
|
3
|
+
ruby_string="1.8.7"
|
4
|
+
gemset_name="neuron-client"
|
5
|
+
|
6
|
+
if rvm list strings | grep -q "${ruby_string}" ; then
|
7
|
+
|
8
|
+
# Load or create the specified environment
|
9
|
+
if [[ -d "${rvm_path:-$HOME/.rvm}/environments" \
|
10
|
+
&& -s "${rvm_path:-$HOME/.rvm}/environments/${ruby_string}@${gemset_name}" ]] ; then
|
11
|
+
\. "${rvm_path:-$HOME/.rvm}/environments/${ruby_string}@${gemset_name}"
|
12
|
+
else
|
13
|
+
rvm --create "${ruby_string}@${gemset_name}"
|
14
|
+
fi
|
15
|
+
|
16
|
+
else
|
17
|
+
|
18
|
+
# Notify the user to install the desired interpreter before proceeding.
|
19
|
+
echo "${ruby_string} was not found, please run 'rvm install ${ruby_string}' and then cd back into the project directory."
|
20
|
+
|
21
|
+
fi
|
data/Rakefile
CHANGED
@@ -20,5 +20,5 @@ end
|
|
20
20
|
desc "Open development console"
|
21
21
|
task :console do
|
22
22
|
puts "Loading development console..."
|
23
|
-
system "irb -I #{File.join('.', 'lib')} -r #{File.join('.', '
|
23
|
+
system "irb -I #{File.join('.', 'lib')} -r #{File.join('.', 'environment')}"
|
24
24
|
end
|
data/environment.rb
ADDED
data/lib/neuron-client.rb
CHANGED
data/lib/neuron-client/api.rb
CHANGED
@@ -49,7 +49,10 @@ module Neuron
|
|
49
49
|
|
50
50
|
def configure_membase_connection
|
51
51
|
required(@config, :membase_servers)
|
52
|
-
self.connection = MembaseConnection.new(config.membase_servers
|
52
|
+
self.connection = MembaseConnection.new(config.membase_servers,
|
53
|
+
:local_cache_size => config[:local_cache_size],
|
54
|
+
:local_cache_expires => config[:local_cache_expires]
|
55
|
+
)
|
53
56
|
end
|
54
57
|
|
55
58
|
class << self
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'dalli'
|
2
|
+
require 'lrucache'
|
2
3
|
|
3
4
|
module Neuron
|
4
5
|
module Client
|
@@ -6,12 +7,36 @@ module Neuron
|
|
6
7
|
|
7
8
|
attr_reader :client
|
8
9
|
|
9
|
-
def initialize(servers)
|
10
|
+
def initialize(servers, opts={})
|
10
11
|
@client = Dalli::Client.new(servers)
|
12
|
+
@local_cache = LRUCache.new(
|
13
|
+
:max_items => opts[:local_cache_size],
|
14
|
+
:ttl => opts[:local_cache_expires] || 60.seconds)
|
11
15
|
end
|
12
16
|
|
13
|
-
def get(key)
|
14
|
-
@
|
17
|
+
def get(key, ttl=nil)
|
18
|
+
@local_cache.fetch(key, local_ttl(ttl)) do
|
19
|
+
@client.get(key)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def fetch(key, ttl=nil, options=nil, &callback)
|
24
|
+
@local_cache.fetch(key, local_ttl(ttl)) do
|
25
|
+
@client.fetch(key, options, &callback)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def local_ttl(ttl)
|
32
|
+
return nil if ttl.nil?
|
33
|
+
ttl = Float(ttl)
|
34
|
+
local_ttl = @local_cache.ttl
|
35
|
+
if local_ttl.nil? || local_ttl == 0 || local_ttl > ttl
|
36
|
+
ttl
|
37
|
+
else
|
38
|
+
nil
|
39
|
+
end
|
15
40
|
end
|
16
41
|
end
|
17
42
|
end
|
@@ -4,7 +4,7 @@ module Neuron
|
|
4
4
|
module Admin
|
5
5
|
module Base
|
6
6
|
def attributes
|
7
|
-
self.class.attributes || []
|
7
|
+
self.class.superclass.attributes || []
|
8
8
|
end
|
9
9
|
|
10
10
|
def to_hash(*except)
|
@@ -55,7 +55,7 @@ module Neuron
|
|
55
55
|
end
|
56
56
|
|
57
57
|
def self.included(base)
|
58
|
-
base.send(:attr_accessor, :errors)
|
58
|
+
base.superclass.send(:attr_accessor, :errors)
|
59
59
|
base.extend(ClassMethods)
|
60
60
|
end
|
61
61
|
|
@@ -73,7 +73,7 @@ module Neuron
|
|
73
73
|
end
|
74
74
|
|
75
75
|
def create(attrs={})
|
76
|
-
@errors = catch
|
76
|
+
@errors = catch(:errors) do
|
77
77
|
return create!(attrs)
|
78
78
|
end
|
79
79
|
nil
|
@@ -9,7 +9,7 @@ module Neuron
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def method_missing(meth, *args, &block)
|
12
|
-
(@proxied_model.
|
12
|
+
(@proxied_model.respond_to?(meth) ? @proxied_model.send(meth, *args, &block) : super)
|
13
13
|
end
|
14
14
|
|
15
15
|
class << self
|
@@ -29,7 +29,7 @@ module Neuron
|
|
29
29
|
end
|
30
30
|
|
31
31
|
def method_missing(meth, *args, &block)
|
32
|
-
(class_to_proxy.
|
32
|
+
(class_to_proxy.respond_to?(meth) ? class_to_proxy.send(meth, *args, &block) : super)
|
33
33
|
end
|
34
34
|
end
|
35
35
|
end
|
@@ -91,7 +91,7 @@ module Neuron
|
|
91
91
|
# Doesn't worry about whether or not the time is in the ad's date range.
|
92
92
|
# Assumes ad is partitioned.
|
93
93
|
def partitioned_hour?(time)
|
94
|
-
day_partitions
|
94
|
+
day_partitions.at((time.wday * 24) + time.hour) == 'T'
|
95
95
|
end
|
96
96
|
|
97
97
|
# Assume time is in the time zone of the ad.
|
@@ -3,6 +3,10 @@ module Neuron
|
|
3
3
|
module Model
|
4
4
|
module Membase
|
5
5
|
class Ad < Common::Ad
|
6
|
+
|
7
|
+
ACTIVE_TTL = 60 #seconds
|
8
|
+
PRESSURE_TTL = 60 #seconds
|
9
|
+
|
6
10
|
def total_impressed
|
7
11
|
key = "count_delivery_ad_#{self.id}"
|
8
12
|
self.class.connection.get(key).to_f
|
@@ -15,6 +19,18 @@ module Neuron
|
|
15
19
|
self.class.connection.get(key).to_f
|
16
20
|
end
|
17
21
|
|
22
|
+
def active?
|
23
|
+
self.class.connection.fetch("Ad:#{id}:active", ACTIVE_TTL) do
|
24
|
+
calculate_active?(Time.now, total_impressed, today_impressed)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def pressure
|
29
|
+
self.class.connection.fetch("Ad:#{id}:pressure", PRESSURE_TTL) do
|
30
|
+
calculate_pressure(Time.now, total_impressed, today_impressed)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
18
34
|
class << self
|
19
35
|
def find(id)
|
20
36
|
ad = nil
|
@@ -3,6 +3,15 @@ module Neuron
|
|
3
3
|
module Model
|
4
4
|
module Membase
|
5
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
|
+
|
6
15
|
class << self
|
7
16
|
def find(id)
|
8
17
|
zone = nil
|
data/neuron-client.gemspec
CHANGED
@@ -19,10 +19,11 @@ Gem::Specification.new do |s|
|
|
19
19
|
s.require_paths = ["lib"]
|
20
20
|
s.add_dependency "rest-client", "~> 1.6.3"
|
21
21
|
s.add_dependency "yajl-ruby", "~> 0.8.2"
|
22
|
-
s.add_dependency "activesupport", "
|
22
|
+
s.add_dependency "activesupport", ">= 2.3.11", "< 3.2"
|
23
23
|
s.add_dependency "tzinfo", "~> 0.3.29"
|
24
24
|
s.add_dependency "i18n", "~> 0.6.0"
|
25
25
|
s.add_dependency "dalli", "~> 1.0.5"
|
26
|
+
s.add_dependency "lrucache", "~> 0.1.0"
|
26
27
|
|
27
28
|
s.add_development_dependency "rspec", "~> 2.6.0"
|
28
29
|
s.add_development_dependency "simplecov", "~> 0.4.2"
|
@@ -1,403 +1,219 @@
|
|
1
|
-
---
|
2
|
-
- !ruby/struct:VCR::HTTPInteraction
|
3
|
-
request: !ruby/struct:VCR::Request
|
1
|
+
---
|
2
|
+
- !ruby/struct:VCR::HTTPInteraction
|
3
|
+
request: !ruby/struct:VCR::Request
|
4
4
|
method: :post
|
5
5
|
uri: http://127.0.0.1:3000/s3_files.json?api_key=secret
|
6
|
-
body:
|
7
|
-
headers:
|
8
|
-
accept:
|
6
|
+
body:
|
7
|
+
headers:
|
8
|
+
accept:
|
9
9
|
- application/json
|
10
|
-
|
11
|
-
- gzip, deflate
|
12
|
-
content-type:
|
10
|
+
content-type:
|
13
11
|
- application/json
|
14
|
-
|
15
|
-
-
|
16
|
-
|
17
|
-
|
12
|
+
accept-encoding:
|
13
|
+
- gzip, deflate
|
14
|
+
content-length:
|
15
|
+
- "77"
|
16
|
+
response: !ruby/struct:VCR::Response
|
17
|
+
status: !ruby/struct:VCR::ResponseStatus
|
18
18
|
code: 201
|
19
19
|
message: Created
|
20
|
-
headers:
|
21
|
-
|
20
|
+
headers:
|
21
|
+
x-ua-compatible:
|
22
|
+
- IE=Edge
|
23
|
+
location:
|
22
24
|
- http://127.0.0.1:3000/s3_files/1
|
23
|
-
content-type:
|
25
|
+
content-type:
|
24
26
|
- application/json; charset=utf-8
|
25
|
-
|
26
|
-
-
|
27
|
-
|
28
|
-
- IE=Edge
|
29
|
-
x-runtime:
|
30
|
-
- '2.156203'
|
31
|
-
server:
|
27
|
+
date:
|
28
|
+
- Thu, 08 Sep 2011 19:15:34 GMT
|
29
|
+
server:
|
32
30
|
- WEBrick/1.3.1 (Ruby/1.9.2/2011-07-09)
|
33
|
-
|
34
|
-
-
|
35
|
-
content-length:
|
36
|
-
-
|
37
|
-
set-cookie:
|
38
|
-
- _neuron-admin_session=
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
message: Created
|
46
|
-
header:
|
47
|
-
location:
|
48
|
-
- http://127.0.0.1:3000/s3_files/1
|
49
|
-
content-type:
|
50
|
-
- application/json; charset=utf-8
|
51
|
-
cache-control:
|
52
|
-
- no-cache
|
53
|
-
x-ua-compatible:
|
54
|
-
- IE=Edge
|
55
|
-
x-runtime:
|
56
|
-
- '2.156203'
|
57
|
-
server:
|
58
|
-
- WEBrick/1.3.1 (Ruby/1.9.2/2011-07-09)
|
59
|
-
date:
|
60
|
-
- Tue, 26 Jul 2011 21:15:03 GMT
|
61
|
-
content-length:
|
62
|
-
- '156'
|
63
|
-
set-cookie:
|
64
|
-
- _neuron-admin_session=BAh7BkkiD3Nlc3Npb25faWQGOgZFRiIlNTkyMGNkZGRkZGEzMmI3ODFiMDhlZjI3ZjZjN2Y5ZTY%3D--abc9759030ac57f081014793dd0a18200acd40ce;
|
65
|
-
path=/; HttpOnly
|
66
|
-
body: !str
|
67
|
-
str: ! '{"s3_file":{"bucket":"test","created_at":"2011-07-26T21:15:03Z","filename":"filename","id":1,"purpose":"RAW_EVENT_LOG","updated_at":"2011-07-26T21:15:03Z"}}'
|
68
|
-
net_http_res: *30964600
|
69
|
-
args: &30979260
|
70
|
-
:method: :post
|
71
|
-
:url: http://127.0.0.1:3000/s3_files.json?api_key=secret
|
72
|
-
:payload: ! '{"s3_file":{"bucket":"test","filename":"filename","purpose":"RAW_EVENT_LOG"}}'
|
73
|
-
:headers:
|
74
|
-
:content_type: :json
|
75
|
-
:accept: :json
|
76
|
-
code: 201
|
77
|
-
read: true
|
78
|
-
args: *30979260
|
79
|
-
code: 201
|
80
|
-
http_version: '1.1'
|
81
|
-
- !ruby/struct:VCR::HTTPInteraction
|
82
|
-
request: !ruby/struct:VCR::Request
|
31
|
+
x-runtime:
|
32
|
+
- "0.271855"
|
33
|
+
content-length:
|
34
|
+
- "172"
|
35
|
+
set-cookie:
|
36
|
+
- _neuron-admin_session=BAh7BkkiD3Nlc3Npb25faWQGOgZFRiIlMGYwMjIzYzc3ZjAzYjIwNDYzYjhlN2FmN2E1MmI5MGI%3D--f9c0be3ce928c665c7e4008c87bc8ae44725dcb4; path=/; HttpOnly
|
37
|
+
cache-control:
|
38
|
+
- no-cache
|
39
|
+
body: "{\"s3_file\":{\"bucket\":\"test\",\"created_at\":\"2011-09-08T19:15:34Z\",\"filename\":\"filename\",\"filesize\":null,\"id\":1,\"purpose\":\"RAW_EVENT_LOG\",\"updated_at\":\"2011-09-08T19:15:34Z\"}}"
|
40
|
+
http_version: "1.1"
|
41
|
+
- !ruby/struct:VCR::HTTPInteraction
|
42
|
+
request: !ruby/struct:VCR::Request
|
83
43
|
method: :get
|
84
44
|
uri: http://127.0.0.1:3000/s3_files.json?api_key=secret
|
85
|
-
body:
|
86
|
-
headers:
|
87
|
-
accept:
|
45
|
+
body:
|
46
|
+
headers:
|
47
|
+
accept:
|
88
48
|
- application/json
|
89
|
-
|
90
|
-
- gzip, deflate
|
91
|
-
content-type:
|
49
|
+
content-type:
|
92
50
|
- application/json
|
93
|
-
|
94
|
-
|
51
|
+
accept-encoding:
|
52
|
+
- gzip, deflate
|
53
|
+
response: !ruby/struct:VCR::Response
|
54
|
+
status: !ruby/struct:VCR::ResponseStatus
|
95
55
|
code: 200
|
96
56
|
message: OK
|
97
|
-
headers:
|
98
|
-
|
99
|
-
- application/json; charset=utf-8
|
100
|
-
etag:
|
101
|
-
- ! '"f28f9f731f02abb52de52eeb140f3904"'
|
102
|
-
cache-control:
|
103
|
-
- max-age=0, private, must-revalidate
|
104
|
-
x-ua-compatible:
|
57
|
+
headers:
|
58
|
+
x-ua-compatible:
|
105
59
|
- IE=Edge
|
106
|
-
|
107
|
-
-
|
108
|
-
|
60
|
+
etag:
|
61
|
+
- "\"f653f39c883bdf1acabccea70ef2cb84\""
|
62
|
+
content-type:
|
63
|
+
- application/json; charset=utf-8
|
64
|
+
date:
|
65
|
+
- Thu, 08 Sep 2011 19:15:34 GMT
|
66
|
+
server:
|
109
67
|
- WEBrick/1.3.1 (Ruby/1.9.2/2011-07-09)
|
110
|
-
|
111
|
-
-
|
112
|
-
content-length:
|
113
|
-
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
header:
|
121
|
-
content-type:
|
122
|
-
- application/json; charset=utf-8
|
123
|
-
etag:
|
124
|
-
- ! '"f28f9f731f02abb52de52eeb140f3904"'
|
125
|
-
cache-control:
|
126
|
-
- max-age=0, private, must-revalidate
|
127
|
-
x-ua-compatible:
|
128
|
-
- IE=Edge
|
129
|
-
x-runtime:
|
130
|
-
- '0.058083'
|
131
|
-
server:
|
132
|
-
- WEBrick/1.3.1 (Ruby/1.9.2/2011-07-09)
|
133
|
-
date:
|
134
|
-
- Tue, 26 Jul 2011 21:15:03 GMT
|
135
|
-
content-length:
|
136
|
-
- '158'
|
137
|
-
body: !str
|
138
|
-
str: ! '[{"s3_file":{"bucket":"test","created_at":"2011-07-26T21:15:03Z","filename":"filename","id":1,"purpose":"RAW_EVENT_LOG","updated_at":"2011-07-26T21:15:03Z"}}]'
|
139
|
-
net_http_res: *30899300
|
140
|
-
args: &30918140
|
141
|
-
:method: :get
|
142
|
-
:url: http://127.0.0.1:3000/s3_files.json?api_key=secret
|
143
|
-
:headers:
|
144
|
-
:content_type: :json
|
145
|
-
:accept: :json
|
146
|
-
code: 200
|
147
|
-
read: true
|
148
|
-
args: *30918140
|
149
|
-
code: 200
|
150
|
-
http_version: '1.1'
|
151
|
-
- !ruby/struct:VCR::HTTPInteraction
|
152
|
-
request: !ruby/struct:VCR::Request
|
68
|
+
x-runtime:
|
69
|
+
- "0.417905"
|
70
|
+
content-length:
|
71
|
+
- "174"
|
72
|
+
cache-control:
|
73
|
+
- max-age=0, private, must-revalidate
|
74
|
+
body: "[{\"s3_file\":{\"bucket\":\"test\",\"created_at\":\"2011-09-08T19:15:34Z\",\"filename\":\"filename\",\"filesize\":null,\"id\":1,\"purpose\":\"RAW_EVENT_LOG\",\"updated_at\":\"2011-09-08T19:15:34Z\"}}]"
|
75
|
+
http_version: "1.1"
|
76
|
+
- !ruby/struct:VCR::HTTPInteraction
|
77
|
+
request: !ruby/struct:VCR::Request
|
153
78
|
method: :get
|
154
79
|
uri: http://127.0.0.1:3000/s3_files/1.json?api_key=secret
|
155
|
-
body:
|
156
|
-
headers:
|
157
|
-
accept:
|
80
|
+
body:
|
81
|
+
headers:
|
82
|
+
accept:
|
158
83
|
- application/json
|
159
|
-
|
160
|
-
- gzip, deflate
|
161
|
-
content-type:
|
84
|
+
content-type:
|
162
85
|
- application/json
|
163
|
-
|
164
|
-
|
86
|
+
accept-encoding:
|
87
|
+
- gzip, deflate
|
88
|
+
response: !ruby/struct:VCR::Response
|
89
|
+
status: !ruby/struct:VCR::ResponseStatus
|
165
90
|
code: 200
|
166
91
|
message: OK
|
167
|
-
headers:
|
168
|
-
|
169
|
-
- application/json; charset=utf-8
|
170
|
-
etag:
|
171
|
-
- ! '"67aa857a0fae3ef759591bfd7c6ce984"'
|
172
|
-
cache-control:
|
173
|
-
- max-age=0, private, must-revalidate
|
174
|
-
x-ua-compatible:
|
92
|
+
headers:
|
93
|
+
x-ua-compatible:
|
175
94
|
- IE=Edge
|
176
|
-
|
177
|
-
-
|
178
|
-
|
95
|
+
etag:
|
96
|
+
- "\"a4662af39919ae7cebe8fab76bb44b76\""
|
97
|
+
content-type:
|
98
|
+
- application/json; charset=utf-8
|
99
|
+
date:
|
100
|
+
- Thu, 08 Sep 2011 19:15:35 GMT
|
101
|
+
server:
|
179
102
|
- WEBrick/1.3.1 (Ruby/1.9.2/2011-07-09)
|
180
|
-
|
181
|
-
-
|
182
|
-
content-length:
|
183
|
-
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
header:
|
191
|
-
content-type:
|
192
|
-
- application/json; charset=utf-8
|
193
|
-
etag:
|
194
|
-
- ! '"67aa857a0fae3ef759591bfd7c6ce984"'
|
195
|
-
cache-control:
|
196
|
-
- max-age=0, private, must-revalidate
|
197
|
-
x-ua-compatible:
|
198
|
-
- IE=Edge
|
199
|
-
x-runtime:
|
200
|
-
- '0.058488'
|
201
|
-
server:
|
202
|
-
- WEBrick/1.3.1 (Ruby/1.9.2/2011-07-09)
|
203
|
-
date:
|
204
|
-
- Tue, 26 Jul 2011 21:15:03 GMT
|
205
|
-
content-length:
|
206
|
-
- '156'
|
207
|
-
body: !str
|
208
|
-
str: ! '{"s3_file":{"bucket":"test","created_at":"2011-07-26T21:15:03Z","filename":"filename","id":1,"purpose":"RAW_EVENT_LOG","updated_at":"2011-07-26T21:15:03Z"}}'
|
209
|
-
net_http_res: *30863640
|
210
|
-
args: &30882500
|
211
|
-
:method: :get
|
212
|
-
:url: http://127.0.0.1:3000/s3_files/1.json?api_key=secret
|
213
|
-
:headers:
|
214
|
-
:content_type: :json
|
215
|
-
:accept: :json
|
216
|
-
code: 200
|
217
|
-
read: true
|
218
|
-
args: *30882500
|
219
|
-
code: 200
|
220
|
-
http_version: '1.1'
|
221
|
-
- !ruby/struct:VCR::HTTPInteraction
|
222
|
-
request: !ruby/struct:VCR::Request
|
103
|
+
x-runtime:
|
104
|
+
- "0.370982"
|
105
|
+
content-length:
|
106
|
+
- "172"
|
107
|
+
cache-control:
|
108
|
+
- max-age=0, private, must-revalidate
|
109
|
+
body: "{\"s3_file\":{\"bucket\":\"test\",\"created_at\":\"2011-09-08T19:15:34Z\",\"filename\":\"filename\",\"filesize\":null,\"id\":1,\"purpose\":\"RAW_EVENT_LOG\",\"updated_at\":\"2011-09-08T19:15:34Z\"}}"
|
110
|
+
http_version: "1.1"
|
111
|
+
- !ruby/struct:VCR::HTTPInteraction
|
112
|
+
request: !ruby/struct:VCR::Request
|
223
113
|
method: :get
|
224
114
|
uri: http://127.0.0.1:3000/s3_files/1.json?api_key=secret
|
225
|
-
body:
|
226
|
-
headers:
|
227
|
-
accept:
|
115
|
+
body:
|
116
|
+
headers:
|
117
|
+
accept:
|
228
118
|
- application/json
|
229
|
-
|
230
|
-
- gzip, deflate
|
231
|
-
content-type:
|
119
|
+
content-type:
|
232
120
|
- application/json
|
233
|
-
|
234
|
-
|
121
|
+
accept-encoding:
|
122
|
+
- gzip, deflate
|
123
|
+
response: !ruby/struct:VCR::Response
|
124
|
+
status: !ruby/struct:VCR::ResponseStatus
|
235
125
|
code: 200
|
236
126
|
message: OK
|
237
|
-
headers:
|
238
|
-
|
239
|
-
- application/json; charset=utf-8
|
240
|
-
etag:
|
241
|
-
- ! '"67aa857a0fae3ef759591bfd7c6ce984"'
|
242
|
-
cache-control:
|
243
|
-
- max-age=0, private, must-revalidate
|
244
|
-
x-ua-compatible:
|
127
|
+
headers:
|
128
|
+
x-ua-compatible:
|
245
129
|
- IE=Edge
|
246
|
-
|
247
|
-
-
|
248
|
-
|
130
|
+
etag:
|
131
|
+
- "\"a4662af39919ae7cebe8fab76bb44b76\""
|
132
|
+
content-type:
|
133
|
+
- application/json; charset=utf-8
|
134
|
+
date:
|
135
|
+
- Thu, 08 Sep 2011 19:15:35 GMT
|
136
|
+
server:
|
249
137
|
- WEBrick/1.3.1 (Ruby/1.9.2/2011-07-09)
|
250
|
-
|
251
|
-
-
|
252
|
-
content-length:
|
253
|
-
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
header:
|
261
|
-
content-type:
|
262
|
-
- application/json; charset=utf-8
|
263
|
-
etag:
|
264
|
-
- ! '"67aa857a0fae3ef759591bfd7c6ce984"'
|
265
|
-
cache-control:
|
266
|
-
- max-age=0, private, must-revalidate
|
267
|
-
x-ua-compatible:
|
268
|
-
- IE=Edge
|
269
|
-
x-runtime:
|
270
|
-
- '0.103646'
|
271
|
-
server:
|
272
|
-
- WEBrick/1.3.1 (Ruby/1.9.2/2011-07-09)
|
273
|
-
date:
|
274
|
-
- Tue, 26 Jul 2011 21:15:03 GMT
|
275
|
-
content-length:
|
276
|
-
- '156'
|
277
|
-
body: !str
|
278
|
-
str: ! '{"s3_file":{"bucket":"test","created_at":"2011-07-26T21:15:03Z","filename":"filename","id":1,"purpose":"RAW_EVENT_LOG","updated_at":"2011-07-26T21:15:03Z"}}'
|
279
|
-
net_http_res: *30800000
|
280
|
-
args: &30814500
|
281
|
-
:method: :get
|
282
|
-
:url: http://127.0.0.1:3000/s3_files/1.json?api_key=secret
|
283
|
-
:headers:
|
284
|
-
:content_type: :json
|
285
|
-
:accept: :json
|
286
|
-
code: 200
|
287
|
-
read: true
|
288
|
-
args: *30814500
|
289
|
-
code: 200
|
290
|
-
http_version: '1.1'
|
291
|
-
- !ruby/struct:VCR::HTTPInteraction
|
292
|
-
request: !ruby/struct:VCR::Request
|
138
|
+
x-runtime:
|
139
|
+
- "0.432809"
|
140
|
+
content-length:
|
141
|
+
- "172"
|
142
|
+
cache-control:
|
143
|
+
- max-age=0, private, must-revalidate
|
144
|
+
body: "{\"s3_file\":{\"bucket\":\"test\",\"created_at\":\"2011-09-08T19:15:34Z\",\"filename\":\"filename\",\"filesize\":null,\"id\":1,\"purpose\":\"RAW_EVENT_LOG\",\"updated_at\":\"2011-09-08T19:15:34Z\"}}"
|
145
|
+
http_version: "1.1"
|
146
|
+
- !ruby/struct:VCR::HTTPInteraction
|
147
|
+
request: !ruby/struct:VCR::Request
|
293
148
|
method: :put
|
294
149
|
uri: http://127.0.0.1:3000/s3_files/1.json?api_key=secret
|
295
|
-
body:
|
296
|
-
headers:
|
297
|
-
accept:
|
150
|
+
body:
|
151
|
+
headers:
|
152
|
+
accept:
|
298
153
|
- application/json
|
299
|
-
|
300
|
-
- gzip, deflate
|
301
|
-
content-type:
|
154
|
+
content-type:
|
302
155
|
- application/json
|
303
|
-
|
304
|
-
-
|
305
|
-
|
306
|
-
|
156
|
+
accept-encoding:
|
157
|
+
- gzip, deflate
|
158
|
+
content-length:
|
159
|
+
- "37"
|
160
|
+
response: !ruby/struct:VCR::Response
|
161
|
+
status: !ruby/struct:VCR::ResponseStatus
|
307
162
|
code: 200
|
308
163
|
message: OK
|
309
|
-
headers:
|
310
|
-
|
311
|
-
- application/json; charset=utf-8
|
312
|
-
etag:
|
313
|
-
- ! '"99914b932bd37a50b983c5e7c90ae93b"'
|
314
|
-
cache-control:
|
315
|
-
- max-age=0, private, must-revalidate
|
316
|
-
x-ua-compatible:
|
164
|
+
headers:
|
165
|
+
x-ua-compatible:
|
317
166
|
- IE=Edge
|
318
|
-
|
319
|
-
-
|
320
|
-
|
167
|
+
etag:
|
168
|
+
- "\"99914b932bd37a50b983c5e7c90ae93b\""
|
169
|
+
content-type:
|
170
|
+
- application/json; charset=utf-8
|
171
|
+
date:
|
172
|
+
- Thu, 08 Sep 2011 19:15:36 GMT
|
173
|
+
server:
|
321
174
|
- WEBrick/1.3.1 (Ruby/1.9.2/2011-07-09)
|
322
|
-
|
323
|
-
-
|
324
|
-
content-length:
|
325
|
-
-
|
326
|
-
set-cookie:
|
327
|
-
- _neuron-admin_session=
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
175
|
+
x-runtime:
|
176
|
+
- "0.377332"
|
177
|
+
content-length:
|
178
|
+
- "2"
|
179
|
+
set-cookie:
|
180
|
+
- _neuron-admin_session=BAh7BkkiD3Nlc3Npb25faWQGOgZFRiIlNDk0OWE5MjQ1MDk2OGQ3NDM5OWI2MjIyMTMwNTdkZTI%3D--b9b28d47b6b1ead701897392b8486b60cc1a8f53; path=/; HttpOnly
|
181
|
+
cache-control:
|
182
|
+
- max-age=0, private, must-revalidate
|
183
|
+
body: "{}"
|
184
|
+
http_version: "1.1"
|
185
|
+
- !ruby/struct:VCR::HTTPInteraction
|
186
|
+
request: !ruby/struct:VCR::Request
|
333
187
|
method: :get
|
334
188
|
uri: http://127.0.0.1:3000/s3_files/1.json?api_key=secret
|
335
|
-
body:
|
336
|
-
headers:
|
337
|
-
accept:
|
189
|
+
body:
|
190
|
+
headers:
|
191
|
+
accept:
|
338
192
|
- application/json
|
339
|
-
|
340
|
-
- gzip, deflate
|
341
|
-
content-type:
|
193
|
+
content-type:
|
342
194
|
- application/json
|
343
|
-
|
344
|
-
|
195
|
+
accept-encoding:
|
196
|
+
- gzip, deflate
|
197
|
+
response: !ruby/struct:VCR::Response
|
198
|
+
status: !ruby/struct:VCR::ResponseStatus
|
345
199
|
code: 200
|
346
200
|
message: OK
|
347
|
-
headers:
|
348
|
-
|
349
|
-
- application/json; charset=utf-8
|
350
|
-
etag:
|
351
|
-
- ! '"717dca0db92d340da526fc4e869d36a6"'
|
352
|
-
cache-control:
|
353
|
-
- max-age=0, private, must-revalidate
|
354
|
-
x-ua-compatible:
|
201
|
+
headers:
|
202
|
+
x-ua-compatible:
|
355
203
|
- IE=Edge
|
356
|
-
|
357
|
-
-
|
358
|
-
|
204
|
+
etag:
|
205
|
+
- "\"2e781d02ae0edd8b484cab6de90dac46\""
|
206
|
+
content-type:
|
207
|
+
- application/json; charset=utf-8
|
208
|
+
date:
|
209
|
+
- Thu, 08 Sep 2011 19:15:36 GMT
|
210
|
+
server:
|
359
211
|
- WEBrick/1.3.1 (Ruby/1.9.2/2011-07-09)
|
360
|
-
|
361
|
-
-
|
362
|
-
content-length:
|
363
|
-
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
method: :put
|
369
|
-
uri: http://127.0.0.1:3000//1.json?api_key=secret
|
370
|
-
body: !!null
|
371
|
-
headers:
|
372
|
-
accept:
|
373
|
-
- application/json
|
374
|
-
accept-encoding:
|
375
|
-
- gzip, deflate
|
376
|
-
content-type:
|
377
|
-
- application/json
|
378
|
-
content-length:
|
379
|
-
- '30'
|
380
|
-
response: !ruby/struct:VCR::Response
|
381
|
-
status: !ruby/struct:VCR::ResponseStatus
|
382
|
-
code: 404
|
383
|
-
message: Not Found
|
384
|
-
headers:
|
385
|
-
content-type:
|
386
|
-
- text/html
|
387
|
-
content-length:
|
388
|
-
- '627'
|
389
|
-
x-runtime:
|
390
|
-
- '0.299115'
|
391
|
-
connection:
|
392
|
-
- keep-alive
|
393
|
-
server:
|
394
|
-
- thin 1.2.11 codename Bat-Shit Crazy
|
395
|
-
body: ! "<html xmlns=\"http://www.w3.org/1999/xhtml\">\n<head>\n <title>Action
|
396
|
-
Controller: Exception caught</title>\n <style>\n body { background-color:
|
397
|
-
#fff; color: #333; }\n\n body, p, ol, ul, td {\n font-family: verdana,
|
398
|
-
arial, helvetica, sans-serif;\n font-size: 13px;\n line-height:
|
399
|
-
18px;\n }\n\n pre {\n background-color: #eee;\n padding: 10px;\n
|
400
|
-
\ font-size: 11px;\n }\n\n a { color: #000; }\n a:visited { color:
|
401
|
-
#666; }\n a:hover { color: #fff; background-color:#000; }\n </style>\n</head>\n<body>\n\n<h1>Routing
|
402
|
-
Error</h1>\n<p><pre>No route matches "/1.json"</pre></p>\n\n\n\n</body>\n</html>\n"
|
403
|
-
http_version: '1.1'
|
212
|
+
x-runtime:
|
213
|
+
- "0.430121"
|
214
|
+
content-length:
|
215
|
+
- "174"
|
216
|
+
cache-control:
|
217
|
+
- max-age=0, private, must-revalidate
|
218
|
+
body: "{\"s3_file\":{\"bucket\":\"test\",\"created_at\":\"2011-09-08T19:15:34Z\",\"filename\":\"filename_2\",\"filesize\":null,\"id\":1,\"purpose\":\"RAW_EVENT_LOG\",\"updated_at\":\"2011-09-08T19:15:36Z\"}}"
|
219
|
+
http_version: "1.1"
|
@@ -1,82 +1,180 @@
|
|
1
1
|
module Neuron
|
2
2
|
module Client
|
3
3
|
describe AdminConnection do
|
4
|
+
|
5
|
+
def stub_rest_client(receive, with_args, yield_args)
|
6
|
+
expectation = RestClient.should_receive(receive).with(*with_args)
|
7
|
+
if RUBY_VERSION =~ /^1\.8\./
|
8
|
+
expectation.and_yield(yield_args)
|
9
|
+
elsif RUBY_VERSION =~ /^1\.9\./
|
10
|
+
expectation.and_yield(*yield_args)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
before(:each) do
|
15
|
+
@ac = AdminConnection.new('url', 'key')
|
16
|
+
@response = mock(:response, :code=>200, :to_str=>"{}")
|
17
|
+
@request = mock(:request)
|
18
|
+
@result = mock(:result)
|
19
|
+
end
|
20
|
+
|
4
21
|
describe "initialize(url, key)" do
|
5
|
-
it "should set the appropriate instance variables"
|
22
|
+
it "should set the appropriate instance variables" do
|
23
|
+
@ac.class.should == Neuron::Client::AdminConnection
|
24
|
+
end
|
6
25
|
end
|
7
26
|
|
8
27
|
describe "query_string(attrs={})" do
|
9
|
-
it "should return the expected value"
|
28
|
+
it "should return the expected value" do
|
29
|
+
@ac.query_string({}).should == "api_key=key"
|
30
|
+
@ac.query_string(:foo=>'foo').split('&').sort.should == ["api_key=key","foo=foo"]
|
31
|
+
end
|
10
32
|
end
|
11
33
|
|
12
34
|
describe "get(path="", attrs={})" do
|
13
35
|
context "when response.code is 200" do
|
14
36
|
context "when the format is :json" do
|
15
|
-
it "should call the expected methods and return the expected value"
|
37
|
+
it "should call the expected methods and return the expected value" do
|
38
|
+
stub_rest_client(:get, ["url/json?api_key=key", {:content_type=>:json, :accept=>:json}], [@response, @request, @result])
|
39
|
+
@ac.get().should == Yajl.load(@response.to_str)
|
40
|
+
end
|
16
41
|
end
|
17
42
|
end
|
18
43
|
context "when response.code is not 200" do
|
19
|
-
it "it should raise an error"
|
44
|
+
it "it should raise an error" do
|
45
|
+
@response.should_receive(:code).twice.and_return(500)
|
46
|
+
stub_rest_client(:get,["url/json?api_key=key", {:content_type=>:json, :accept=>:json}],[@response, @request, @result])
|
47
|
+
lambda{
|
48
|
+
@ac.get()
|
49
|
+
}.should raise_error
|
50
|
+
end
|
20
51
|
end
|
21
52
|
end
|
22
53
|
|
23
54
|
describe "post(path="", form={}, attrs={})" do
|
24
55
|
context "when response.code is 201" do
|
25
56
|
context "when the format is :json" do
|
26
|
-
it "should call the expected methods and return the expected value"
|
57
|
+
it "should call the expected methods and return the expected value" do
|
58
|
+
@response.should_receive(:code).and_return(201)
|
59
|
+
stub_rest_client(:post,["url/json?api_key=key", "{}", {:content_type=>:json, :accept=>:json}],[@response, @request, @result])
|
60
|
+
@ac.post().should == Yajl.load(@response.to_str)
|
61
|
+
end
|
27
62
|
end
|
28
63
|
context "when the format is not :json" do
|
29
|
-
it "should call the expected methods and return the expected value"
|
64
|
+
it "should call the expected methods and return the expected value" do
|
65
|
+
@response.should_receive(:code).and_return(201)
|
66
|
+
stub_rest_client(:post,["url/path.html?api_key=key", "{}", {:content_type=>:html, :accept=>:html}],[@response, @request, @result])
|
67
|
+
@ac.post(:path, "{}", :format=>:html).should == @response.to_str
|
68
|
+
end
|
30
69
|
end
|
31
70
|
end
|
32
71
|
context "when response.code is 422" do
|
33
72
|
context "when the format is :json" do
|
34
|
-
it "should throw the expected symbol and object"
|
73
|
+
it "should throw the expected symbol and object" do
|
74
|
+
@response.should_receive(:code).and_return(422)
|
75
|
+
stub_rest_client(:post, ["url/json?api_key=key", "{}", {:content_type=>:json, :accept=>:json}],[@response, @request, @result])
|
76
|
+
lambda{
|
77
|
+
@ac.post()
|
78
|
+
}.should raise_error
|
79
|
+
end
|
35
80
|
end
|
36
81
|
context "when the format is not :json" do
|
37
|
-
it "should throw the expected symbol and object"
|
82
|
+
it "should throw the expected symbol and object" do
|
83
|
+
@response.should_receive(:code).and_return(422)
|
84
|
+
stub_rest_client(:post, ["url/path.html?api_key=key", "{}", {:content_type=>:html, :accept=>:html}],[@response, @request, @result])
|
85
|
+
lambda{
|
86
|
+
@ac.post(:path, "{}", :format=>:html)
|
87
|
+
}.should raise_error
|
88
|
+
end
|
38
89
|
end
|
39
90
|
end
|
40
91
|
context "when response.code is not 201 or 422" do
|
41
|
-
it "should raise an error"
|
92
|
+
it "should raise an error" do
|
93
|
+
@response.should_receive(:code).and_return(500)
|
94
|
+
stub_rest_client(:post,["url/json?api_key=key", "{}", {:content_type=>:json, :accept=>:json}],[@response, @request, @result])
|
95
|
+
lambda{
|
96
|
+
@ac.post()
|
97
|
+
}.should raise_error
|
98
|
+
end
|
42
99
|
end
|
43
100
|
end
|
44
|
-
|
101
|
+
|
45
102
|
describe "put(path="", form={}, attrs={})" do
|
46
103
|
context "when response.code is 200" do
|
47
104
|
context "when the format is :json" do
|
48
|
-
it "should call the expected methods and return the expected value"
|
105
|
+
it "should call the expected methods and return the expected value" do
|
106
|
+
@response.should_receive(:code).and_return(200)
|
107
|
+
stub_rest_client(:put,["url/json?api_key=key", "{}", {:content_type=>:json, :accept=>:json}],[@response, @request, @result])
|
108
|
+
@ac.put().should == Yajl.load(@response.to_str)
|
109
|
+
end
|
49
110
|
end
|
50
111
|
context "when the format is not :json" do
|
51
|
-
it "should call the expected methods and return the expected value"
|
112
|
+
it "should call the expected methods and return the expected value" do
|
113
|
+
@response.should_receive(:code).and_return(200)
|
114
|
+
stub_rest_client(:put,["url/path.html?api_key=key", "{}", {:content_type=>:html, :accept=>:html}],[@response, @request, @result])
|
115
|
+
@ac.put(:path, "{}", :format=>:html).should == @response.to_str
|
116
|
+
end
|
52
117
|
end
|
53
118
|
end
|
54
119
|
context "when response.code is 422" do
|
55
120
|
context "when the format is :json" do
|
56
|
-
it "should throw the expected symbol and object"
|
121
|
+
it "should throw the expected symbol and object" do
|
122
|
+
@response.should_receive(:code).and_return(422)
|
123
|
+
stub_rest_client(:put,["url/json?api_key=key", "{}", {:content_type=>:json, :accept=>:json}],[@response, @request, @result])
|
124
|
+
lambda{
|
125
|
+
@ac.put()
|
126
|
+
}.should raise_error
|
127
|
+
end
|
57
128
|
end
|
58
129
|
context "when the format is not :json" do
|
59
|
-
it "should throw the expected symbol and object"
|
130
|
+
it "should throw the expected symbol and object" do
|
131
|
+
@response.should_receive(:code).and_return(422)
|
132
|
+
stub_rest_client(:put,["url/json?api_key=key", "{}", {:content_type=>:json, :accept=>:json}],[@response, @request, @result])
|
133
|
+
lambda{
|
134
|
+
@ac.put()
|
135
|
+
}.should raise_error
|
136
|
+
end
|
60
137
|
end
|
61
138
|
end
|
62
139
|
context "when response.code is not 200 or 422" do
|
63
|
-
it "should raise an error"
|
140
|
+
it "should raise an error" do
|
141
|
+
@response.should_receive(:code).and_return(500)
|
142
|
+
stub_rest_client(:put,["url/json?api_key=key", "{}", {:content_type=>:json, :accept=>:json}],[@response, @request, @result])
|
143
|
+
lambda{
|
144
|
+
@ac.put()
|
145
|
+
}.should raise_error
|
146
|
+
end
|
64
147
|
end
|
65
148
|
end
|
66
|
-
|
149
|
+
|
67
150
|
describe "delete(path="", attrs={})" do
|
68
151
|
context "when response.code is 200" do
|
69
152
|
context "when format is :json" do
|
70
|
-
it "should call the expected methods and return the expected value"
|
153
|
+
it "should call the expected methods and return the expected value" do
|
154
|
+
@response.should_receive(:code).and_return(200)
|
155
|
+
stub_rest_client(:delete,["url/path.json?api_key=key", {:content_type=>:json, :accept=>:json}],[@response, @request, @result])
|
156
|
+
@ac.delete(:path).should == Yajl.load(@response.to_str)
|
157
|
+
end
|
71
158
|
end
|
72
159
|
context "when format is not :json" do
|
73
|
-
it "should call the expected methods and return the expected value"
|
160
|
+
it "should call the expected methods and return the expected value" do
|
161
|
+
@response.should_receive(:code).and_return(200)
|
162
|
+
stub_rest_client(:delete,["url/path.html?api_key=key", {:content_type=>:html, :accept=>:html}],[@response, @request, @result])
|
163
|
+
@ac.delete(:path, :format=>:html).should == @response.to_str
|
164
|
+
end
|
74
165
|
end
|
75
166
|
end
|
76
167
|
context "when response.code is not 200" do
|
77
|
-
it "should raise an error"
|
168
|
+
it "should raise an error" do
|
169
|
+
@response.should_receive(:code).and_return(500)
|
170
|
+
stub_rest_client(:delete,["url/json?api_key=key", {:content_type=>:json, :accept=>:json}],[@response, @request, @result])
|
171
|
+
lambda{
|
172
|
+
@ac.delete()
|
173
|
+
}.should raise_error
|
174
|
+
end
|
78
175
|
end
|
79
176
|
end
|
177
|
+
|
80
178
|
end
|
81
179
|
end
|
82
180
|
end
|
@@ -14,12 +14,12 @@ module Neuron
|
|
14
14
|
|
15
15
|
describe "get(key)" do
|
16
16
|
it "should call the expected method and return the expected value" do
|
17
|
-
m = MembaseConnection.allocate
|
18
17
|
c = stub(:client)
|
19
|
-
|
18
|
+
Dalli::Client.should_receive(:new).with('127.0.0.1:11211').and_return(c)
|
19
|
+
m = MembaseConnection.new('127.0.0.1:11211')
|
20
20
|
c.should_receive(:get).with('key_value')
|
21
21
|
|
22
|
-
m.get('key_value')
|
22
|
+
m.get('key_value', 42)
|
23
23
|
end
|
24
24
|
end
|
25
25
|
end
|
@@ -19,9 +19,12 @@ module Neuron
|
|
19
19
|
describe AdCalculations do
|
20
20
|
context "given an Ad with date range Sat, 01 Jan 2011, 00:00 -> Tue, 01 Feb 2011, 12:00; Beijing time; Day parted for 9:00 - 17:00, M-F; Daily cap of 10; Overall cap of 100; total_impressed of 50; today_impressed of 5" do
|
21
21
|
before(:each) do
|
22
|
+
@time_zone = "Beijing"
|
23
|
+
Time.zone = @time_zone
|
24
|
+
Chronic.time_class = Time.zone
|
22
25
|
@ad = FakeAd.new(
|
23
|
-
:start_datetime =>
|
24
|
-
:end_datetime =>
|
26
|
+
:start_datetime => Chronic.parse("2011-01-01 00:00"),
|
27
|
+
:end_datetime => Chronic.parse("2011-02-01 12:00"),
|
25
28
|
:time_zone => "Beijing",
|
26
29
|
:day_partitions => "F"*24 + ("F"*9 + "T"*8 + "F"*7)*5 + "F"*24,
|
27
30
|
:daily_cap => 10,
|
@@ -32,22 +35,22 @@ module Neuron
|
|
32
35
|
)
|
33
36
|
end
|
34
37
|
it "should be inactive on December 10th, 2010" do
|
35
|
-
Timecop.freeze(
|
38
|
+
Timecop.freeze(Chronic.parse("2010-12-10")) do
|
36
39
|
@ad.active?.should be_false
|
37
40
|
end
|
38
41
|
end
|
39
42
|
it "should be inactive on January 1st, 2011" do
|
40
|
-
Timecop.freeze(
|
43
|
+
Timecop.freeze(Chronic.parse("2011-01-01 10:00")) do
|
41
44
|
@ad.active?.should be_false
|
42
45
|
end
|
43
46
|
end
|
44
47
|
it "should be inactive on January 3rd, 2011 at 5:00 AM" do
|
45
|
-
Timecop.freeze(
|
48
|
+
Timecop.freeze(Chronic.parse("2011-01-03 05:00")) do
|
46
49
|
@ad.active?.should be_false
|
47
50
|
end
|
48
51
|
end
|
49
52
|
context "on January 3rd, 2011 at 10:00 AM" do
|
50
|
-
before(:each) { Timecop.freeze(
|
53
|
+
before(:each) { Timecop.freeze(Chronic.parse("2011-01-03 10:00")) }
|
51
54
|
after(:each) { Timecop.return }
|
52
55
|
it "should be active" do
|
53
56
|
@ad.active?.should be_true
|
@@ -57,7 +60,7 @@ module Neuron
|
|
57
60
|
end
|
58
61
|
end
|
59
62
|
context "on January 3rd, 2011 at 16:00" do
|
60
|
-
before(:each) { Timecop.freeze(
|
63
|
+
before(:each) { Timecop.freeze(Chronic.parse("2011-1-3 16:00")) }
|
61
64
|
after(:each) { Timecop.return }
|
62
65
|
it "should be active" do
|
63
66
|
@ad.active?.should be_true
|
@@ -67,7 +70,7 @@ module Neuron
|
|
67
70
|
end
|
68
71
|
end
|
69
72
|
context "on January 27th, 2011 at 16:00" do
|
70
|
-
before(:each) { Timecop.freeze(
|
73
|
+
before(:each) { Timecop.freeze(Chronic.parse("2011-1-27 16:00")) }
|
71
74
|
after(:each) { Timecop.return }
|
72
75
|
it "should be active" do
|
73
76
|
@ad.active?.should be_true
|
@@ -77,7 +80,7 @@ module Neuron
|
|
77
80
|
end
|
78
81
|
end
|
79
82
|
it "should be inactive on February 1st, 2011 at 13:00" do
|
80
|
-
Timecop.freeze(
|
83
|
+
Timecop.freeze(Chronic.parse("2011-2-1 13:00")) do
|
81
84
|
@ad.active?.should be_false
|
82
85
|
end
|
83
86
|
end
|
@@ -17,7 +17,7 @@ module Neuron
|
|
17
17
|
it "should call the expected methods and return the expected value" do
|
18
18
|
a = Ad.allocate
|
19
19
|
a.should_receive(:time_zone).and_return('time_zone_value')
|
20
|
-
Time.stub_chain(:now, :in_time_zone).with('time_zone_value').and_return(Time.
|
20
|
+
Time.stub_chain(:now, :in_time_zone).with('time_zone_value').and_return(Time.parse("2011-05-06 07:08"))
|
21
21
|
a.should_receive(:id).and_return(7)
|
22
22
|
Ad.stub_chain(:connection, :get).with('count_delivery_20110506_ad_7').and_return('99.99')
|
23
23
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: neuron-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 21
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 1
|
10
|
+
version: 0.2.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- RMM Online
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-09-
|
18
|
+
date: 2011-09-08 00:00:00 -05:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -56,14 +56,21 @@ dependencies:
|
|
56
56
|
requirement: &id003 !ruby/object:Gem::Requirement
|
57
57
|
none: false
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
hash:
|
61
|
+
hash: 21
|
62
62
|
segments:
|
63
|
+
- 2
|
63
64
|
- 3
|
64
|
-
-
|
65
|
-
|
66
|
-
|
65
|
+
- 11
|
66
|
+
version: 2.3.11
|
67
|
+
- - <
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
hash: 3
|
70
|
+
segments:
|
71
|
+
- 3
|
72
|
+
- 2
|
73
|
+
version: "3.2"
|
67
74
|
type: :runtime
|
68
75
|
version_requirements: *id003
|
69
76
|
- !ruby/object:Gem::Dependency
|
@@ -115,9 +122,25 @@ dependencies:
|
|
115
122
|
type: :runtime
|
116
123
|
version_requirements: *id006
|
117
124
|
- !ruby/object:Gem::Dependency
|
118
|
-
name:
|
125
|
+
name: lrucache
|
119
126
|
prerelease: false
|
120
127
|
requirement: &id007 !ruby/object:Gem::Requirement
|
128
|
+
none: false
|
129
|
+
requirements:
|
130
|
+
- - ~>
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
hash: 27
|
133
|
+
segments:
|
134
|
+
- 0
|
135
|
+
- 1
|
136
|
+
- 0
|
137
|
+
version: 0.1.0
|
138
|
+
type: :runtime
|
139
|
+
version_requirements: *id007
|
140
|
+
- !ruby/object:Gem::Dependency
|
141
|
+
name: rspec
|
142
|
+
prerelease: false
|
143
|
+
requirement: &id008 !ruby/object:Gem::Requirement
|
121
144
|
none: false
|
122
145
|
requirements:
|
123
146
|
- - ~>
|
@@ -129,11 +152,11 @@ dependencies:
|
|
129
152
|
- 0
|
130
153
|
version: 2.6.0
|
131
154
|
type: :development
|
132
|
-
version_requirements: *
|
155
|
+
version_requirements: *id008
|
133
156
|
- !ruby/object:Gem::Dependency
|
134
157
|
name: simplecov
|
135
158
|
prerelease: false
|
136
|
-
requirement: &
|
159
|
+
requirement: &id009 !ruby/object:Gem::Requirement
|
137
160
|
none: false
|
138
161
|
requirements:
|
139
162
|
- - ~>
|
@@ -145,11 +168,11 @@ dependencies:
|
|
145
168
|
- 2
|
146
169
|
version: 0.4.2
|
147
170
|
type: :development
|
148
|
-
version_requirements: *
|
171
|
+
version_requirements: *id009
|
149
172
|
- !ruby/object:Gem::Dependency
|
150
173
|
name: rb-fsevent
|
151
174
|
prerelease: false
|
152
|
-
requirement: &
|
175
|
+
requirement: &id010 !ruby/object:Gem::Requirement
|
153
176
|
none: false
|
154
177
|
requirements:
|
155
178
|
- - ~>
|
@@ -161,11 +184,11 @@ dependencies:
|
|
161
184
|
- 3
|
162
185
|
version: 0.4.3
|
163
186
|
type: :development
|
164
|
-
version_requirements: *
|
187
|
+
version_requirements: *id010
|
165
188
|
- !ruby/object:Gem::Dependency
|
166
189
|
name: guard
|
167
190
|
prerelease: false
|
168
|
-
requirement: &
|
191
|
+
requirement: &id011 !ruby/object:Gem::Requirement
|
169
192
|
none: false
|
170
193
|
requirements:
|
171
194
|
- - ~>
|
@@ -177,11 +200,11 @@ dependencies:
|
|
177
200
|
- 2
|
178
201
|
version: 0.6.2
|
179
202
|
type: :development
|
180
|
-
version_requirements: *
|
203
|
+
version_requirements: *id011
|
181
204
|
- !ruby/object:Gem::Dependency
|
182
205
|
name: guard-bundler
|
183
206
|
prerelease: false
|
184
|
-
requirement: &
|
207
|
+
requirement: &id012 !ruby/object:Gem::Requirement
|
185
208
|
none: false
|
186
209
|
requirements:
|
187
210
|
- - ~>
|
@@ -193,11 +216,11 @@ dependencies:
|
|
193
216
|
- 3
|
194
217
|
version: 0.1.3
|
195
218
|
type: :development
|
196
|
-
version_requirements: *
|
219
|
+
version_requirements: *id012
|
197
220
|
- !ruby/object:Gem::Dependency
|
198
221
|
name: guard-rspec
|
199
222
|
prerelease: false
|
200
|
-
requirement: &
|
223
|
+
requirement: &id013 !ruby/object:Gem::Requirement
|
201
224
|
none: false
|
202
225
|
requirements:
|
203
226
|
- - ~>
|
@@ -209,11 +232,11 @@ dependencies:
|
|
209
232
|
- 2
|
210
233
|
version: 0.4.2
|
211
234
|
type: :development
|
212
|
-
version_requirements: *
|
235
|
+
version_requirements: *id013
|
213
236
|
- !ruby/object:Gem::Dependency
|
214
237
|
name: fakeweb
|
215
238
|
prerelease: false
|
216
|
-
requirement: &
|
239
|
+
requirement: &id014 !ruby/object:Gem::Requirement
|
217
240
|
none: false
|
218
241
|
requirements:
|
219
242
|
- - ~>
|
@@ -225,11 +248,11 @@ dependencies:
|
|
225
248
|
- 0
|
226
249
|
version: 1.3.0
|
227
250
|
type: :development
|
228
|
-
version_requirements: *
|
251
|
+
version_requirements: *id014
|
229
252
|
- !ruby/object:Gem::Dependency
|
230
253
|
name: vcr
|
231
254
|
prerelease: false
|
232
|
-
requirement: &
|
255
|
+
requirement: &id015 !ruby/object:Gem::Requirement
|
233
256
|
none: false
|
234
257
|
requirements:
|
235
258
|
- - ~>
|
@@ -241,11 +264,11 @@ dependencies:
|
|
241
264
|
- 1
|
242
265
|
version: 1.11.1
|
243
266
|
type: :development
|
244
|
-
version_requirements: *
|
267
|
+
version_requirements: *id015
|
245
268
|
- !ruby/object:Gem::Dependency
|
246
269
|
name: timecop
|
247
270
|
prerelease: false
|
248
|
-
requirement: &
|
271
|
+
requirement: &id016 !ruby/object:Gem::Requirement
|
249
272
|
none: false
|
250
273
|
requirements:
|
251
274
|
- - ~>
|
@@ -257,11 +280,11 @@ dependencies:
|
|
257
280
|
- 5
|
258
281
|
version: 0.3.5
|
259
282
|
type: :development
|
260
|
-
version_requirements: *
|
283
|
+
version_requirements: *id016
|
261
284
|
- !ruby/object:Gem::Dependency
|
262
285
|
name: chronic
|
263
286
|
prerelease: false
|
264
|
-
requirement: &
|
287
|
+
requirement: &id017 !ruby/object:Gem::Requirement
|
265
288
|
none: false
|
266
289
|
requirements:
|
267
290
|
- - ~>
|
@@ -273,7 +296,7 @@ dependencies:
|
|
273
296
|
- 2
|
274
297
|
version: 0.6.2
|
275
298
|
type: :development
|
276
|
-
version_requirements: *
|
299
|
+
version_requirements: *id017
|
277
300
|
description: Neuron Admin Client Gem
|
278
301
|
email:
|
279
302
|
- devteam@rmmonline.com
|
@@ -290,6 +313,7 @@ files:
|
|
290
313
|
- Guardfile
|
291
314
|
- README.md
|
292
315
|
- Rakefile
|
316
|
+
- environment.rb
|
293
317
|
- lib/neuron-client.rb
|
294
318
|
- lib/neuron-client/admin_connection.rb
|
295
319
|
- lib/neuron-client/api.rb
|