Skip to content

Commit

Permalink
Fix all standardrb offences
Browse files Browse the repository at this point in the history
  • Loading branch information
GabrielNagy committed Aug 12, 2024
1 parent 1fb0b90 commit 32a9eca
Show file tree
Hide file tree
Showing 10 changed files with 18 additions and 16 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ group :test do
gem "sqlite3"
gem "mysql2"
gem "simplecov", require: false
gem 'simplecov-cobertura', require: false
gem "simplecov-cobertura", require: false
end
2 changes: 1 addition & 1 deletion enummer.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ Gem::Specification.new do |spec|
Dir["{app,config,db,lib}/**/*", "MIT-LICENSE", "Rakefile", "README.md"]
end

spec.required_ruby_version = '>= 2.7'
spec.required_ruby_version = ">= 2.7"
spec.add_dependency "rails", ">= 7.0.0"
end
6 changes: 3 additions & 3 deletions lib/enummer/extension.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,16 @@ def _enummer_build_values(attribute_name, values, options)
values.each do |name, bit|
method_name = _enummer_method_name(attribute_name, name, options)

define_method("#{method_name}?") { self[attribute_name].include?(name) }
define_method("#{method_name}=") do |new_value|
define_method(:"#{method_name}?") { self[attribute_name].include?(name) }
define_method(:"#{method_name}=") do |new_value|
if ActiveModel::Type::Boolean.new.cast(new_value)
self[attribute_name] += [name]
else
self[attribute_name] -= [name]
end
self[attribute_name].uniq!
end
define_method("#{method_name}!") do
define_method(:"#{method_name}!") do
update(attribute_name => self[attribute_name] + [name])
end

Expand Down
1 change: 1 addition & 0 deletions lib/tasks/enummer_tasks.rake
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

# desc "Explaining what the task does"
# task :enummer do
# # Task goes here
Expand Down
8 changes: 4 additions & 4 deletions test/dummy/app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ class User < ApplicationRecord

enummer facial_features: %i[nose mouth eyes], _prefix: true
enummer diets: {
alcohol: 1,
cigarettes: 0,
greens: 2
}, _prefix: "consumes"
alcohol: 1,
cigarettes: 0,
greens: 2
}, _prefix: "consumes"

enummer transport: %i[car truck submarine], _suffix: true
enummer home: %i[box apartment house], _suffix: "home"
Expand Down
1 change: 1 addition & 0 deletions test/dummy/config/initializers/content_security_policy.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

# Be sure to restart your server when you modify this file.

# Define an application-wide content security policy
Expand Down
1 change: 1 addition & 0 deletions test/dummy/config/initializers/inflections.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

# Be sure to restart your server when you modify this file.

# Add new inflection rules using the following format. Inflections
Expand Down
1 change: 1 addition & 0 deletions test/dummy/config/initializers/permissions_policy.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

# Define an application-wide HTTP permissions policy. For further
# information see https://developers.google.com/web/updates/2018/06/feature-policy
#
Expand Down
2 changes: 0 additions & 2 deletions test/dummy/db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 2022_01_30_163927) do

# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"

Expand All @@ -22,5 +21,4 @@
t.integer "transport"
t.integer "home"
end

end
10 changes: 5 additions & 5 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# frozen_string_literal: true

require 'simplecov'
require "simplecov"
SimpleCov.start do
enable_coverage :branch
add_filter '/test/dummy/'
add_filter "/test/dummy/"

if ENV['CI']
require 'simplecov-cobertura'
if ENV["CI"]
require "simplecov-cobertura"
SimpleCov.formatter = SimpleCov::Formatter::CoberturaFormatter
end
end

# Configure Rails Environment
# Configure Rails Environment
ENV["RAILS_ENV"] = "test"

require_relative "../test/dummy/config/environment"
Expand Down

0 comments on commit 32a9eca

Please sign in to comment.