Skip to content

Commit

Permalink
Remove ActiveSupport dependency 🔥 (#246)
Browse files Browse the repository at this point in the history
* Bump gems

* Drop Ruby 2.7 support, it had EOL on 2023-03-31

* Remove the ActiveSupport dependency for deprecation warnings

* Introduce LightService::Deprecation.warn, switch to it

* Remove ActiveSupport

* Remove active_support dependency

* Update a spec with the correct assertion

* Update the CI build, remove ActiveSupport dependency

* Fix Rubocop errors

* Add Ruby 3.3 version, remove 3.0
  • Loading branch information
adomokos authored Sep 8, 2024
1 parent 0ee0be5 commit 7326b3b
Show file tree
Hide file tree
Showing 18 changed files with 42 additions and 78 deletions.
10 changes: 1 addition & 9 deletions .github/workflows/project-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,8 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu, macos]
ruby: [2.7, '3.0', '3.1', '3.2']
gemfile: [activesupport_5, activesupport_6, activesupport_7]
exclude:
- ruby: '3.2'
gemfile: activesupport_5
- ruby: 2.7
gemfile: activesupport_7
ruby: ['3.1', '3.2', '3.3']
continue-on-error: ${{ endsWith(matrix.ruby, 'head') || matrix.ruby == 'debug' }}
env: # $BUNDLE_GEMFILE must be set at the job level, so it is set for all steps
BUNDLE_GEMFILE: gemfiles/${{ matrix.gemfile }}.gemfile
steps:
- uses: actions/checkout@v3
- uses: ruby/setup-ruby@v1
Expand Down
15 changes: 0 additions & 15 deletions Appraisals

This file was deleted.

7 changes: 0 additions & 7 deletions gemfiles/activesupport_5.gemfile

This file was deleted.

7 changes: 0 additions & 7 deletions gemfiles/activesupport_6.gemfile

This file was deleted.

7 changes: 0 additions & 7 deletions gemfiles/activesupport_7.gemfile

This file was deleted.

8 changes: 4 additions & 4 deletions lib/light-service.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
require 'logger'
require 'active_support/core_ext/string'

require 'light-service/version'

require 'light-service/errors'
require 'light-service/configuration'
require 'light-service/localization_adapter'
require 'light-service/localization_map'
require 'light-service/i18n/localization_adapter'
require 'light-service/context'
require 'light-service/context/key_verifier'
require 'light-service/deprecation_warning'
require 'light-service/i18n/localization_adapter'
require 'light-service/localization_adapter'
require 'light-service/localization_map'
require 'light-service/organizer/scoped_reducable'
require 'light-service/organizer/with_reducer'
require 'light-service/organizer/with_reducer_log_decorator'
Expand Down
8 changes: 3 additions & 5 deletions lib/light-service/action.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
require 'active_support/deprecation'

module LightService
module Action
def self.extended(base_class)
base_class.extend Macros
end

def self.included(base_class)
msg = "including LightService::Action is deprecated. " \
"Please use `extend LightService::Action` instead"
ActiveSupport::Deprecation.warn(msg)
warning_msg = "including LightService::Action is deprecated. " \
"Please use `extend LightService::Action` instead"
LightService::Deprecation.warn(warning_msg)
base_class.extend Macros
end

Expand Down
10 changes: 4 additions & 6 deletions lib/light-service/context.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
require 'active_support/deprecation'

module LightService
module Outcomes
SUCCESS = 0
Expand Down Expand Up @@ -59,9 +57,9 @@ def reset_skip_remaining!
end

def outcome
msg = '`Context#outcome` attribute reader is ' \
'DEPRECATED and will be removed'
ActiveSupport::Deprecation.warn(msg)
warning_msg = '`Context#outcome` attribute reader is ' \
'DEPRECATED and will be removed'
LightService::Deprecation.warn(warning_msg)
@outcome
end

Expand Down Expand Up @@ -103,7 +101,7 @@ def fail_with_rollback!(message = nil, error_code = nil)
def skip_all!(message = nil)
warning_msg = "Using skip_all! has been deprecated, " \
"please use `skip_remaining!` instead."
ActiveSupport::Deprecation.warn(warning_msg)
LightService::Deprecation.warn(warning_msg)

skip_remaining!(message)
end
Expand Down
17 changes: 17 additions & 0 deletions lib/light-service/deprecation_warning.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module LightService
module Deprecation
class << self
# Basic implementation of a deprecation warning
def warn(message, callstack = caller)
# Construct the warning message
warning_message = "DEPRECATION WARNING: #{message}\n"
warning_message += "Called from: #{callstack.first}\n" unless callstack.empty?

# Output the warning message to stderr or a log file
warn warning_message

# Additional logging or actions can be added here
end
end
end
end
6 changes: 3 additions & 3 deletions lib/light-service/orchestrator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,9 @@ def scoped_reduction(ctx, steps)
end

