Skip to content

Commit

Permalink
Coding style
Browse files Browse the repository at this point in the history
  • Loading branch information
n-rodriguez committed Sep 6, 2024
1 parent c5a608c commit 17acf76
Show file tree
Hide file tree
Showing 19 changed files with 199 additions and 202 deletions.
3 changes: 0 additions & 3 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ Style/Documentation:
Style/HashSyntax:
EnforcedShorthandSyntax: never

Style/StringLiterals:
EnforcedStyle: double_quotes

Style/ArgumentsForwarding:
Enabled: false

Expand Down
24 changes: 12 additions & 12 deletions Appraisals
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
# frozen_string_literal: true

appraise "rails_7.0.8" do
gem "rails", "7.0.8"
appraise 'rails_7.0.8' do
gem 'rails', '7.0.8'

# Fix: LoadError: cannot load such file -- base64
install_if '-> { Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("3.3.0") }' do
gem "base64"
gem "bigdecimal"
gem "mutex_m"
gem "drb"
gem "logger"
gem 'base64'
gem 'bigdecimal'
gem 'mutex_m'
gem 'drb'
gem 'logger'
end
end

appraise "rails_7.1.3" do
gem "rails", "7.1.3"
appraise 'rails_7.1.3' do
gem 'rails', '7.1.3'

# Fix:
# warning: logger was loaded from the standard library, but will no longer be part of the default gems since Ruby 3.5.0.
# Add logger to your Gemfile or gemspec.
install_if '-> { Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("3.4.0") }' do
gem "logger"
gem 'logger'
end
end

appraise "rails_7.2.0" do
gem "rails", "7.2.0"
appraise 'rails_7.2.0' do
gem 'rails', '7.2.0'
end
44 changes: 22 additions & 22 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
# frozen_string_literal: true

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

gemspec

gem "appraisal", git: "https://github.com/n-rodriguez/appraisal.git", branch: "wip/combustion"
gem 'appraisal', git: 'https://github.com/n-rodriguez/appraisal.git', branch: 'wip/combustion'

gem "capybara"
gem "cuprite"
gem "database_cleaner"
gem "factory_bot"
gem "faker"
gem "guard-rspec"
gem "puma"
gem "rake"
gem "rspec-rails"
gem "rspec-retry"
gem "rubocop"
gem "rubocop-capybara"
gem "rubocop-factory_bot"
gem "rubocop-performance"
gem "rubocop-rake"
gem "rubocop-rspec"
gem "rubocop-rspec_rails"
gem "simplecov"
gem "sprockets-rails"
gem "sqlite3", "~> 1.5.0"
gem 'capybara'
gem 'cuprite'
gem 'database_cleaner'
gem 'factory_bot'
gem 'faker'
gem 'guard-rspec'
gem 'puma'
gem 'rake'
gem 'rspec-rails'
gem 'rspec-retry'
gem 'rubocop'
gem 'rubocop-capybara'
gem 'rubocop-factory_bot'
gem 'rubocop-performance'
gem 'rubocop-rake'
gem 'rubocop-rspec'
gem 'rubocop-rspec_rails'
gem 'simplecov'
gem 'sprockets-rails'
gem 'sqlite3', '~> 1.5.0'
4 changes: 2 additions & 2 deletions Guardfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

guard :rspec, cmd: "bin/rspec" do
require "guard/rspec/dsl"
guard :rspec, cmd: 'bin/rspec' do
require 'guard/rspec/dsl'
dsl = Guard::RSpec::Dsl.new(self)

# RSpec files
Expand Down
4 changes: 2 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

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

RSpec::Core::RakeTask.new(:spec)
task default: :spec
24 changes: 12 additions & 12 deletions draper.gemspec
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
# frozen_string_literal: true

require_relative "lib/draper/version"
require_relative 'lib/draper/version'

Gem::Specification.new do |s|
s.name = "draper"
s.name = 'draper'
s.version = Draper::VERSION::STRING
s.platform = Gem::Platform::RUBY
s.authors = ["Nicolas Rodriguez"]
s.email = ["nico@nicoladmin.fr"]
s.homepage = "http://github.com/jbox-web/draper"
s.summary = "View Models for Rails"
s.description = "Draper adds an object-oriented layer of presentation logic to your Rails apps."
s.license = "MIT"
s.authors = ['Nicolas Rodriguez']
s.email = ['nico@nicoladmin.fr']
s.homepage = 'http://github.com/jbox-web/draper'
s.summary = 'View Models for Rails'
s.description = 'Draper adds an object-oriented layer of presentation logic to your Rails apps.'
s.license = 'MIT'

s.required_ruby_version = ">= 3.1.0"
s.required_ruby_version = '>= 3.1.0'

