Skip to content

Commit

Permalink
Run rubocop autocorrect
Browse files Browse the repository at this point in the history
  • Loading branch information
lewispb committed Jul 10, 2023
1 parent 79c0a97 commit bdfca0a
Show file tree
Hide file tree
Showing 52 changed files with 118 additions and 19 deletions.
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

source "https://rubygems.org"

gemspec
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ integer.value = 5 # => SET myinteger "5"
5 == integer.value # => GET myinteger

decimal = Kredis.decimal "mydecimal" # accuracy!
decimal.value = "%.47f" % (1.0/10) # => SET mydecimal "0.10000000000000000555111512312578270211815834045"
decimal.value = "%.47f" % (1.0 / 10) # => SET mydecimal "0.10000000000000000555111512312578270211815834045"
BigDecimal("0.10000000000000000555111512312578270211815834045e0") == decimal.value # => GET mydecimal

float = Kredis.float "myfloat" # speed!
float.value = 1.0/10 # => SET myfloat "0.1"
float.value = 1.0 / 10 # => SET myfloat "0.1"
0.1 == float.value # => GET myfloat

boolean = Kredis.boolean "myboolean"
Expand Down Expand Up @@ -228,14 +228,14 @@ If you need to connect to Redis with SSL, the recommended approach is to set you

