diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 4325909..12adec8 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -9,20 +9,22 @@ on: jobs: test: name: Ruby ${{ matrix.ruby }} with ${{ matrix.gemfile }} - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 continue-on-error: ${{ contains(matrix.ruby, 'head') || contains(matrix.gemfile, 'head') }} strategy: fail-fast: false matrix: ruby: - - 2.1.9 - - 2.2.10 - - 2.3.8 - - 2.4.10 - - 2.5.9 - - 2.6.8 - - 2.7.4 - - 3.0.2 + - "2.1" + - "2.2" + - "2.3" + - "2.4" + - "2.5" + - "2.6" + - "2.7" + - "3.0" + - "3.1" + - "3.2" - truffleruby-head gemfile: - gemfiles/rails_3_0.gemfile @@ -36,140 +38,141 @@ jobs: - gemfiles/rails_5_2.gemfile - gemfiles/rails_6_0.gemfile - gemfiles/rails_6_1.gemfile + - gemfiles/rails_7_0.gemfile - Gemfile - gemfiles/rails_head.gemfile exclude: - - ruby: 1.9.2 - gemfile: gemfiles/rails_4_0.gemfile - - ruby: 1.9.2 - gemfile: gemfiles/rails_4_1.gemfile - - ruby: 1.9.2 - gemfile: gemfiles/rails_4_2.gemfile - - ruby: 1.9.2 - gemfile: gemfiles/rails_5_0.gemfile - - ruby: 1.9.2 - gemfile: gemfiles/rails_5_1.gemfile - - ruby: 1.9.2 - gemfile: gemfiles/rails_5_2.gemfile - - ruby: 1.9.2 - gemfile: gemfiles/rails_6_0.gemfile - - ruby: 1.9.2 - gemfile: gemfiles/rails_6_1.gemfile - - ruby: 1.9.2 - gemfile: Gemfile - - ruby: 1.9.2 - gemfile: gemfiles/rails_head.gemfile - - ruby: 1.9.3 - gemfile: gemfiles/rails_5_0.gemfile - - ruby: 1.9.3 - gemfile: gemfiles/rails_5_1.gemfile - - ruby: 1.9.3 - gemfile: gemfiles/rails_5_2.gemfile - - ruby: 1.9.3 - gemfile: gemfiles/rails_6_0.gemfile - - ruby: 1.9.3 - gemfile: gemfiles/rails_6_1.gemfile - - ruby: 1.9.3 - gemfile: Gemfile - - ruby: 1.9.3 - gemfile: gemfiles/rails_head.gemfile - - ruby: 2.0.0 - gemfile: gemfiles/rails_5_0.gemfile - - ruby: 2.0.0 - gemfile: gemfiles/rails_5_1.gemfile - - ruby: 2.0.0 - gemfile: gemfiles/rails_5_2.gemfile - - ruby: 2.0.0 - gemfile: gemfiles/rails_6_0.gemfile - - ruby: 2.0.0 - gemfile: gemfiles/rails_6_1.gemfile - - ruby: 2.0.0 - gemfile: Gemfile - - ruby: 2.0.0 - gemfile: gemfiles/rails_head.gemfile - - ruby: 2.1.9 + - ruby: "2.1" gemfile: gemfiles/rails_5_0.gemfile - - ruby: 2.1.9 + - ruby: "2.1" gemfile: gemfiles/rails_5_1.gemfile - - ruby: 2.1.9 + - ruby: "2.1" gemfile: gemfiles/rails_5_2.gemfile - - ruby: 2.1.9 + - ruby: "2.1" gemfile: gemfiles/rails_6_0.gemfile - - ruby: 2.1.9 + - ruby: "2.1" gemfile: gemfiles/rails_6_1.gemfile - - ruby: 2.1.9 + - ruby: "2.1" + gemfile: gemfiles/rails_7_0.gemfile + - ruby: "2.1" gemfile: Gemfile - - ruby: 2.1.9 + - ruby: "2.1" gemfile: gemfiles/rails_head.gemfile - - ruby: 2.2.10 + - ruby: "2.2" gemfile: gemfiles/rails_6_0.gemfile - - ruby: 2.2.10 + - ruby: "2.2" gemfile: gemfiles/rails_6_1.gemfile - - ruby: 2.2.10 + - ruby: "2.2" + gemfile: gemfiles/rails_7_0.gemfile + - ruby: "2.2" gemfile: Gemfile - - ruby: 2.2.10 + - ruby: "2.2" gemfile: gemfiles/rails_head.gemfile - - ruby: 2.3.8 + - ruby: "2.3" gemfile: gemfiles/rails_6_0.gemfile - - ruby: 2.3.8 + - ruby: "2.3" gemfile: gemfiles/rails_6_1.gemfile - - ruby: 2.3.8 + - ruby: "2.3" + gemfile: gemfiles/rails_7_0.gemfile + - ruby: "2.3" gemfile: Gemfile - - ruby: 2.3.8 + - ruby: "2.3" gemfile: gemfiles/rails_head.gemfile - - ruby: 2.4.10 + - ruby: "2.4" gemfile: gemfiles/rails_6_0.gemfile - - ruby: 2.4.10 + - ruby: "2.4" gemfile: gemfiles/rails_6_1.gemfile - - ruby: 2.4.10 + - ruby: "2.4" + gemfile: gemfiles/rails_7_0.gemfile + - ruby: "2.4" gemfile: Gemfile - - ruby: 2.4.10 + - ruby: "2.4" gemfile: gemfiles/rails_head.gemfile - - ruby: 2.5.9 + - ruby: "2.5" gemfile: gemfiles/rails_3_0.gemfile - - ruby: 2.5.9 + - ruby: "2.5" gemfile: gemfiles/rails_6_1.gemfile - - ruby: 2.5.9 + - ruby: "2.5" + gemfile: gemfiles/rails_7_0.gemfile + - ruby: "2.5" gemfile: Gemfile - - ruby: 2.5.9 + - ruby: "2.5" gemfile: gemfiles/rails_head.gemfile - - ruby: 2.6.8 + - ruby: "2.6" gemfile: gemfiles/rails_3_0.gemfile - - ruby: 2.6.8 + - ruby: "2.6" gemfile: gemfiles/rails_6_1.gemfile - - ruby: 2.6.8 + - ruby: "2.6" + gemfile: gemfiles/rails_7_0.gemfile + - ruby: "2.6" gemfile: Gemfile - - ruby: 2.6.8 + - ruby: "2.6" gemfile: gemfiles/rails_head.gemfile - - ruby: 2.7.4 + - ruby: "2.7" gemfile: gemfiles/rails_3_0.gemfile - - ruby: 2.7.4 + - ruby: "2.7" gemfile: gemfiles/rails_3_1.gemfile - - ruby: 2.7.4 + - ruby: "2.7" gemfile: gemfiles/rails_3_2.gemfile - - ruby: 2.7.4 + - ruby: "2.7" gemfile: gemfiles/rails_4_0.gemfile - - ruby: 2.7.4 + - ruby: "2.7" gemfile: gemfiles/rails_4_1.gemfile - - ruby: 2.7.4 + - ruby: "2.7" gemfile: gemfiles/rails_4_2.gemfile - - ruby: 3.0.2 + - ruby: "3.0" + gemfile: gemfiles/rails_3_0.gemfile + - ruby: "3.0" + gemfile: gemfiles/rails_3_1.gemfile + - ruby: "3.0" + gemfile: gemfiles/rails_3_2.gemfile + - ruby: "3.0" + gemfile: gemfiles/rails_4_0.gemfile + - ruby: "3.0" + gemfile: gemfiles/rails_4_1.gemfile + - ruby: "3.0" + gemfile: gemfiles/rails_4_2.gemfile + - ruby: "3.0" + gemfile: gemfiles/rails_5_0.gemfile + - ruby: "3.0" + gemfile: gemfiles/rails_5_1.gemfile + - ruby: "3.0" + gemfile: gemfiles/rails_5_2.gemfile + - ruby: "3.1" + gemfile: gemfiles/rails_3_0.gemfile + - ruby: "3.1" + gemfile: gemfiles/rails_3_1.gemfile + - ruby: "3.1" + gemfile: gemfiles/rails_3_2.gemfile + - ruby: "3.1" + gemfile: gemfiles/rails_4_0.gemfile + - ruby: "3.1" + gemfile: gemfiles/rails_4_1.gemfile + - ruby: "3.1" + gemfile: gemfiles/rails_4_2.gemfile + - ruby: "3.1" + gemfile: gemfiles/rails_5_0.gemfile + - ruby: "3.1" + gemfile: gemfiles/rails_5_1.gemfile + - ruby: "3.1" + gemfile: gemfiles/rails_5_2.gemfile + - ruby: "3.2" gemfile: gemfiles/rails_3_0.gemfile - - ruby: 3.0.2 + - ruby: "3.2" gemfile: gemfiles/rails_3_1.gemfile - - ruby: 3.0.2 + - ruby: "3.2" gemfile: gemfiles/rails_3_2.gemfile - - ruby: 3.0.2 + - ruby: "3.2" gemfile: gemfiles/rails_4_0.gemfile - - ruby: 3.0.2 + - ruby: "3.2" gemfile: gemfiles/rails_4_1.gemfile - - ruby: 3.0.2 + - ruby: "3.2" gemfile: gemfiles/rails_4_2.gemfile - - ruby: 3.0.2 + - ruby: "3.2" gemfile: gemfiles/rails_5_0.gemfile - - ruby: 3.0.2 + - ruby: "3.2" gemfile: gemfiles/rails_5_1.gemfile - - ruby: 3.0.2 + - ruby: "3.2" gemfile: gemfiles/rails_5_2.gemfile - ruby: truffleruby-head gemfile: gemfiles/rails_3_0.gemfile @@ -195,7 +198,7 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@master + uses: actions/checkout@v4 - name: Nokogiri support for TruffleRuby run: sudo apt-get -yqq install libxml2-dev libxslt-dev if: ${{ matrix.ruby == 'truffleruby-head' }} diff --git a/CHANGELOG.md b/CHANGELOG.md index 1cb4e18..afde742 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +# ActiveAttr 0.16.0 (October 30, 2023) + +* ActiveAttr now supports Ruby 3.1 +* ActiveAttr now supports Ruby 3.2 +* ActiveAttr now supports Rails 7.1 (thanks @mathieujobin) + # ActiveAttr 0.15.4 (December 16, 2021) * ActiveAttr now supports Rails 7.0 (Steve Hoeksema) diff --git a/Gemfile b/Gemfile index c0d03f8..018b8d9 100644 --- a/Gemfile +++ b/Gemfile @@ -2,9 +2,9 @@ source "https://rubygems.org" gemspec :development_group => :test -gem "activemodel", "~> 7.0.0" -gem "activesupport", "~> 7.0.0" -gem "actionpack", "~> 7.0.0" +gem "activemodel", "~> 7.1.0" +gem "activesupport", "~> 7.1.0" +gem "actionpack", "~> 7.1.0" gem "activemodel-serializers-xml", :group => :test gem "rexml", :group => :test gem "protected_attributes_continued", :group => :test diff --git a/active_attr.gemspec b/active_attr.gemspec index f90bbe1..4cc5fb9 100644 --- a/active_attr.gemspec +++ b/active_attr.gemspec @@ -22,9 +22,9 @@ Gem::Specification.new do |gem| gem.required_ruby_version = ">= 2.1.0" - gem.add_runtime_dependency "actionpack", ">= 3.0.2", "< 7.1" - gem.add_runtime_dependency "activemodel", ">= 3.0.2", "< 7.1" - gem.add_runtime_dependency "activesupport", ">= 3.0.2", "< 7.1" + gem.add_runtime_dependency "actionpack", ">= 3.0.2", "< 7.2" + gem.add_runtime_dependency "activemodel", ">= 3.0.2", "< 7.2" + gem.add_runtime_dependency "activesupport", ">= 3.0.2", "< 7.2" gem.add_development_dependency "bundler" gem.add_development_dependency "factory_bot", "< 5.0" diff --git a/gemfiles/rails_7_0.gemfile b/gemfiles/rails_7_0.gemfile new file mode 100644 index 0000000..90c6bdb --- /dev/null +++ b/gemfiles/rails_7_0.gemfile @@ -0,0 +1,10 @@ +source "https://rubygems.org" + +gemspec :development_group => :test, :path => ".." + +gem "activemodel", "~> 7.0.0" +gem "activesupport", "~> 7.0.0" +gem "actionpack", "~> 7.0.0" +gem "activemodel-serializers-xml", :group => :test +gem "rexml", :group => :test +gem "protected_attributes_continued", :group => :test diff --git a/gemfiles/rails_head.gemfile b/gemfiles/rails_head.gemfile index fb1f632..9557d36 100644 --- a/gemfiles/rails_head.gemfile +++ b/gemfiles/rails_head.gemfile @@ -2,13 +2,13 @@ source "https://rubygems.org" gemspec :development_group => :test, :path => ".." -git "git://github.com/rails/rails.git", :branch => "main" do +git "https://github.com/rails/rails.git", :branch => "main" do gem "activemodel" gem "activesupport" gem "actionpack" end -gem "activemodel-serializers-xml", :group => :test, :git => "git://github.com/rails/activemodel-serializers-xml.git" +gem "activemodel-serializers-xml", :group => :test, :git => "https://github.com/rails/activemodel-serializers-xml.git" gem "rexml", :group => :test -gem "protected_attributes_continued", :group => :test, :git => "git://github.com/westonganger/protected_attributes_continued" -gem "rack", :group => :test, :git => "git://github.com/rack/rack.git" +gem "protected_attributes_continued", :group => :test, :git => "https://github.com/westonganger/protected_attributes_continued.git" +gem "rack", :group => :test, :git => "https://github.com/rack/rack.git", :branch => "main" diff --git a/lib/active_attr/attributes.rb b/lib/active_attr/attributes.rb index d385690..f1552f7 100644 --- a/lib/active_attr/attributes.rb +++ b/lib/active_attr/attributes.rb @@ -66,7 +66,7 @@ def self.filter_attributes=(new_filter_attributes) class_attribute :filter_attributes, :instance_writer => false self.filter_attributes = Attributes.filter_attributes - attribute_method_suffix "" if attribute_method_matchers.none? { |matcher| matcher.prefix == "" && matcher.suffix == "" } + attribute_method_suffix "" if attribute_method_patterns.none? { |matcher| matcher.prefix == "" && matcher.suffix == "" } attribute_method_suffix "=" end @@ -323,6 +323,14 @@ def inspect "#{name}#{attributes_list}" end + # Renamed in ActiveModel 7.1 + # + # @private + # @since 0.16.0 + def attribute_method_patterns + attribute_method_matchers + end unless method_defined?(:attribute_method_patterns) + protected # Assign a set of attribute definitions, used when subclassing models @@ -346,7 +354,7 @@ def instance_method_already_implemented?(method_name) # # @since 0.6.0 def attribute_methods(name) - attribute_method_matchers.map { |matcher| matcher.method_name name } + attribute_method_patterns.map { |matcher| matcher.method_name name } end # Ruby inherited hook to assign superclass attributes to subclasses diff --git a/lib/active_attr/version.rb b/lib/active_attr/version.rb index 1b9772e..24edf89 100644 --- a/lib/active_attr/version.rb +++ b/lib/active_attr/version.rb @@ -1,5 +1,5 @@ module ActiveAttr # Complete version string # @since 0.1.0 - VERSION = "0.15.4" + VERSION = "0.16.0" end diff --git a/spec/unit/active_attr/attributes_spec.rb b/spec/unit/active_attr/attributes_spec.rb index 777910d..ba7ccf0 100644 --- a/spec/unit/active_attr/attributes_spec.rb +++ b/spec/unit/active_attr/attributes_spec.rb @@ -211,7 +211,7 @@ def self.name end it "returns false when compared to another type" do - should_not == Struct.new(:attributes).new("first_name" => "Ben") + should_not == Struct.new(:attributes).new({ "first_name" => "Ben" }) end end