Skip to content

Commit

Permalink
Merge pull request #18 from winebarrel/support-ruby3
Browse files Browse the repository at this point in the history
Support ruby3
  • Loading branch information
hirocaster authored Apr 12, 2024
2 parents 20dcb4d + b7255a5 commit dd15192
Show file tree
Hide file tree
Showing 17 changed files with 150 additions and 64 deletions.
30 changes: 24 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,31 @@ jobs:
fail-fast: false
matrix:
ruby:
- "2.3.8"
- "2.4.10"
- "2.5.9"
- "2.6.10"
- "2.7.8"
- "2.5"
- "2.6"
- "2.7"
- "3.0"
- "3.1"
- "3.2"
gemfile:
- gemfiles/activesupport_5_2.gemfile
- gemfiles/activesupport_6_0.gemfile
- gemfiles/activesupport_6_1.gemfile
- gemfiles/activesupport_7_0.gemfile
- gemfiles/without_activesupport.gemfile
exclude:
- ruby: "2.5"
gemfile: gemfiles/activesupport_7_0.gemfile
- ruby: "2.6"
gemfile: gemfiles/activesupport_7_0.gemfile
- ruby: "3.0"
gemfile: gemfiles/activesupport_5_2.gemfile
- ruby: "3.0"
gemfile: gemfiles/activesupport_5_2.gemfile
- ruby: "3.1"
gemfile: gemfiles/activesupport_5_2.gemfile
- ruby: "3.2"
gemfile: gemfiles/activesupport_5_2.gemfile
services:
memcached_11211:
image: memcached
Expand All @@ -39,4 +57,4 @@ jobs:
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
- run: bundle exec rake spec
- run: bundle exec rake
57 changes: 44 additions & 13 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@ AllCops:
Exclude:
- "vendor/**/*"
DisplayCopNames: true
NewCops: disable
TargetRubyVersion: 2.5
SuggestExtensions: false

Style/AsciiComments:
Enabled: false

Style/BracesAroundHashParameters:
Enabled: false

Style/Documentation:
Enabled: false

Style/ExtraSpacing:
Layout/ExtraSpacing:
Enabled: false

Style/GuardClause:
Expand All @@ -27,11 +27,11 @@ Style/ModuleFunction:
Style/StringLiterals:
EnforcedStyle: double_quotes

Style/SingleSpaceBeforeFirstArg:
Layout/SpaceBeforeFirstArg:
Enabled: false

Style/IndentationConsistency:
EnforcedStyle: rails
Layout/IndentationConsistency:
EnforcedStyle: indented_internal_methods

Style/SignalException:
EnforcedStyle: only_raise
Expand All @@ -42,19 +42,50 @@ Style/HashSyntax:
- "**/*.rake"
- "Rakefile"

Metrics/LineLength:
Layout/LineLength:
Max: 160
Exclude:
- "db/migrate/*.rb"

NumericLiterals:
Style/NumericLiterals:
MinDigits: 7

Lint/AssignmentInCondition:
Enabled: false

Lint/BlockAlignment:
Layout/BlockAlignment:
Enabled: false

Metrics/MethodLength:
Max: 12
Enabled: false

Style/FrozenStringLiteralComment:
Enabled: false

Style/NestedParenthesizedCalls:
Enabled: false

Metrics/BlockLength:
Enabled: false

Layout/EmptyLineAfterGuardClause:
Enabled: false

Style/MutableConstant:
Enabled: false

Style/ExpandPathArguments:
Enabled: false

Style/Alias:
Enabled: false

Style/SafeNavigation:
Enabled: false

Style/IfUnlessModifier:
Enabled: false

Style/ExplicitBlockArgument:
Enabled: false

Lint/AmbiguousBlockAssociation:
Enabled: false
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.3.8
3.2.3
15 changes: 15 additions & 0 deletions Appraisals
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
appraise "without_activesupport" do
end

appraise "activesupport_5_2" do
gem "activesupport", "~> 5.2.8.1"
end

appraise "activesupport_6_0" do
gem "activesupport", "~> 6.0.6.1"
end

appraise "activesupport_6_1" do
gem "activesupport", "~> 6.1.7.7"
end

appraise "activesupport_7_0" do
gem "activesupport", "~> 7.0.8.1"
end
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ pre-warming(double write to cach store and other cache store) cache store wrappe
## Support backend cache store

