mobility 1.0.0 → 1.0.5

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: d927c413815d0bd56b1f75e5b0a352d2f5832415c4e1f8c50a98fde44d973e92
4
- data.tar.gz: 72d484c61b6b17b9d99e1061444d209ce66a4de70f904d68d1ce612b24656ae0
3
+ metadata.gz: 64a3453a8f28396a24b95987a4df6fb0fabfd3d90b03fccc47f6b82d72e77d8d
4
+ data.tar.gz: 81ebec57acc6a48596d826716b37239549c01b68db59572d8bf6224b0d276831
5
5
  SHA512:
6
- metadata.gz: 1167adec126a34ff482d01beaa38e18e4188a79aa1be9e5031f8786d86629724984f7597c29d947ae11ad77d72c7538ecc84ed7474c70c87a3da226e81b1f59c
7
- data.tar.gz: d64f21cab45ffa292e9980962d38c7f76fcaacdcac48b7d83b25fbcc0856b49b6814cefdc78e39382d7c12b944ef27ebedb23c14bffb6f819c972e8c9176cb43
6
+ metadata.gz: 63c3046ddce27b50708b73d78119b79b2e554bee7b92f8db843a3ea275acb91694da9c88c473e11c4ad07147bb7d9448229f44d7eb581f8d433313b7e6ecc34a
7
+ data.tar.gz: 56ea4ab41a4984e54c5cb3ccf75fa13f42a4afbb3248463e65235fcdf879100bef6cdf34a29a482e5e790bb043bddf0dc6cb398a5fe24682a886882c6ace1bbb
@@ -1,2 +1,3 @@
1
- Z���yyWy��=���TR?��6�Jl����-��a���q��te����������&�r��Ş�I8��KJ���@FSI�CĔm�z��1y�/�qDI e�~:�!�/��_�8
2
- Σ��U�π�Y��>�)��)�"0�_k�L���N6~#���o��P��^��5К%��\ M9�$�/)t����uԋ�^�t�ʎ@
1
+ |�sx8qQ�/Ρ��w�ҭ|AHr<�RnP���j��˓)��fD Ť\A" ���'��2)��9�lh�=���GKX4v3���]M���_x���6mׯ\.r}Q��is����x�-������+^�xzF0����
2
+ C ��b��ɍ%�fe�I
3
+ cl��E�&��t,�A�t����"��֡b��#S�����4ɇS'����5#�l�cIm�fvӽ=����n�L�-Ȓ
data.tar.gz.sig CHANGED
Binary file
@@ -1,31 +1,73 @@
1
1
  # Mobility Changelog
2
2
 