def issue_deprecation_warning_for(method_name)
msg = "`Orchestrator##{method_name}` is DEPRECATED and will be " \
"removed, please switch to `Organizer##{method_name} instead. "
ActiveSupport::Deprecation.warn(msg)
warning_msg = "`Orchestrator##{method_name}` is DEPRECATED and will be " \
"removed, please switch to `Organizer##{method_name} instead. "
LightService::Deprecation.warn(warning_msg)
end
end
end
Expand Down
4 changes: 1 addition & 3 deletions lib/light-service/organizer.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
require 'active_support/deprecation'

module LightService
module Organizer
def self.extended(base_class)
Expand All @@ -10,7 +8,7 @@ def self.extended(base_class)
def self.included(base_class)
warning_msg = "including LightService::Organizer is deprecated. " \
"Please use `extend LightService::Organizer` instead"
ActiveSupport::Deprecation.warn(warning_msg)
LightService::Deprecation.warn(warning_msg)
extended(base_class)
end

Expand Down
2 changes: 1 addition & 1 deletion lib/light-service/organizer/verify_call_method_exists.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def self.run(klass, first_caller = '')
"its entry method (the one that calls with & reduce) " \
"should be named `call`. " \
"Please use #{klass}.call going forward."
ActiveSupport::Deprecation.warn(warning_msg)
LightService.deprecation_warning(warning_msg)
end

def self.caller_method(first_caller)
Expand Down
3 changes: 0 additions & 3 deletions light-service.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,8 @@ Gem::Specification.new do |gem|
gem.version = LightService::VERSION
gem.required_ruby_version = '>= 2.6.0'

gem.add_runtime_dependency("activesupport", ">= 4.0.0")

gem.add_development_dependency("generator_spec", "~> 0.9.4")
gem.add_development_dependency("test-unit", "~> 3.0") # Needed for generator specs.
gem.add_development_dependency("appraisal", "~> 2.3")
gem.add_development_dependency("rspec", "~> 3.0")
gem.add_development_dependency("simplecov", "~> 0.17")
gem.add_development_dependency("codecov", "~> 0.1")
Expand Down
4 changes: 2 additions & 2 deletions spec/acceptance/include_warning_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
it "gives warning" do
expected_msg = "including LightService::Organizer is deprecated. " \
"Please use `extend LightService::Organizer` instead"
expect(ActiveSupport::Deprecation).to receive(:warn)
expect(LightService::Deprecation).to receive(:warn)
.with(expected_msg)

class OrganizerIncludingLS
Expand All @@ -18,7 +18,7 @@ class OrganizerIncludingLS
it "gives warning" do
expected_msg = "including LightService::Action is deprecated. " \
"Please use `extend LightService::Action` instead"
expect(ActiveSupport::Deprecation).to receive(:warn)
expect(LightService::Deprecation).to receive(:warn)
.with(expected_msg)

class ActionIncludingLS
Expand Down
6 changes: 3 additions & 3 deletions spec/acceptance/not_having_call_method_warning_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
describe "Organizer should invoke with/reduce from a call method" do
context "when the organizer does not have a `call` method" do
it "gives warning" do
expect(ActiveSupport::Deprecation)
.to receive(:warn)
expect(LightService)
.to receive(:deprecation_warning)
.with(/^The <OrganizerWithoutCallMethod> class is an organizer/)

class OrganizerWithoutCallMethod
Expand All @@ -22,7 +22,7 @@ def self.do_something

context "when the organizer has the `call` method" do
it "does not issue a warning" do
expect(ActiveSupport::Deprecation)
expect(LightService::Deprecation)
.not_to receive(:warn)

class OrganizerWithCallMethod
Expand Down
2 changes: 1 addition & 1 deletion spec/acceptance/skip_all_warning_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class SkipAllDeprecatedAction

expected_msg = "Using skip_all! has been deprecated, " \
"please use `skip_remaining!` instead."
expect(ActiveSupport::Deprecation).to receive(:warn)
expect(LightService::Deprecation).to receive(:warn)
.with(expected_msg)

SkipAllDeprecatedAction.execute
Expand Down
2 changes: 1 addition & 1 deletion spec/context_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@
end

it "warns about the outcome attribute reader being deprecated" do
expect(ActiveSupport::Deprecation).to receive(:warn)
expect(LightService::Deprecation).to receive(:warn)

expect(context.outcome).to eq(::LightService::Outcomes::SUCCESS)
end
Expand Down
2 changes: 1 addition & 1 deletion spec/support.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
RSpec.shared_context 'expect orchestrator warning' do
before do
expect(ActiveSupport::Deprecation)
expect(LightService::Deprecation)
.to receive(:warn)
.with(/^`Orchestrator#/)
.at_least(:once)
Expand Down

0 comments on commit 7326b3b

Please sign in to comment.