services 4.0.1 → 4.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ffdcdb285cbcbd081d2a061bab59150e91478fc0
4
- data.tar.gz: b7ece5a7a3cf09b02d0020e0e188127c48e92415
3
+ metadata.gz: f848f7e6c1284b6671f565cb1d27d4119cb4a355
4
+ data.tar.gz: 3dbce97879f9e9768715839d9151fb2e3e0bd3ee
5
5
  SHA512:
6
- metadata.gz: 299c7c815229e345be412a0f7ab4bca0d1da1848ac9e29935f0e74b378c9f7dea7e22efed1fe48856060815c68d9bfe0048279da27b313e711ef5dc65c24ef53
7
- data.tar.gz: a5dd66ac67005ba9530e38a2e483bcde53583a044ffbff553dab3ad82123567408c3e281cef66d8c8055ec6638a4c8620b71c53136b91f743f8b3f6dca78d3df
6
+ metadata.gz: 3c370c5325be285ad139465aeb88b471570de89dd0b791afcb4d18f83cf9505071edb0234c61f13946ed1bee9e2dda0013e5644607747ed04d23f049fd06149d
7
+ data.tar.gz: 5cfe01abb853bf5b6ac99127fecde95f225b23df823a1d46d6b09bee498a2a7d41f72062ed5d8bc3a07937c0ffda9e0d087e7b61a512fdd3df87076500e4c419
@@ -1,3 +1,23 @@
1
+ ## 4.0.2
2
+
3
+ * Add null logger
4
+
5
+ ## 4.0.1
6
+
7
+ * Account for that `redis.multi` can return nil
8
+
9
+ ## 4.0.0
10
+
11
+ * Remove host configuration and controller method
12
+
13
+ ## 3.1.1
14
+
15
+ * Query does not have its own error, raise ArgumentError instead
16
+
17
+ ## 3.1.0
18
+
19
+ * Verify that query ids parameter is not nil
20
+
1
21
  ## 3.0.1
2
22
 
3
23
  * Fix for Ruby 2.0
data/Guardfile CHANGED
@@ -15,17 +15,23 @@ module ::Guard
15
15
  REDIS_CLI = SPEC_SUPPORT_DIR.join('redis-cli')
16
16
  REDIS_PIDFILE = SPEC_SUPPORT_DIR.join('redis.pid')
17
17
  REDIS_LOGFILE = SPEC_SUPPORT_DIR.join('log', 'redis.log')
18
+ REDIS_PORT = 6479
19
+
20
+ def self.options_to_string(options)
21
+ options.map { |k, v| "-#{'-' if k.length > 1}#{k} #{v}" }.join(' ')
22
+ end
18
23
 
19
24
  class OnStart
20
25
  def call(guard_class, event, *args)
