Skip to content

Commit

Permalink
Bump RuboCop & default to double-quoted strings 🤖 (#60)
Browse files Browse the repository at this point in the history
  • Loading branch information
sunny committed Apr 25, 2022
1 parent 3779019 commit 50f1858
Show file tree
Hide file tree
Showing 45 changed files with 308 additions and 301 deletions.
13 changes: 10 additions & 3 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,18 @@ Style/HashTransformValues:
Style/Documentation:
Enabled: false

Style/ExponentialNotation:
Enabled: true

Style/OpenStructUse:
Enabled: false

# Allow using the second parameter as a boolean.
Style/OptionalBooleanParameter:
Enabled: false

Style/StringLiterals:
EnforcedStyle: double_quotes

Style/TrailingCommaInArguments:
EnforcedStyleForMultiline: comma

Style/ExponentialNotation:
Enabled: true
4 changes: 2 additions & 2 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Examples of unacceptable behavior by participants include:
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
* Publishing others’ private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting
Expand Down Expand Up @@ -63,7 +63,7 @@ Further details of specific enforcement policies may be posted separately.

Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.
members of the project’s leadership.

## Attribution

Expand Down
14 changes: 7 additions & 7 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
# frozen_string_literal: true

source 'https://rubygems.org'
source "https://rubygems.org"

gemspec

if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.5')
if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("2.5")
# Here because v1.13 requires ruby version >= 2.5.
gem 'rubocop', '< 1.13'
gem "rubocop", "< 1.13"

# Here because v1.11.0 requires ruby version >= 2.5.
gem 'rubocop-performance', '< 1.11.0'
gem "rubocop-performance", "< 1.11.0"

# Here because v2.3.0 requires ruby version >= 2.5.
gem 'rubocop-rspec', '< 2.3.0'
gem "rubocop-rspec", "< 2.3.0"

# RuboCop dependency
# Here because v1.21.0 requires ruby version >= 2.5.
gem 'parallel', '< 1.21'
gem "parallel", "< 1.21"

# RuboCop dependency
# Here because v1.4.2 requires ruby version >= 2.5.
gem 'rubocop-ast', '< 1.4.2'
gem "rubocop-ast", "< 1.4.2"
end
18 changes: 9 additions & 9 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ GEM
diff-lcs (1.4.4)
interactor (3.1.2)
method_source (1.0.0)
parallel (1.21.0)
parser (3.0.2.0)
parallel (1.22.1)
parser (3.1.2.0)
ast (~> 2.4.1)
pry (0.14.1)
coderay (~> 1.1)
method_source (~> 1.0)
rainbow (3.0.0)
rainbow (3.1.1)
rake (13.0.6)
regexp_parser (2.1.1)
regexp_parser (2.3.1)
rexml (3.2.5)
rspec (3.10.0)
rspec-core (~> 3.10.0)
Expand All @@ -36,17 +36,17 @@ GEM
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.10.0)
rspec-support (3.10.3)
rubocop (1.23.0)
rubocop (1.28.2)
parallel (~> 1.10)
parser (>= 3.0.0.0)
parser (>= 3.1.0.0)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml
rubocop-ast (>= 1.12.0, < 2.0)
rubocop-ast (>= 1.17.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 3.0)
rubocop-ast (1.13.0)
parser (>= 3.0.1.1)
rubocop-ast (1.17.0)
parser (>= 3.1.1.0)
rubocop-performance (1.12.0)
rubocop (>= 1.7.0, < 2.0)
rubocop-ast (>= 0.4.0)
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Add these lines to your application’s Gemfile:

```rb
# Composable service objects
gem 'service_actor'
gem "service_actor"
```

