has_defaults 1.1.1 → 1.2.1
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 +4 -4
- data/.github/workflows/test.yml +4 -8
- data/.ruby-version +1 -1
- data/CHANGELOG.md +18 -0
- data/Gemfile.3.2.mysql2.lock +3 -3
- data/Gemfile.4.2.mysql2.lock +2 -2
- data/Gemfile.4.2.pg.lock +2 -2
- data/Gemfile.5.2.mysql2 +2 -2
- data/Gemfile.5.2.mysql2.lock +5 -5
- data/Gemfile.5.2.pg +1 -1
- data/Gemfile.5.2.pg.lock +3 -3
- data/Gemfile.6.1.pg +2 -2
- data/Gemfile.6.1.pg.lock +9 -9
- data/Gemfile.7.0.pg +3 -3
- data/Gemfile.7.0.pg.lock +21 -21
- data/README.md +6 -6
- data/lib/has_defaults/active_record_ext.rb +3 -3
- data/lib/has_defaults/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 699a82dd69eb3ae0e29640deef82f676973939af56412ac5ca976de1d6d73518
|
|
4
|
+
data.tar.gz: 48c12946f600f3becd44af5e2c8067e08fc802576d68fa2e9ca8b1e19385af1b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9aa21669bba0d8ab54f752702e5da7f3438f3dd1feb9a233d8ed095940a9575f11e2ae906bdcd5484897d0ebe41abfc60cdd0ab83806dcb97dcc4da76017bcce
|
|
7
|
+
data.tar.gz: cf3e65d6cd134ff80cd06af116f6200e360fef62ce5e40a6d87b96b7b0890a972fe0693513f1f6bf5006b9e65991a84c2735d684ce19f0552c1d5d9e17f4c1c5
|
data/.github/workflows/test.yml
CHANGED
|
@@ -44,8 +44,6 @@ jobs:
|
|
|
44
44
|
ruby-version: "${{ matrix.ruby }}"
|
|
45
45
|
- name: Setup database
|
|
46
46
|
run: |
|
|
47
|
-
sudo apt-get update
|
|
48
|
-
sudo apt-get install -y mariadb-client libmariadbclient-dev
|
|
49
47
|
mysql -e 'create database IF NOT EXISTS test;' -u root --password=password -P 3306 -h 127.0.0.1
|
|
50
48
|
- name: Bundle
|
|
51
49
|
run: |
|
|
@@ -68,25 +66,23 @@ jobs:
|
|
|
68
66
|
fail-fast: false
|
|
69
67
|
# Rails 4.2: Ruby 2.5.7
|
|
70
68
|
# Rails 5.2: Ruby 2.5.7 and 2.7.4
|
|
71
|
-
# Rails 6.1: Ruby 2.
|
|
72
|
-
# Rails 7.0: Ruby 2.7.4 and 3.
|
|
69
|
+
# Rails 6.1: Ruby 2.7.4 and 3.2.1
|
|
70
|
+
# Rails 7.0: Ruby 2.7.4 and 3.2.1
|
|
73
71
|
matrix:
|
|
74
72
|
include:
|
|
75
73
|
- ruby: 2.5.7
|
|
76
74
|
gemfile: Gemfile.4.2.pg
|
|
77
75
|
- ruby: 2.5.7
|
|
78
76
|
gemfile: Gemfile.5.2.pg
|
|
79
|
-
- ruby: 2.5.7
|
|
80
|
-
gemfile: Gemfile.6.1.pg
|
|
81
77
|
- ruby: 2.7.4
|
|
82
78
|
gemfile: Gemfile.5.2.pg
|
|
83
79
|
- ruby: 2.7.4
|
|
84
80
|
gemfile: Gemfile.6.1.pg
|
|
85
81
|
- ruby: 2.7.4
|
|
86
82
|
gemfile: Gemfile.7.0.pg
|
|
87
|
-
- ruby: 3.
|
|
83
|
+
- ruby: 3.2.1
|
|
88
84
|
gemfile: Gemfile.6.1.pg
|
|
89
|
-
- ruby: 3.
|
|
85
|
+
- ruby: 3.2.1
|
|
90
86
|
gemfile: Gemfile.7.0.pg
|
|
91
87
|
env:
|
|
92
88
|
BUNDLE_GEMFILE: "${{ matrix.gemfile }}"
|
data/.ruby-version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2.7.4
|
|
1
|
+
2.7.4
|
data/CHANGELOG.md
CHANGED
|
@@ -11,6 +11,24 @@ This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html
|
|
|
11
11
|
### Compatible changes
|
|
12
12
|
|
|
13
13
|
|
|
14
|
+
## 1.2.1 - 2024-10-25
|
|
15
|
+
|
|
16
|
+
### Compatible changes
|
|
17
|
+
|
|
18
|
+
* Follow recommended way to extend Railties
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
## 1.2.0 - 2023-03-15
|
|
22
|
+
|
|
23
|
+
### Breaking changes
|
|
24
|
+
|
|
25
|
+
* Drop support for Ruby 2.5 with Rails 6.1
|
|
26
|
+
|
|
27
|
+
### Compatible changes
|
|
28
|
+
|
|
29
|
+
* Add support for Ruby 3.2
|
|
30
|
+
|
|
31
|
+
|
|
14
32
|
## 1.1.1 - 2022-03-09
|
|
15
33
|
|
|
16
34
|
### Breaking changes
|
data/Gemfile.3.2.mysql2.lock
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
GIT
|
|
2
2
|
remote: https://github.com/makandra/mysql2
|
|
3
|
-
revision:
|
|
3
|
+
revision: 451c4a666212aa3c5e9f4dbfbe94f49bade4286b
|
|
4
4
|
branch: 0.3.x-lts
|
|
5
5
|
specs:
|
|
6
6
|
mysql2 (0.3.21)
|
|
@@ -8,7 +8,7 @@ GIT
|
|
|
8
8
|
PATH
|
|
9
9
|
remote: .
|
|
10
10
|
specs:
|
|
11
|
-
has_defaults (1.
|
|
11
|
+
has_defaults (1.2.1)
|
|
12
12
|
activerecord
|
|
13
13
|
|
|
14
14
|
GEM
|
|
@@ -72,4 +72,4 @@ DEPENDENCIES
|
|
|
72
72
|
rspec (~> 3.4)
|
|
73
73
|
|
|
74
74
|
BUNDLED WITH
|
|
75
|
-
2.
|
|
75
|
+
2.3.4
|
data/Gemfile.4.2.mysql2.lock
CHANGED
data/Gemfile.4.2.pg.lock
CHANGED
data/Gemfile.5.2.mysql2
CHANGED
data/Gemfile.5.2.mysql2.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
has_defaults (1.
|
|
4
|
+
has_defaults (1.2.1)
|
|
5
5
|
activerecord
|
|
6
6
|
|
|
7
7
|
GEM
|
|
@@ -29,7 +29,7 @@ GEM
|
|
|
29
29
|
concurrent-ruby (~> 1.0)
|
|
30
30
|
method_source (1.0.0)
|
|
31
31
|
minitest (5.14.2)
|
|
32
|
-
mysql2 (0.
|
|
32
|
+
mysql2 (0.4.10)
|
|
33
33
|
pry (0.13.1)
|
|
34
34
|
coderay (~> 1.1)
|
|
35
35
|
method_source (~> 1.0)
|
|
@@ -58,14 +58,14 @@ PLATFORMS
|
|
|
58
58
|
ruby
|
|
59
59
|
|
|
60
60
|
DEPENDENCIES
|
|
61
|
-
activerecord (~> 5
|
|
61
|
+
activerecord (~> 5)
|
|
62
62
|
database_cleaner
|
|
63
63
|
gemika (>= 0.2.0)
|
|
64
64
|
has_defaults!
|
|
65
|
-
mysql2 (~> 0.
|
|
65
|
+
mysql2 (~> 0.4.10)
|
|
66
66
|
pry-byebug
|
|
67
67
|
rake
|
|
68
68
|
rspec (~> 3.5)
|
|
69
69
|
|
|
70
70
|
BUNDLED WITH
|
|
71
|
-
2.3.
|
|
71
|
+
2.3.26
|
data/Gemfile.5.2.pg
CHANGED
data/Gemfile.5.2.pg.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
has_defaults (1.
|
|
4
|
+
has_defaults (1.2.1)
|
|
5
5
|
activerecord
|
|
6
6
|
|
|
7
7
|
GEM
|
|
@@ -63,7 +63,7 @@ PLATFORMS
|
|
|
63
63
|
ruby
|
|
64
64
|
|
|
65
65
|
DEPENDENCIES
|
|
66
|
-
activerecord
|
|
66
|
+
activerecord (~> 5)
|
|
67
67
|
activesupport
|
|
68
68
|
database_cleaner
|
|
69
69
|
gemika (>= 0.2.0)
|
|
@@ -74,4 +74,4 @@ DEPENDENCIES
|
|
|
74
74
|
rspec (~> 3.5)
|
|
75
75
|
|
|
76
76
|
BUNDLED WITH
|
|
77
|
-
2.3.
|
|
77
|
+
2.3.26
|
data/Gemfile.6.1.pg
CHANGED
|
@@ -2,13 +2,13 @@ source 'https://rubygems.org'
|
|
|
2
2
|
|
|
3
3
|
# Runtime dependencies
|
|
4
4
|
gem 'activerecord', '~>6.1.3'
|
|
5
|
-
gem 'pg', '
|
|
5
|
+
gem 'pg', '>=1.3'
|
|
6
6
|
|
|
7
7
|
# Development dependencies
|
|
8
8
|
gem 'rake'
|
|
9
9
|
gem 'database_cleaner'
|
|
10
10
|
gem 'rspec', '~>3.5'
|
|
11
|
-
gem 'gemika', '>=
|
|
11
|
+
gem 'gemika', '>=0.8.1'
|
|
12
12
|
gem 'pry-byebug'
|
|
13
13
|
|
|
14
14
|
# Gem under test
|
data/Gemfile.6.1.pg.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
has_defaults (1.
|
|
4
|
+
has_defaults (1.2.1)
|
|
5
5
|
activerecord
|
|
6
6
|
|
|
7
7
|
GEM
|
|
@@ -28,18 +28,18 @@ GEM
|
|
|
28
28
|
database_cleaner-core (~> 2.0.0)
|
|
29
29
|
database_cleaner-core (2.0.1)
|
|
30
30
|
diff-lcs (1.4.4)
|
|
31
|
-
gemika (0.
|
|
31
|
+
gemika (0.8.1)
|
|
32
32
|
i18n (1.8.9)
|
|
33
33
|
concurrent-ruby (~> 1.0)
|
|
34
34
|
method_source (1.0.0)
|
|
35
35
|
minitest (5.14.4)
|
|
36
|
-
pg (1.
|
|
37
|
-
pry (0.
|
|
36
|
+
pg (1.4.5)
|
|
37
|
+
pry (0.14.2)
|
|
38
38
|
coderay (~> 1.1)
|
|
39
39
|
method_source (~> 1.0)
|
|
40
|
-
pry-byebug (3.
|
|
40
|
+
pry-byebug (3.8.0)
|
|
41
41
|
byebug (~> 11.0)
|
|
42
|
-
pry (~> 0.
|
|
42
|
+
pry (~> 0.10)
|
|
43
43
|
rake (13.0.3)
|
|
44
44
|
rspec (3.10.0)
|
|
45
45
|
rspec-core (~> 3.10.0)
|
|
@@ -64,12 +64,12 @@ PLATFORMS
|
|
|
64
64
|
DEPENDENCIES
|
|
65
65
|
activerecord (~> 6.1.3)
|
|
66
66
|
database_cleaner
|
|
67
|
-
gemika (>= 0.
|
|
67
|
+
gemika (>= 0.8.1)
|
|
68
68
|
has_defaults!
|
|
69
|
-
pg (
|
|
69
|
+
pg (>= 1.3)
|
|
70
70
|
pry-byebug
|
|
71
71
|
rake
|
|
72
72
|
rspec (~> 3.5)
|
|
73
73
|
|
|
74
74
|
BUNDLED WITH
|
|
75
|
-
2.3.
|
|
75
|
+
2.3.26
|
data/Gemfile.7.0.pg
CHANGED
|
@@ -2,14 +2,14 @@ source 'https://rubygems.org'
|
|
|
2
2
|
|
|
3
3
|
# Runtime dependencies
|
|
4
4
|
gem 'activerecord', '~>7.0.1'
|
|
5
|
-
gem 'pg', '
|
|
5
|
+
gem 'pg', '>=1.3'
|
|
6
6
|
|
|
7
7
|
# Development dependencies
|
|
8
8
|
gem 'rake'
|
|
9
9
|
gem 'database_cleaner'
|
|
10
10
|
gem 'rspec', '~>3.5'
|
|
11
|
-
gem 'gemika', '>=
|
|
12
|
-
gem 'pry-byebug'
|
|
11
|
+
gem 'gemika', '>=0.8.1'
|
|
12
|
+
gem 'pry-byebug', '>=3.10.1'
|
|
13
13
|
|
|
14
14
|
# Gem under test
|
|
15
15
|
gem 'has_defaults', path: '.'
|
data/Gemfile.7.0.pg.lock
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
has_defaults (1.
|
|
4
|
+
has_defaults (1.2.1)
|
|
5
5
|
activerecord
|
|
6
6
|
|
|
7
7
|
GEM
|
|
8
8
|
remote: https://rubygems.org/
|
|
9
9
|
specs:
|
|
10
|
-
activemodel (7.0.
|
|
11
|
-
activesupport (= 7.0.
|
|
12
|
-
activerecord (7.0.
|
|
13
|
-
activemodel (= 7.0.
|
|
14
|
-
activesupport (= 7.0.
|
|
15
|
-
activesupport (7.0.
|
|
10
|
+
activemodel (7.0.4.2)
|
|
11
|
+
activesupport (= 7.0.4.2)
|
|
12
|
+
activerecord (7.0.4.2)
|
|
13
|
+
activemodel (= 7.0.4.2)
|
|
14
|
+
activesupport (= 7.0.4.2)
|
|
15
|
+
activesupport (7.0.4.2)
|
|
16
16
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
|
17
17
|
i18n (>= 1.6, < 2)
|
|
18
18
|
minitest (>= 5.1)
|
|
19
19
|
tzinfo (~> 2.0)
|
|
20
20
|
byebug (11.1.3)
|
|
21
21
|
coderay (1.1.3)
|
|
22
|
-
concurrent-ruby (1.
|
|
22
|
+
concurrent-ruby (1.2.2)
|
|
23
23
|
database_cleaner (2.0.1)
|
|
24
24
|
database_cleaner-active_record (~> 2.0.0)
|
|
25
25
|
database_cleaner-active_record (2.0.1)
|
|
@@ -27,18 +27,18 @@ GEM
|
|
|
27
27
|
database_cleaner-core (~> 2.0.0)
|
|
28
28
|
database_cleaner-core (2.0.1)
|
|
29
29
|
diff-lcs (1.5.0)
|
|
30
|
-
gemika (0.
|
|
31
|
-
i18n (1.
|
|
30
|
+
gemika (0.8.1)
|
|
31
|
+
i18n (1.12.0)
|
|
32
32
|
concurrent-ruby (~> 1.0)
|
|
33
33
|
method_source (1.0.0)
|
|
34
|
-
minitest (5.
|
|
35
|
-
pg (1.
|
|
36
|
-
pry (0.
|
|
34
|
+
minitest (5.17.0)
|
|
35
|
+
pg (1.4.6)
|
|
36
|
+
pry (0.14.2)
|
|
37
37
|
coderay (~> 1.1)
|
|
38
38
|
method_source (~> 1.0)
|
|
39
|
-
pry-byebug (3.
|
|
39
|
+
pry-byebug (3.10.1)
|
|
40
40
|
byebug (~> 11.0)
|
|
41
|
-
pry (
|
|
41
|
+
pry (>= 0.13, < 0.15)
|
|
42
42
|
rake (13.0.6)
|
|
43
43
|
rspec (3.10.0)
|
|
44
44
|
rspec-core (~> 3.10.0)
|
|
@@ -53,21 +53,21 @@ GEM
|
|
|
53
53
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
54
54
|
rspec-support (~> 3.10.0)
|
|
55
55
|
rspec-support (3.10.3)
|
|
56
|
-
tzinfo (2.0.
|
|
56
|
+
tzinfo (2.0.6)
|
|
57
57
|
concurrent-ruby (~> 1.0)
|
|
58
58
|
|
|
59
59
|
PLATFORMS
|
|
60
|
-
|
|
60
|
+
ruby
|
|
61
61
|
|
|
62
62
|
DEPENDENCIES
|
|
63
63
|
activerecord (~> 7.0.1)
|
|
64
64
|
database_cleaner
|
|
65
|
-
gemika (>= 0.
|
|
65
|
+
gemika (>= 0.8.1)
|
|
66
66
|
has_defaults!
|
|
67
|
-
pg (
|
|
68
|
-
pry-byebug
|
|
67
|
+
pg (>= 1.3)
|
|
68
|
+
pry-byebug (>= 3.10.1)
|
|
69
69
|
rake
|
|
70
70
|
rspec (~> 3.5)
|
|
71
71
|
|
|
72
72
|
BUNDLED WITH
|
|
73
|
-
2.3.
|
|
73
|
+
2.3.26
|
data/README.md
CHANGED
|
@@ -6,13 +6,13 @@ Default values for ActiveRecord models.
|
|
|
6
6
|
|
|
7
7
|
In your `Gemfile`
|
|
8
8
|
|
|
9
|
-
```
|
|
9
|
+
```rb
|
|
10
10
|
gem 'has_defaults'
|
|
11
11
|
```
|
|
12
12
|
|
|
13
13
|
Now run
|
|
14
14
|
|
|
15
|
-
```
|
|
15
|
+
```sh
|
|
16
16
|
bundle install
|
|
17
17
|
```
|
|
18
18
|
|
|
@@ -20,7 +20,7 @@ bundle install
|
|
|
20
20
|
|
|
21
21
|
Add the method call `has_defaults` to your model.
|
|
22
22
|
|
|
23
|
-
```
|
|
23
|
+
```rb
|
|
24
24
|
class Page < ActiveRecord::Base
|
|
25
25
|
has_defaults :title => "New page", :body => "Put your text here"
|
|
26
26
|
end
|
|
@@ -30,19 +30,19 @@ Attributes will be set only if it's a new record and the attribute is blank.
|
|
|
30
30
|
|
|
31
31
|
Retrieve the default attribute with the `default_for` instance method:
|
|
32
32
|
|
|
33
|
-
```
|
|
33
|
+
```rb
|
|
34
34
|
@page.default_for(:title)
|
|
35
35
|
```
|
|
36
36
|
|
|
37
37
|
You can pass Proc as attribute:
|
|
38
38
|
|
|
39
|
-
```
|
|
39
|
+
```rb
|
|
40
40
|
has_defaults :expires_at => proc { Time.now }
|
|
41
41
|
```
|
|
42
42
|
|
|
43
43
|
You can override the default attributes as follow:
|
|
44
44
|
|
|
45
|
-
```
|
|
45
|
+
```rb
|
|
46
46
|
Page.has_defaults_options = {:title => "Here's your new page", :body => "Write your page text"}
|
|
47
47
|
```
|
|
48
48
|
|
data/lib/has_defaults/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: has_defaults
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.2.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Henning Koch
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2024-10-25 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activerecord
|