mobility 1.3.0.rc1 → 1.3.0.rc3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8a89e6682c14088be7f337e5a03c5b510a67dd7a93ee88024f3686f9bfc4694e
4
- data.tar.gz: c5a99fc2000e05d2d3ccc3ff9d6dd00357dc3b5ace57d7c92782b2601bd32e51
3
+ metadata.gz: fd0b53980f62d9538827053f6e08b8ffd287d44a7a4aa87602c5d85e87bf30fc
4
+ data.tar.gz: 540af4290175ec08b109a8cc0e783c1a634c66fe87bf97fd014d5c5a0f78b79c
5
5
  SHA512:
6
- metadata.gz: f60e92ede85fc444d4151a14c833a13ced95c1e2f073fafa024aa967de01810e5b2b6ccfc4365c5d338679d1899573ec2921453ce44dcdc9736fde749ad650ed
7
- data.tar.gz: 21319dd41e1025a82545a08da30fcafd38d5bc61c86bdcfe2b017b195d670a9a503fbff8101a7897b99fe32e3c0bf19666bd0c86f06887fb697a8bce132b6253
6
+ metadata.gz: 25fc7f6a40125020f7425691a3d183a290bfaa3381594d1ad218a924797a0329f76ca39494742f380a3310fbe9d3c879849e366de20bd695219b247c90161d17
7
+ data.tar.gz: 8b02e9620070979a64e71d2774495a1be0054e92180116e4e40790575d05faff38fb78001ab460581de2524598af3823f312734b67804d2debe1de428737801a
checksums.yaml.gz.sig CHANGED
Binary file
data/CHANGELOG.md CHANGED
@@ -2,6 +2,24 @@
2
2
 
3
3
  ## 1.3
4
4
 