When using Rails, you can include the
Expand Down Expand Up @@ -70,8 +70,8 @@ SendNotification.call # => <ServiceActor::Result…>
```

When called, actors return a Result. Reading and writing to this result allows
actors to accept and return multiple arguments. Let's find out how to do that
and then we'll see how to chain multiple actors togethor.
actors to accept and return multiple arguments. Let’s find out how to do that
and then we’ll see how to chain multiple actors togethor.

### Inputs

Expand Down Expand Up @@ -207,7 +207,7 @@ class UpdateUser < Actor
end
```

You may also use strings instead of constants, such as `type: 'User'`.
You may also use strings instead of constants, such as `type: "User"`.

When using a type condition, `allow_nil` defaults to `false`.

Expand Down
6 changes: 3 additions & 3 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# frozen_string_literal: true

require 'bundler/gem_tasks'
require 'rubocop/rake_task'
require 'rspec/core/rake_task'
require "bundler/gem_tasks"
require "rubocop/rake_task"
require "rspec/core/rake_task"

RSpec::Core::RakeTask.new(:spec)
RuboCop::RakeTask.new(:rubocop)
Expand Down
6 changes: 3 additions & 3 deletions bin/console
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

require 'bundler/setup'
require 'service_actor'
require "bundler/setup"
require "service_actor"

require 'pry'
require "pry"
Pry.start
18 changes: 9 additions & 9 deletions bin/rake
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,26 @@
# this file is here to facilitate running it.
#

require 'pathname'
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile',
require "pathname"
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
Pathname.new(__FILE__).realpath)

bundle_binstub = File.expand_path('bundle', __dir__)
bundle_binstub = File.expand_path("bundle", __dir__)

if File.file?(bundle_binstub)
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
load(bundle_binstub)
else
abort(
'Your `bin/bundle` was not generated by Bundler, so this binstub ' \
"Your `bin/bundle` was not generated by Bundler, so this binstub " \
"cannot run.\n" \
'Replace `bin/bundle` by running `bundle binstubs bundler --force`, ' \
'then run this command again.',
"Replace `bin/bundle` by running `bundle binstubs bundler --force`, " \
"then run this command again.",
)
end
end

require 'rubygems'
require 'bundler/setup'
require "rubygems"
require "bundler/setup"

load Gem.bin_path('rake', 'rake')
load Gem.bin_path("rake", "rake")
18 changes: 9 additions & 9 deletions bin/rspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,26 @@
# this file is here to facilitate running it.
#

require 'pathname'
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile',
require "pathname"
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
Pathname.new(__FILE__).realpath)

bundle_binstub = File.expand_path('bundle', __dir__)
bundle_binstub = File.expand_path("bundle", __dir__)

if File.file?(bundle_binstub)
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
load(bundle_binstub)
else
abort(
'Your `bin/bundle` was not generated by Bundler, so this binstub ' \
"Your `bin/bundle` was not generated by Bundler, so this binstub " \
"cannot run.\n" \
'Replace `bin/bundle` by running `bundle binstubs bundler --force`, ' \
'then run this command again.',
"Replace `bin/bundle` by running `bundle binstubs bundler --force`, " \
"then run this command again.",
)
end
end

require 'rubygems'
require 'bundler/setup'
require "rubygems"
require "bundler/setup"

load Gem.bin_path('rspec-core', 'rspec')
load Gem.bin_path("rspec-core", "rspec")
20 changes: 10 additions & 10 deletions bin/rubocop
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,26 @@
# this file is here to facilitate running it.
#

require 'pathname'
ENV['BUNDLE_GEMFILE'] ||=
File.expand_path('../../Gemfile', Pathname.new(__FILE__).realpath)
require "pathname"
ENV["BUNDLE_GEMFILE"] ||=
File.expand_path("../../Gemfile", Pathname.new(__FILE__).realpath)

bundle_binstub = File.expand_path('bundle', __dir__)
bundle_binstub = File.expand_path("bundle", __dir__)

