chillout 0.5.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
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", "~> 0.12.7"
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"
@@ -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(@filter, @server_side).freeze
32
+ @dispatcher = Dispatcher.new(@server_side).freeze
33
33
  @queue = Queue.new
34
34
  end
35
35
 
@@ -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 |app|
7
- if !app.config.chillout.empty?
8
- existing_option_keys = [:port, :hostname, :ssl].select{|key| app.config.chillout.has_key?(key)}
9
- options_list = existing_option_keys.map{|key| [key, app.config.chillout[key]]}
10
- options = Hash[options_list].merge(:logger => Rails.logger)
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
- client = Client.new(app.config.chillout[:secret], options)
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
- ActiveRecord::Base.extend(CreationListener)
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
- app.middleware.use Middleware::CreationsMonitor, client
36
+ def options
37
+ Hash[options_list].merge(:logger => @rails_logger)
38
+ end
17
39
 
18
- client.start_worker
19
- end
40
+ def options_list
41
+ existing_option_keys.map{|key| [key, @chillout_config[key]]}
20
42
  end
21
43
 
22
- rake_tasks do
23
- load "chillout/tasks.rb"
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
@@ -3,8 +3,7 @@ module Chillout
3
3
  class SendCreationsFailed < StandardError
4
4
  end
5
5
 
6
- def initialize(filter, server_side)
7
- @filter = filter
6
+ def initialize(server_side)
8
7
  @server_side = server_side
9
8
  end
10
9
 
@@ -1,3 +1,3 @@
1
1
  module Chillout
2
- VERSION = "0.5.0"
2
+ VERSION = "0.5.1"
3
3
  end
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
@@ -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(filter, server_side)
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(mock, server_side)
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: 11
4
+ hash: 9
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 5
9
- - 0
10
- version: 0.5.0
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-29 00:00:00 Z
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: 33
77
+ hash: 63
78
78
  segments:
79
79
  - 0
80
80
  - 12
81
- - 7
82
- version: 0.12.7
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/server_side.rb
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