5
+ ### 1.3.0.rc3
6
+
7
+ - Don't try to load generators if Rails is loaded but AR is not
8
+ ([#627](https://github.com/shioyama/mobility/pull/627)), thanks
9
+ [flop](https://github.com/flop)!
10
+ - Allow compound foreign keys
11
+ ([#632](https://github.com/shioyama/mobility/pull/632)), thanks
12
+ [mival](https://github.com/mival)!
13
+ - Fix active model `*_previously_changed?` and active record
14
+ `will_save_change_to_*?` and `saved_change_to_*?` dirty methods to accept
15
+ kwargs ([#639](https://github.com/shioyama/mobility/pull/639)) thanks
16
+ [doits](https://github.com/doits)!
17
+
18
+ ### 1.3.0.rc2
19
+
20
+ - Pass `coder` as keyword argument to `serialize` (ActiveRecord version > 7.1)
21
+ ([#617](https://github.com/shioyama/mobility/pull/617))
22
+
5
23
  ### 1.3.0.rc1
6
24
 
7
25
  This version includes potentially breaking chnages for jsonb and hstore
data/Gemfile CHANGED
@@ -10,7 +10,7 @@ group :development, :test do
10
10
  when 'active_record'
11
11
  orm_version ||= '7.0'
12
12
  case orm_version
13
- when '4.2', '5.0', '5.1', '5.2', '6.0', '6.1', '7.0'
13
+ when '6.1', '7.0', '7.1'
14
14
  gem 'activerecord', "~> #{orm_version}.0"
15
15
  when 'edge'
16
16
  git 'https://github.com/rails/rails.git', branch: 'main' do
data/Gemfile.lock CHANGED
@@ -8,15 +8,15 @@ PATH
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- benchmark-ips (2.10.0)
11
+ benchmark-ips (2.13.0)
12
12
  byebug (11.1.3)
13
13
  coderay (1.1.3)
14
- concurrent-ruby (1.2.2)
14
+ concurrent-ruby (1.2.3)
15
15
  database_cleaner (1.99.0)
16
- diff-lcs (1.5.0)
17
- ffi (1.15.5)
16
+ diff-lcs (1.5.1)
17
+ ffi (1.16.3)
18
18
  formatador (1.1.0)
19
- guard (2.18.0)
19
+ guard (2.18.1)
20
20
  formatador (>= 0.2.4)
21
21
  listen (>= 2.7, < 4.0)
22
22
  lumberjack (>= 1.0.12, < 2.0)
@@ -30,51 +30,50 @@ GEM
30
30
  guard (~> 2.1)
31
31
  guard-compat (~> 1.1)
32
32
  rspec (>= 2.99.0, < 4.0)
33
- i18n (1.12.0)
33
+ i18n (1.14.4)
34
34
  concurrent-ruby (~> 1.0)
35
- listen (3.7.1)
35
+ listen (3.9.0)
36
36
  rb-fsevent (~> 0.10, >= 0.10.3)
37
37
  rb-inotify (~> 0.9, >= 0.9.10)
38
- lumberjack (1.2.8)
38
+ lumberjack (1.2.10)
39
39
  method_source (1.0.0)
40
40
  nenv (0.3.0)
41
41
  notiffany (0.1.3)
42
42
  nenv (~> 0.1)
43
43
  shellany (~> 0.0)
44
- pry (0.13.1)
44
+ pry (0.14.2)
45
45
  coderay (~> 1.1)
46
46
  method_source (~> 1.0)
47
- pry-byebug (3.9.0)
47
+ pry-byebug (3.10.1)
48
48
  byebug (~> 11.0)
49
- pry (~> 0.13.0)
50
- rack (3.0.7)
49
+ pry (>= 0.13, < 0.15)
50
+ rack (3.0.9.1)
51
51
  rake (12.3.3)
52
- rb-fsevent (0.11.1)
52
+ rb-fsevent (0.11.2)
53
53
  rb-inotify (0.10.1)
54
54
  ffi (~> 1.0)
55
- request_store (1.5.1)
55
+ request_store (1.6.0)
56
56
  rack (>= 1.4)
57
- rspec (3.11.0)
58
- rspec-core (~> 3.11.0)
59
- rspec-expectations (~> 3.11.0)
60
- rspec-mocks (~> 3.11.0)
61
- rspec-core (3.11.0)
62
- rspec-support (~> 3.11.0)
63
- rspec-expectations (3.11.0)
57
+ rspec (3.13.0)
58
+ rspec-core (~> 3.13.0)
59
+ rspec-expectations (~> 3.13.0)
60
+ rspec-mocks (~> 3.13.0)
61
+ rspec-core (3.13.0)
62
+ rspec-support (~> 3.13.0)
63
+ rspec-expectations (3.13.0)
64
64
  diff-lcs (>= 1.2.0, < 2.0)
65
- rspec-support (~> 3.11.0)
66
- rspec-mocks (3.11.1)
65
+ rspec-support (~> 3.13.0)
66
+ rspec-mocks (3.13.0)
67
67
  diff-lcs (>= 1.2.0, < 2.0)
68
- rspec-support (~> 3.11.0)
69
- rspec-support (3.11.0)
68
+ rspec-support (~> 3.13.0)
69
+ rspec-support (3.13.1)
70
70
  shellany (0.0.1)
71
- thor (1.2.1)
72
- webrick (1.7.0)
73
- yard (0.9.28)
74
- webrick (~> 1.7.0)
71
+ sqlite3 (1.4.4)
72
+ thor (1.3.1)
73
+ yard (0.9.36)
75
74
 
76
75
  PLATFORMS
77
- ruby
76
+ x86_64-linux
78
77
 
79
78
  DEPENDENCIES
80
79
  benchmark-ips
@@ -84,6 +83,7 @@ DEPENDENCIES
84
83
  pry-byebug
85
84
  rake (~> 12, >= 12.2.1)
86
85
  rspec (~> 3.0)
86
+ sqlite3 (~> 1.4.1)
87
87
  yard (~> 0.9.0)
88
88
 
89
89
  BUNDLED WITH
data/README.md CHANGED
@@ -4,7 +4,6 @@ Mobility
4
4
  [![Gem Version](https://badge.fury.io/rb/mobility.svg)][gem]
5
5
  [![Build Status](https://github.com/shioyama/mobility/workflows/CI/badge.svg)][actions]
6
6
  [![Code Climate](https://api.codeclimate.com/v1/badges/72200f2b00c339ec4537/maintainability.svg)][codeclimate]
7
- [![Gitter Chat](https://badges.gitter.im/mobility-ruby/mobility.svg)](https://gitter.im/mobility-ruby/mobility)
8
7
 
9
8
  [gem]: https://rubygems.org/gems/mobility
10
9
  [actions]: https://github.com/shioyama/mobility/actions
@@ -55,17 +54,13 @@ Installation
55
54
  Add this line to your application's Gemfile:
56
55
 
57
56
  ```ruby
58
- gem 'mobility', '~> 1.3.0.rc1'
57
+ gem 'mobility', '~> 1.3.0.rc3'
59
58
  ```
60
59
 
61
60
  ### ActiveRecord (Rails)
62
61
 
63
62
  Requirements:
64
- - ActiveRecord >= 5.0 (including 6.x)
65
-
66
- (Support for most backends and features is also supported with
67
- ActiveRecord/Rails 4.2, but there are some tests still failing. To see exactly
68
- what might not work, check pending specs in Rails 4.2 builds.)
63
+ - ActiveRecord >= 6.1
69
64
 
70
65
  To translate attributes on a model, extend `Mobility`, then call `translates`
71
66
  passing in one or more attributes as well as a hash of options (see below).
@@ -1027,6 +1022,7 @@ Integrations
1027
1022
  * [mobility-actiontext](https://github.com/sedubois/mobility-actiontext): Translate
1028
1023
  Rails [Action Text](https://guides.rubyonrails.org/action_text_overview.html) rich text
1029
1024
  with Mobility.
1025
+ * [mobility_typed](https://github.com/GeorgeGorbanev/mobility_typed): Add type checking to Rails models accessors.
1030
1026
 
1031
1027
  Tutorials
1032
1028
  ---------
@@ -51,7 +51,13 @@ Implements {Mobility::Backends::Serialized} backend for ActiveRecord models.
51
51
 
52
52
  setup do |attributes, options|
53
53
  coder = { yaml: YAMLCoder, json: JSONCoder }[options[:format]]
54
- attributes.each { |attribute| serialize (options[:column_affix] % attribute), coder }
54
+ attributes.each do |attribute|
55
+ if (::ActiveRecord::VERSION::STRING >= "7.1")
56
+ serialize (options[:column_affix] % attribute), coder: coder
57
+ else
58
+ serialize (options[:column_affix] % attribute), coder
59
+ end
60
+ end
55
61
  end
56
62
 
57
63
  # @!group Cache Methods
@@ -109,7 +109,13 @@ columns to that table.
109
109
  options[:association_name] = :translations
110
110
  options[:subclass_name] ||= :Translation
111
111
  end
112
- %i[foreign_key association_name subclass_name table_name].each { |key| options[key] = options[key].to_sym }
112
+ %i[foreign_key association_name subclass_name table_name].each { |key|
113
+ if options[key].is_a?(Enumerable)
114
+ options[key] = options[key].map!(&:to_sym)
115
+ else
116
+ options[key] = options[key].to_sym
117
+ end
118
+ }
113
119
  end
114
120
  # @!endgroup
115
121
 
@@ -119,6 +119,14 @@ the ActiveRecord dirty plugin for more information.
119
119
  class HandlerMethodsBuilder < Module
120
120
  attr_reader :klass
121
121
 
122
+ PATTERNS_WITH_KWARGS =
123
+ %w[
124
+ %s_changed?
125
+ %s_previously_changed?
126
+ will_save_change_to_%s?
127
+ saved_change_to_%s?
128
+ ].freeze
129
+
122
130
  # @param [Class] klass Dirty class to mimic
123
131
  def initialize(klass)
124
132
  @klass = klass
@@ -135,7 +143,7 @@ the ActiveRecord dirty plugin for more information.
135
143
  public_patterns.each do |pattern|
136
144
  method_name = pattern % 'attribute'
137
145
 
138
- kwargs = pattern == '%s_changed?' ? ', **kwargs' : ''
146
+ kwargs = PATTERNS_WITH_KWARGS.include?(pattern) ? ', **kwargs' : ''
139
147
  module_eval <<-EOM, __FILE__, __LINE__ + 1
140
148
  def #{method_name}(attr_name, *rest#{kwargs})
141
149
  if (mutations_from_mobility.attribute_changed?(attr_name) ||
@@ -298,8 +306,10 @@ the ActiveRecord dirty plugin for more information.
298
306
  (OPTION_NOT_GIVEN == to || fetch_value(attr_name) == to)
299
307
  end
300
308
 
301
- def attribute_previously_changed?(attr_name)
302
- previous_changes.include?(attr_name)
309
+ def attribute_previously_changed?(attr_name, from: OPTION_NOT_GIVEN, to: OPTION_NOT_GIVEN)
310
+ previous_changes.include?(attr_name) &&
311
+ (OPTION_NOT_GIVEN == from || attribute_previous_change(attr_name).first == from) &&
312
+ (OPTION_NOT_GIVEN == to || attribute_previous_change(attr_name).second == to)
303
313
  end
304
314
 
305
315
  def attribute_was(attr_name)
@@ -9,7 +9,7 @@ module Mobility
9
9
  MAJOR = 1
10
10
  MINOR = 3
11
11
  TINY = 0
12
- PRE = "rc1"
12
+ PRE = "rc3"
13
13
 
14
14
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
15
15
  end
data/lib/mobility.rb CHANGED
@@ -90,7 +90,7 @@ module Mobility
90
90
  CALL_COMPILABLE_REGEXP = /\A[a-zA-Z_]\w*[!?]?\z/
91
91
  private_constant :CALL_COMPILABLE_REGEXP
92
92
 
93
- require "rails/generators/mobility/generators" if defined?(Rails)
93
+ require "rails/generators/mobility/generators" if defined?(Rails) && defined?(ActiveRecord)
94
94
 
95
95
  class << self
96
96
  def extended(model_class)
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mobility
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0.rc1
4
+ version: 1.3.0.rc3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Salzberg
@@ -12,30 +12,30 @@ cert_chain:
12
12
  -----BEGIN CERTIFICATE-----
13
13
  MIIEcDCCAtigAwIBAgIBATANBgkqhkiG9w0BAQsFADA/MQ4wDAYDVQQDDAVjaHJp
14
14
  czEYMBYGCgmSJomT8ixkARkWCGRlamltYXRhMRMwEQYKCZImiZPyLGQBGRYDY29t
15
- MB4XDTIz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v0Lc/5QsK8wIDAQABo3cwdTAJBgNV
26
+ HRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNVHQ4EFgQUJ5UzoaDdOqk4a8OQ95no0vg3
27
+ ROcwHQYDVR0RBBYwFIESY2hyaXNAZGVqaW1hdGEuY29tMB0GA1UdEgQWMBSBEmNo
28
+ cmlzQGRlamltYXRhLmNvbTANBgkqhkiG9w0BAQsFAAOCAYEAmx0ugOC2yOTQTetP
29
+ H8akUD7tRMeEki8Ba2F/+YP0x6cnsEBcKnp0CO5pMVY+6MssLgHh1IXDQlmKuPOW
30
+ oht9yh6CWgzufzi+XApY1k/TYWAjxOMZAMdvd7iHo7igRK5pPbSaP5uubQfaLn7X
31
+ ge1VLOBAn9XlSOvFZiYZ7Nk8zEvYrvLbQGVtcfceZK4BHC4M3pKsV+m7euWMYguz
32
+ ctOqZgbvGDwFvsH302xC53hld7AaFLBep6XaQZSRleVqgIEKZwlG0cX8UwG482Xt
33
+ WJSXNylIIbzRndVjbVdGVhhcyjnswfu1qJpl+0YlbAdHJVsd8Ux8TOXEPFMv5wz9
34
+ wXhTYFvkOuleWf/45E5f8BtT1iqsH2w3P2Cfy+yOo2aReAVSeR12YDCuV0q6RjTD
35
+ 3I5AfnFAG4/1IwhadqwF5cl3jOUa7n3mS2OJl3tRCGuPvwAA9MV10hmwbQTXMrNK
36
+ tD9kfT9eseUE4mfPnIaHOs4FiIoHniA7zdtjB7GIQ4cEpB6o
37
37
  -----END CERTIFICATE-----
38
- date: 2023-03-28 00:00:00.000000000 Z
38
+ date: 2024-03-31 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: request_store
metadata.gz.sig CHANGED
Binary file