- ActiveSupport::Cache::MemCacheStore
- ActiveSupport::Cache::DalliStore in Dalli
- Dalli::Client

## Installation
Expand Down Expand Up @@ -66,7 +65,12 @@ end
docker compose up -d
bundle install
bundle exec appraisal install
bundle exec appraisal activesupport_5_2 rake spec
bundle exec appraisal activesupport_7_0 rake
#bundle exec appraisal activesupport_5_2 rake
#bundle exec appraisal activesupport_6_0 rake
#bundle exec appraisal activesupport_6_1 rake
#bundle exec appraisal without_activesupport rake
```

## Contributing
Expand Down
7 changes: 6 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
require "bundler/gem_tasks"
require "rspec/core/rake_task"
require "rubocop/rake_task"

RSpec::Core::RakeTask.new(:spec)

task default: :spec
RuboCop::RakeTask.new do |task|
task.options = %w[-c .rubocop.yml]
end

task default: %i[rubocop spec]
2 changes: 1 addition & 1 deletion activesupport.gemfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
source "https://rubygems.org"

gem "rack"
gem "activesupport"
gem "rack"

# Specify your gem's dependencies in active_record_sharding.gemspec
gemspec
12 changes: 7 additions & 5 deletions double_write_cache_stores.gemspec
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# coding: utf-8
lib = File.expand_path("../lib", __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require "double_write_cache_stores/version"
Expand All @@ -18,12 +17,15 @@ Gem::Specification.new do |spec|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
spec.require_paths = ["lib"]

spec.add_runtime_dependency "dalli", "~> 2.7.4"
spec.required_ruby_version = Gem::Requirement.new(">= 2.5")

spec.add_development_dependency "bundler", ">= 1.5"
spec.add_runtime_dependency "dalli", "~> 3.0"

spec.add_development_dependency "appraisal", "~> 2.5.0"
spec.add_development_dependency "bundler", "~> 2.0"
spec.add_development_dependency "pry"
spec.add_development_dependency "rake"
spec.add_development_dependency "rspec"
spec.add_development_dependency "pry"
spec.add_development_dependency "rubocop"
spec.add_development_dependency "tilt", "1.3.7"
spec.add_development_dependency "appraisal", "~> 2.5.0"
end
7 changes: 7 additions & 0 deletions gemfiles/activesupport_6_0.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "activesupport", "~> 6.0.6.1"

gemspec path: "../"
7 changes: 7 additions & 0 deletions gemfiles/activesupport_6_1.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "activesupport", "~> 6.1.7.7"

gemspec path: "../"
7 changes: 7 additions & 0 deletions gemfiles/activesupport_7_0.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "activesupport", "~> 7.0.8.1"

gemspec path: "../"
5 changes: 5 additions & 0 deletions gemfiles/without_activesupport.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gemspec path: "../"
2 changes: 1 addition & 1 deletion lib/double_write_cache_stores.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module DoubleWriteCacheStores
begin
require "active_support"
loaded_active_support = true
rescue LoadError # rubocop:disable Lint/HandleExceptions
rescue LoadError # rubocop:disable Lint/SuppressedException
end

loaded_active_support.freeze
Expand Down
4 changes: 2 additions & 2 deletions lib/double_write_cache_stores/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ def incr_or_increment_method_call(cache_store, key, amount, options)
cache_store.incr key, amount, ttl, default
elsif cache_store.respond_to? :increment
options[:initial] = amount unless options.key?(:initial)
cache_store.increment key, amount, options
cache_store.increment key, amount, **options
end
end

Expand All @@ -191,7 +191,7 @@ def decr_or_decrement_method_call(cache_store, key, amount, options)
cache_store.decr key, amount, ttl, default
elsif cache_store.respond_to? :decrement
options[:initial] = 0 unless options.key?(:initial)
cache_store.decrement key, amount, options
cache_store.decrement key, amount, **options
end
end

Expand Down
4 changes: 2 additions & 2 deletions lib/mem_cache_store_patch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ def dalli
begin
require "active_support/cache/mem_cache_store"

ActiveSupport::Cache::MemCacheStore.send(:include, MemCacheStorePatch)
rescue LoadError # rubocop:disable Lint/HandleExceptions
ActiveSupport::Cache::MemCacheStore.include MemCacheStorePatch
rescue LoadError # rubocop:disable Lint/SuppressedException
end
Loading

0 comments on commit dd15192

Please sign in to comment.