```ruby
Kredis::Connections.connections[:shared] = Redis.new(
url: ENV['REDIS_URL'],
url: ENV["REDIS_URL"],
ssl_params: {
cert_store: OpenSSL::X509::Store.new.tap { |store|
store.add_file(Rails.root.join('config', 'ca_cert.pem').to_s)
store.add_file(Rails.root.join("config", "ca_cert.pem").to_s)
},

cert: OpenSSL::X509::Certificate.new(File.read(
Rails.root.join('config', 'client.crt')
Rails.root.join("config", "client.crt")
)),

key: OpenSSL::PKey::RSA.new(
Expand Down
1 change: 1 addition & 0 deletions bin/console
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

require "irb"
require "bundler/inline"
Expand Down
2 changes: 2 additions & 0 deletions bin/test
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

$: << File.expand_path("../test", __dir__)

require "bundler/setup"
Expand Down
2 changes: 2 additions & 0 deletions kredis.gemspec
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require_relative "lib/kredis/version"

Gem::Specification.new do |s|
Expand Down
2 changes: 2 additions & 0 deletions lib/install/install.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

yaml_path = Rails.root.join("config/redis/shared.yml")
unless yaml_path.exist?
say "Adding `config/redis/shared.yml`"
Expand Down
2 changes: 2 additions & 0 deletions lib/kredis.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "active_support"
require "active_support/core_ext/module/attribute_accessors"
require "active_support/core_ext/module/attribute_accessors_per_thread"
Expand Down
4 changes: 3 additions & 1 deletion lib/kredis/attributes.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Kredis::Attributes
extend ActiveSupport::Concern

Expand Down Expand Up @@ -106,7 +108,7 @@ def kredis_key_evaluated(key)
end

def kredis_key_for_attribute(name)
"#{self.class.name.tableize.gsub("/", ":")}:#{extract_kredis_id}:#{name}"
"#{self.class.name.tableize.tr("/", ":")}:#{extract_kredis_id}:#{name}"
end

def extract_kredis_id
Expand Down
6 changes: 3 additions & 3 deletions lib/kredis/connections.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "redis"

module Kredis::Connections
Expand All @@ -6,11 +8,9 @@ module Kredis::Connections
mattr_accessor :connector, default: ->(config) { Redis.new(config) }

def configured_for(name)
connections[name] ||= begin
Kredis.instrument :meta, message: "Connected to #{name}" do
connections[name] ||= Kredis.instrument :meta, message: "Connected to #{name}" do
connector.call configurator.config_for("redis/#{name}")
end
end
end

def clear_all
Expand Down
2 changes: 2 additions & 0 deletions lib/kredis/log_subscriber.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "active_support/log_subscriber"

class Kredis::LogSubscriber < ActiveSupport::LogSubscriber
Expand Down
2 changes: 2 additions & 0 deletions lib/kredis/migration.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "active_support/core_ext/module/delegation"

class Kredis::Migration
Expand Down
2 changes: 2 additions & 0 deletions lib/kredis/namespace.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Kredis::Namespace
def namespace=(namespace)
Thread.current[:kredis_namespace] = namespace
Expand Down
2 changes: 2 additions & 0 deletions lib/kredis/railtie.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class Kredis::Railtie < ::Rails::Railtie
config.kredis = ActiveSupport::OrderedOptions.new

Expand Down
2 changes: 2 additions & 0 deletions lib/kredis/type_casting.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "json"
require "active_model/type"
require "kredis/type/json"
Expand Down
2 changes: 2 additions & 0 deletions lib/kredis/types.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Kredis::Types
autoload :CallbacksProxy, "kredis/types/callbacks_proxy"

Expand Down
2 changes: 2 additions & 0 deletions lib/kredis/types/callbacks_proxy.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class Kredis::Types::CallbacksProxy
attr_reader :type
delegate :to_s, to: :type
Expand Down
2 changes: 2 additions & 0 deletions lib/kredis/types/counter.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class Kredis::Types::Counter < Kredis::Types::Proxying
proxying :multi, :set, :incrby, :decrby, :get, :del, :exists?

Expand Down
2 changes: 2 additions & 0 deletions lib/kredis/types/cycle.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class Kredis::Types::Cycle < Kredis::Types::Counter
attr_accessor :values

Expand Down
2 changes: 2 additions & 0 deletions lib/kredis/types/enum.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "active_support/core_ext/object/inclusion"

class Kredis::Types::Enum < Kredis::Types::Proxying
Expand Down
2 changes: 2 additions & 0 deletions lib/kredis/types/flag.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class Kredis::Types::Flag < Kredis::Types::Proxying
proxying :set, :exists?, :del

Expand Down
4 changes: 3 additions & 1 deletion lib/kredis/types/hash.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "active_support/core_ext/hash"

class Kredis::Types::Hash < Kredis::Types::Proxying
Expand All @@ -14,7 +16,7 @@ def []=(key, value)
end

def update(**entries)
hset entries.transform_values{ |val| type_to_string(val, typed) } if entries.flatten.any?
hset entries.transform_values { |val| type_to_string(val, typed) } if entries.flatten.any?
end

def values_at(*keys)
Expand Down
2 changes: 2 additions & 0 deletions lib/kredis/types/list.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class Kredis::Types::List < Kredis::Types::Proxying
proxying :lrange, :lrem, :lpush, :ltrim, :rpush, :exists?, :del

Expand Down
4 changes: 3 additions & 1 deletion lib/kredis/types/ordered_set.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class Kredis::Types::OrderedSet < Kredis::Types::Proxying
proxying :multi, :zrange, :zrem, :zadd, :zremrangebyrank, :zcard, :exists?, :del

Expand Down Expand Up @@ -42,7 +44,7 @@ def insert(elements, prepending: false)
base_score + incremental_score
end

[ score , element ]
[ score, element ]
end

multi do
Expand Down
2 changes: 2 additions & 0 deletions lib/kredis/types/proxy.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class Kredis::Types::Proxy
require_relative "proxy/failsafe"
include Failsafe
Expand Down
2 changes: 2 additions & 0 deletions lib/kredis/types/proxy/failsafe.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Kredis::Types::Proxy::Failsafe
def initialize(*)
super
Expand Down
2 changes: 2 additions & 0 deletions lib/kredis/types/proxying.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "active_support/core_ext/module/delegation"

class Kredis::Types::Proxying
Expand Down
2 changes: 2 additions & 0 deletions lib/kredis/types/scalar.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class Kredis::Types::Scalar < Kredis::Types::Proxying
proxying :set, :get, :exists?, :del, :expire, :expireat

Expand Down
2 changes: 2 additions & 0 deletions lib/kredis/types/set.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class Kredis::Types::Set < Kredis::Types::Proxying
proxying :smembers, :sadd, :srem, :multi, :del, :sismember, :scard, :spop, :exists?, :srandmember

Expand Down
2 changes: 2 additions & 0 deletions lib/kredis/types/slots.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class Kredis::Types::Slots < Kredis::Types::Proxying
class NotAvailable < StandardError; end

Expand Down
2 changes: 2 additions & 0 deletions lib/kredis/types/unique_list.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# You'd normally call this a set, but Redis already has another data type for that
class Kredis::Types::UniqueList < Kredis::Types::List
proxying :multi, :ltrim, :exists?
Expand Down
2 changes: 2 additions & 0 deletions lib/kredis/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Kredis
VERSION = "1.5.0"
end
2 changes: 2 additions & 0 deletions lib/tasks/kredis/install.rake
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

namespace :kredis do
desc "Install kredis"
task :install do
Expand Down
2 changes: 2 additions & 0 deletions test/attributes_callbacks_test.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "test_helper"

class AttributesCallbacksTest < ActiveSupport::TestCase
Expand Down
4 changes: 3 additions & 1 deletion test/attributes_test.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "test_helper"
require "active_support/core_ext/integer"

Expand Down Expand Up @@ -249,7 +251,7 @@ class AttributesTest < ActiveSupport::TestCase
assert @person.onboarded.value

@person.onboarded.value = false
refute @person.onboarded.value
assert_not @person.onboarded.value
end

test "missing id to constrain key" do
Expand Down
4 changes: 3 additions & 1 deletion test/callbacks_test.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "test_helper"

class CallbacksTest < ActiveSupport::TestCase
Expand Down Expand Up @@ -30,7 +32,7 @@ class CallbacksTest < ActiveSupport::TestCase
attention = Kredis.slot "attention", after_change: ->(slot) { @callback_check = slot.available? }
attention.reserve

refute @callback_check
assert_not @callback_check
end

test "enum with after_change proc callback" do
Expand Down
2 changes: 2 additions & 0 deletions test/connections_test.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "test_helper"

class ConnectionsTest < ActiveSupport::TestCase
Expand Down
2 changes: 2 additions & 0 deletions test/log_subscriber_test.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "test_helper"
require "active_support/log_subscriber/test_helper"

Expand Down
2 changes: 2 additions & 0 deletions test/migration_test.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "test_helper"

class MigrationTest < ActiveSupport::TestCase
Expand Down
2 changes: 2 additions & 0 deletions test/namespace_test.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "test_helper"

class NamespaceTest < ActiveSupport::TestCase
Expand Down
2 changes: 2 additions & 0 deletions test/proxy_test.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "test_helper"

class ProxyTest < ActiveSupport::TestCase
Expand Down
2 changes: 2 additions & 0 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "bundler/setup"
require "active_support/test_case"
require "active_support/testing/autorun"
Expand Down
2 changes: 2 additions & 0 deletions test/types/counter_test.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "test_helper"
require "active_support/core_ext/integer"

Expand Down
2 changes: 2 additions & 0 deletions test/types/cycle_test.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "test_helper"
require "active_support/core_ext/integer"

Expand Down
2 changes: 2 additions & 0 deletions test/types/enum_test.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "test_helper"

class EnumTest < ActiveSupport::TestCase
Expand Down
2 changes: 2 additions & 0 deletions test/types/flag_test.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "test_helper"

class FlagTest < ActiveSupport::TestCase
Expand Down
4 changes: 3 additions & 1 deletion test/types/hash_test.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "test_helper"
require "active_support/core_ext/integer"

Expand Down Expand Up @@ -87,7 +89,7 @@ class HashTest < ActiveSupport::TestCase
test "exists?" do
assert_not @hash.exists?

@hash[:key] = :value
@hash[:key] = :value
assert @hash.exists?
end
end
2 changes: 2 additions & 0 deletions test/types/list_test.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "test_helper"
require "active_support/core_ext/integer"

Expand Down
2 changes: 2 additions & 0 deletions test/types/ordered_set_test.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "test_helper"

class OrderedSetTest < ActiveSupport::TestCase
Expand Down
Loading

0 comments on commit bdfca0a

Please sign in to comment.