chillout 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0-p0
4
+ - 1.9.3
5
+ - 1.9.2
6
+ - 1.8.7
7
+ - ree
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # Chillout
2
2
 
3
+ [![Build Status](https://travis-ci.org/chilloutio/chillout.png)](https://travis-ci.org/chilloutio/chillout)
4
+
3
5
  ## Installation
4
6
 
5
7
  Add this line to your Rails application's Gemfile:
@@ -20,3 +22,9 @@ config.chillout = {
20
22
  hostname: 'api.chillout.io'
21
23
  }
22
24
  ```
25
+
26
+ Check if everything is ok:
27
+
28
+ $ RAILS_ENV=production rake chillout:check
29
+
30
+ You'll see "Chillout API available" if everything is ok. Otherwise you'll be informed about problem with authorization (maybe you've put wrong secret?) or not known problems, like invalid values in configuration.
data/chillout.gemspec CHANGED
@@ -17,6 +17,7 @@ Gem::Specification.new do |gem|
17
17
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
18
  gem.require_paths = ["lib"]
19
19
 
20
+ gem.add_dependency "json", "~> 1.7.0"
20
21
  gem.add_development_dependency "minitest", "~>3.2.0"
21
22
  gem.add_development_dependency "rake", "~> 0.9.2"
22
23
  gem.add_development_dependency "mocha", "~> 0.12.7"
@@ -5,7 +5,7 @@ module Chillout
5
5
  def inherited(subclass)
6
6
  super
7
7
  class_name = subclass.name
8
- subclass.after_commit on: :create do
8
+ subclass.after_commit :on => :create do
9
9
  Thread.current[:creations] ||= CreationsContainer.new
10
10
  creations = Thread.current[:creations]
11
11
  creations.increment!(class_name)
@@ -6,13 +6,13 @@ module Chillout
6
6
 
7
7
  def build_from_creations_container(creations_container, timestamp)
8
8
  {
9
- metric: "creations",
10
- timestamp: timestamp,
11
- content: {
12
- creations: build_creations_content(creations_container),
13
- environment: @config.environment
9
+ :metric => "creations",
10
+ :timestamp => timestamp,
11
+ :content => {
12
+ :creations => build_creations_content(creations_container),
13
+ :environment => @config.environment
14
14
  },
15
- notifier: build_notifier
15
+ :notifier => build_notifier
16
16
  }
17
17
  end
18
18
 
@@ -25,9 +25,9 @@ module Chillout
25
25
 
26
26
  def build_notifier
27
27
  {
28
- name: @config.notifier_name,
29
- version: @config.version,
30
- url: @config.notifier_url
28
+ :name => @config.notifier_name,
29
+ :version => @config.version,
30
+ :url => @config.notifier_url
31
31
  }
32
32
  end
33
33
  end
@@ -1,4 +1,5 @@
1
1
  require 'net/http'
2
+ require 'net/https'
2
3
  require 'json'
3
4
 
4
5
  module Chillout
@@ -7,7 +7,7 @@ module Chillout
7
7
  if !app.config.chillout.empty?
8
8
  existing_option_keys = [:port, :hostname, :ssl].select{|key| app.config.chillout.has_key?(key)}
9
9
  options_list = existing_option_keys.map{|key| [key, app.config.chillout[key]]}
10
- options = Hash[options_list].merge(logger: Rails.logger)
10
+ options = Hash[options_list].merge(:logger => Rails.logger)
11
11
 
12
12
  client = Client.new(app.config.chillout[:secret], options)
13
13
 
@@ -3,7 +3,7 @@ namespace :chillout do
3
3
  task :check do
4
4
  Rails.initialize!
5
5
  config = Rails.configuration.chillout
6
- client = Chillout::Client.new(config[:secret], config.reject{|x| x == :secret})
6
+ client = Chillout::Client.new(config[:secret], config.reject{|key, value| key == :secret})
7
7
  check_result = client.check_api_connection
8
8
 
9
9
  if check_result.successful?
@@ -1,3 +1,3 @@
1
1
  module Chillout
2
- VERSION = "0.4.0"
2
+ VERSION = "0.4.1"
3
3
  end
@@ -2,13 +2,13 @@ require 'test_helper'
2
2
 
3
3
  class CheckResultTest < ChilloutTestCase
4
4
  def test_successful_for_response_with_200_code
5
- response = stub(code: "200")
5
+ response = stub(:code => "200")
6
6
  check_result = CheckResult.new(response)
7
7
  assert check_result.successful?
8
8
  end
9
9
 
10
10
  def test_not_successful_for_response_with_other_code
11
- response = stub(code: "304")
11
+ response = stub(:code => "304")
12
12
  check_result = CheckResult.new(response)
13
13
  refute check_result.successful?
14
14
  end
@@ -20,19 +20,19 @@ class CheckResultTest < ChilloutTestCase
20
20
  end
21
21
 
22
22
  def test_dont_have_problem_with_authorization_for_response_with_200_code
23
- response = stub(code: "200")
23
+ response = stub(:code => "200")
24
24
  check_result = CheckResult.new(response)
25
25
  refute check_result.has_problem_with_authorization?
26
26
  end
27
27
 
28
28
  def test_have_problem_with_authorization_for_response_with_401_code
29
- response = stub(code: "401")
29
+ response = stub(:code => "401")
30
30
  check_result = CheckResult.new(response)
31
31
  assert check_result.has_problem_with_authorization?
32
32
  end
33
33
 
34
34
  def test_dont_have_problem_with_authorization_for_response_with_other_code
35
- response = stub(code: "501")
35
+ response = stub(:code => "501")
36
36
  check_result = CheckResult.new(response)
37
37
  refute check_result.has_problem_with_authorization?
38
38
  end
data/test/client_test.rb CHANGED
@@ -9,7 +9,7 @@ class ClientTest < ChilloutTestCase
9
9
  end
10
10
 
11
11
  def test_initialize_with_options_hash
12
- client = Chillout::Client.new("xyz123", platform: 'rack')
12
+ client = Chillout::Client.new("xyz123", :platform => 'rack')
13
13
  assert_equal "xyz123", client.config.api_key
14
14
  assert_equal "rack", client.config.platform
15
15
  end
@@ -23,7 +23,7 @@ class ClientTest < ChilloutTestCase
23
23
  end
24
24
 
25
25
  def test_initialize_with_options_hash_and_block
26
- client = Chillout::Client.new("xyz", platform: 'rack') do |config|
26
+ client = Chillout::Client.new("xyz", :platform => 'rack') do |config|
27
27
  config.port = 443
28
28
  end
29
29
  assert_equal "xyz", client.config.api_key
data/test/config_test.rb CHANGED
@@ -11,7 +11,7 @@ class ConfigTest < ChilloutTestCase
11
11
  end
12
12
 
13
13
  def test_update_with_options_hash
14
- @config.update(platform: 'rack')
14
+ @config.update(:platform => 'rack')
15
15
  assert_equal 'rack', @config.platform
16
16
  end
17
17
 
@@ -3,10 +3,10 @@ require 'test_helper'
3
3
  module Chillout
4
4
  class HttpClientTest < ChilloutTestCase
5
5
  def test_post_raises_not_sent_exception_when_get_any_error
6
- logger = stub(error: nil)
6
+ logger = stub(:error => nil)
7
7
  http_client = HttpClient.new(:wrong_config, logger)
8
8
  assert_raises HttpClient::NotSent do
9
- http_client.post("/events", {fake_data: "client"})
9
+ http_client.post("/events", {:fake_data => "client"})
10
10
  end
11
11
  end
12
12
  end
@@ -4,7 +4,7 @@ class ClientIntegrationTest < ChilloutTestCase
4
4
  def test_check_api_connection_with_200_ok_response
5
5
  @_api_key = "xyz123"
6
6
  url = api_url("check")
7
- stub_request(:get, url).to_return(body: "OK", status: 200)
7
+ stub_request(:get, url).to_return(:body => "OK", :status => 200)
8
8
 
9
9
  client = Chillout::Client.new(@_api_key)
10
10
  check_result = client.check_api_connection
@@ -14,7 +14,7 @@ class ClientIntegrationTest < ChilloutTestCase
14
14
  def test_check_api_connection_with_other_response
15
15
  @_api_key = "xyz123"
16
16
  url = api_url("check")
17
- stub_request(:get, url).to_return(body: "Not Found", status: 404)
17
+ stub_request(:get, url).to_return(:body => "Not Found", :status => 404)
18
18
 
19
19
  client = Chillout::Client.new(@_api_key)
20
20
  check_result = client.check_api_connection
data/test/test_helper.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  require 'test/unit'
2
2
  require 'mocha'
3
3
  require 'contest'
4
- require 'webmock/minitest'
4
+ require 'webmock/test_unit'
5
5
  require 'rack/test'
6
6
 
7
7
  $LOAD_PATH << File.expand_path('../../lib', __FILE__)
@@ -9,6 +9,13 @@ $LOAD_PATH << File.expand_path('../../lib', __FILE__)
9
9
  require 'chillout'
10
10
 
11
11
  class ChilloutTestCase < Test::Unit::TestCase
12
+ def refute(value, message=nil)
13
+ assert !value, message || "Expected #{value.inspect} to be false."
14
+ end
15
+
16
+ def assert_includes(collection, object, message=nil)
17
+ assert collection.include?(object), message || "#{collection.inspect} expected to include #{object.inspect}."
18
+ end
12
19
 
13
20
  def build_exception(klass = Exception, message = "Test Exception")
14
21
  raise klass.new(message)
@@ -33,7 +40,7 @@ class ChilloutTestCase < Test::Unit::TestCase
33
40
  end
34
41
 
35
42
  def assert_request_headers(resource_name, headers = {})
36
- assert_requested(:post, api_url(resource_name), headers: headers)
43
+ assert_requested(:post, api_url(resource_name), :headers => headers)
37
44
  end
38
45
 
39
46
  def api_url(resource_name)
data/test/worker_test.rb CHANGED
@@ -6,8 +6,8 @@ module Chillout
6
6
  @dispatcher = stub
7
7
  @queue = stub
8
8
  @container = stub
9
- @logger = stub(info: "", error: "")
10
- @container_class = stub(new: @container)
9
+ @logger = stub(:info => "", :error => "")
10
+ @container_class = stub(:new => @container)
11
11
  @worker = Worker.new(@dispatcher, @queue, @logger, @container_class)
12
12
  end
13
13
 
metadata CHANGED
@@ -1,123 +1,149 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: chillout
3
- version: !ruby/object:Gem::Version
4
- version: 0.4.0
3
+ version: !ruby/object:Gem::Version
4
+ hash: 13
5
5
  prerelease:
6
+ segments:
7
+ - 0
8
+ - 4
9
+ - 1
10
+ version: 0.4.1
6
11
  platform: ruby
7
- authors:
8
- - Michał Łomnicki
12
+ authors:
13
+ - "Micha\xC5\x82 \xC5\x81omnicki"
9
14
  - Jan Filipowski
10
15
  autorequire:
11
16
  bindir: bin
12
17
  cert_chain: []
13
- date: 2013-03-25 00:00:00.000000000 Z
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
16
- name: minitest
17
- requirement: !ruby/object:Gem::Requirement
18
+
19
+ date: 2013-03-27 00:00:00 Z
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: json
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
18
25
  none: false
19
- requirements:
26
+ requirements:
20
27
  - - ~>
21
- - !ruby/object:Gem::Version
22
- version: 3.2.0
23
- type: :development
28
+ - !ruby/object:Gem::Version
29
+ hash: 11
30
+ segments:
31
+ - 1
32
+ - 7
33
+ - 0
34
+ version: 1.7.0
35
+ type: :runtime
36
+ version_requirements: *id001
37
+ - !ruby/object:Gem::Dependency
38
+ name: minitest
24
39
  prerelease: false
25
- version_requirements: !ruby/object:Gem::Requirement
40
+ requirement: &id002 !ruby/object:Gem::Requirement
26
41
  none: false
27
- requirements:
42
+ requirements:
28
43
  - - ~>
29
- - !ruby/object:Gem::Version
44
+ - !ruby/object:Gem::Version
45
+ hash: 15
46
+ segments:
47
+ - 3
48
+ - 2
49
+ - 0
30
50
  version: 3.2.0
31
- - !ruby/object:Gem::Dependency
32
- name: rake
33
- requirement: !ruby/object:Gem::Requirement
34
- none: false
35
- requirements:
36
- - - ~>
37
- - !ruby/object:Gem::Version
38
- version: 0.9.2
39
51
  type: :development
52
+ version_requirements: *id002
53
+ - !ruby/object:Gem::Dependency
54
+ name: rake
40
55
  prerelease: false
41
- version_requirements: !ruby/object:Gem::Requirement
56
+ requirement: &id003 !ruby/object:Gem::Requirement
42
57
  none: false
43
- requirements:
58
+ requirements:
44
59
  - - ~>
45
- - !ruby/object:Gem::Version
60
+ - !ruby/object:Gem::Version
61
+ hash: 63
62
+ segments:
63
+ - 0
64
+ - 9
65
+ - 2
46
66
  version: 0.9.2
47
- - !ruby/object:Gem::Dependency
48
- name: mocha
49
- requirement: !ruby/object:Gem::Requirement
50
- none: false
51
- requirements:
52
- - - ~>
53
- - !ruby/object:Gem::Version
54
- version: 0.12.7
55
67
  type: :development
68
+ version_requirements: *id003
69
+ - !ruby/object:Gem::Dependency
70
+ name: mocha
56
71
  prerelease: false
57
- version_requirements: !ruby/object:Gem::Requirement
72
+ requirement: &id004 !ruby/object:Gem::Requirement
58
73
  none: false
59
- requirements:
74
+ requirements:
60
75
  - - ~>
61
- - !ruby/object:Gem::Version
76
+ - !ruby/object:Gem::Version
77
+ hash: 33
78
+ segments:
79
+ - 0
80
+ - 12
81
+ - 7
62
82
  version: 0.12.7
63
- - !ruby/object:Gem::Dependency
64
- name: contest
65
- requirement: !ruby/object:Gem::Requirement
66
- none: false
67
- requirements:
68
- - - ~>
69
- - !ruby/object:Gem::Version
70
- version: 0.1.3
71
83
  type: :development
84
+ version_requirements: *id004
85
+ - !ruby/object:Gem::Dependency
86
+ name: contest
72
87
  prerelease: false
73
- version_requirements: !ruby/object:Gem::Requirement
88
+ requirement: &id005 !ruby/object:Gem::Requirement
74
89
  none: false
75
- requirements:
90
+ requirements:
76
91
  - - ~>
77
- - !ruby/object:Gem::Version
92
+ - !ruby/object:Gem::Version
93
+ hash: 29
94
+ segments:
95
+ - 0
96
+ - 1
97
+ - 3
78
98
  version: 0.1.3
79
- - !ruby/object:Gem::Dependency
80
- name: rack-test
81
- requirement: !ruby/object:Gem::Requirement
82
- none: false
83
- requirements:
84
- - - ~>
85
- - !ruby/object:Gem::Version
86
- version: 0.6.2
87
99
  type: :development
100
+ version_requirements: *id005
101
+ - !ruby/object:Gem::Dependency
102
+ name: rack-test
88
103
  prerelease: false
89
- version_requirements: !ruby/object:Gem::Requirement
104
+ requirement: &id006 !ruby/object:Gem::Requirement
90
105
  none: false
91
- requirements:
106
+ requirements:
92
107
  - - ~>
93
- - !ruby/object:Gem::Version
108
+ - !ruby/object:Gem::Version
109
+ hash: 3
110
+ segments:
111
+ - 0
112
+ - 6
113
+ - 2
94
114
  version: 0.6.2
95
- - !ruby/object:Gem::Dependency
96
- name: webmock
97
- requirement: !ruby/object:Gem::Requirement
98
- none: false
99
- requirements:
100
- - - ~>
101
- - !ruby/object:Gem::Version
102
- version: 1.8.11
103
115
  type: :development
116
+ version_requirements: *id006
117
+ - !ruby/object:Gem::Dependency
118
+ name: webmock
104
119
  prerelease: false
105
- version_requirements: !ruby/object:Gem::Requirement
120
+ requirement: &id007 !ruby/object:Gem::Requirement
106
121
  none: false
107
- requirements:
122
+ requirements:
108
123
  - - ~>
109
- - !ruby/object:Gem::Version
124
+ - !ruby/object:Gem::Version
125
+ hash: 33
126
+ segments:
127
+ - 1
128
+ - 8
129
+ - 11
110
130
  version: 1.8.11
131
+ type: :development
132
+ version_requirements: *id007
111
133
  description: Chillout.io Ruby client
112
- email:
134
+ email:
113
135
  - michal.lomnicki@gmail.com
114
136
  - jachuf@gmail.com
115
137
  - dev@arkency.com
116
138
  executables: []
139
+
117
140
  extensions: []
141
+
118
142
  extra_rdoc_files: []
119
- files:
143
+
144
+ files:
120
145
  - .gitignore
146
+ - .travis.yml
121
147
  - Gemfile
122
148
  - LICENSE.txt
123
149
  - README.md
@@ -155,35 +181,38 @@ files:
155
181
  - test/worker_test.rb
156
182
  homepage: http://chillout.io/
157
183
  licenses: []
184
+
158
185
  post_install_message:
159
186
  rdoc_options: []
160
- require_paths:
187
+
188
+ require_paths:
161
189
  - lib
162
- required_ruby_version: !ruby/object:Gem::Requirement
190
+ required_ruby_version: !ruby/object:Gem::Requirement
163
191
  none: false
164
- requirements:
165
- - - ! '>='
166
- - !ruby/object:Gem::Version
167
- version: '0'
168
- segments:
192
+ requirements:
193
+ - - ">="
194
+ - !ruby/object:Gem::Version
195
+ hash: 3
196
+ segments:
169
197
  - 0
170
- hash: 1830182422873723913
171
- required_rubygems_version: !ruby/object:Gem::Requirement
198
+ version: "0"
199
+ required_rubygems_version: !ruby/object:Gem::Requirement
172
200
  none: false
173
- requirements:
174
- - - ! '>='
175
- - !ruby/object:Gem::Version
176
- version: '0'
177
- segments:
201
+ requirements:
202
+ - - ">="
203
+ - !ruby/object:Gem::Version
204
+ hash: 3
205
+ segments:
178
206
  - 0
179
- hash: 1830182422873723913
207
+ version: "0"
180
208
  requirements: []
209
+
181
210
  rubyforge_project:
182
- rubygems_version: 1.8.25
211
+ rubygems_version: 1.8.15
183
212
  signing_key:
184
213
  specification_version: 3
185
214
  summary: Chillout.io Ruby client
186
- test_files:
215
+ test_files:
187
216
  - test/check_result_test.rb
188
217
  - test/client_test.rb
189
218
  - test/config_test.rb