21
- redis_options = {
26
+ options = {
22
27
  daemonize: 'yes',
23
28
  dir: SPEC_SUPPORT_DIR,
24
29
  dbfilename: 'redis.rdb',
25
30
  logfile: REDIS_LOGFILE,
26
31
  pidfile: REDIS_PIDFILE,
32
+ port: REDIS_PORT
27
33
  }
28
- system "#{REDIS_BIN} #{redis_options.map { |k, v| "--#{k} #{v}" }.join(' ')}"
34
+ system "#{REDIS_BIN} #{ServicesGemHelpers.options_to_string options}"
29
35
 
30
36
  i = 0
31
37
  while !File.exist?(REDIS_PIDFILE)
@@ -39,7 +45,10 @@ module ::Guard
39
45
 
40
46
  class OnStop
41
47
  def call(guard_class, event, *args)
42
- system "#{REDIS_CLI} shutdown"
48
+ options = {
49
+ p: REDIS_PORT
50
+ }
51
+ system "#{REDIS_CLI} #{ServicesGemHelpers.options_to_string options} shutdown"
43
52
 
44
53
  i = 0
45
54
  while File.exist?(REDIS_PIDFILE)
@@ -1,12 +1,14 @@
1
1
  require 'gem_config'
2
2
 
3
+ require_relative 'services/logger/null'
4
+
3
5
  module Services
4
6
  include GemConfig::Base
5
7
 
6
8
  BackgroundProcessorNotFound = Class.new(StandardError)
7
9
 
8
10
  with_configuration do
9
- has :logger
11
+ has :logger, default: Services::Logger::Null.new
10
12
  has :redis
11
13
  end
12
14
  end
@@ -27,6 +27,10 @@ module Services
27
27
 
28
28
  private
29
29
 
30
+ def log(message, meta = {}, severity = 'info')
31
+ Services.configuration.logger.log message, meta.merge(service: self.class.to_s, id: @id), severity
32
+ end
33
+
30
34
  def _split_ids_and_objects(ids_or_objects, klass)
31
35
  ids_or_objects = Array(ids_or_objects)
32
36
  ids, objects = ids_or_objects.grep(Fixnum), ids_or_objects.grep(klass)
@@ -0,0 +1,8 @@
1
+ module Services
2
+ module Logger
3
+ class Null
4
+ def log(*args)
5
+ end
6
+ end
7
+ end
8
+ end
@@ -28,7 +28,6 @@ module Services
28
28
  end
29
29
 
30
30
  def call(*args)
31
- return super if Services.configuration.logger.nil?
32
31
  unless self.class.call_logging_disabled
33
32
  log "START with args: #{args}", caller: caller
34
33
  start = Time.now
@@ -46,10 +45,6 @@ module Services
46
45
 
47
46
  private
48
47
 
49
- def log(message, meta = {}, severity = 'info')
50
- Services.configuration.logger.log message, meta.merge(service: self.class.to_s, id: @id), severity
51
- end
52
-
53
48
  def exception_message(e)
54
49
  message = "#{e.class}: #{e.message}"
55
50
  e.backtrace.each do |line|
@@ -1,3 +1,3 @@
1
1
  module Services
2
- VERSION = '4.0.1'
2
+ VERSION = '4.0.2'
3
3
  end
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+
3
+ describe Services do
4
+ context 'configuration' do
5
+ describe 'logger' do
6
+ it 'uses the null logger by default' do
7
+ expect(Services.configuration.logger).to be_a(Services::Logger::Null)
8
+ end
9
+ end
10
+ end
11
+ end
@@ -17,20 +17,20 @@ SIDEKIQ_PIDFILE = SUPPORT_DIR.join('sidekiq.pid')
17
17
  WAIT = 0.5
18
18
  START_TIMEOUT = 5
19
19
  SIDEKIQ_TIMEOUT = 20
20
+ REDIS_PORT = 6479
20
21
 
21
22
  Dir[SUPPORT_DIR.join('**', '*.rb')].each { |f| require f }
22
23
 
23
-
24
24
  Services.configure do |config|
25
25
  config.redis = Redis.new
26
26
  end
27
27
 
28
28
  Sidekiq.configure_client do |config|
29
- config.redis = { redis: 'redis://localhost:6379/0', namespace: 'sidekiq', size: 1 }
29
+ config.redis = { redis: "redis://localhost:#{REDIS_PORT}/0", namespace: 'sidekiq', size: 1 }
30
30
  end
31
31
 
32
32
  Sidekiq.configure_server do |config|
33
- config.redis = { redis: 'redis://localhost:6379/0', namespace: 'sidekiq' }
33
+ config.redis = { redis: "redis://localhost:#{REDIS_PORT}/0", namespace: 'sidekiq' }
34
34
  end
35
35
 
36
36
  RSpec.configure do |config|
@@ -14,6 +14,6 @@ RSpec.shared_context 'capture logs' do
14
14
  end
15
15
 
16
16
  after do
17
- Services.configuration.logger = nil
17
+ Services.configuration.logger = Services::Logger::Null.new
18
18
  end
19
19
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: services
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.1
4
+ version: 4.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Manuel Meurer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-20 00:00:00.000000000 Z
11
+ date: 2015-04-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -154,6 +154,7 @@ files:
154
154
  - lib/services/asyncable.rb
155
155
  - lib/services/base.rb
156
156
  - lib/services/logger/file.rb
157
+ - lib/services/logger/null.rb
157
158
  - lib/services/logger/redis.rb
158
159
  - lib/services/modules/call_logger.rb
159
160
  - lib/services/modules/exception_wrapper.rb
@@ -164,6 +165,7 @@ files:
164
165
  - lib/services/version.rb
165
166
  - services.gemspec
166
167
  - spec/services/base_spec.rb
168
+ - spec/services/configuration_spec.rb
167
169
  - spec/services/logger/redis_spec.rb
168
170
  - spec/services/modules/call_logger_spec.rb
169
171
  - spec/services/modules/exception_wrapper_spec.rb
@@ -197,12 +199,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
197
199
  version: '0'
198
200
  requirements: []
199
201
  rubyforge_project:
200
- rubygems_version: 2.2.2
202
+ rubygems_version: 2.4.5
201
203
  signing_key:
202
204
  specification_version: 4
203
205
  summary: A nifty service layer for your Rails app
204
206
  test_files:
205
207
  - spec/services/base_spec.rb
208
+ - spec/services/configuration_spec.rb
206
209
  - spec/services/logger/redis_spec.rb
207
210
  - spec/services/modules/call_logger_spec.rb
208
211
  - spec/services/modules/exception_wrapper_spec.rb