3
+ ### Unreleased
4
+ - Remove `Mobility::Plugins::Attributes#each`
5
+ ([#475](https://github.com/shioyama/mobility/pull/475))
6
+ - Add public method `Mobility::Plugins::ActiveRecord::Query.build_query`
7
+ ([#471](https://github.com/shioyama/mobility/pull/471))
8
+ - Allow setting locale per node in query block
9
+ ([#479](https://github.com/shioyama/mobility/pull/479))
10
+ - Add `Mobility.validate_locale!`
11
+ ([#479](https://github.com/shioyama/mobility/pull/479))
12
+ - Call after_destroy in setup block to delete associated translations
13
+ ([#487](https://github.com/shioyama/mobility/pull/487))
14
+ - Add key, value and belongs_to options to key-value backend
15
+ ([#488](https://github.com/shioyama/mobility/pull/488)) thanks
16
+ [sedubois](https://github.com/sedubois)!
17
+
3
18
  ## 1.0
4
19
 
5
- 1.0 is a rewrite of many internals of the gem. Please see the [wiki page on v1.0](https://github.com/shioyama/mobility/wiki/Introduction-to-Mobility-v1.0) for more details on how to upgrade.
20
+ 1.0 is a rewrite of many internals of the gem. Please see the [wiki page on
21
+ v1.0](https://github.com/shioyama/mobility/wiki/Introduction-to-Mobility-v1.0)
22
+ for more details on how to upgrade.
23
+
24
+ ### 1.0.5
25
+ - Fix duping with AR Table backend, fixes
26
+ [#490](https://github.com/shioyama/mobility/issues/490)
27
+ ([#499](https://github.com/shioyama/mobility/pull/499) and
28
+ [#501](https://github.com/shioyama/mobility/pull/501))
29
+
30
+ ### 1.0.4
31
+ - Correctly override default backend options, fixes
32
+ [#492](https://github.com/shioyama/mobility/issues/492)
33
+ ([#495](https://github.com/shioyama/mobility/pull/495))
34
+
35
+ ### 1.0.3
36
+ - Fix `Mobility.default_backend`
37
+ ([#497](https://github.com/shioyama/mobility/pull/497))
38
+
39
+ ### 1.0.2
40
+
41
+ ### 1.0.1
42
+
43
+ - Make `Mobility::Plugins::ActiveRecord::Query::VirtualRow` and
44
+ `Mobility::Plugins::ActiveRecord::Query::QueryExtension`
45
+ ([#471](https://github.com/shioyama/mobility/pull/471)) public
46
+ - Fix typo in initializer template
47
+ ([#474](https://github.com/shioyama/mobility/pull/474))
6
48
 
7
- ## 1.0.0
49
+ ### 1.0.0
8
50
 
9
51
  - Fix setting a locale from Rails config
10
52
  ([#468](https://github.com/shioyama/mobility/pull/468)) thanks
11
53
  [sergey-alekseev](https://github.com/sergey-alekseev)!
12
54
  - Fixes validations with validates_uniqueness_of
13
55
  ([#470](https://github.com/shioyama/mobility/pull/470)) thanks
14
- [artplan1](https://github.com/shioyama/mobility/pull/470)!
56
+ [artplan1](https://github.com/artplan1)!
15
57
 
16
- ## 1.0.0.rc1 (pre-release)
58
+ ### 1.0.0.rc1 (pre-release)
17
59
 
18
60
  - Remove `Mobility::ActiveRecord`, `Mobility::Sequel` and `Mobility::Arel`, and
19
61
  general cleanup ([#464](https://github.com/shioyama/mobility/pull/464))
20
62
 
21
- ## 1.0.0.beta2 (pre-release)
63
+ ### 1.0.0.beta2 (pre-release)
22
64
 
23
65
  - Refactor attributes & backend plugins and make `mobility_attributes` public
24
66
  ([#462](https://github.com/shioyama/mobility/pull/462))
25
67
  - Make attribute_methods plugin depend on attributes
26
68
  ([#461](https://github.com/shioyama/mobility/pull/461))
27
69
 
28
- ## 1.0.0.beta1 (pre-release)
70
+ ### 1.0.0.beta1 (pre-release)
29
71
 
30
72
  - Remove `Mobility::Backend#apply_plugin`
31
73
  ([#454](https://github.com/shioyama/mobility/pull/454))
@@ -36,7 +78,7 @@
36
78
  - Fix Ruby 2.7 deprecation warnings
37
79
  ([#460](https://github.com/shioyama/mobility/pull/460))
38
80
 
39
- ## 1.0.0.alpha (pre-release)
81
+ ### 1.0.0.alpha (pre-release)
40
82
 
41
83
  - Default fallbacks plugin to `true` when enabled
42
84
  ([#447](https://github.com/shioyama/mobility/pull/447))
data/Gemfile CHANGED
@@ -8,20 +8,11 @@ orm, orm_version = ENV['ORM'], ENV['ORM_VERSION']
8
8
  group :development, :test do
9
9
  case orm
10
10
  when 'active_record'
11
- orm_version ||= '6.0'
11
+ orm_version ||= '6.1'
12
12
  case orm_version
13
- when '4.2'
14
- gem 'activerecord', '>= 4.2.6', '< 5.0'
15
- when '5.0'
16
- gem 'activerecord', '>= 5.0', '< 5.1'
17
- when '5.1'
18
- gem 'activerecord', '>= 5.1', '< 5.2'
19
- when '5.2'
20
- gem 'activerecord', '>= 5.2.0', '< 5.3'
21
- gem 'railties', '>= 5.2.0.rc2', '< 5.3'
22
- when '6.0'
23
- gem 'activerecord', '>= 6.0.0', '< 6.1'
24
- when '6.1'
13
+ when '4.2', '5.0', '5.1', '5.2', '6.0', '6.1'
14
+ gem 'activerecord', "~> #{orm_version}.0"
15
+ when '6.2'
25
16
  git 'https://github.com/rails/rails.git' do
26
17
  gem 'activerecord'
27
18
  gem 'activesupport'
@@ -32,10 +23,8 @@ group :development, :test do
32
23
  when 'sequel'
33
24
  orm_version ||= '5'
34
25
  case orm_version
35
- when '4'
36
- gem 'sequel', '>= 4.46.0', '< 5.0'
37
26
  when '5'
38
- gem 'sequel', '>= 5.0.0', '< 6.0.0'
27
+ gem 'sequel', "~> #{orm_version}.0"
39
28
  else
40
29
  raise ArgumentError, 'Invalid Sequel version'
41
30
  end
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- mobility (1.0.0.rc1)
4
+ mobility (1.0.4)
5
5
  i18n (>= 0.6.10, < 2)
6
6
  request_store (~> 1.0)
7
7
 
@@ -48,7 +48,7 @@ GEM
48
48
  rb-inotify (~> 0.9, >= 0.9.10)
49
49
  lumberjack (1.2.8)
50
50
  method_source (1.0.0)
51
- minitest (5.14.2)
51
+ minitest (5.14.3)
52
52
  nenv (0.3.0)
53
53
  notiffany (0.1.3)
54
54
  nenv (~> 0.1)
@@ -83,16 +83,16 @@ GEM
83
83
  shellany (0.0.1)
84
84
  thor (1.0.1)
85
85
  thread_safe (0.3.6)
86
- tzinfo (1.2.8)
86
+ tzinfo (1.2.9)
87
87
  thread_safe (~> 0.1)
88
88
  yard (0.9.25)
89
- zeitwerk (2.4.1)
89
+ zeitwerk (2.4.2)
90
90
 
91
91
  PLATFORMS
92
92
  ruby
93
93
 
94
94
  DEPENDENCIES
95
- activerecord (>= 6.0.0, < 6.1)
95
+ activerecord (~> 6.0.0)
96
96
  benchmark-ips
97
97
  database_cleaner (~> 1.5, >= 1.5.3)
98
98
  guard-rspec
data/README.md CHANGED
@@ -13,8 +13,8 @@ Mobility
13
13
  [wiki]: https://github.com/shioyama/mobility/wiki
14
14
 
15
15
  **This is the readme for version 1.0 of Mobility. If you are using an earlier
16
- version (0.8.x or earlier), you probably want the readme on the [0-8-stable
17
- branch](https://github.com/shioyama/mobility/tree/0-8-stable).**
16
+ version (0.8.x or earlier), you probably want the readme on the [0-8
17
+ branch](https://github.com/shioyama/mobility/tree/0-8).**
18
18
 
19
19
  Mobility is a gem for storing and retrieving translations as attributes on a
20
20
  class. These translations could be the content of blog posts, captions on
@@ -56,12 +56,9 @@ To use the latest pre-version of Mobility 1.0, add this line to your
56
56
  application's Gemfile:
57
57
 
58
58
  ```ruby
59
- gem 'mobility', '~> 1.0.0'
59
+ gem 'mobility', '~> 1.0.5'
60
60
  ```
61
61
 
62
- For the latest stable version of Mobility, see the readme on the
63
- [0-8-stable](https://github.com/shioyama/mobility/tree/0-8-stable) branch.
64
-
65
62
  ### ActiveRecord (Rails)
66
63
 
67
64
  Requirements:
@@ -107,7 +107,7 @@ module Mobility
107
107
  # Alias to default backend defined on *translations_class+.
108
108
  # @return [Symbol,Class]
109
109
  def default_backend
110
- translations_class.defaults[:backend]
110
+ translations_class.defaults[:backend]&.first
111
111
  end
112
112
 
113
113
  # Configure Mobility
@@ -274,6 +274,12 @@ columns to that table.
274
274
  define_method :initialize_dup do |source|
275
275
  super(source)
276
276
  self.send("#{association_name}=", source.send(association_name).map(&:dup))
277
+
278
+ # for cache
279
+ # FIXME: do this better
280
+ if options[:cache]
281
+ instance_variable_set(:"@__mobility_#{association_name}_cache", {})
282
+ end
277
283
  end
278
284
  end
279
285
  include const_set(module_name, dupable)
@@ -121,8 +121,8 @@ Also includes a +configure+ class method to apply plugins to a pluggable
121
121
  # Does this class include all plugins this plugin depends (directly) on?
122
122
  # @param [Class] klass Pluggable class
123
123
  def dependencies_satisfied?(klass)
124
- required_plugins = dependencies.keys.map { |name| Plugins.load_plugin(name) }
125
- (required_plugins - klass.included_modules).none?
124
+ plugin_keys = klass.included_plugins.map { |plugin| Plugins.lookup_name(plugin) }
125
+ (dependencies.keys - plugin_keys).none?
126
126
  end
127
127
 
128
128
  # Specifies a dependency of this plugin.
@@ -67,9 +67,9 @@ enabled for any one attribute on the model.
67
67
  end
68
68
  end
69
69
 
70
- # Internal class to create a "clean room" for manipulating translated
71
- # attribute nodes in an instance-eval'ed block. Inspired by Sequel's
72
- # (much more sophisticated) virtual rows.
70
+ # Creates a "clean room" for manipulating translated attribute nodes in
71
+ # an instance-eval'ed block. Inspired by Sequel's (much more
72
+ # sophisticated) virtual rows.
73
73
  class VirtualRow < BasicObject
74
74
  attr_reader :__backends
75
75
 
@@ -108,7 +108,7 @@ enabled for any one attribute on the model.
108
108
  end
109
109
  end
110
110
  end
111
- private_constant :QueryMethod, :VirtualRow
111
+ private_constant :QueryMethod
112
112
 
113
113
  module QueryExtension
114
114
  def where!(opts, *rest)
@@ -273,7 +273,7 @@ enabled for any one attribute on the model.
273
273
  end
274
274
  end
275
275
 
276
- private_constant :QueryExtension, :FindByMethods
276
+ private_constant :FindByMethods
277
277
  end
278
278
 
279
279
  class MissingBackend < Mobility::Error; end
@@ -33,13 +33,6 @@ Defines:
33
33
  def initialize(*args, **original_options)
34
34
  super
35
35
 
36
- # Validate that the default backend from config has valid keys
37
- if (default = self.class.defaults[:backend])
38
- name, backend_options = default
39
- extra_keys = backend_options.keys - backend.valid_keys
40
- raise InvalidOptionKey, "These are not valid #{name} backend keys: #{extra_keys.join(', ')}." unless extra_keys.empty?
41
- end
42
-
43
36
  include InstanceMethods
44
37
  end
45
38
 
@@ -87,7 +80,7 @@ Defines:
87
80
 
88
81
  case options[:backend]
89
82
  when String, Symbol, Class
90
- @backend, @backend_options = options[:backend], options
83
+ @backend, @backend_options = options[:backend], options.dup
91
84
  when Array
92
85
  @backend, @backend_options = options[:backend]
93
86
  @backend_options = @backend_options.merge(original_options)
@@ -105,6 +98,14 @@ Defines:
105
98
  def validate_options(options)
106
99
  return super unless backend
107
100
  super(options.slice(*(options.keys - backend.valid_keys)))
101
+
102
+ # Validate that the default backend from config has valid keys, or if
103
+ # it is overridden by an array input that the array has valid keys.
104
+ if options[:backend].is_a?(Array)
105
+ name, backend_options = options[:backend]
106
+ extra_keys = backend_options.keys - backend.valid_keys
107
+ raise InvalidOptionKey, "These are not valid #{name} backend keys: #{extra_keys.join(', ')}." unless extra_keys.empty?
108
+ end
108
109
  end
109
110
 
110
111
  # Override default argument-handling in DSL to store kwargs passed along
@@ -8,7 +8,7 @@ module Mobility
8
8
  module VERSION
9
9
  MAJOR = 1
10
10
  MINOR = 0
11
- TINY = 0
11
+ TINY = 5
12
12
  PRE = nil
13
13
 
14
14
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
@@ -108,7 +108,7 @@ Mobility.configure do
108
108
  #
109
109
  # Adds translated attributes to +attributes+ hash, and defines methods
110
110
  # +translated_attributes+ and +untranslated_attributes+ which return hashes
111
- # with translatd and untranslated attributes, respectively. Be aware that
111
+ # with translated and untranslated attributes, respectively. Be aware that
112
112
  # this plugin can create conflicts with other gems.
113
113
  #
114
114
  # attribute_methods
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.0.0
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Salzberg
@@ -34,7 +34,7 @@ cert_chain:
34
34
  gSQml7TqcC6dZRsZRwYqzD9kUwdAJoCqno2CBUKs2l0yQAjFT36lRrVJznb7uWwa
35
35
  xpPFnsrtyaZW6Dty8TSG3qzmeGpmpIotA8x1VA==
36
36
  -----END CERTIFICATE-----
37
- date: 2020-12-12 00:00:00.000000000 Z
37
+ date: 2021-01-31 00:00:00.000000000 Z
38
38
  dependencies:
39
39
  - !ruby/object:Gem::Dependency
40
40
  name: request_store
metadata.gz.sig CHANGED
Binary file