if File.file?(bundle_binstub)
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
load(bundle_binstub)
else
abort(
'Your `bin/bundle` was not generated by Bundler, so this binstub ' \
"Your `bin/bundle` was not generated by Bundler, so this binstub " \
"cannot run.\n" \
'Replace `bin/bundle` by running `bundle binstubs bundler --force`, ' \
'then run this command again.',
"Replace `bin/bundle` by running `bundle binstubs bundler --force`, " \
"then run this command again.",
)
end
end

require 'rubygems'
require 'bundler/setup'
require "rubygems"
require "bundler/setup"

load Gem.bin_path('rubocop', 'rubocop')
load Gem.bin_path("rubocop", "rubocop")
2 changes: 1 addition & 1 deletion lib/service_actor.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

require 'service_actor/base'
require "service_actor/base"

# Class to inherit from in your application.
class Actor
Expand Down
26 changes: 13 additions & 13 deletions lib/service_actor/base.rb
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
# frozen_string_literal: true

# Exceptions
require 'service_actor/error'
require 'service_actor/failure'
require 'service_actor/argument_error'
require "service_actor/error"
require "service_actor/failure"
require "service_actor/argument_error"

# Core
require 'service_actor/core'
require 'service_actor/attributable'
require 'service_actor/playable'
require 'service_actor/result'
require "service_actor/core"
require "service_actor/attributable"
require "service_actor/playable"
require "service_actor/result"

# Concerns
require 'service_actor/type_checkable'
require 'service_actor/nil_checkable'
require 'service_actor/conditionable'
require 'service_actor/defaultable'
require 'service_actor/collectionable'
require 'service_actor/failable'
require "service_actor/type_checkable"
require "service_actor/nil_checkable"
require "service_actor/conditionable"
require "service_actor/defaultable"
require "service_actor/collectionable"
require "service_actor/failable"

module ServiceActor
module Base
Expand Down
2 changes: 1 addition & 1 deletion lib/service_actor/collectionable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module ServiceActor
# Example:
#
# class Pay < Actor
# input :provider, in: ['MANGOPAY', 'PayPal', 'Stripe']
# input :provider, in: ["MANGOPAY", "PayPal", "Stripe"]
# end
module Collectionable
def self.included(base)
Expand Down
4 changes: 2 additions & 2 deletions lib/service_actor/core.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def self.included(base)
module ClassMethods
# Call an actor with a given result. Returns the result.
#
# CreateUser.call(name: 'Joe')
# CreateUser.call(name: "Joe")
def call(options = nil, **arguments)
result = Result.to_result(options).merge!(arguments)
new(result)._call
Expand All @@ -19,7 +19,7 @@ def call(options = nil, **arguments)
# Call an actor with arguments. Returns the result and does not raise on
# failure.
#
# CreateUser.result(name: 'Joe')
# CreateUser.result(name: "Joe")
def result(data = nil, **arguments)
call(data, **arguments)
rescue Failure => e
Expand Down
6 changes: 3 additions & 3 deletions lib/service_actor/nil_checkable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ def self.included(base)

module PrependedMethods
def _call
check_context_for_nil(self.class.inputs, origin: 'input')
check_context_for_nil(self.class.inputs, origin: "input")

super

check_context_for_nil(self.class.outputs, origin: 'output')
check_context_for_nil(self.class.outputs, origin: "output")
end

private
Expand All @@ -31,7 +31,7 @@ def check_context_for_nil(definitions, origin:)

raise ArgumentError,
"The #{origin} \"#{name}\" on #{self.class} does not allow " \
'nil values'
"nil values"
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/service_actor/playable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def play_service_actor(actor)

def play_interactor(actor)
return unless actor.is_a?(Class)
return unless actor.ancestors.map(&:name).include?('Interactor')
return unless actor.ancestors.map(&:name).include?("Interactor")

result.merge!(actor.call(result).to_h)
end
Expand Down
2 changes: 1 addition & 1 deletion lib/service_actor/result.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

require 'ostruct'
require "ostruct"

module ServiceActor
# Represents the context of an actor, holding the data from both its inputs
Expand Down

0 comments on commit 50f1858

Please sign in to comment.