active_type 2.7.0 → 2.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f11ea5914e78ff48fe20270960c6e8b6062b22b87752eb814f2e7c935257a60a
4
- data.tar.gz: 3bd47fa49ec42f7cae09ec396a7442df2ecfd9840ee087e9531c359e20d88a64
3
+ metadata.gz: 28986180d23a749310c496d900fc83b79ca4bfe305704f2bb93ec6a8c69cf131
4
+ data.tar.gz: 6647ff958ee1be018e654c7689fa333fa3789c1fcb972b6125a4f9e65c0a2aaa
5
5
  SHA512:
6
- metadata.gz: f74d712d4f74b4d7b7e212b0280b4bfff20245a9ed8430445a38cdf3c30017cb48121f109f0a150bf8cdb82d86700867618e3407e3c82ff8abc74ffe83ff493d
7
- data.tar.gz: 5b21a579e4e1de11547f94215d9b69c02dcb442f2dc42b915ced261f5f0661f213d440bcf5c26f65006e474b7ad74118b71b6e674856dd7682af484d6db3a936
6
+ metadata.gz: 18f57bad0539e91f6725ccfd63ceb6faa32a23d96b9033d0bbc240b62f475dd385d03e395f7ba82646078e64add7bc26241848f0c9177568e29699404355c346
7
+ data.tar.gz: 13de6f297c36eb2e2dc75c719f1e8a858a783576f9aaf322e4c46654ae8ee578a8299f73aee651bd64e395ec2dd3a09a6fc02f0b4cbc2977a2ba26c7556d3592
data/CHANGELOG.md CHANGED
@@ -2,6 +2,13 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ ## 2.8.0 (2026-01-22)
6
+ * Added: Add support `attributes_for_inspect` on ActiveType::Object.
7
+ Tanks to @makmic.
8
+
9
+ ## 2.7.1 (2025-11-03)
10
+ * Fixed: Removed some unnecessary files from the packaged gem. Gets rid of symlink warnings during installation.
11
+
5
12
  ## 2.7.0 (2025-11-03)
6
13
  * Removed: Support for Ruby < 3.1, Rails < 7.
7
14
  * Fixed: Exception when using ActiveType::Record with Rails 8.1.
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActiveType
4
- VERSION = '2.7.0'
4
+ VERSION = '2.8.0'
5
5
  end
@@ -134,6 +134,19 @@ module ActiveType
134
134
  result
135
135
  end
136
136
 
