From 1585cde59c92bdba4eeed25027610c34d2715b25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20A=C3=9Fmann?= Date: Thu, 17 Feb 2022 08:53:15 +0100 Subject: [PATCH 1/6] loosen dependency in gemspec for ruby 3.0 usage the gem also works with ruby 3, but the gemspec does not allow this yet. With a newer rails version, update_attributes is depreacted, but update_attribute also does the job. --- .ruby-version | 1 + schemattr.gemspec | 2 +- spec/schemattr/active_record_extension_spec.rb | 8 ++++---- 3 files changed, 6 insertions(+), 5 deletions(-) create mode 100644 .ruby-version diff --git a/.ruby-version b/.ruby-version new file mode 100644 index 0000000..fd2a018 --- /dev/null +++ b/.ruby-version @@ -0,0 +1 @@ +3.1.0 diff --git a/schemattr.gemspec b/schemattr.gemspec index 3cff725..be24bde 100644 --- a/schemattr.gemspec +++ b/schemattr.gemspec @@ -17,5 +17,5 @@ Gem::Specification.new do |s| s.license = "MIT" s.files = Dir["{lib}/**/*"] + ["MIT.LICENSE", "README.md"] - s.required_ruby_version = "~> 2.4" + s.required_ruby_version = ">= 2.4" end diff --git a/spec/schemattr/active_record_extension_spec.rb b/spec/schemattr/active_record_extension_spec.rb index ec6dd98..d20080e 100644 --- a/spec/schemattr/active_record_extension_spec.rb +++ b/spec/schemattr/active_record_extension_spec.rb @@ -68,16 +68,16 @@ end it "coerces sane truthy/falsey values to acutal booleans" do - subject.update_attributes(settings: { active: "1" }) + subject.update_attribute(:settings, { active: "1" }) expect(subject.settings.active).to eq(true) - subject.update_attributes(settings: { active: "0" }) + subject.update_attribute(:settings, { active: "0" }) expect(subject.settings.active).to eq(false) - subject.update_attributes(settings: { active: "on" }) + subject.update_attribute(:settings, { active: "on" }) expect(subject.settings.active).to eq(true) - subject.update_attributes(settings: { active: "off" }) + subject.update_attribute(:settings, { active: "off" }) expect(subject.settings.active).to eq(false) end From 0babaf7af08dc3b146ead200f1fa84bf3a62145d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20A=C3=9Fmann?= Date: Thu, 17 Feb 2022 08:59:27 +0100 Subject: [PATCH 2/6] replace travis with github action travis is letting us down, but github action is a great, free replacement --- .github/workflows/ci.yml | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..f8e27b3 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,34 @@ +name: Run tests + +on: [push, pull_request] + +defaults: + run: + shell: bash + + +jobs: + specs: + name: 'run-specs' + # skip on [ci skip] and do not run 2 on push and interal PR + if: (contains(github.event.commits[0].message, '[ci skip]') == false) && (github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository) + continue-on-error: ${{ matrix.allow_failure || false }} + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - uses: ruby/setup-ruby@v1 + with: + ruby-version: 3.1.0 + bundler-cache: true + + - name: run specs + run: | + bundle exec rake + + # needs the right code climate reporter id + # - name: Test & publish code coverage + # uses: paambaati/codeclimate-action@v3.0.0 + # env: + # CC_TEST_REPORTER_ID: From 5ca7d2b873b48053cb79150fc79f89ce235dcf5a Mon Sep 17 00:00:00 2001 From: Jeremy Jackson Date: Wed, 21 Jun 2023 16:00:02 -0600 Subject: [PATCH 3/6] Update schemattr.gemspec Allow any ruby version above 2.4 --- schemattr.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/schemattr.gemspec b/schemattr.gemspec index be24bde..2b4fbbb 100644 --- a/schemattr.gemspec +++ b/schemattr.gemspec @@ -17,5 +17,5 @@ Gem::Specification.new do |s| s.license = "MIT" s.files = Dir["{lib}/**/*"] + ["MIT.LICENSE", "README.md"] - s.required_ruby_version = ">= 2.4" + s.required_ruby_version = "=> 2.4" end From a0ddc55f26a37794fcdfb4dfa69fad76b4ff33aa Mon Sep 17 00:00:00 2001 From: Jeremy Jackson Date: Wed, 21 Jun 2023 16:01:05 -0600 Subject: [PATCH 4/6] Update schemattr.gemspec --- schemattr.gemspec | 2 -- 1 file changed, 2 deletions(-) diff --git a/schemattr.gemspec b/schemattr.gemspec index 2b4fbbb..374bcb7 100644 --- a/schemattr.gemspec +++ b/schemattr.gemspec @@ -16,6 +16,4 @@ Gem::Specification.new do |s| s.description = "Write schema-less attributes in ActiveRecord using a helpful and flexible DSL." s.license = "MIT" s.files = Dir["{lib}/**/*"] + ["MIT.LICENSE", "README.md"] - - s.required_ruby_version = "=> 2.4" end From f9b1164957048aa73cfb73db95c7c0ddc10b6e46 Mon Sep 17 00:00:00 2001 From: Jeremy Jackson Date: Sat, 22 Jul 2023 13:48:37 -0600 Subject: [PATCH 5/6] Modernizing --- .gitignore | 12 +- .rubocop.yml | 347 +++++++++++++++++- .travis.yml | 13 - CHANGELOG.md | 0 Gemfile | 21 +- Gemfile.lock | 102 +++++ MIT.LICENSE => MIT-LICENSE | 4 +- README.md | 2 - Rakefile | 9 +- lib/schemattr.rb | 4 +- lib/schemattr/active_record_extension.rb | 3 +- lib/schemattr/attribute.rb | 3 +- lib/schemattr/dsl.rb | 4 +- lib/schemattr/version.rb | 16 +- schemattr.gemspec | 41 ++- .../schemattr/active_record_extension_spec.rb | 10 +- spec/schemattr/attribute_spec.rb | 2 + spec/schemattr/dsl_spec.rb | 2 + spec/spec_helper.rb | 4 +- spec/support/user_model.rb | 2 + 20 files changed, 527 insertions(+), 74 deletions(-) delete mode 100644 .travis.yml create mode 100644 CHANGELOG.md create mode 100644 Gemfile.lock rename MIT.LICENSE => MIT-LICENSE (93%) diff --git a/.gitignore b/.gitignore index 985c9ea..27b3d26 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,7 @@ -.env -pkg/ -tmp/ -coverage -Gemfile.lock +/.bundle/ +/doc/ +/pkg/ +/tmp/ +/bin/ +/test/dummy/ +/coverage/ \ No newline at end of file diff --git a/.rubocop.yml b/.rubocop.yml index 93012dd..6d247a8 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,16 +1,341 @@ -inherit_gem: - rubocop-rails_config: - - config/rails.yml +require: + - rubocop-minitest + - rubocop-packaging + - rubocop-performance + - rubocop-rails -inherit_mode: - merge: - - Exclude +AllCops: + TargetRubyVersion: 2.7 + # RuboCop has a bunch of cops enabled by default. This setting tells RuboCop + # to ignore them, so only the ones explicitly set in this file are enabled. + DisabledByDefault: true + SuggestExtensions: false + Exclude: + - 'bin/**/*' + - '**/tmp/**/*' + - '**/templates/**/*' + - '**/vendor/**/*' + - 'actionpack/lib/action_dispatch/journey/parser.rb' + - 'actionmailbox/test/dummy/**/*' + - 'actiontext/test/dummy/**/*' + - '**/node_modules/**/*' + +Performance: + Exclude: + - '**/test/**/*' + +# Prefer assert_not over assert ! +Rails/AssertNot: + Include: + - '**/test/**/*' + +# Prefer assert_not_x over refute_x +Rails/RefuteMethods: + Include: + - '**/test/**/*' + +Rails/IndexBy: + Enabled: true + +Rails/IndexWith: + Enabled: true + +# Prefer &&/|| over and/or. +Style/AndOr: + Enabled: true + +# Align `when` with `case`. +Layout/CaseIndentation: + Enabled: true + +Layout/ClosingHeredocIndentation: + Enabled: true + +Layout/ClosingParenthesisIndentation: + Enabled: true + +# Align comments with method definitions. +Layout/CommentIndentation: + Enabled: true + +Layout/ElseAlignment: + Enabled: true + +# Align `end` with the matching keyword or starting expression except for +# assignments, where it should be aligned with the LHS. +Layout/EndAlignment: + Enabled: true + EnforcedStyleAlignWith: variable + AutoCorrect: true + +Layout/EndOfLine: + Enabled: true + +Layout/EmptyLineAfterMagicComment: + Enabled: true + +Layout/EmptyLinesAroundAccessModifier: + Enabled: true + EnforcedStyle: only_before + +Layout/EmptyLinesAroundBlockBody: + Enabled: true + +# In a regular class definition, no empty lines around the body. +Layout/EmptyLinesAroundClassBody: + Enabled: true + +# In a regular method definition, no empty lines around the body. +Layout/EmptyLinesAroundMethodBody: + Enabled: true + +# In a regular module definition, no empty lines around the body. +Layout/EmptyLinesAroundModuleBody: + Enabled: true + +# Use Ruby >= 1.9 syntax for hashes. Prefer { a: :b } over { :a => :b }. +Style/HashSyntax: + Enabled: true + +# Method definitions after `private` or `protected` isolated calls need one +# extra level of indentation. +Layout/IndentationConsistency: + Enabled: true + EnforcedStyle: indented_internal_methods + +# Two spaces, no tabs (for indentation). +Layout/IndentationWidth: + Enabled: true + +Layout/LeadingCommentSpace: + Enabled: true + +Layout/SpaceAfterColon: + Enabled: true + +Layout/SpaceAfterComma: + Enabled: true + +Layout/SpaceAfterSemicolon: + Enabled: true + +Layout/SpaceAroundEqualsInParameterDefault: + Enabled: true + +Layout/SpaceAroundKeyword: + Enabled: true + +Layout/SpaceAroundOperators: + Enabled: true + +Layout/SpaceBeforeComma: + Enabled: true + +Layout/SpaceBeforeComment: + Enabled: true + +Layout/SpaceBeforeFirstArg: + Enabled: true + +Style/DefWithParentheses: + Enabled: true + +# Defining a method with parameters needs parentheses. +Style/MethodDefParentheses: + Enabled: true + +Style/ExplicitBlockArgument: + Enabled: true Style/FrozenStringLiteralComment: - Enabled: false + Enabled: true + EnforcedStyle: always + Exclude: + - 'actionview/test/**/*.builder' + - 'actionview/test/**/*.ruby' + - 'actionpack/test/**/*.builder' + - 'actionpack/test/**/*.ruby' + - 'activestorage/db/migrate/**/*.rb' + - 'activestorage/db/update_migrate/**/*.rb' + - 'actionmailbox/db/migrate/**/*.rb' + - 'actiontext/db/migrate/**/*.rb' -Layout/DefEndAlignment: - EnforcedStyleAlignWith: def +Style/MapToHash: + Enabled: true -AllCops: - TargetRubyVersion: 2.6.2 +Style/RedundantFreeze: + Enabled: true + +# Use `foo {}` not `foo{}`. +Layout/SpaceBeforeBlockBraces: + Enabled: true + +# Use `foo { bar }` not `foo {bar}`. +Layout/SpaceInsideBlockBraces: + Enabled: true + EnforcedStyleForEmptyBraces: space + +# Use `{ a: 1 }` not `{a:1}`. +Layout/SpaceInsideHashLiteralBraces: + Enabled: true + +Layout/SpaceInsideParens: + Enabled: true + +# Check quotes usage according to lint rule below. +Style/StringLiterals: + Enabled: true + EnforcedStyle: double_quotes + +# Detect hard tabs, no hard tabs. +Layout/IndentationStyle: + Enabled: true + +# Empty lines should not have any spaces. +Layout/TrailingEmptyLines: + Enabled: true + +# No trailing whitespace. +Layout/TrailingWhitespace: + Enabled: true + +# Use quotes for string literals when they are enough. +Style/RedundantPercentQ: + Enabled: true + +Lint/AmbiguousOperator: + Enabled: true + +Lint/AmbiguousRegexpLiteral: + Enabled: true + +Lint/DuplicateRequire: + Enabled: true + +Lint/DuplicateMagicComment: + Enabled: true + +Lint/DuplicateMethods: + Enabled: true + +Lint/ErbNewArguments: + Enabled: true + +Lint/EnsureReturn: + Enabled: true + +# Use my_method(my_arg) not my_method( my_arg ) or my_method my_arg. +Lint/RequireParentheses: + Enabled: true + +Lint/RedundantStringCoercion: + Enabled: true + +Lint/UriEscapeUnescape: + Enabled: true + +Lint/UselessAssignment: + Enabled: true + +Lint/DeprecatedClassMethods: + Enabled: true + +Style/ParenthesesAroundCondition: + Enabled: true + +Style/HashTransformKeys: + Enabled: true + +Style/HashTransformValues: + Enabled: true + +Style/RedundantBegin: + Enabled: true + +Style/RedundantReturn: + Enabled: true + AllowMultipleReturnValues: true + +Style/RedundantRegexpEscape: + Enabled: true + +Style/Semicolon: + Enabled: true + AllowAsExpressionSeparator: true + +# Prefer Foo.method over Foo::method +Style/ColonMethodCall: + Enabled: true + +Style/TrivialAccessors: + Enabled: true + +# Prefer a = b || c over a = b ? b : c +Style/RedundantCondition: + Enabled: true + +Performance/BindCall: + Enabled: true + +Performance/FlatMap: + Enabled: true + +Performance/MapCompact: + Enabled: true + +Performance/SelectMap: + Enabled: true + +Performance/RedundantMerge: + Enabled: true + +Performance/StartWith: + Enabled: true + +Performance/EndWith: + Enabled: true + +Performance/RegexpMatch: + Enabled: true + +Performance/ReverseEach: + Enabled: true + +Performance/StringReplacement: + Enabled: true + +Performance/UnfreezeString: + Enabled: true + +Performance/DeletePrefix: + Enabled: true + +Performance/DeleteSuffix: + Enabled: true + +Performance/OpenStruct: + Enabled: true + +Performance/InefficientHashSearch: + Enabled: true + +Performance/ConstantRegexp: + Enabled: true + +Performance/RedundantStringChars: + Enabled: true + +Performance/StringInclude: + Enabled: true + +Minitest/AssertRaisesWithRegexpArgument: + Enabled: true + +Minitest/AssertWithExpectedArgument: + Enabled: true + +Minitest/SkipEnsure: + Enabled: true + +Minitest/UnreachableAssertion: + Enabled: true \ No newline at end of file diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index f3cb387..0000000 --- a/.travis.yml +++ /dev/null @@ -1,13 +0,0 @@ -language: ruby -rvm: - - 2.6.0 -before_script: - - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter - - chmod +x ./cc-test-reporter - - ./cc-test-reporter before-build -before_install: - - gem install bundler -script: - - bundle exec rspec -after_script: - - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..e69de29 diff --git a/Gemfile b/Gemfile index 4858fa5..0945d57 100644 --- a/Gemfile +++ b/Gemfile @@ -1,15 +1,18 @@ +# frozen_string_literal: true + source "https://rubygems.org" git_source(:github) { |repo| "https://github.com/#{repo}.git" } gemspec -gem "sqlite3" -gem "activerecord" - -# test dependencies -gem "rspec" -gem "simplecov" +gem "rubocop", ">= 1.25.1", require: false +gem "rubocop-minitest", require: false +gem "rubocop-packaging", require: false +gem "rubocop-performance", require: false +gem "rubocop-rails", require: false -# services -gem "rubocop", require: false -gem "rubocop-rails_config" +group :test do + gem "rspec" + gem "simplecov" + gem "sqlite3" +end diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000..4f878a7 --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,102 @@ +PATH + remote: . + specs: + schemattr (0.1.0) + activerecord (>= 5.0.0) + +GEM + remote: https://rubygems.org/ + specs: + activemodel (7.0.6) + activesupport (= 7.0.6) + activerecord (7.0.6) + activemodel (= 7.0.6) + activesupport (= 7.0.6) + activesupport (7.0.6) + concurrent-ruby (~> 1.0, >= 1.0.2) + i18n (>= 1.6, < 2) + minitest (>= 5.1) + tzinfo (~> 2.0) + ast (2.4.2) + concurrent-ruby (1.2.2) + diff-lcs (1.5.0) + docile (1.4.0) + i18n (1.14.1) + concurrent-ruby (~> 1.0) + json (2.6.3) + language_server-protocol (3.17.0.3) + minitest (5.18.1) + parallel (1.23.0) + parser (3.2.2.3) + ast (~> 2.4.1) + racc + racc (1.7.1) + rack (3.0.8) + rainbow (3.1.1) + regexp_parser (2.8.1) + rexml (3.2.5) + rspec (3.12.0) + rspec-core (~> 3.12.0) + rspec-expectations (~> 3.12.0) + rspec-mocks (~> 3.12.0) + rspec-core (3.12.2) + rspec-support (~> 3.12.0) + rspec-expectations (3.12.3) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.12.0) + rspec-mocks (3.12.6) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.12.0) + rspec-support (3.12.1) + rubocop (1.54.2) + json (~> 2.3) + language_server-protocol (>= 3.17.0) + parallel (~> 1.10) + parser (>= 3.2.2.3) + rainbow (>= 2.2.2, < 4.0) + regexp_parser (>= 1.8, < 3.0) + rexml (>= 3.2.5, < 4.0) + rubocop-ast (>= 1.28.0, < 2.0) + ruby-progressbar (~> 1.7) + unicode-display_width (>= 2.4.0, < 3.0) + rubocop-ast (1.29.0) + parser (>= 3.2.1.0) + rubocop-minitest (0.31.0) + rubocop (>= 1.39, < 2.0) + rubocop-packaging (0.5.2) + rubocop (>= 1.33, < 2.0) + rubocop-performance (1.18.0) + rubocop (>= 1.7.0, < 2.0) + rubocop-ast (>= 0.4.0) + rubocop-rails (2.20.2) + activesupport (>= 4.2.0) + rack (>= 1.1) + rubocop (>= 1.33.0, < 2.0) + ruby-progressbar (1.13.0) + simplecov (0.22.0) + docile (~> 1.1) + simplecov-html (~> 0.11) + simplecov_json_formatter (~> 0.1) + simplecov-html (0.12.3) + simplecov_json_formatter (0.1.4) + sqlite3 (1.6.3-arm64-darwin) + tzinfo (2.0.6) + concurrent-ruby (~> 1.0) + unicode-display_width (2.4.2) + +PLATFORMS + arm64-darwin-22 + +DEPENDENCIES + rspec + rubocop (>= 1.25.1) + rubocop-minitest + rubocop-packaging + rubocop-performance + rubocop-rails + schemattr! + simplecov + sqlite3 + +BUNDLED WITH + 2.4.14 diff --git a/MIT.LICENSE b/MIT-LICENSE similarity index 93% rename from MIT.LICENSE rename to MIT-LICENSE index 03fdfea..93a8e4d 100644 --- a/MIT.LICENSE +++ b/MIT-LICENSE @@ -1,6 +1,4 @@ -Copyright 2019 Jeremy Jackson - -https://github.com/jejacks0n/schemattr +Copyright 2023 Jeremy Jackson Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the diff --git a/README.md b/README.md index b691089..16f3704 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,5 @@ # Schemattr -========= - [![Gem Version](https://img.shields.io/gem/v/schemattr.svg)](http://badge.fury.io/rb/schemattr) [![Build Status](https://img.shields.io/travis/jejacks0n/schemattr.svg)](https://travis-ci.org/jejacks0n/schemattr) [![Code Climate](https://codeclimate.com/github/jejacks0n/schemattr/badges/gpa.svg)](https://codeclimate.com/github/jejacks0n/schemattr) diff --git a/Rakefile b/Rakefile index a8a142c..8089c49 100644 --- a/Rakefile +++ b/Rakefile @@ -1,11 +1,6 @@ -begin - require "bundler/setup" -rescue LoadError - puts "You must `gem install bundler` and `bundle install` to run rake tasks" -end +# frozen_string_literal: true -# useful bundler gem tasks -Bundler::GemHelper.install_tasks +require "bundler/gem_tasks" # load in rspec tasks require "rspec/core/rake_task" diff --git a/lib/schemattr.rb b/lib/schemattr.rb index 05ecc7d..8c89497 100644 --- a/lib/schemattr.rb +++ b/lib/schemattr.rb @@ -1,6 +1,8 @@ +# frozen_string_literal: true + require "schemattr/version" require "schemattr/dsl" require "schemattr/attribute" -require "schemattr/active_record_extension.rb" +require "schemattr/active_record_extension" ActiveRecord::Base.send(:include, Schemattr::ActiveRecordExtension) if defined?(ActiveRecord) diff --git a/lib/schemattr/active_record_extension.rb b/lib/schemattr/active_record_extension.rb index 12ea9a0..f85e069 100644 --- a/lib/schemattr/active_record_extension.rb +++ b/lib/schemattr/active_record_extension.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Schemattr module ActiveRecordExtension module ClassMethods @@ -38,7 +40,6 @@ def reload(*_args) end private - def schemaless_attributes @_schemaless_attributes ||= {} end diff --git a/lib/schemattr/attribute.rb b/lib/schemattr/attribute.rb index 0881f16..20282f2 100644 --- a/lib/schemattr/attribute.rb +++ b/lib/schemattr/attribute.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Schemattr class Attribute attr_accessor :model, :attr_name, :hash @@ -22,7 +24,6 @@ def as_json(*args) end private - def method_missing(m, *args) if @allow_arbitrary_attributes self[$1] = args[0] if args.length == 1 && /^(\w+)=$/ =~ m diff --git a/lib/schemattr/dsl.rb b/lib/schemattr/dsl.rb index 7f1d596..b5700de 100644 --- a/lib/schemattr/dsl.rb +++ b/lib/schemattr/dsl.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Schemattr class DSL attr_accessor :attribute_class, :delegated, :defaults @@ -13,7 +15,6 @@ def initialize(klass_override = nil, &block) end protected - def field(name, type, options = {}) if options[:from].present? options[:value_from] = options.delete(:from) @@ -60,7 +61,6 @@ def boolean(name, options = {}) alias_method :time, :datetime private - def define(name, boolean, options, blocks = {}) setter = blocks[:setter] || lambda { sync_value(self[name] = val, options[:sync]) } getter = blocks[:getter] || lambda { migrate_value(self[name], options[:value_from]) } diff --git a/lib/schemattr/version.rb b/lib/schemattr/version.rb index 47f6f34..456c3bd 100644 --- a/lib/schemattr/version.rb +++ b/lib/schemattr/version.rb @@ -1,3 +1,17 @@ +# frozen_string_literal: true + module Schemattr - VERSION = "0.1.1" + # Returns the currently loaded version as a +Gem::Version+. + def self.version + Gem::Version.new(VERSION::STRING) + end + + module VERSION + MAJOR = 0 + MINOR = 1 + TINY = 0 + PRE = nil + + STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".") + end end diff --git a/schemattr.gemspec b/schemattr.gemspec index 374bcb7..dc84593 100644 --- a/schemattr.gemspec +++ b/schemattr.gemspec @@ -1,19 +1,34 @@ -# encoding: utf-8 +# frozen_string_literal: true -$:.push File.expand_path("../lib", __FILE__) +require_relative "lib/schemattr/version" +version = Schemattr.version -# Maintain your gem's version: -require "schemattr/version" - -# Describe your gem and declare its dependencies: Gem::Specification.new do |s| + s.platform = Gem::Platform::RUBY s.name = "schemattr" - s.version = Schemattr::VERSION - s.authors = ["jejacks0n"] - s.email = ["jejacks0n@gmail.com"] - s.homepage = "http://github.com/jejacks0n/bitbot" - s.summary = "Schemattr: Simple schema-less column definitions for ActiveRecord" + s.version = version + s.summary = "Schemattr: Simple schema-less column definitions for ActiveRecord." s.description = "Write schema-less attributes in ActiveRecord using a helpful and flexible DSL." - s.license = "MIT" - s.files = Dir["{lib}/**/*"] + ["MIT.LICENSE", "README.md"] + + s.required_ruby_version = ">= 2.7.0" + + s.license = "MIT" + + s.author = "Jeremy Jackson" + s.email = "jejacks0n@gmail.com" + s.homepage = "https://github.com/jejacks0n/schemattr" + + s.files = Dir["CHANGELOG.md", "MIT-LICENSE", "README.md", "lib/**/*"] + s.require_path = "lib" + + s.metadata = { + "homepage_uri" => s.homepage, + "source_code_uri" => s.homepage, + "bug_tracker_uri" => s.homepage + "/issues", + "changelog_uri" => s.homepage + "/CHANGELOG.md", + "documentation_uri" => s.homepage + "/README.md", + "rubygems_mfa_required" => "true", + } + + s.add_dependency "activerecord", ">= 5.0.0" end diff --git a/spec/schemattr/active_record_extension_spec.rb b/spec/schemattr/active_record_extension_spec.rb index d20080e..c1794a6 100644 --- a/spec/schemattr/active_record_extension_spec.rb +++ b/spec/schemattr/active_record_extension_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "spec_helper" describe Schemattr::ActiveRecordExtension do @@ -68,16 +70,16 @@ end it "coerces sane truthy/falsey values to acutal booleans" do - subject.update_attribute(:settings, { active: "1" }) + subject.update(settings: { active: "1" }) expect(subject.settings.active).to eq(true) - subject.update_attribute(:settings, { active: "0" }) + subject.update(settings: { active: "0" }) expect(subject.settings.active).to eq(false) - subject.update_attribute(:settings, { active: "on" }) + subject.update(settings: { active: "on" }) expect(subject.settings.active).to eq(true) - subject.update_attribute(:settings, { active: "off" }) + subject.update(settings: { active: "off" }) expect(subject.settings.active).to eq(false) end diff --git a/spec/schemattr/attribute_spec.rb b/spec/schemattr/attribute_spec.rb index a08949a..0a24ac4 100644 --- a/spec/schemattr/attribute_spec.rb +++ b/spec/schemattr/attribute_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "spec_helper" describe Schemattr::Attribute do diff --git a/spec/schemattr/dsl_spec.rb b/spec/schemattr/dsl_spec.rb index 8e554c6..35c1914 100644 --- a/spec/schemattr/dsl_spec.rb +++ b/spec/schemattr/dsl_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "spec_helper" describe Schemattr::DSL do diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index efff94d..d7c0953 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,6 +1,8 @@ -require "active_record" +# frozen_string_literal: true +require "active_record" require "simplecov" + SimpleCov.start require "schemattr" diff --git a/spec/support/user_model.rb b/spec/support/user_model.rb index d65cb77..754201e 100644 --- a/spec/support/user_model.rb +++ b/spec/support/user_model.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class User < ActiveRecord::Base serialize :settings serialize :preferences From f4d69936b098f9bcfa09590bc59a35114f244ef3 Mon Sep 17 00:00:00 2001 From: Jeremy Jackson Date: Sat, 22 Jul 2023 14:11:41 -0600 Subject: [PATCH 6/6] updates version --- README.md | 5 +++-- lib/schemattr/version.rb | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 16f3704..c038652 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,11 @@ # Schemattr -[![Gem Version](https://img.shields.io/gem/v/schemattr.svg)](http://badge.fury.io/rb/schemattr) +[![Gem Version](https://badge.fury.io/rb/schemattr.svg)](https://badge.fury.io/rb/schemattr) +[![License](https://img.shields.io/badge/license-MIT-brightgreen.svg)](https://opensource.org/licenses/MIT) + [![Build Status](https://img.shields.io/travis/jejacks0n/schemattr.svg)](https://travis-ci.org/jejacks0n/schemattr) [![Code Climate](https://codeclimate.com/github/jejacks0n/schemattr/badges/gpa.svg)](https://codeclimate.com/github/jejacks0n/schemattr) [![Test Coverage](https://codeclimate.com/github/jejacks0n/schemattr/badges/coverage.svg)](https://codeclimate.com/github/jejacks0n/schemattr) -[![License](https://img.shields.io/badge/license-MIT-brightgreen.svg)](https://opensource.org/licenses/MIT) Schemattr is an ActiveRecord extension that provides a helpful schema-less attribute DSL. It can be used to define a simple schema for a single attribute that can change over time without having to migrate existing data. diff --git a/lib/schemattr/version.rb b/lib/schemattr/version.rb index 456c3bd..9774755 100644 --- a/lib/schemattr/version.rb +++ b/lib/schemattr/version.rb @@ -8,7 +8,7 @@ def self.version module VERSION MAJOR = 0 - MINOR = 1 + MINOR = 2 TINY = 0 PRE = nil