Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix CI failures by resolving RuboCop offenses #12

Merged
merged 2 commits into from
Feb 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 22 additions & 14 deletions lib/modis.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,31 @@ module Modis
@mutex = Mutex.new

class << self
attr_accessor :connection_pool, :redis_options, :connection_pool_size,
:connection_pool_timeout
end
attr_writer :redis_options, :connection_pool_size, :connection_pool_timeout,
:connection_pool

self.redis_options = { driver: :hiredis }
self.connection_pool_size = 5
self.connection_pool_timeout = 5
def redis_options
@redis_options ||= { driver: :hiredis }
end

def self.connection_pool
return @connection_pool if @connection_pool
@mutex.synchronize do
options = { size: connection_pool_size, timeout: connection_pool_timeout }
@connection_pool = ConnectionPool.new(options) { Redis.new(redis_options) }
def connection_pool_size
@connection_pool_size ||= 5
end

def connection_pool_timeout
@connection_pool_timeout ||= 5
end

def connection_pool
return @connection_pool if @connection_pool
@mutex.synchronize do
options = { size: connection_pool_size, timeout: connection_pool_timeout }
@connection_pool = ConnectionPool.new(options) { Redis.new(redis_options) }
end
end
end

def self.with_connection
connection_pool.with { |connection| yield(connection) }
def with_connection
connection_pool.with { |connection| yield(connection) }
end
end
end
2 changes: 1 addition & 1 deletion lib/modis/attribute.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def attribute(name, type, options = {})
end
RUBY

class_eval <<-RUBY, __FILE__, __LINE__
class_eval <<-RUBY, __FILE__, __LINE__ + 1
def #{name}
attributes['#{name}']
end
Expand Down
5 changes: 3 additions & 2 deletions lib/modis/persistence.rb
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ def persist

future
end
# rubocop:enable Metrics/AbcSize, Metrics/PerceivedComplexity

def coerced_attributes
attrs = []
Expand All @@ -234,8 +235,8 @@ def coerced_attributes
end
end
else
changed_attributes.each do |k, _|
attrs << k << coerce_for_persistence(attributes[k])
changed_attributes.each_key do |key|
attrs << key << coerce_for_persistence(attributes[key])
end
end

Expand Down
2 changes: 1 addition & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
unless ENV['TRAVIS']
begin
require './spec/support/simplecov_helper'
include SimpleCovHelper
include SimpleCovHelper # rubocop:disable Style/MixinUsage
start_simple_cov('unit')
rescue LoadError
puts "Coverage disabled."
Expand Down