Skip to content

Commit a8edcdc

Browse files
author
Sebastian Wilgosz
committed
Refactor to meet rubocop expectations
1 parent ad7c0f4 commit a8edcdc

12 files changed

+49
-36
lines changed

Gemfile

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
source "https://rubygems.org"
1+
# frozen_string_literal: true
2+
3+
source 'https://rubygems.org'
24

35
# Specify your gem's dependencies in fast_cqrs.gemspec
46
gemspec
57

6-
gem "rake", "~> 12.0"
7-
gem "rspec", "~> 3.0"
8+
gem 'rake', '~> 12.0'
9+
gem 'rspec', '~> 3.0'

Rakefile

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
require "bundler/gem_tasks"
2-
require "rspec/core/rake_task"
1+
# frozen_string_literal: true
2+
3+
require 'bundler/gem_tasks'
4+
require 'rspec/core/rake_task'
35

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

6-
task :default => :spec
8+
task default: :spec

bin/console

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
#!/usr/bin/env ruby
2+
# frozen_string_literal: true
23

3-
require "bundler/setup"
4-
require "fast_cqrs"
4+
require 'bundler/setup'
5+
require 'fast_cqrs'
56

67
# You can add fixtures and/or initialization code here to make experimenting
78
# with your gem easier. You can also use a different console, if you like.
@@ -10,5 +11,5 @@ require "fast_cqrs"
1011
# require "pry"
1112
# Pry.start
1213

13-
require "irb"
14+
require 'irb'
1415
IRB.start(__FILE__)

fast_cqrs.gemspec

+16-14
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,33 @@
1+
# frozen_string_literal: true
2+
13
require_relative 'lib/fast_cqrs/version'
24

35
Gem::Specification.new do |spec|
4-
spec.name = "fast_cqrs"
6+
spec.name = 'fast_cqrs'
57
spec.version = FastCqrs::VERSION
6-
spec.authors = ["Sebastian Wilgosz"]
7-
spec.email = ["[email protected]"]
8+
spec.authors = ['Sebastian Wilgosz']
9+
spec.email = ['[email protected]']
810

9-
spec.summary = %q{A lightweight CQRS scaffold for ruby-based web applications.}
10-
spec.description = %q{Write CQRS applications easily using functional endpoints without a hassle.}
11-
spec.homepage = "https://github.com/driggl/fast_cqrs"
12-
spec.license = "MIT"
13-
spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
11+
spec.summary = 'A lightweight CQRS scaffold for ruby-based web applications.'
12+
spec.description = 'Write CQRS applications easily using functional endpoints without a hassle.'
13+
spec.homepage = 'https://github.com/driggl/fast_cqrs'
14+
spec.license = 'MIT'
15+
spec.required_ruby_version = Gem::Requirement.new('>= 2.3.0')
1416

1517
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
1618

17-
spec.metadata["homepage_uri"] = spec.homepage
18-
spec.metadata["source_code_uri"] = "https://github.com/driggl/fast_cqrs"
19-
spec.metadata["changelog_uri"] = "https://github.com/driggl/fast_cqrs/releases"
19+
spec.metadata['homepage_uri'] = spec.homepage
20+
spec.metadata['source_code_uri'] = 'https://github.com/driggl/fast_cqrs'
21+
spec.metadata['changelog_uri'] = 'https://github.com/driggl/fast_cqrs/releases'
2022

2123
# Specify which files should be added to the gem when it is released.
2224
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
23-
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
25+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
2426
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
2527
end
26-
spec.bindir = "exe"
28+
spec.bindir = 'exe'
2729
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28-
spec.require_paths = ["lib"]
30+
spec.require_paths = ['lib']
2931

3032
spec.add_dependency 'dry-matcher'
3133
spec.add_dependency 'dry-monads'

lib/fast_cqrs.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'fast_cqrs/version'
24
require 'fast_cqrs/authorizer'
35
require 'fast_cqrs/request'

lib/fast_cqrs/authorizer.rb

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ def self.inherited(klass)
1313

1414
def call(**)
1515
return Success() if authorize
16+
1617
fail!
1718
end
1819

lib/fast_cqrs/deserializer/json_api.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@ def call(params = { data: {} })
2828
end
2929
end
3030
end
31-
end
31+
end

lib/fast_cqrs/transaction.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def self.inherited(klass)
1515
end
1616
end
1717

18-
def call(input, **)
18+
def call(_input, **)
1919
Success()
2020
end
2121
end

lib/fast_cqrs/version.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module FastCqrs
24
VERSION = '0.1.1'
35
end

spec/fast_cqrs/request_spec.rb

+6-7
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44

55
module FastCqrs
66
RSpec.describe Request do
7-
describe "#call" do
7+
describe '#call' do
88
let(:deserializer) { double('deserializer') }
99

1010
context 'when valid request' do
1111
before do
12-
allow(deserializer).to receive(:call) do |hash={}|
12+
allow(deserializer).to receive(:call) do |_hash = {}|
1313
{ foo: 'foo', bar: 'bar' }
1414
end
1515
end
@@ -22,8 +22,8 @@ module FastCqrs
2222

2323
context 'when invalid request' do
2424
before do
25-
allow(deserializer).to receive(:call) do |hash={}|
26-
raise "Invalid request"
25+
allow(deserializer).to receive(:call) do |_hash = {}|
26+
raise 'Invalid request'
2727
end
2828
end
2929
subject { described_class.new(deserializer: deserializer) }
@@ -35,7 +35,6 @@ module FastCqrs
3535
end
3636
end
3737

38-
3938
context 'inherited invalid request' do
4039
subject { InvalidRequest.new(deserializer: Deserializer::JsonApi.new).call({}) }
4140

@@ -60,15 +59,15 @@ class InvalidRequest < Request
6059
protected
6160

6261
def model(_input)
63-
return
62+
nil
6463
end
6564
end
6665

6766
class ValidRequest < Request
6867
protected
6968

7069
def model(_input)
71-
return { foo: 'foo', bar: 'bar' }
70+
{ foo: 'foo', bar: 'bar' }
7271
end
7372
end
7473
end

spec/fast_cqrs_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# frozen_string_literal: true
22

33
RSpec.describe FastCqrs do
4-
it "has a version number" do
4+
it 'has a version number' do
55
expect(FastCqrs::VERSION).not_to be nil
66
end
77
end

spec/spec_helper.rb

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
require "bundler/setup"
2-
require "fast_cqrs"
1+
# frozen_string_literal: true
2+
3+
require 'bundler/setup'
4+
require 'fast_cqrs'
35
require 'dry/monads'
46

57
RSpec.configure do |config|
68
config.include include Dry::Monads[:result]
79
# Enable flags like --only-failures and --next-failure
8-
config.example_status_persistence_file_path = ".rspec_status"
10+
config.example_status_persistence_file_path = '.rspec_status'
911

1012
# Disable RSpec exposing methods globally on `Module` and `main`
1113
config.disable_monkey_patching!

0 commit comments

Comments
 (0)