s.files = `git ls-files`.split("\n")

s.add_dependency "rails", ">= 7.0"
s.add_dependency "request_store", ">= 1.0"
s.add_dependency "zeitwerk"
s.add_dependency 'rails', '>= 7.0'
s.add_dependency 'request_store', '>= 1.0'
s.add_dependency 'zeitwerk'
end
10 changes: 5 additions & 5 deletions lib/draper.rb
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# frozen_string_literal: true

require "active_support/concern"
require "request_store"
require 'active_support/concern'
require 'request_store'

require "zeitwerk"
require 'zeitwerk'
loader = Zeitwerk::Loader.for_gem
loader.ignore("#{__dir__}/draper/rails")
loader.ignore("#{__dir__}/draper/test")
loader.setup

module Draper
require "draper/engine" if defined?(Rails)
require 'draper/engine' if defined?(Rails)

class UninferrableDecoratorError < NameError
def initialize(klass, decorator)
Expand Down Expand Up @@ -49,7 +49,7 @@ def _decorate(object_or_enumerable, with: nil, namespace: nil)
def _guess_decorator(object_or_enumerable, with: nil, namespace: nil)
object_or_enumerable = object_or_enumerable.first if object_or_enumerable.is_a? Enumerable
klass = with || "#{object_or_enumerable.class.name}Decorator"
decorator = [namespace, klass].compact.join("::")
decorator = [namespace, klass].compact.join('::')
decorator.safe_constantize || raise(Draper::UninferrableDecoratorError.new(klass, decorator))
end

Expand Down
6 changes: 3 additions & 3 deletions lib/draper/decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ def delegate(*methods)
# end
def decorates_association(relation_name, with: nil, namespace: nil, scope: nil)
relation_sym = ":#{relation_name}"
with = with.nil? ? "nil" : "#{with}" # rubocop:disable Style/RedundantInterpolation
namespace = namespace.nil? ? "nil" : "'#{namespace}'"
scope = scope.nil? ? "nil" : ":#{scope}"
with = with.nil? ? 'nil' : "#{with}" # rubocop:disable Style/RedundantInterpolation
namespace = namespace.nil? ? 'nil' : "'#{namespace}'"
scope = scope.nil? ? 'nil' : ":#{scope}"

class_eval <<-METHOD, __FILE__, __LINE__ + 1 # rubocop:disable Style/DocumentDynamicEvalDefinition
# frozen_string_literal: true
Expand Down
8 changes: 4 additions & 4 deletions lib/draper/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@
module Draper
class Engine < ::Rails::Engine

initializer "draper.setup_action_controller" do
initializer 'draper.setup_action_controller' do
ActiveSupport.on_load :action_controller do
include Draper::ViewContext::BaseHelper
include Draper::ViewContext::ControllerHelper
end
end

initializer "draper.setup_action_mailer" do
initializer 'draper.setup_action_mailer' do
ActiveSupport.on_load :action_mailer do
include Draper::ViewContext::BaseHelper
end
end

config.after_initialize do |_app|
if Rails.env.test? && defined?(RSpec) && RSpec.respond_to?(:configure)
require "draper/test/rspec_integration"
require 'draper/test/rspec_integration'

RSpec.configure do |config|
config.include Draper::Test::RspecIntegration, file_path: %r{spec/decorators}, type: :decorator
Expand All @@ -31,7 +31,7 @@ class Engine < ::Rails::Engine
end

rake_tasks do
load "draper/rails/tasks/draper.rake"
load 'draper/rails/tasks/draper.rake'
end

end
Expand Down
6 changes: 3 additions & 3 deletions lib/draper/rails/tasks/draper.rake
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# frozen_string_literal: true

task stats: "draper:statsetup" # rubocop:disable Rake/Desc
task stats: 'draper:statsetup' # rubocop:disable Rake/Desc

namespace :draper do
task statsetup: :environment do # rubocop:disable Rake/Desc
require "rails/code_statistics"
require 'rails/code_statistics'

::STATS_DIRECTORIES << ["Decorators", "app/decorators"] # rubocop:disable Style/RedundantConstantBase
::STATS_DIRECTORIES << ['Decorators', 'app/decorators'] # rubocop:disable Style/RedundantConstantBase
end
end
2 changes: 1 addition & 1 deletion lib/draper/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ module VERSION
TINY = 0
PRE = nil

STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
end
end
2 changes: 1 addition & 1 deletion spec/config_rspec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
config.include HaveTextMatcher

# Use DB agnostic schema by default
load Rails.root.join("db", "schema.rb").to_s
load Rails.root.join('db', 'schema.rb').to_s

config.order = :random
Kernel.srand config.seed
Expand Down
Loading

0 comments on commit 17acf76

Please sign in to comment.