137
+ def self.attribute_for_inspect(value)
138
+ if value.is_a?(String) && value.length > 50
139
+ "#{value[0, 50]}...".inspect
140
+ elsif value.is_a?(Date) || value.is_a?(Time)
141
+ %("#{value.to_formatted_s(:db)}")
142
+ elsif value.is_a?(Array) && value.size > 10
143
+ inspected = value.first(10).inspect
144
+ %(#{inspected[0...-1]}, ...])
145
+ else
146
+ value.inspect
147
+ end
148
+ end
149
+
137
150
  extend ActiveSupport::Concern
138
151
 
139
152
  included do
@@ -141,6 +154,14 @@ module ActiveType
141
154
  class_attribute :virtual_columns_hash
142
155
  self.virtual_columns_hash = {}
143
156
 
157
+ if respond_to?(:attributes_for_inspect)
158
+ # 7.1 had [:id] as a default, we want a consistent default across all versions
159
+ self.attributes_for_inspect = :all
160
+ else
161
+ # ActiveRecord < 7.2
162
+ class_attribute :attributes_for_inspect, instance_accessor: false, default: :all
163
+ end
164
+
144
165
  class << self
145
166
  if method_defined?(:attribute)
146
167
  alias_method :ar_attribute, :attribute
@@ -270,25 +291,28 @@ module ActiveType
270
291
  virtual_attributes[name] = value
271
292
  end
272
293
 
273
- # Returns the contents of the record as a nicely formatted string.
294
+ def attributes_for_inspect
295
+ self.class.attributes_for_inspect == :all ? attributes.keys : self.class.attributes_for_inspect
296
+ end
297
+
274
298
  def inspect
275
- inspection = attributes.collect do |name, value|
276
- "#{name}: #{VirtualAttributes.attribute_for_inspect(value)}"
277
- end.sort.compact.join(", ")
278
- "#<#{self.class} #{inspection}>"
299
+ inspect_with_attributes(attributes_for_inspect)
279
300
  end
280
301
 
281
- def self.attribute_for_inspect(value)
282
- if value.is_a?(String) && value.length > 50
283
- "#{value[0, 50]}...".inspect
284
- elsif value.is_a?(Date) || value.is_a?(Time)
285
- %("#{value.to_formatted_s(:db)}")
286
- elsif value.is_a?(Array) && value.size > 10
287
- inspected = value.first(10).inspect
288
- %(#{inspected[0...-1]}, ...])
289
- else
290
- value.inspect
291
- end
302
+ def full_inspect
303
+ inspect_with_attributes(attributes.keys)
304
+ end
305
+
306
+ # Returns the contents of the record as a nicely formatted string.
307
+ def inspect_with_attributes(attribute_names)
308
+ inspection = attribute_names.collect do |name|
309
+ name = name.to_s
310
+ if attributes.key?(name)
311
+ value = attributes[name]
312
+ "#{name}: #{VirtualAttributes.attribute_for_inspect(value)}"
313
+ end
314
+ end.compact.sort.join(", ")
315
+ "#<#{self.class} #{inspection}>"
292
316
  end
293
317
 
294
318
  private
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_type
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.7.0
4
+ version: 2.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tobias Kraze
@@ -58,31 +58,9 @@ executables: []
58
58
  extensions: []
59
59
  extra_rdoc_files: []
60
60
  files:
61
- - ".github/workflows/test.yml"
62
- - ".gitignore"
63
- - ".rspec"
64
- - ".ruby-version"
65
61
  - CHANGELOG.md
66
- - Gemfile
67
- - Gemfile.7.1.sqlite3
68
- - Gemfile.7.1.sqlite3.lock
69
- - Gemfile.7.2.mysql2
70
- - Gemfile.7.2.mysql2.lock
71
- - Gemfile.7.2.pg
72
- - Gemfile.7.2.pg.lock
73
- - Gemfile.7.2.sqlite3
74
- - Gemfile.7.2.sqlite3.lock
75
- - Gemfile.8.0.sqlite3
76
- - Gemfile.8.0.sqlite3.lock
77
- - Gemfile.8.1.pg
78
- - Gemfile.8.1.pg.lock
79
- - Gemfile.8.1.sqlite3
80
- - Gemfile.8.1.sqlite3.lock
81
- - Gemfile.lock
82
62
  - LICENSE
83
63
  - README.md
84
- - Rakefile
85
- - active_type.gemspec
86
64
  - lib/active_type.rb
87
65
  - lib/active_type/change_association.rb
88
66
  - lib/active_type/marshalling.rb
@@ -103,12 +81,6 @@ files:
103
81
  - lib/active_type/util/unmutable_attributes.rb
104
82
  - lib/active_type/version.rb
105
83
  - lib/active_type/virtual_attributes.rb
106
- - media/logo.dark.shapes.svg
107
- - media/logo.dark.text.svg
108
- - media/logo.light.shapes.svg
109
- - media/logo.light.text.svg
110
- - media/makandra-with-bottom-margin.dark.svg
111
- - media/makandra-with-bottom-margin.light.svg
112
84
  homepage: https://github.com/makandra/active_type
113
85
  licenses:
114
86
  - MIT
@@ -131,7 +103,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
131
103
  - !ruby/object:Gem::Version
132
104
  version: '0'
133
105
  requirements: []
134
- rubygems_version: 3.6.7
106
+ rubygems_version: 3.6.9
135
107
  specification_version: 4
136
108
  summary: Make any Ruby object quack like ActiveRecord
137
109
  test_files: []
@@ -1,114 +0,0 @@
1
- name: Tests
2
-
3
- on:
4
- push:
5
- branches: [main]
6
- pull_request:
7
- branches: [main]
8
-
9
- jobs:
10
- test_sqlite:
11
- runs-on: ubuntu-24.04
12
-
13
- strategy:
14
- fail-fast: false
15
- matrix:
16
- include:
17
- - ruby: "3.1.6"
18
- gemfile: Gemfile.7.1.sqlite3
19
- - ruby: "3.1.6"
20
- gemfile: Gemfile.7.2.sqlite3
21
- - ruby: "3.2.6"
22
- gemfile: Gemfile.7.2.sqlite3
23
- - ruby: "3.3.6"
24
- gemfile: Gemfile.8.0.sqlite3
25
- - ruby: "3.4.7"
26
- gemfile: Gemfile.8.1.sqlite3
27
- env:
28
- BUNDLE_GEMFILE: ${{ matrix.gemfile }}
29
-
30
- steps:
31
- - uses: actions/checkout@v3
32
- - name: Install ruby
33
- uses: ruby/setup-ruby@v1
34
- with:
35
- ruby-version: ${{ matrix.ruby }}
36
- bundler-cache: true
37
- - name: Run tests
38
- run: bundle exec rake spec
39
-
40
- test_mysql:
41
- runs-on: ubuntu-24.04
42
-
43
- services:
44
- mysql:
45
- image: mysql:5.6
46
- env:
47
- MYSQL_ROOT_PASSWORD: password
48
- ports:
49
- - 3306:3306
50
- options: >-
51
- --health-cmd="mysqladmin ping"
52
- --health-interval=10s
53
- --health-timeout=5s
54
- --health-retries=3
55
-
56
- strategy:
57
- fail-fast: false
58
- matrix:
59
- include:
60
- - ruby: "3.2.6"
61
- gemfile: Gemfile.7.2.mysql2
62
- env:
63
- BUNDLE_GEMFILE: ${{ matrix.gemfile }}
64
-
65
- steps:
66
- - uses: actions/checkout@v3
67
- - name: Install ruby
68
- uses: ruby/setup-ruby@v1
69
- with:
70
- ruby-version: ${{ matrix.ruby }}
71
- bundler-cache: true
72
- - name: Setup databases
73
- run: |
74
- mysql -e 'create database IF NOT EXISTS active_type_test;' -u root --password=password -P 3306 -h 127.0.0.1
75
- - name: Run tests
76
- run: bundle exec rake spec
77
-
78
- test_pg:
79
- runs-on: ubuntu-24.04
80
-
81
- services:
82
- postgres:
83
- image: postgres
84
- env:
85
- POSTGRES_PASSWORD: postgres
86
- POSTGRES_DB: active_type_test
87
- options: >-
88
- --health-cmd pg_isready
89
- --health-interval 10s
90
- --health-timeout 5s
91
- --health-retries 5
92
- ports:
93
- - 5432:5432
94
-
95
- strategy:
96
- fail-fast: false
97
- matrix:
98
- include:
99
- - ruby: "3.2.6"
100
- gemfile: Gemfile.7.2.pg
101
- - ruby: "3.4.7"
102
- gemfile: Gemfile.8.1.pg
103
- env:
104
- BUNDLE_GEMFILE: ${{ matrix.gemfile }}
105
-
106
- steps:
107
- - uses: actions/checkout@v3
108
- - name: Install ruby
109
- uses: ruby/setup-ruby@v1
110
- with:
111
- ruby-version: ${{ matrix.ruby }}
112
- bundler-cache: true
113
- - name: Run tests
114
- run: bundle exec rake spec
data/.gitignore DELETED
@@ -1,8 +0,0 @@
1
- doc
2
- pkg
3
- tags
4
- *.gem
5
- .idea
6
- tmp
7
- spec/support/database.yml
8
- .bundle
data/.rspec DELETED
@@ -1 +0,0 @@
1
- --color
data/.ruby-version DELETED
@@ -1 +0,0 @@
1
- 3.4
data/Gemfile DELETED
@@ -1 +0,0 @@
1
- Gemfile.7.0.sqlite3
data/Gemfile.7.1.sqlite3 DELETED
@@ -1,9 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gem 'activerecord', '~>7.1.0'
4
- gem 'rspec', '~>3.4'
5
- gem 'sqlite3', '=1.6.0'
6
- gem 'rake'
7
- gem 'gemika'
8
-
9
- gem 'active_type', :path => '.'
@@ -1,70 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- active_type (2.7.0)
5
- activerecord (>= 6.1)
6
-
7
- GEM
8
- remote: https://rubygems.org/
9
- specs:
10
- activemodel (7.1.3.4)
11
- activesupport (= 7.1.3.4)
12
- activerecord (7.1.3.4)
13
- activemodel (= 7.1.3.4)
14
- activesupport (= 7.1.3.4)
15
- timeout (>= 0.4.0)
16
- activesupport (7.1.3.4)
17
- base64
18
- bigdecimal
19
- concurrent-ruby (~> 1.0, >= 1.0.2)
20
- connection_pool (>= 2.2.5)
21
- drb
22
- i18n (>= 1.6, < 2)
23
- minitest (>= 5.1)
24
- mutex_m
25
- tzinfo (~> 2.0)
26
- base64 (0.2.0)
27
- bigdecimal (3.1.8)
28
- concurrent-ruby (1.3.4)
29
- connection_pool (2.4.1)
30
- diff-lcs (1.5.1)
31
- drb (2.2.1)
32
- gemika (0.8.3)
33
- i18n (1.14.5)
34
- concurrent-ruby (~> 1.0)
35
- mini_portile2 (2.8.7)
36
- minitest (5.24.1)
37
- mutex_m (0.2.0)
38
- rake (13.2.1)
39
- rspec (3.13.0)
40
- rspec-core (~> 3.13.0)
41
- rspec-expectations (~> 3.13.0)
42
- rspec-mocks (~> 3.13.0)
43
- rspec-core (3.13.0)
44
- rspec-support (~> 3.13.0)
45
- rspec-expectations (3.13.1)
46
- diff-lcs (>= 1.2.0, < 2.0)
47
- rspec-support (~> 3.13.0)
48
- rspec-mocks (3.13.1)
49
- diff-lcs (>= 1.2.0, < 2.0)
50
- rspec-support (~> 3.13.0)
51
- rspec-support (3.13.1)
52
- sqlite3 (1.6.0)
53
- mini_portile2 (~> 2.8.0)
54
- timeout (0.4.1)
55
- tzinfo (2.0.6)
56
- concurrent-ruby (~> 1.0)
57
-
58
- PLATFORMS
59
- ruby
60
-
61
- DEPENDENCIES
62
- active_type!
63
- activerecord (~> 7.1.0)
64
- gemika
65
- rake
66
- rspec (~> 3.4)
67
- sqlite3 (= 1.6.0)
68
-
69
- BUNDLED WITH
70
- 2.5.6
data/Gemfile.7.2.mysql2 DELETED
@@ -1,9 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gem 'activerecord', '~>7.2.0'
4
- gem 'rspec', '~>3.4'
5
- gem 'mysql2'
6
- gem 'rake'
7
- gem 'gemika'
8
-
9
- gem 'active_type', :path => '.'
@@ -1,73 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- active_type (2.7.0)
5
- activerecord (>= 6.1)
6
-
7
- GEM
8
- remote: https://rubygems.org/
9
- specs:
10
- activemodel (7.2.2.1)
11
- activesupport (= 7.2.2.1)
12
- activerecord (7.2.2.1)
13
- activemodel (= 7.2.2.1)
14
- activesupport (= 7.2.2.1)
15
- timeout (>= 0.4.0)
16
- activesupport (7.2.2.1)
17
- base64
18
- benchmark (>= 0.3)
19
- bigdecimal
20
- concurrent-ruby (~> 1.0, >= 1.3.1)
21
- connection_pool (>= 2.2.5)
22
- drb
23
- i18n (>= 1.6, < 2)
24
- logger (>= 1.4.2)
25
- minitest (>= 5.1)
26
- securerandom (>= 0.3)
27
- tzinfo (~> 2.0, >= 2.0.5)
28
- base64 (0.2.0)
29
- benchmark (0.4.0)
30
- bigdecimal (3.1.8)
31
- concurrent-ruby (1.3.4)
32
- connection_pool (2.4.1)
33
- diff-lcs (1.5.1)
34
- drb (2.2.1)
35
- gemika (0.8.3)
36
- i18n (1.14.6)
37
- concurrent-ruby (~> 1.0)
38
- logger (1.6.4)
39
- minitest (5.25.4)
40
- mysql2 (0.5.6)
41
- rake (13.2.1)
42
- rspec (3.13.0)
43
- rspec-core (~> 3.13.0)
44
- rspec-expectations (~> 3.13.0)
45
- rspec-mocks (~> 3.13.0)
46
- rspec-core (3.13.2)
47
- rspec-support (~> 3.13.0)
48
- rspec-expectations (3.13.3)
49
- diff-lcs (>= 1.2.0, < 2.0)
50
- rspec-support (~> 3.13.0)
51
- rspec-mocks (3.13.2)
52
- diff-lcs (>= 1.2.0, < 2.0)
53
- rspec-support (~> 3.13.0)
54
- rspec-support (3.13.2)
55
- securerandom (0.4.1)
56
- timeout (0.4.3)
57
- tzinfo (2.0.6)
58
- concurrent-ruby (~> 1.0)
59
-
60
- PLATFORMS
61
- ruby
62
- x86_64-linux
63
-
64
- DEPENDENCIES
65
- active_type!
66
- activerecord (~> 7.2.0)
67
- gemika
68
- mysql2
69
- rake
70
- rspec (~> 3.4)
71
-
72
- BUNDLED WITH
73
- 2.6.2
data/Gemfile.7.2.pg DELETED
@@ -1,9 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gem 'activerecord', '~>7.2.0'
4
- gem 'rspec', '~>3.4'
5
- gem 'pg'
6
- gem 'rake'
7
- gem 'gemika'
8
-
9
- gem 'active_type', :path => '.'
data/Gemfile.7.2.pg.lock DELETED
@@ -1,70 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- active_type (2.7.0)
5
- activerecord (>= 6.1)
6
-
7
- GEM
8
- remote: https://rubygems.org/
9
- specs:
10
- activemodel (7.2.0)
11
- activesupport (= 7.2.0)
12
- activerecord (7.2.0)
13
- activemodel (= 7.2.0)
14
- activesupport (= 7.2.0)
15
- timeout (>= 0.4.0)
16
- activesupport (7.2.0)
17
- base64
18
- bigdecimal
19
- concurrent-ruby (~> 1.0, >= 1.3.1)
20
- connection_pool (>= 2.2.5)
21
- drb
22
- i18n (>= 1.6, < 2)
23
- logger (>= 1.4.2)
24
- minitest (>= 5.1)
25
- securerandom (>= 0.3)
26
- tzinfo (~> 2.0, >= 2.0.5)
27
- base64 (0.2.0)
28
- bigdecimal (3.1.8)
29
- concurrent-ruby (1.3.4)
30
- connection_pool (2.4.1)
31
- diff-lcs (1.5.1)
32
- drb (2.2.1)
33
- gemika (0.8.3)
34
- i18n (1.14.5)
35
- concurrent-ruby (~> 1.0)
36
- logger (1.6.0)
37
- minitest (5.24.1)
38
- pg (1.5.7)
39
- rake (13.2.1)
40
- rspec (3.13.0)
41
- rspec-core (~> 3.13.0)
42
- rspec-expectations (~> 3.13.0)
43
- rspec-mocks (~> 3.13.0)
44
- rspec-core (3.13.0)
45
- rspec-support (~> 3.13.0)
46
- rspec-expectations (3.13.1)
47
- diff-lcs (>= 1.2.0, < 2.0)
48
- rspec-support (~> 3.13.0)
49
- rspec-mocks (3.13.1)
50
- diff-lcs (>= 1.2.0, < 2.0)
51
- rspec-support (~> 3.13.0)
52
- rspec-support (3.13.1)
53
- securerandom (0.3.1)
54
- timeout (0.4.1)
55
- tzinfo (2.0.6)
56
- concurrent-ruby (~> 1.0)
57
-
58
- PLATFORMS
59
- ruby
60
-
61
- DEPENDENCIES
62
- active_type!
63
- activerecord (~> 7.2.0)
64
- gemika
65
- pg
66
- rake
67
- rspec (~> 3.4)
68
-
69
- BUNDLED WITH
70
- 2.5.6
data/Gemfile.7.2.sqlite3 DELETED
@@ -1,9 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gem 'activerecord', '~>7.2.0'
4
- gem 'rspec', '~>3.4'
5
- gem 'sqlite3', '=1.6.0'
6
- gem 'rake'
7
- gem 'gemika'
8
-
9
- gem 'active_type', :path => '.'
@@ -1,72 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- active_type (2.7.0)
5
- activerecord (>= 6.1)
6
-
7
- GEM
8
- remote: https://rubygems.org/
9
- specs:
10
- activemodel (7.2.0)
11
- activesupport (= 7.2.0)
12
- activerecord (7.2.0)
13
- activemodel (= 7.2.0)
14
- activesupport (= 7.2.0)
15
- timeout (>= 0.4.0)
16
- activesupport (7.2.0)
17
- base64
18
- bigdecimal
19
- concurrent-ruby (~> 1.0, >= 1.3.1)
20
- connection_pool (>= 2.2.5)
21
- drb
22
- i18n (>= 1.6, < 2)
23
- logger (>= 1.4.2)
24
- minitest (>= 5.1)
25
- securerandom (>= 0.3)
26
- tzinfo (~> 2.0, >= 2.0.5)
27
- base64 (0.2.0)
28
- bigdecimal (3.1.8)
29
- concurrent-ruby (1.3.4)
30
- connection_pool (2.4.1)
31
- diff-lcs (1.5.1)
32
- drb (2.2.1)
33
- gemika (0.8.3)
34
- i18n (1.14.5)
35
- concurrent-ruby (~> 1.0)
36
- logger (1.6.0)
37
- mini_portile2 (2.8.7)
38
- minitest (5.24.1)
39
- rake (13.2.1)
40
- rspec (3.13.0)
41
- rspec-core (~> 3.13.0)
42
- rspec-expectations (~> 3.13.0)
43
- rspec-mocks (~> 3.13.0)
44
- rspec-core (3.13.0)
45
- rspec-support (~> 3.13.0)
46
- rspec-expectations (3.13.1)
47
- diff-lcs (>= 1.2.0, < 2.0)
48
- rspec-support (~> 3.13.0)
49
- rspec-mocks (3.13.1)
50
- diff-lcs (>= 1.2.0, < 2.0)
51
- rspec-support (~> 3.13.0)
52
- rspec-support (3.13.1)
53
- securerandom (0.3.1)
54
- sqlite3 (1.6.0)
55
- mini_portile2 (~> 2.8.0)
56
- timeout (0.4.1)
57
- tzinfo (2.0.6)
58
- concurrent-ruby (~> 1.0)
59
-
60
- PLATFORMS
61
- ruby
62
-
63
- DEPENDENCIES
64
- active_type!
65
- activerecord (~> 7.2.0)
66
- gemika
67
- rake
68
- rspec (~> 3.4)
69
- sqlite3 (= 1.6.0)
70
-
71
- BUNDLED WITH
72
- 2.5.6
data/Gemfile.8.0.sqlite3 DELETED
@@ -1,9 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gem 'activerecord', '~>8.0.0'
4
- gem 'rspec', '~>3.4'
5
- gem 'sqlite3'
6
- gem 'rake'
7
- gem 'gemika'
8
-
9
- gem 'active_type', :path => '.'