chillout 0.5.0 → 0.5.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/chillout.gemspec +1 -1
- data/lib/chillout/client.rb +4 -4
- data/lib/chillout/railtie.rb +35 -12
- data/lib/chillout/{dispatcher.rb → server-side/dispatcher.rb} +1 -2
- data/lib/chillout/{http_client.rb → server-side/http_client.rb} +0 -0
- data/lib/chillout/{server_side.rb → server-side/server_side.rb} +0 -0
- data/lib/chillout/version.rb +1 -1
- data/lib/chillout.rb +3 -3
- data/test/dispatcher_test.rb +2 -4
- metadata +11 -11
data/chillout.gemspec
CHANGED
@@ -20,7 +20,7 @@ Gem::Specification.new do |gem|
|
|
20
20
|
gem.add_dependency "json", "~> 1.7.0"
|
21
21
|
gem.add_development_dependency "minitest", "~>3.2.0"
|
22
22
|
gem.add_development_dependency "rake", "~> 0.9.2"
|
23
|
-
gem.add_development_dependency "mocha", "
|
23
|
+
gem.add_development_dependency "mocha", "0.12.8"
|
24
24
|
gem.add_development_dependency "contest", "~> 0.1.3"
|
25
25
|
gem.add_development_dependency "rack-test", "~> 0.6.2"
|
26
26
|
gem.add_development_dependency "webmock", "~> 1.8.11"
|
data/lib/chillout/client.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'forwardable'
|
2
|
-
require 'chillout/server_side'
|
3
|
-
require 'chillout/http_client'
|
4
|
-
require 'chillout/dispatcher'
|
2
|
+
require 'chillout/server-side/server_side'
|
3
|
+
require 'chillout/server-side/http_client'
|
4
|
+
require 'chillout/server-side/dispatcher'
|
5
5
|
require 'chillout/config'
|
6
6
|
require 'chillout/event_data_builder'
|
7
7
|
require 'chillout/prefixed_logger'
|
@@ -29,7 +29,7 @@ module Chillout
|
|
29
29
|
@http_client = HttpClient.new(@config, logger).freeze
|
30
30
|
@event_data_builder = EventDataBuilder.new(@config).freeze
|
31
31
|
@server_side = ServerSide.new(@event_data_builder, @http_client).freeze
|
32
|
-
@dispatcher = Dispatcher.new(@
|
32
|
+
@dispatcher = Dispatcher.new(@server_side).freeze
|
33
33
|
@queue = Queue.new
|
34
34
|
end
|
35
35
|
|
data/lib/chillout/railtie.rb
CHANGED
@@ -3,24 +3,47 @@ require 'chillout/creation_listener'
|
|
3
3
|
module Chillout
|
4
4
|
class Railtie < Rails::Railtie
|
5
5
|
config.chillout = ActiveSupport::OrderedOptions.new
|
6
|
-
initializer "chillout.creations_listener_initialization" do |
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
6
|
+
initializer "chillout.creations_listener_initialization" do |rails_app|
|
7
|
+
chillout_config = rails_app.config.chillout
|
8
|
+
return if chillout_config.empty?
|
9
|
+
RailsInitializer.new(rails_app, chillout_config, Rails.logger).start
|
10
|
+
end
|
11
|
+
|
12
|
+
rake_tasks do
|
13
|
+
load "chillout/tasks.rb"
|
14
|
+
end
|
15
|
+
end
|
11
16
|
|
12
|
-
|
17
|
+
class RailsInitializer
|
18
|
+
|
19
|
+
def initialize(rails_app, chillout_config, rails_logger)
|
20
|
+
@rails_app = rails_app
|
21
|
+
@chillout_config = chillout_config
|
22
|
+
@rails_logger = rails_logger
|
23
|
+
end
|
13
24
|
|
14
|
-
|
25
|
+
def start
|
26
|
+
@rails_logger.info "[Chillout] railtie initializing"
|
27
|
+
client = Client.new(@chillout_config[:secret], options)
|
28
|
+
ActiveRecord::Base.extend(CreationListener)
|
29
|
+
@rails_logger.info "[Chillout] creation listener attached"
|
30
|
+
@rails_app.middleware.use Middleware::CreationsMonitor, client
|
31
|
+
@rails_logger.info "[Chillout] creation monitor enabled"
|
32
|
+
client.start_worker
|
33
|
+
@rails_logger.info "[Chillout] worker started"
|
34
|
+
end
|
15
35
|
|
16
|
-
|
36
|
+
def options
|
37
|
+
Hash[options_list].merge(:logger => @rails_logger)
|
38
|
+
end
|
17
39
|
|
18
|
-
|
19
|
-
|
40
|
+
def options_list
|
41
|
+
existing_option_keys.map{|key| [key, @chillout_config[key]]}
|
20
42
|
end
|
21
43
|
|
22
|
-
|
23
|
-
|
44
|
+
def existing_option_keys
|
45
|
+
[:port, :hostname, :ssl].select{|key| @chillout_config.has_key?(key)}
|
24
46
|
end
|
47
|
+
|
25
48
|
end
|
26
49
|
end
|
File without changes
|
File without changes
|
data/lib/chillout/version.rb
CHANGED
data/lib/chillout.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
require "chillout/version"
|
2
2
|
require "chillout/config"
|
3
3
|
require "chillout/middleware/creations_monitor"
|
4
|
-
require "chillout/dispatcher"
|
5
|
-
require "chillout/server_side"
|
6
|
-
require "chillout/http_client"
|
4
|
+
require "chillout/server-side/dispatcher"
|
5
|
+
require "chillout/server-side/server_side"
|
6
|
+
require "chillout/server-side/http_client"
|
7
7
|
require "chillout/client"
|
8
8
|
|
9
9
|
module Chillout
|
data/test/dispatcher_test.rb
CHANGED
@@ -2,12 +2,10 @@ require 'test_helper'
|
|
2
2
|
|
3
3
|
class DispatcherTest < ChilloutTestCase
|
4
4
|
def test_send_creations
|
5
|
-
filter = mock("Filter")
|
6
|
-
|
7
5
|
server_side = mock("ServerSide")
|
8
6
|
server_side.expects(:send_creations).with(:creations)
|
9
7
|
|
10
|
-
dispatcher = Chillout::Dispatcher.new(
|
8
|
+
dispatcher = Chillout::Dispatcher.new(server_side)
|
11
9
|
dispatcher.send_creations(:creations)
|
12
10
|
end
|
13
11
|
|
@@ -15,7 +13,7 @@ class DispatcherTest < ChilloutTestCase
|
|
15
13
|
server_side = stub()
|
16
14
|
server_side.stubs(:send_creations).raises(Chillout::HttpClient::NotSent.new(:http_error))
|
17
15
|
|
18
|
-
dispatcher = Chillout::Dispatcher.new(
|
16
|
+
dispatcher = Chillout::Dispatcher.new(server_side)
|
19
17
|
|
20
18
|
assert_raises Chillout::Dispatcher::SendCreationsFailed do
|
21
19
|
dispatcher.send_creations(:creations)
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chillout
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 9
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 5
|
9
|
-
-
|
10
|
-
version: 0.5.
|
9
|
+
- 1
|
10
|
+
version: 0.5.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- "Micha\xC5\x82 \xC5\x81omnicki"
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2013-03
|
19
|
+
date: 2013-04-03 00:00:00 Z
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
22
|
name: json
|
@@ -72,14 +72,14 @@ dependencies:
|
|
72
72
|
requirement: &id004 !ruby/object:Gem::Requirement
|
73
73
|
none: false
|
74
74
|
requirements:
|
75
|
-
- -
|
75
|
+
- - "="
|
76
76
|
- !ruby/object:Gem::Version
|
77
|
-
hash:
|
77
|
+
hash: 63
|
78
78
|
segments:
|
79
79
|
- 0
|
80
80
|
- 12
|
81
|
-
-
|
82
|
-
version: 0.12.
|
81
|
+
- 8
|
82
|
+
version: 0.12.8
|
83
83
|
type: :development
|
84
84
|
version_requirements: *id004
|
85
85
|
- !ruby/object:Gem::Dependency
|
@@ -155,13 +155,13 @@ files:
|
|
155
155
|
- lib/chillout/config.rb
|
156
156
|
- lib/chillout/creation_listener.rb
|
157
157
|
- lib/chillout/creations_container.rb
|
158
|
-
- lib/chillout/dispatcher.rb
|
159
158
|
- lib/chillout/event_data_builder.rb
|
160
|
-
- lib/chillout/http_client.rb
|
161
159
|
- lib/chillout/middleware/creations_monitor.rb
|
162
160
|
- lib/chillout/prefixed_logger.rb
|
163
161
|
- lib/chillout/railtie.rb
|
164
|
-
- lib/chillout/
|
162
|
+
- lib/chillout/server-side/dispatcher.rb
|
163
|
+
- lib/chillout/server-side/http_client.rb
|
164
|
+
- lib/chillout/server-side/server_side.rb
|
165
165
|
- lib/chillout/tasks.rb
|
166
166
|
- lib/chillout/version.rb
|
167
167
|
- lib/chillout/worker.rb
|